- 1
- 2
- 3
if ( !log.append(log_line) )
log.append("Can't append to log");
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+50
if ( !log.append(log_line) )
log.append("Can't append to log");
+54
// We now have a locale string, but the global locale can be changed by
// another thread. If we allow this thread's locale to be updated before we're done
// with this string, it might be freed from under us.
// Call versions of the wide-to-MB-char conversions that do not update the current thread's
// locale.
//...
/*
* Note that we are using a risky trick here. We are adding this
* locale to an existing threadlocinfo struct, and thus starting
* the locale's refcount with the same value as the whole struct.
* That means all code which modifies both threadlocinfo::refcount
* and threadlocinfo::lc_category[]::refcount in structs that are
* potentially shared across threads must make those modifications
* under _SETLOCALE_LOCK. Otherwise, there's a race condition
* for some other thread modifying threadlocinfo::refcount after
* we load it but before we store it to refcount.
*/
MS VS 2013 CRT
+157
function calcHTime($stt) {
$secs = time() - $stt;
$h = (int) ($secs / 3600);
$m = (int) (($secs - ($h * 3600)) / 60);
$s = (int) ($secs - ($h * 3600) - ($m * 60));
return sprintf("%02d:%02d:%02d", $h, $m, $s);
}
+159
function time(){
var vr=new Date();
var hour=vr.getHours();
var min=vr.getMinutes();
var sec=vr.getSeconds();
if (sec<=9) {
if (min<=9) {
if (hour<=9) {
document.forms[0].elements[0].value = "0" + hour +":"+ "0" + min +":"+ "0" + sec;
}
else {
document.forms[0].elements[0].value = hour +":"+ "0" + min +":"+ "0" + sec;
}
}
else {
if (hour<=9) {
document.forms[0].elements[0].value = "0" + hour +":"+ min +":"+ "0" + sec;
}
else {
document.forms[0].elements[0].value = hour +":"+ min +":"+ "0" + sec;
}
}
}
else {
if (min<=9) {
if (hour<=9) {
document.forms[0].elements[0].value = "0" + hour +":"+ "0" + min +":"+ sec;
}
else {
document.forms[0].elements[0].value = hour +":"+ "0" + min +":"+ sec;
}
}
else {
if (hour<=9) {
document.forms[0].elements[0].value = "0" + hour +":"+ min +":"+ sec;
}
else {
document.forms[0].elements[0].value = hour +":"+ min +":"+ sec;
}
}
}
setTimeout("time()",1000);
}
Вот такой вот toString().
+133
void Nay_Prer_Timer2(void)
{
Obr_Func_Prer.Sh_Time2 = Obr_Func_Prer.Sh_Time2_Init;
Spec_Vkl_Indic.Sh_Time2 = Spec_Vkl_Indic.Sh_Time2_Init;
Spec_Vykl_Indic.Sh_Time2 = Spec_Vykl_Indic.Sh_Time2_Init;
Flag_Morg=0; // Флаг моргания для Config_Bibl_Max6954
Flag_Vykl_Diod=0;
if(Config_Bibl_Max6954&0x4) // 2-й бит =1 - Прерывания разрешены
Vkl_Prer_Timer2();
return;
}
Чел писал тестовое задание для микроконтроллера (поморгать светодиодами).
На вопрос что означает слово Nay в названии функции был дан ответ - это сокращение от нач. (начало).
−396
BOOL = omg;
if (omg == YES)
{
[self go];
}
else
{
if (omg == YES)
{
omg = YES;
[self go];
}
}
МОИ ГЛАЗАААА
+56
bool XIsEmptyString( LPCTSTR str )
{
CString s(str);
s.TrimLeft();
s.TrimRight();
return ( s.IsEmpty() || s == _T("") );
}
Кажется разработчика настиг приступ паранойи.
Взято из библиотека XMLite
−170
CREATE TRIGGER TR_Table1 ON Table1
INSTEAD OF INSERT
AS
INSERT INTO Table1
SELECT * FROM INSERTED
Диалект MS SQL
INSTEAD OF INSERT - триггер, отменяющий вставку и передающий список значений, указанных в запросе в псевдотаблице INSERTED.
т.е. автор вместо того чтобы позволить северу вставлять строк решил каждый раз вставлять их лично.
−89
# Да, да, захардкоженные id!
# .where(id: [id_arrays]) ? Не, не слышал
@cities = [52, 21, 9, 18, 196, 27, 106, 4, 40, 71].collect { |c| City.find(c) }
# Это все в одном экшене, ага.
session[:latitude] = params[:my_latitude]
session[:longitude] = params[:my_longitude]
session[:my_address] = params[:my_address]
session[:fuel] = params[:fuel][:fuel_id]
session[:range] = params[:station][:range]
# А потом кто-нибудь развернет базу из бэкапа без сохранения первичных ключей и все перестанет работать.
@fuels = Fuel.where(:id=>[1, 2, 3, 5])
# Типичный экшен
session[:view_sub_page] = action_name
id = params[:station_chain].split("-")
s_id = id[id.size - 2]
station = Station.where(:id=>s_id)
@fuels_level = AppUtils.calculate_price(station)
@prices = station.last.prices.order("created_at").group_by { |item| item.fuel_id }
@fuel_id = id[id.size - 1].to_i
@station_lists = Station.get_station_detail_map(station, @fuels_level, @fuel_id, @prices)
@station = station.last
@station_logo = ''
@station_logo_chain = ManageStationChain.where(:brand_id=>@station.brand_id).last
@station_logo = PromoLogo.find_by_station_id(@station.id)
@end = @station.address
@fuels = Fuel.where(:id=>[1, 2, 3, 5])
@sub_station = ""
@cities = Station.get_static_cities()
# Какие еще Rails, у меня свой лисопед
def City.find_by_name(name)
city = City.where("name = ?", name).first
if city.nil?
city = City.new
city.name = name
city.save
end
return city
end
# Именно так, в одну строчку. station.open_time и close_time - типа :time в базе
if !station.open_time.nil? and !station.close_time.nil? and (Time.parse(station.open_time.to_s)...Time.parse(station.close_time.to_s)).cover?(Time.now.utc.change(year: 2000, month: 1, day: 1, hour: Time.now.hour, min: Time.now.min, second: 0)) == false
return "PRICE_LEVEL_CLOSE"
end
# Компьютер купил, программировать не купил
# В таблице Points - тысячи записей
def get_points
points = Points.all
render json: {:success => true, :data => {:points => points.as_json(:only => [:action, :points, :points_new])}} and return
end
# И под занавес - код логина
# Гемы? Devise? OAuth? А чой энта?
def login
register = false
url = "https://graph.facebook.com/me/?access_token="+params[:facebook_token]
uri = URI.parse(url)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri.path + "?" + uri.query)
response = http.request(request)
if response.code == "200"
facebook_response = JSON.parse(response.body)
user = User.where("facebook_id = ?", facebook_response["id"]).first
if !user
user = User.new
user.facebook_id = facebook_response["id"]
user.nick = facebook_response["username"]
user.email = facebook_response["email"]
register = true
end
user.email = facebook_response["email"]
user.generate_token
user.save
if register == true
history = History.new
history.user = user
points = Points.where(:action => "REGISTER").first
history.points_action = points
history.points = points.points
user.points+=points.points
user.save
history.save
end
logger.debug("Calculating point");
points = Points.where('action != ?', 'FACEBOOK_INVITES')
logger.debug(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
logger.debug("Testing for points");
logger.debug(points.as_json(:only => [:action, :points]))
logger.debug(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
if user.disabled == true
render json: {:success => false, :error => {:message => "Invalid facebook token", :error_code => "INVALID_TOKEN"}}, status: :unauthorized and return
else
render json: {:success => true, :data => {:auth_token => user.auth_token, :points => points.as_json(:only => [:action, :points])}} and return#
...
Почему никогда нельзя нанимать индусских программистов. Выдержки из избранного.
+56
` enum SearchFlag
{
IgnoreCase = 0x00000001, ///< Case differences are ignored
- WholeWorlds = 0x00000002 ///< Only whole words are matched
+ WholeWords = 0x00000002 ///< Only whole words are matched
};
очепятка + копи-паста = world domination.
http://lists.freedesktop.org/archives/poppler/2015-January/011251.html
http://cgit.freedesktop.org/poppler/poppler/commit/?id=78abf540057181b708c546aee421f81a1dd5 8331