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

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

    +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
    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
    function order_to() {
        jQuery.ajax({
            type: "POST",
            url: url+'/saveMethod/',
            data: {
                "method": "guest"
            },
            success: function(success) {
                console.log(success);
                jQuery.ajax({
                    type: "POST",
                    url: url+'/saveBilling/',
                    data: {
                        "billing[address_id]": "",
                        "billing[firstname]": "Test",
                        "billing[lastname]": "Query",
                        "billing[company]": "",
                        "billing[email]": "[email protected]",
                        "billing[street][]": "Street",
                        "billing[city]": "City",
                        "billing[region_id]": "",
                        "billing[region]": "",
                        "billing[postcode]": "50",
                        "billing[country_id]": "UA",
                        "billing[telephone]": "+100500",
                        "billing[fax]": "",
                        "billing[customer_password]": "",
                        "billing[confirm_password]": "",
                        "billing[save_in_address_book]": "1",
                        "billing[use_for_shipping]": "1"
                    },
                    success: function(success) {
                        console.log(success);
                        jQuery.ajax({
                            type: "POST",
                            url: url+'/saveShippingMethod/',
                            data: {
                                "shipping_method": "flatrate_flatrate"
                            },
                            success: function(success) {
                                console.log(success);
                                jQuery.ajax({
                                    type: "POST",
                                    url: url+'/savePayment/',
                                    data: {
                                        "payment[method]": "checkmo"
                                    },
                                    success: function(success) {
                                        console.log(success);
                                        var reg = /\/form_key\/(.*?)\/\'\)/;
                                        var raw = jQuery('button.button.btn-cart').attr('onclick');
                                        if (raw == undefined) {
                                            key_form = jQuery('form input[name=form_key]').val();
                                        } else {
                                            var key_form = reg.exec(raw)[1];
                                        };
                                        console.log(key_form);
    
                                        jQuery.ajax({
                                            type: "POST",
                                            url: url+'/saveOrder/form_key/' + key_form + '/',
                                            data: {
                                                "payment[method]": "checkmo"
                                            },
                                            success: function(success) {
                                                console.log(success);
                                            }
                                        });
                                    }
                                });
                            }
                        });
                    }
                });
            }
        });
    }
    order_to();
    order_to();

    Каскадный запрос на jQuery на подтверждение заказа в Magento загнан в функцию и вызывается два раза, потому что с первого не проходит. А еще в одном блоке токен получается из артибута узла через регулярку...

    stail, 16 Мая 2015

    Комментарии (19)
  3. JavaScript / Говнокод #17839

    +154

    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
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    	<title></title>
    </head>
    <body>
    
    </body>
    </html>
    
    <script>
    
    var text = "adsdmdlmf 34vfvf";
    var regex = /\s /
    if (regex != 0){
    	alert("Тут два слова")
    }
    else {
    	alert("Тут одно слово")
    }
    </script>

    Первый говнопост (задача проверить является ли текст одним словом)

    kychagovn, 22 Марта 2015

    Комментарии (19)
  4. VisualBasic / Говнокод #17728

    −121

    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
    If ((ind_imit_gun = 0) And _
                ((input_B_LA2 And shop) = shop) And _
                ((input_B_LA2 And loading) = loading) And _
                ((input_B_LA2 And lonely) = lonely) And _
                (input_A_LA48 And choice_k) = choice_k) _
                Or ((ind_imit_gun = 0) And _
                ((input_B_LA2 And shop) = shop) And _
                ((input_B_LA2 And loading) = loading) And _
                ((input_B_LA2 And mashin) = mashin) And _
                (input_A_LA48 And choice_k) = choice_k) _
                Or ((ind_imit_gun = 1) And _
                ((input_B_LA2 And shop) = shop) And _
                ((input_B_LA2 And loading) = loading) And _
                ((input_B_LA2 And lonely) = lonely) And _
                (input_A_LA48 And choice_k) = choice_k) _
                Or ((ind_imit_gun = 2) And _
                ((input_B_LA2 And loading) = loading) And _
                ((input_B_LA2 And lonely) = lonely) And _
                (input_A_LA48 And choice_k) = choice_k) _
                Or ((ind_imit_gun = 2) And _
                ((input_B_LA2 And loading) = loading) And _
                ((input_B_LA2 And mashin) = mashin) And _
                (input_A_LA48 And choice_k) = choice_k) _
                Or ((ind_imit_gun = 3) And _
                ((input_B_LA2 And loading) = loading) And _
                ((input_B_LA2 And mashin) = mashin) And _
                (input_A_LA48 And choice_k) = choice_k) _
                Or ((ind_imit_gun = 4) And _
                ((input_B_LA2 And loading) = loading) And _
                ((input_B_LA2 And lonely) = lonely) And _
                (input_A_LA48 And choice_k) = choice_k) _
                Or ((ind_imit_gun = 6) And _
               ((input_B_LA2 And loading) = loading) And _
                ((input_B_LA2 And lonely) = lonely) And _
                (input_A_LA48 And choice_k) = choice_k) Then

    Вот такая страшная проверка нужных битов битовыми масками используется в одном военном ПО xD
    И на мой взгляд тут есть ошибки,но почему то работает.

    Ramirag, 05 Марта 2015

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

    +48

    1. 1
    (selectedChessman ?: selected)->unselect();

    да уж

    artembegood, 24 Февраля 2015

    Комментарии (19)
  6. C++ / Говнокод #17661

    +55

    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
    bool validateIp(std::string& ip) {
        if( ip.length() == 0 ) {
            return false;
        }
        
        if( ip[0] == '.' ) {
            return false;
        }
        
        // Проверка на наличие 3 точек
        int cp = 0;
        for( int i = 0; i < ip.length(); i++ ) {
            if( ip[i] == '.' ) {
                cp++;
            }
        }
        if( cp != 3 ) {
            std::cout << "проверка на 3 точки" << std::endl;
            return false;
        }
        //=====================
        
        
        // Проверка на 2 точки подряд
        for( int i = 0; i < ip.length()-1; i++ ) {
            if( ip[i] == '.' && ip[i+1] == '.' ) {
                std::cout << "проверка на 2 точки подряд" << std::endl;
                return false;
            }
        }
        //===========================
        
        
        //Проверка на больше 3 цифр подряд
        int i = 0;
        int j = 0;
        for( i = 0; i < ip.length(); i++ ) {
            for( j = i; j < i+4 && j < ip.length(); j++ ) {
                if( j == i+3 && ip[j] != '.' ) {
                    std::cout << "проверка на 4 цифры подряд" << std::endl;
                    return false;
                }
                if( ip[j] == '.' ) {
                    i = j;
                    break;
                }
            }
        }
        
        return true;
        //============================
    }

    Валидация IP-адреса

    lukaville, 17 Февраля 2015

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

    +160

    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
    if ($sub_sub_sub_sub_category_id !== null) {
    
    													if ($this->core->countUrl > 5) {
    														header('Location: /404/');
    													}
    
    													foreach ($categories[$category_id][$sub_category_id][$sub_sub_category_id][$sub_sub_sub_category_id][$sub_sub_sub_sub_category_id] as $k1 => $v1) {
    														if ($k1 !== 0) {
    															foreach ($v1 as $k2 => $v2) {
    																if ($k2 !== 0) {
    																	if ($this->core->translit($v2[0]) == $sub_sub_sub_category) {
    																		$sub_sub_sub_sub_sub_category_id = $k1;
    																		$sub_sub_sub_sub_sub_sub_category_id = $k2;
    																		break;
    																	}
    																}
    															}
    														}
    													}
    
    													$this->core->title($categories[$category_id][$sub_category_id][$sub_sub_category_id][$sub_sub_sub_category_id][$sub_sub_sub_sub_category_id][$sub_sub_sub_sub_sub_category_id][$sub_sub_sub_sub_sub_sub_category_id][0]);
    													$bread_crumbs[] = array(
    														'text' => $categories[$category_id][$sub_category_id][$sub_sub_category_id][$sub_sub_sub_category_id][$sub_sub_sub_sub_category_id][$sub_sub_sub_sub_sub_category_id][$sub_sub_sub_sub_sub_sub_category_id][0],
    														'url' => $location['alias'] . '/' . $this->core->translit($categories[$category_id][0]) . '/' . $this->core->translit($categories[$category_id][$sub_category_id][$sub_sub_category_id][0]) . '/' . $this->core->translit($categories[$category_id][$sub_category_id][$sub_sub_category_id][$sub_sub_sub_category_id][$sub_sub_sub_sub_category_id][0]) . '/' . $this->core->translit($categories[$category_id][$sub_category_id][$sub_sub_category_id][$sub_sub_sub_category_id][$sub_sub_sub_sub_category_id][$sub_sub_sub_sub_sub_category_id][$sub_sub_sub_sub_sub_sub_category_id][0])
    													);
    
    													$query_add = "
    														AND (`market_item`.`category_key` = '" . $category_id . "')
    														AND  `market_item`.`param` REGEXP '(\&quot;" . $sub_sub_sub_sub_category_id . "\&quot;)'
    													";
    													
    													$vip_query_add = "
    														AND `market_item`.`category_key` = '" . $category_id . "'
    													";
    
    												}

    qualitycode, 16 Февраля 2015

    Комментарии (19)
  8. Java / Говнокод #17588

    +81

    1. 1
    2. 2
    3. 3
    4. 4
    try {
        // долго и упорно делаем что-то полезное
    } catch (Exception e) {
    }

    После увольнения говнопрограммиста разбираю его творчество.
    Выскочил непонятный Exception? Не беда! Пустой блок catch легко исправит ситуацию и избавит пользователя от неприятных эмоций :)

    farnsworth, 06 Февраля 2015

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

    +136

    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
    private static string RemoveInvalidChars(string source)
    {
        foreach (var c in invalidChars)
            source = source.Replace(c.ToString(), "");
    
        return source;
    }
    
    public static string Validate(string source)
    {
        source = RemoveInvalidChars(source);
    
        return source;
    }

    pushistayapodmyshka, 02 Февраля 2015

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

    +95

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    static void Main(string[] args)
            {
                Func<int, int> m = delegate(int a)
                {
                    Func<int, int> c = x => x / 2;
                    return a * c(a);
                };
                Console.WriteLine(m(10));
                Console.ReadKey();
            }

    Нестандартный подход

    SharK1870, 24 Января 2015

    Комментарии (19)
  11. C++ / Говнокод #17483

    +76

    1. 1
    2. 2
    if ( !log.append(log_line) )
    	log.append("Can't append to log");

    Безумие, оно рядом.

    Anus, 20 Января 2015

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