1. Лучший говнокод

    В номинации:
    За время:
  2. C# / Говнокод #13142

    +132

    1. 1
    private static string TestExistFiles(ref int maxd, ref Hashtable executedgroups)

    taburetka, 10 Июня 2013

    Комментарии (15)
  3. PHP / Говнокод #13060

    +147

    1. 1
    trim($_GET['password'])

    nc

    sleeper, 28 Мая 2013

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

    +162

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    try {
                die(@date("d.m.Y H:i:s") . "\t" . $this->x($id, true) . "\r\n");
    } catch (Exception $e) {
                die(@date("d.m.Y H:i:s") . "\tERROR: " . $e->getMessage() . "\r\n");
    }

    остаться в живых

    Lure Of Chaos, 15 Мая 2013

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

    +101

    1. 1
    2. 2
    3. 3
    4. 4
    if(searchParams == null)
    {
    	throw new NullReferenceException("параметры поиска = null" + searchParams.ToString());
    }

    Эдакий InnerException, чтоб верняково

    NeoN, 01 Мая 2013

    Комментарии (15)
  6. 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)
  7. JavaScript / Говнокод #12807

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    $.post("include/show_watching.php",
        function(data) {
            $('#content').empty().append(data);
        }
    );

    Вот такой вот POST-запрос.

    Stallman, 26 Марта 2013

    Комментарии (15)
  8. C# / Говнокод #12803

    +133

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    using (var twainManager = new DeviceManager())
    {
        twainManager.Open();
        using (var evn = new ManualResetEvent(false))
        {
            var device = twainManager.Devices[targetDevice.Index];
            device.UserInterfaceClosed += (sender, args) => { evn.Set(); };
            device.Setup();
            evn.WaitOne();
        }
        twainManager.Close();
    }

    Модальное открытие говноформы.

    kovyl2404, 25 Марта 2013

    Комментарии (15)
  9. JavaScript / Говнокод #12774

    +161

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    function printf(format, value) {
          return format.replace(/%s/, value.toString());
        }
    
        return {
    
          updateProgressBar: function (percentage) {
            console.log("update \"progressBar\" status");
            progressBar.innerHTML = printf("<p>%s %</p>", percentage);
          }
    
        };

    __proto__, 21 Марта 2013

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

    +149

    1. 1
    2. 2
    $ev = '$atHtml[] = template::translateTemplate('.$atArr[0].'::getHTML($atArr[1]));';
    eval($ev);

    Самый простой способ заставить работать статический метод класса из переменной в PHP ниже 5.3.

    Lander, 20 Марта 2013

    Комментарии (15)
  11. SQL / Говнокод #12742

    −167

    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
    declare @billing_types table(k int null, t varchar(14)
    	collate SQL_Latin1_General_CP1255_CI_AS)
    insert @billing_types 
    values (1, 'אשרי')
    	   ,(2, 'צ׳ק')
    	   ,(3, 'הוראת קבע')
    
    declare @standing_order_status table(i int null, s varchar(14)
    	collate SQL_Latin1_General_CP1255_CI_AS)
    insert @standing_order_status 
    values (4, 'מבותל')
    	   ,(3, 'לא מאושר')
    	   ,(2, 'ממתין')
    	   ,(1, 'מאושר')
    
    declare @fax varchar(20)
    
    select billing_company_id
          ,internal_company_name
    	  ,isnull(t, 'לא פעיל') collate SQL_Latin1_General_CP1255_CI_AS as payment_type_string
          ,case when company_email is null then ''
    			when replace((ltrim(rtrim(company_email))), '0', '') = '' then ''
    			-- some emails were imported in the way, they aren't valid
    			when charindex('@', company_email) = 0 then ''
    			else (ltrim(rtrim(company_email))) end as email
          ,case when replace(ltrim(rtrim(company_fax)), '0', '') = '' 
    			then ''
    	   		when -- some times there are words like "none", "n/a" etc. in there
    			replace(replace(replace(replace(replace(replace(replace(
    				replace(replace(replace(replace(ltrim(rtrim(company_fax)), '-', ''), 
    				'0', ''), '1', ''), '2', ''), '3', ''), '4', ''), '5', ''), '6', ''),
    				'7', ''), '8', ''), '9', '') != '' 
    			then ''
    			else replace(ltrim(rtrim(company_fax)), '-', '')
    		end as c_fax
          ,ltrim(rtrim(company_address)) as c_address
          ,ltrim(rtrim(cast(company_comments as varchar(1000)))) as c_comments
          ,invoice_send_with_details
          ,invoice_send_fax
          ,invoice_print
          ,ltrim(rtrim(cc_name)) as c_name
          ,ltrim(rtrim(cc_number)) as c_number
          ,ltrim(rtrim(cc_cvv)) as c_cvv
          ,ltrim(rtrim(cc_id)) as c_id
          ,ltrim(rtrim(cc_expire)) as c_expire
          ,ltrim(rtrim(bank_number)) as number
          ,ltrim(rtrim(bank_branch)) as branch
          ,ltrim(rtrim(bank_account)) as account
          ,bank_hoshen
    	  ,isnull(s, 'אין') collate SQL_Latin1_General_CP1255_CI_AS as order_status
    from billing_companies
    left join @billing_types bt on bt.k = payment_type
    left join @standing_order_status os on os.i = bank_standing_order_status

    Война. Экспорт в Эксель, для того, чтобы потом ее обратно, но уже другим людям в базу передать.
    Из интересных подробностей. Поле "факс" в базе имеет тип varchar(50), например. Никакой серверной валидации отродясь не было. Иногда люди просто путали факс и электорпочту, когда заполняли данные.

    wvxvw, 13 Марта 2013

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