1. JavaScript / Говнокод #12890

    +144

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    genchatmessage: function(text, avatar1, avatar2, time, rtl) {
    		if (typeof rtl == "undefined") var rtl = false;
    		if (typeof avatar == "undefined") var avatar = "images/user_male.png";
    		if (typeof time == "undefined") var time = this.gettime();
    		var tr = document.createElement("tr");
    		var td = [document.createElement("td"), document.createElement("td"), document.createElement("td")];
    		var div = document.createElement("div");
    		var span = document.createElement("span");
    		var pre = document.createElement("pre");
    		span.innerHTML = time;
    		pre.innerHTML = interface.innerText(String(text));
    		if (rtl) {
    			div.className = "chat-message-rtl";
    		} else div.className = "chat-message";
    		if (typeof avatar1 == "string") {
    			var img1 = document.createElement("img");
    			img1.src = avatar1;
    			td[0].appendChild(img1);
    		}
    		if (typeof avatar2 == "string") {
    			var img2 = document.createElement("img");
    			img2.src = avatar2;
    			td[2].appendChild(img2);
    		}

    Govnisti_Diavol, 14 Апреля 2013

    Комментарии (4)
  2. PHP / Говнокод #12889

    +157

    1. 1
    strrev(strstr(strrev(substr(strip_tags(stripslashes(htmlspecialchars_decode($row['description']))), 0, 250))," "))

    Вывод краткого содержания материала, найдено на просторах самописного сайта.

    Sanasol, 13 Апреля 2013

    Комментарии (8)
  3. Си / Говнокод #12887

    +138

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    typedef struct {
       UInt8 byte0;
       UInt8 byte1;
       UInt8 byte2;
       UInt8 byte3;
       UInt8 byte4;
       UInt8 byte5;
       UInt8 byte6;
       UInt8 byte7;
       UInt8 byte8;
       UInt8 byte9;
       UInt8 byte10;
       UInt8 byte11;
       UInt8 byte12;
       UInt8 byte13;
       UInt8 byte14;
       UInt8 byte15;
    } CFUUIDBytes;

    http://developer.apple.com/library/ios/documentation/CoreFoundation/Reference/CFUUIDRef/Reference/reference.html
    Nuff said.

    byss, 12 Апреля 2013

    Комментарии (148)
  4. Куча / Говнокод #12886

    +138

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    (04/12/2013 01:39:15 AM) Он: здаров
    (01:39:26 AM) Он: какова хуя $num_point_reverse =  $num_point['number'] - 5;
    (01:39:40 AM) Он: возвращает число и перед числом знак -
    (01:39:42 AM) Он: 
    ?
    (01:50:00 AM) Я: 2-5 =скока?
    (01:50:18 AM) Он: а блядь
    (01:50:25 AM) Я: ))))

    deep, 12 Апреля 2013

    Комментарии (18)
  5. PHP / Говнокод #12885

    +148

    1. 1
    2. 2
    3. 3
    if (!$_FILES['image']['size'] > 0) {
    		return;
    	}

    и что самое интересное - оно делает то, что автор пытался изобразить!

    paulrudy, 12 Апреля 2013

    Комментарии (5)
  6. Objective C / Говнокод #12884

    −112

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    +(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;
    }

    Золотые у тебя руки парень. Но всеравно не оттуды растут (;

    Psionic, 11 Апреля 2013

    Комментарии (12)
  7. PHP / Говнокод #12883

    +149

    1. 1
    2. 2
    3. 3
    // Hack - blacklist
    if ($msg->abonent == '12345678910')
        die("Database error");

    Найдено в крупном и сложном проекте, посреди часто вызываемого кода - проверка на забаненный номер (номер изменён).

    neTpyceB, 11 Апреля 2013

    Комментарии (2)
  8. SQL / Говнокод #12882

    −163

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    $query = $sql -> query("SELECT *, COUNT(`id`) as count FROM `d_download` WHERE `id` = '{$id}'", true);
    
    if($query['count'] == 1) {
     // code
    }

    Проверка, что значение найдено.

    neTpyceB, 11 Апреля 2013

    Комментарии (10)
  9. Objective C / Говнокод #12881

    −102

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    @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"?

    Не, не слышал.

    QuickNick, 11 Апреля 2013

    Комментарии (15)
  10. Python / Говнокод #12880

    −97

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    @render_to_json()
    def view(request):
        # ...
        return {'name':obj.name for obj in
                    Company.objects.filter(id=cid, is_valid=True)}

    Не, ну а чё? )

    Crazyzubr, 11 Апреля 2013

    Комментарии (26)