- 1
eval("document.getElementById('bmnu_rbt').onclick = function () { menu_to_left(); }");
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+147
eval("document.getElementById('bmnu_rbt').onclick = function () { menu_to_left(); }");
Без комментанриев
−101
@implementation NSString (toint)
- (long long)toInt {
if (self == nil) return 0;
if (self.length == 0) return 0;
return [self longLongValue];
}
@end
В этом коде все прекрасно. Я просто оставлю это здесь. Джава головного мозга.
−120
- (NSManagedObject *)entityForName:(NSString *)entityName withServerID:(NSString *)serverID inContext:(NSManagedObjectContext *)context
{
if ((entityName==nil) || ([entityName isEqualToString:@""]) || (serverID==nil) || ([serverID isEqualToString:@""]))
{
return nil;
};
NSFetchRequest *fr=[[NSFetchRequest alloc] init];
[fr setEntity:[NSEntityDescription entityForName:entityName inManagedObjectContext:context]];
[fr setPredicate:[NSPredicate predicateWithFormat:@"server_id == %@", serverID]];
[fr setIncludesPropertyValues:YES];
NSError *err;
NSArray *res=[context executeFetchRequest:fr error:&err];
if (err!=nil)
{
NSLog(@"PANIC: PTDataFetchHelper: entityWithName:serverID:inContext: an error occured while gathering objects. %@ | %@ | %@", err.localizedDescription, err.localizedFailureReason, err.localizedRecoverySuggestion);
return nil;
}
else
{
if ([res count]<=0)
{
NSLog(@"[res count]<=0");
//NSLog(@"PTDataFetchHelper: findEntity:%@ withServerID:%@ inContext: not found", entityName, serverID);
return nil;
}
else if([res count]>1)
{
NSLog(@"PANIC: PTDataFetchHelper: entityWithName:serverID:inContext: unable to fetch single object. server_id uniqueness error");
return nil;
}
else //[res count] == 1
{
return [res objectAtIndex:0];
};
};
}
Фетч
+141
if x > 0 then
begin
if y <= 0 then
begin
if z <> 0 then
begin
if x1 > 0 then
begin
if y1 < 7 then
begin
if z1 > 0 then
begin
if z1 mod 5 = 0 then
begin
if m <> 3 then
begin
if n > 5 then
begin
writeln('1');
end;
end;
end;
end;
end;
end;
end;
end;
end;
+134
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <inttypes.h>
union Str
{
uint64_t a;
char str[8];
};
int main(void)
{
union Str str;
memcpy( &str.str, "12345678", sizeof(str.a));
str.a = ((str.a & 0x0F000F000F000F00)>>8) +
((str.a & 0x000F000F000F000F)*10);
str.a = 1000000 * ((str.a >> 0 ) & 0xFF) +
10000 * ((str.a >> 16) & 0xFF) +
100 * ((str.a >> 32) & 0xFF) +
((str.a >> 48) & 0xFF);
//little-endian only. Можно переделать под big-endian
printf("%"PRIu64, str.a);
return 0;
}
Байтоебское преобразование строки из 8 цифр(в виде ascii символов) в число
+7
namespace engine { namespace ui { class Console; } }
class Dummy
{
engine::ui::Console * _ptr;
};
Решение проблемы с перекрёстными #include, когда классы должны хранить указатели друг на друга. Простое объявление class engine::ui::Console; не работает.
Не в первый раз сталкиваюсь с этой проблемой из-за примитивной системы импорта.
+17
#if defined(SDL_MAIN_NEEDED) || defined(SDL_MAIN_AVAILABLE)
#define main SDL_main
#endif
Боже, за что??!
http://hg.libsdl.org/SDL/file/75726efbf679/include/SDL_main.h
+115
private string GenerateUserName(ISession session)
{
string userName = "";
while (true)
{
if (IsBrand) userName = FName.Replace(" ", "");
else userName = string.Format("{0}.{1}", FName, LName);
if (String.IsNullOrEmpty(FName) && String.IsNullOrEmpty(LName))
{
userName = UserID.ToString();
}
else
{
var i = 0;
while (UserBeanHelper.GetUserByUserName(session, userName) != null)
{
i++;
userName = string.Format("{0}.{1}-{2}", FName, LName, i);
}
}
UserTransferBean userByUserName = UserBeanHelper.GetUserByUserName(session, userName);
if (userByUserName != null)
;
else
{
break;
}
}
return userName;
}
+5
#include <iostream>
using namespace std;
void f(void){cout<<"f"<<endl;}
void f1(void){cout<<"f1"<<endl;}
bool secondIfIsTryed(){cout<<"secondIfIsTryed"<<endl;return true;}
#define asserts(Condition) {cout<<"Assert"<<endl;}
int main() {
if(true)
if(secondIfIsTryed() && false)
f();
else
f1();
if(true)
if(secondIfIsTryed() && false)
asserts(true)
else
f1();
return 0;
}
Помните того вечно сомневающегося знакомого, тест крестов, написанный которым я недавно приводил?
http://ideone.com/9Q61D1
В этот раз под его глуповатый, но пытливый взгляд попал макрос ассерта. Написан он конечно не так, как в этом тесте, но имеет код вида:
#define asserts(Condition) {/*...*/}
+124
// Просрока быть недолжно.
// Если нет платежа, то будет исключение.
// Оба эти случая логически исключены, если медот не дергать в неположеном месте.