- 1
- 2
- 3
if (!$_FILES['image']['size'] > 0) {
return;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+148
if (!$_FILES['image']['size'] > 0) {
return;
}
и что самое интересное - оно делает то, что автор пытался изобразить!
−112
+(NSString*)filterDigits:(NSString*)number
{
unichar zer = '0', nine = '9', cur;
unsigned long l = [number length];
NSMutableData *buf = [NSMutableData data];
for (unsigned long j = 0; j!=l; j++)
{
cur = [number characterAtIndex:j];
if (cur>=zer&&cur<=nine)
{
char digit = (char)cur;
[buf appendBytes:&digit length:sizeof(char)];
}
}
NSString* ret = [[[NSString alloc] initWithData:buf encoding:NSUTF8StringEncoding] autorelease];
return ret;
}
Золотые у тебя руки парень. Но всеравно не оттуды растут (;
+149
// Hack - blacklist
if ($msg->abonent == '12345678910')
die("Database error");
Найдено в крупном и сложном проекте, посреди часто вызываемого кода - проверка на забаненный номер (номер изменён).
−163
$query = $sql -> query("SELECT *, COUNT(`id`) as count FROM `d_download` WHERE `id` = '{$id}'", true);
if($query['count'] == 1) {
// code
}
Проверка, что значение найдено.
−102
@interface CORERatingImages : NSObject
{
UIImage *imageForOne;
UIImage *imageForTwo;
UIImage *imageForThree;
UIImage *imageForFour;
UIImage *imageForFive;
}
+(CORERatingImages *) ratingImages;
-(UIImage *) getRatingImage:(int) ratings;
@property (nonatomic, retain) UIImage *imageForOne;
@property (nonatomic, retain) UIImage *imageForTwo;
@property (nonatomic, retain) UIImage *imageForThree;
@property (nonatomic, retain) UIImage *imageForFour;
@property (nonatomic, retain) UIImage *imageForFive;
-(void) releaseResources;
@end
static CORERatingImages *ratingImages = nil;
@implementation CORERatingImages
@synthesize imageForOne;
@synthesize imageForTwo;
@synthesize imageForThree;
@synthesize imageForFour;
@synthesize imageForFive;
+(CORERatingImages *) ratingImages
{
@synchronized(self)
{
if (ratingImages == nil)
{
ratingImages = [[self alloc] init];
}
}
return ratingImages;
}
-(id) init
{
if (self = [super init])
{
self.imageForOne = [UIImage imageNamed:@"1.png"];
self.imageForTwo = [UIImage imageNamed:@"2.png"];
self.imageForThree = [UIImage imageNamed:@"3.png"];
self.imageForFour = [UIImage imageNamed:@"4.png"];
self.imageForFive = [UIImage imageNamed:@"5.png"];
}
return self;
}
-(UIImage *) getRatingImage:(int) ratings
{
if (ratings == 1)
{
return imageForOne;
}
else if (ratings == 2)
{
return imageForTwo;
}
else if (ratings == 3)
{
return imageForThree;
}
else if (ratings == 4)
{
return imageForFour;
}
else if (ratings == 5)
{
return imageForFive;
}
else
{
return [UIImage imageNamed:@"0.png"];
}
}
-(void) dealloc
{
NSLog(@"release Images");
[imageForOne release];
[imageForTwo release];
[imageForThree release];
[imageForFour release];
[imageForFive release];
[super dealloc];
}
-(void) releaseResources
{
[ratingImages release];
ratingImages = nil;
}
@end
Массив или stringWithFormat: @"%d.png"?
Не, не слышал.
−97
@render_to_json()
def view(request):
# ...
return {'name':obj.name for obj in
Company.objects.filter(id=cid, is_valid=True)}
Не, ну а чё? )
−113
if ([_categories count] != 0) {
for (NSString *item in _categories) {
[path appendFormat:@"categories/%@/", item];
}
}
Случайно обнаружил у себя :)
+150
$Not = array('\\',",","/","¬","#",";",":","~","[","]","{","}",")","(","*","^","%","$","<",">","?","!",'"',"'","|");
...
function check($string){
$string = preg_replace("/[^a-zA-Z a-яА-яёЁ]/i", "",$string);
$string = str_replace($Not,'',$string);
$string = htmlspecialchars($string);
return $string;
}
Нашёл у себя убойный фильтр. Работает как зверь :-)
−113
+ (BOOL) isInteger:(CGFloat) number
{
return number - (int) number<0.0001;
}
В классе используется только ради того, чтобы при передаче нецелого флоата вывести километровый NSLog, в котором долго жаловаться на жизнь и полпикселя.
+123
xorl %eax, %eax # cx - source, ebx - result
movw %cx, %ax
andw $0x8000, %ax
shrw $15, %ax
movl $0xFFFFFFFF, %ebx
addl %eax, %ebx
notl %ebx
andl $0xffff0000, %ebx
addw %cx, %bx