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

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

    −2

    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
    connect_attempt = 0
    		while True:
    			try:
    				r = requests_method(**kwargs)
    			except Exception as e:
    				if connect_attempt < cls.CONNECT_ATTEMPT_MAX:
    					connect_attempt += 1
    				else:
    					connect_attempt = 0
    					switchNext('Bad proxy')
    				
    				continue
    			
    			connect_attempt = 0
    			if cls.re_captcha.search(r.text):
    				switchNext('Capthca')
    				continue
    			return r

    Отрывок из прокси свитчера для моего парсера.
    try except в цикле - это плохо?

    OlegUP, 04 Сентября 2019

    Комментарии (140)
  3. Куча / Говнокод #19049

    +2

    1. 1
    2. 2
    А что Рутубом кто то пользуется ? 
    http://habrahabr.ru/company/rutube/blog/271143/

    Vasiliy, 19 Ноября 2015

    Комментарии (140)
  4. Java / Говнокод #17137

    +73

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    public MyVirtualMachine(URL uri, String name, String username,
                String password) throws RemoteException, MalformedURLException {
    
    ...
    
              if (!name.equalsIgnoreCase(name)) {
                       continue;
              }
    }

    Использование одного и того же поля name при сравнении.
    http://wernerstrydom.com/2013/04/14/a-helper-class-to-manage-a-virtual-machine-in-vmware-vsphere-hypervisor-5-1/

    seriousden, 19 Ноября 2014

    Комментарии (140)
  5. Куча / Говнокод #11978

    +132

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    main = do
            print [1 .. 9]
            print [1, 3 .. 9]
            print [1, 3 .. 10]
            print [26.0, 26.2 .. 27.0]
            print [25.5..30.0]
            print [25, 25 .. 25]

    В хаскеле сломан генератор списков. :(
    http://ideone.com/AvBSuz

    HaskellGovno, 22 Октября 2012

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

    +1003

    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
    namespace ExtensionMethods
    {
        public static class MyExtensions
        {
            public static int WordCount(this String str)
            {
                return str.Split(new char[] { ' ', '.', '?' }, 
                                 StringSplitOptions.RemoveEmptyEntries).Length;
            }
        }   
    }
    ....
    string s = "Hello Extension Methods";
    int i = s.WordCount();

    http://msdn.microsoft.com/en-us/library/bb383977.aspx

    In your code you invoke the extension method with instance method syntax. However, the intermediate language (IL) generated by the compiler translates your code into a call on the static method. Therefore, the principle of encapsulation is not really being violated. In fact, extension methods cannot access private variables in the type they are extending.

    Синтаксический сахар. Бессмысленный и беспощадный.
    Ждк, когда шарпоблядки уже начнут дохнуть от диабета.

    3.14159265, 26 Ноября 2011

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

    +3

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    Помните шутку про 1С/C++/CSH программиста?
    Так вот: парень хочет работать с COM портом, но почему-то COM объект в Windows не создается.
    
    
    https://phpclub.ru/talk/threads/%D0%9E%D1%88%D0%B8%D0%B1%D0%BA%D0%B0-failed-to-create-com-object.86770/

    MAKAKA, 21 Мая 2020

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

    +2

    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
    http://faqs.org.ru/progr/c_cpp/watcom_c.htm
    
                    WATCOM C/C++ FAQ
    
                       version 3.0
                       29 Aug 1998
    
            compiled by Lenik Terenin, 2:5061/1
    
    Maintained by Cyril Pertsev, 2:5020/1415.1
    Please send your additions and suggestions to the above address.
    
    Для удобства потpебления данного текста
    добавления выделены символом квотинга
    
    ...
    
    > Q: Гpафическая библиотека ваткома отказывается пеpеключать pежимы/банки
    > или делает это кpиво
    
    >A: В результате ковыряния в библиотеке выяснилось, что криворукие
    >ваткомовцы
    >совершенно не задумываются ни о какой переносимости и универсальности их
    >библиотек. В результате, если видео-карта имеет в биосе прошитое имя
    >производителя или другую информацию о нем, то для нее будет вызываться
    >вместо
    >функции переключения банков через VESA, другая функция, работающая с
    >картой
    >напрямую (иногда даже через порты).
    >Единственная проблема, что у каждого производителя (ATI, в моем случае),
    >рано
    >или поздно выходят новые и продвинутые карты, раскладка портов в которых
    >может
    >отличаться от той, которая использовалась в старых моделях. В результате,
    >все
    >это свинство начинает глючить и иногда даже виснуть.
    >После того, как я руками заткнул ему возможность использовать "родные"
    >фишки
    >для конкретной карты и прописал пользоваться только VESA -- все работает
    >как из
    >пушки ;))
    >Как затыкать -- а просто, есть переменная: _SVGAType, которую я
    >описывается
    >следующим образом: "extern "C" int _SVGAType;", и потом _перед_ (важно!)
    >вызовом _setvideomode нужно сказать "_SVGAType = 1;".

    Люблю читать несвежие FAQ.

    Сегодня-то такого не встретишь, чтобы кто-то прямо в порты в видеокарту что-то писал, эхх...

    j123123, 31 Июля 2018

    Комментарии (139)
  9. Куча / Говнокод #18045

    −306

    1. 1
    http://stackoverflow.com/questions/1995113/strangest-language-feature

    Может, кто-то еще не видел. Пишите, что вам понравилось.

    3_14dar, 23 Апреля 2015

    Комментарии (139)
  10. Куча / Говнокод #27842

    0

    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
    <style type="text/css" media="all">
    	html.cms a[href^="https://www.who.int"][href$="/en"] {background-color:#ffcc00;}
    	html.cms a[href^="https://www.who.int"][href$="/en/"] {background-color:#ffcc00;}
        html.cms a[href^="http://www.who.int"][href$="/en"] {background-color:#ffcc00;}
    	html.cms a[href^="http://www.who.int"][href$="/en/"] {background-color:#ffcc00;}
    	html.cms a[href^="/"][href$="/en"] {background-color:#ffcc00;}
    	html.cms a[href^="/"][href$="/en/"] {background-color:#ffcc00;}
    	html.cms a[href="/"] {background-color:inherit !important;}
    	html.cms a[href="/en"] {background-color:inherit !important;}
    	html.cms a[href="/en/"] {background-color:inherit !important;}
    	html.cms a[href$="http://www.who.int/en"] {background-color:inherit !important;}
    	html.cms a[href$="http://www.who.int/en/"] {background-color:inherit !important;}
    	html.cms a[href$="https://www.who.int/en"] {background-color:inherit !important;}
    	html.cms a[href$="https://www.who.int/en/"] {background-color:inherit !important;}
        html.cms a[href^="https://www.who.int"][href$="/ar"] {background-color:#ffcc00;}
    	html.cms a[href^="https://www.who.int"][href$="/ar/"] {background-color:#ffcc00;}
    	html.cms a[href^="http://www.who.int"][href$="/ar"] {background-color:#ffcc00;}
    	html.cms a[href^="http://www.who.int"][href$="/ar/"] {background-color:#ffcc00;}
    	html.cms a[href^="/"][href$="/ar"] {background-color:#ffcc00;}
    	html.cms a[href^="/"][href$="/ar/"] {background-color:#ffcc00;}
    	html.cms a[href="/ar"] {background-color:inherit !important;}
    	html.cms a[href="/ar/"] {background-color:inherit !important;}
    	html.cms a[href$="http://www.who.int/ar"] {background-color:inherit !important;}
    	html.cms a[href$="http://www.who.int/ar/"] {background-color:inherit !important;}
    	html.cms a[href^="https://www.who.int"][href$="/zh"] {background-color:#ffcc00;}
    	html.cms a[href^="https://www.who.int"][href$="/zh/"] {background-color:#ffcc00;}
    	html.cms a[href^="http://www.who.int"][href$="/zh"] {background-color:#ffcc00;}
    	html.cms a[href^="http://www.who.int"][href$="/zh/"] {background-color:#ffcc00;}
    	html.cms a[href^="/"][href$="/zh"] {background-color:#ffcc00;}
    	html.cms a[href^="/"][href$="/zh/"] {background-color:#ffcc00;}
    	html.cms a[href="/zh"] {background-color:inherit !important;}
    	html.cms a[href="/zh/"] {background-color:inherit !important;}
    	html.cms a[href$="http://www.who.int/zh"] {background-color:inherit !important;}
    	html.cms a[href$="http://www.who.int/zh/"] {background-color:inherit !important;}
    	html.cms a[href$="https://www.who.int/zh"] {background-color:inherit !important;}
    	html.cms a[href$="https://www.who.int/zh/"] {background-color:inherit !important;}
    	html.cms a[href^="https://www.who.int"][href$="/fr"] {background-color:#ffcc00;}
    	html.cms a[href^="https://www.who.int"][href$="/fr/"] {background-color:#ffcc00;}
        html.cms a[href^="http://www.who.int"][href$="/fr"] {background-color:#ffcc00;}
    	html.cms a[href^="http://www.who.int"][href$="/fr/"] {background-color:#ffcc00;}
    	html.cms a[href^="/"][href$="/fr"] {background-color:#ffcc00;}
    	html.cms a[href^="/"][href$="/fr/"] {background-color:#ffcc00;}
    	html.cms a[href="/fr"] {background-color:inherit !important;}
    	html.cms a[href="/fr"] {background-color:inherit !important;}
    	html.cms a[href="/fr/"] {background-color:inherit !important;}
    	html.cms a[href$="http://www.who.int/fr"] {background-color:inherit !important;}
    	html.cms a[href$="http://www.who.int/fr/"] {background-color:inherit !important;}
    	html.cms a[href$="https://www.who.int/fr"] {background-color:inherit !important;}
    	html.cms a[href$="https://www.who.int/fr/"] {background-color:inherit !important;}
    	html.cms a[href^="https://www.who.int"][href$="/ru"] {background-color:#ffcc00;}
    	html.cms a[href^="https://www.who.int"][href$="/ru/"] {background-color:#ffcc00;}
    </style>

    Сайт ВОЗ. Многое можно ожидать от frontend, но такое...

    rotoeb, 26 Ноября 2021

    Комментарии (138)
  11. Куча / Говнокод #26984

    +1

    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
    pub struct Vec { x: u32, y: u32, z: u32, }
    
    pub extern "C" fn sum_c(a: &Vec, b: &Vec) -> Vec {
        return Vec {x: a.x + b.x, y: a.y + b.y, z: a.z + b.z };
    }
    
    pub fn sum_rust(a: &Vec, b: &Vec) -> Vec {
        return Vec {x: a.x + b.x, y: a.y + b.y, z: a.z + b.z };
    }
    
    Выхлоп:
    
    example::sum_c:
            mov     eax, dword ptr [rsi]
            add     eax, dword ptr [rdi]
            mov     ecx, dword ptr [rsi + 4]
            add     ecx, dword ptr [rdi + 4]
            mov     edx, dword ptr [rsi + 8]
            add     edx, dword ptr [rdi + 8]
            shl     rcx, 32
            or      rax, rcx
            ret
    
    example::sum_rust:
            mov     ecx, dword ptr [rdx]
            mov     r8d, dword ptr [rdx + 4]
            add     ecx, dword ptr [rsi]
            add     r8d, dword ptr [rsi + 4]
            mov     edx, dword ptr [rdx + 8]
            add     edx, dword ptr [rsi + 8]
            mov     rax, rdi
            mov     dword ptr [rdi], ecx
            mov     dword ptr [rdi + 4], r8d
            mov     dword ptr [rdi + 8], edx
            ret

    «Дак йаже как Сишка!», «Даёшь пuтушатню в Ядро!»
    https://godbolt.org/z/Tcnz75
    rustc 1.46 (latest)

    3.14159265, 28 Сентября 2020

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