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

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

    +10

    1. 1
    2. 2
    3. 3
    4. 4
    #ifdef _MSC_VER
    template<typename> using void_t = void;
    __if_exists(void_t<int>) {}
    #endif

    Эти строчки превратят Visual Studio 2015 в блокнот с подсветкой синтаксиса.
    Для максимального эффекта их следует поместить в stdafx.h или любой другой повсеместно используемый заголовок.
    Предположительно, на более старых студиях будет тот же эффект, но я не проверял.

    gammaker, 05 Августа 2016

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

    +139

    1. 1
    #define LIFMT(X) (long int) (X)

    Всё тот же квантовохимический пакет. Что характерно, от обычных кастов дальше никто не отказывается.

    dxd, 20 Марта 2015

    Комментарии (172)
  4. Assembler / Говнокод #11319

    +146

    1. 1
    huiX5uiPH5;;P5;@@5HH4XPPDXDPhuiX5fiTГ

    Было запощено в 11315, но, мне кажется, что этот ГК заслуживает отдельного топика.

    Когда-то давно пытался на ассемблере включить видеорежим 320x200x256 (13h) и порисовать. Но XP сменив режим потеряла управление. Помог только ребут. В тот день, матерясь на MS, я и решил написать эту строчку так, чтобы ее можно было вводить с помощью обычного блокнота на любой машине...

    Системные требования: Windows XP
    Текст набирается в кодировке CP1251. Файл должен иметь расширение COM.

    bormand, 29 Июня 2012

    Комментарии (172)
  5. Java / Говнокод #3655

    +81

    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
    if (f.mColor != null) {
                    int c = -1;
    
                    if (f.mColor.equalsIgnoreCase("aqua")) {
                        c = 0x00FFFF;
                    } else if (f.mColor.equalsIgnoreCase("black")) {
                        c = 0x000000;
                    } else if (f.mColor.equalsIgnoreCase("blue")) {
                        c = 0x0000FF;
                    } else if (f.mColor.equalsIgnoreCase("fuchsia")) {
                        c = 0xFF00FF;
                    } else if (f.mColor.equalsIgnoreCase("green")) {
                        c = 0x008000;
                    } else if (f.mColor.equalsIgnoreCase("grey")) {
                        c = 0x808080;
                    } else if (f.mColor.equalsIgnoreCase("lime")) {
                        c = 0x00FF00;
                    } else if (f.mColor.equalsIgnoreCase("maroon")) {
                        c = 0x800000;
                    } else if (f.mColor.equalsIgnoreCase("navy")) {
                        c = 0x000080;
                    } else if (f.mColor.equalsIgnoreCase("olive")) {
                        c = 0x808000;
                    } else if (f.mColor.equalsIgnoreCase("purple")) {
                        c = 0x800080;
                    } else if (f.mColor.equalsIgnoreCase("red")) {
                        c = 0xFF0000;
                    } else if (f.mColor.equalsIgnoreCase("silver")) {
                        c = 0xC0C0C0;
                    } else if (f.mColor.equalsIgnoreCase("teal")) {
                        c = 0x008080;
                    } else if (f.mColor.equalsIgnoreCase("white")) {
                        c = 0xFFFFFF;
                    } else if (f.mColor.equalsIgnoreCase("yellow")) {
                        c = 0xFFFF00;
                    } else {
                        try {
                            c = XmlUtils.convertValueToInt(f.mColor, -1);
                        } catch (NumberFormatException nfe) {
                            // Can't understand the color, so just drop it.
                        }
                    }

    Исходники Android 1.5, Html.java:636 .

    Неудивительно, что Html.fromHtml() тормозит так, что юзать для списков вообще нельзя, даже один раз.

    yvu, 07 Июля 2010

    Комментарии (172)
  6. Куча / Говнокод #28940

    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
    Пиздец-оффтоп #100
                                    (
    
                                    )
                                   (o)
                                   ,|,
                                   |~\
                          o@@@@@@@@\ |@@@@@I@@r@
                     oo@@@@@@@@@@@@|`|@@@@@@@@@@@T@@ 
                 o@@@@@@@@@@@@@@@@@\ |@@@@@@@@@@@@@R@@@@o
               o@@@y@@@@@@@@@@@@@@@|`\@@@@@@@@@@@@@@K@@@@@o
              @@@@@@o@@@@@@@@@@@@@@\ |@@@@@@@@@@@@@@@a@@@@@@
              p@@@@@@@u@@@@@@@@@@@@@@@@@@@@@@@@@@@@F@@@@@@@q
              @@o@@@@@@@@t@@@@@@@@@@@@@@@@@@@@@@@j@@@@@@@o@@
              @:@@@o@@@@@@@@u@@@@@@@@@@@@@@@@@@l@@@@@@o@@::@
              ::@@::@@o@@@@@@@.@@b@e@@/@@Y@@6@@@@@@o@@:@@::@
              ::@@::@@@@::oo@@@@oo@@@@@ooo@@@@@o:::@@@::::::
              %::::::@::::::@@@@:::@@@:::::@@@@:::::@@:::::%
              %%::::::::::::@@::::::@:::::::@@::::::::::::%%
              ::%%%::::::::::@::::::::::::::@::::::::::%%%::
            .#::%::%%%%%%:::::::::::::::::::::::::%%%%%::%::#.
          .###::::::%%:::%:%%%%%%%%%%%%%%%%%%%%%:%:::%%:::::###.
        .#####::::::%:::::%%::::::%%%%:::::%%::::%::::::::::#####.
       .######`:::::::::::%:::::::%:::::::::%::::%:::::::::'######.
       .#########``::::::::::::::::::::::::::::::::::::''#########.
       `.#############```::::::::::::::::::::::::'''#############.'
        `.######################################################.'
          ` .###########,._.,,,. #######<_\##################. '
             ` .#######,;:      `,/____,__`\_____,_________,_____
                `  .###;;;`.   _,;>-,------,,--------,----------'
                    `  `,;' ~~~ ,'\######_/'#######  .  '
                        ''~`''''    -  .'/;  -    '

    #70: (vanished) https://govnokod.xyz/_28667
    #71: https://govnokod.ru/28677 https://govnokod.xyz/_28677
    #72: https://govnokod.ru/28685 https://govnokod.xyz/_28685
    #73: https://govnokod.ru/28692 https://govnokod.xyz/_28692
    #74: https://govnokod.ru/28699 https://govnokod.xyz/_28699
    #75: https://govnokod.ru/28705 https://govnokod.xyz/_28705
    #76: https://govnokod.ru/28712 https://govnokod.xyz/_28712
    #77: https://govnokod.ru/28722 https://govnokod.xyz/_28722
    #78: https://govnokod.ru/28730 https://govnokod.xyz/_28730
    #79: https://govnokod.ru/28736 https://govnokod.xyz/_28736
    #80: https://govnokod.ru/28740 https://govnokod.xyz/_28740
    #81: https://govnokod.ru/28750 https://govnokod.xyz/_28750
    #82: https://govnokod.ru/28779 https://govnokod.xyz/_28779
    #83: https://govnokod.ru/28788 https://govnokod.xyz/_28788
    #84: https://govnokod.ru/28795 https://govnokod.xyz/_28795
    #85: https://govnokod.ru/28808 https://govnokod.xyz/_28808
    #86: (vanished) https://govnokod.xyz/_28814
    #87: https://govnokod.ru/28817 https://govnokod.xyz/_28817
    #88: https://govnokod.ru/28836 https://govnokod.xyz/_28836
    #89: https://govnokod.ru/28843 https://govnokod.xyz/_28843
    #90: https://govnokod.ru/28874 https://govnokod.xyz/_28874
    #91: https://govnokod.ru/28880 https://govnokod.xyz/_28880
    #92: https://govnokod.ru/28884 https://govnokod.xyz/_28884
    #93: https://govnokod.ru/28889 https://govnokod.xyz/_28889
    #94: https://govnokod.ru/28895 https://govnokod.xyz/_28895
    #95: https://govnokod.ru/28904 https://govnokod.xyz/_28904
    #96: https://govnokod.ru/28912 https://govnokod.xyz/_28912
    #97: https://govnokod.ru/28918 https://govnokod.xyz/_28918
    #98: https://govnokod.ru/28932 https://govnokod.xyz/_28932
    #99: https://govnokod.ru/28936 https://govnokod.xyz/_28936

    nepeKamHblu_nemyx, 10 Мая 2024

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

    0

    1. 1
    2. 2
    3. 3
    4. 4
    <?php $o_ids = array();
    foreach ($orders_num as $thiso){array_push($o_ids, $thiso->id);}
    echo implode(", ", $o_ids);
    ?>

    Найдено в дебрях легаси

    fiammathegreat, 19 Февраля 2020

    Комментарии (171)
  8. PHP / Говнокод #17103

    +157

    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
    //
    // JS-protected mailto: link
    //
    function s2_js_mailto($name, $email)
    {
    	$parts = explode('@', $email);
    
    	if (count($parts) != 2)
    		return $name;
    
    	return '<script type="text/javascript">var mailto="'.$parts[0].'"+"%40"+"'.$parts[1].'";'.
    		'document.write(\'<a href="mailto:\'+mailto+\'">'.str_replace('\'', '\\\'', $name).'</a>\');</script>'.
    		'<noscript>'.$name.', <small>['.$parts[0].' at '.$parts[1].']</small></noscript>';
    }

    И вот таким образом, S2 CMS защищает почтовые адреса через PHP/JS. Оригинально.

    volter9, 13 Ноября 2014

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

    +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
    final class HackFormFlowPanel extends FormPanel {
    	...
    	
    	@Override
    	public void reset() {
    		GWT.log("Upload form reset suppressed");
    		// Overridden to do nothing.
    	}
    	
    	public void reallyReset() {
    		super.reset();
    	}
    }

    После успешного аплоада файла gwtupload говорит reset форме с элементом выбора файла. И никак не отключается. А нужно, чтобы файл оставался выбранным.

    Пришлось нагородить вот такой костыль.

    someone, 24 Января 2014

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

    +19

    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
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <iostream>
    }
    void main (){
    int prog=0,n;
    
    printf ("Which programm?  ");
    scanf ("%d",&prog);
    
    if (prog==1){
    int glas=0,sogl=0,j=0,k=0;
     char *s,*l,*m;
     s=(char*)calloc(20,sizeof(char));
     l=(char*)calloc(20,sizeof(char));
     m=(char*)calloc(20,sizeof(char));
     flushall();
     printf ("\nEnter text:  ");
     gets(s);
     n=strlen(s);
     /*Разбиваем на два массива исходную строку*/
     for (int i=0;i<n;i++){
    if(s[i]=='a'||s[i]=='q'||s[i]=='e'||s[i]=='y'||s[i]=='u'||s[i]=='i'||s[i]=='o'||s[i]=='j'){ l[j]=s[i]; glas++;j++;}
    if(s[i]=='g'||s[i]=='f'||s[i]=='d'||s[i]=='s'||s[i]=='p'||s[i]=='t'||s[i]=='r'||s[i]=='w'||s[i]=='h'||s[i]=='k'||s[i]=='l'||s[i]=='z'||s[i]=='x'||s[i]=='c'||s[i]=='v'||s[i]=='b'||s[i]=='b'||s[i]=='n'||s[i]=='m'){ m[k]=s[i];sogl++;k++;}
       }
        printf ("\nDivided:\n");
     puts(l);puts(m);
    /*Сортируем каждый массив*/
     char c=51,d=11;
     for(j=0;j<sogl;j++) {for (int i=0;i<sogl;i++){if (m[i]>m[i+1] && (i+1)<sogl){d=m[i+1];  m[i+1]=l[i];  m[i]=d;}}}
     for(j=0;j<glas;j++){ for (int i=0;i<glas;i++){if (l[i]>l[i+1] && (i+1)<glas){c=l[i+1];  l[i+1]=l[i];  l[i]=c;}}}
     
      printf ("\nFinal:\n");
     puts(l);
     flushall();
     puts(m);
     }

    Источник: http://otvety.google.ru/otvety/thread?tid=78a81d7ac11a8804&table=/otvety/topics?clk=lftpn&tab=wtmtosb
    Цитата: "Задача: Написать программу для обработки строки следующим образом: вначале должны идти гласные буквы, упорядоченные по возрастанию (aaeeiioo), затем согласные, упорядоченные по убыванию.
    Написал программу, она нормально сортирует гласные, но когда переходит к согласным - совершенно не работает."

    10a10b1s, 12 Января 2013

    Комментарии (171)
  11. Pascal / Говнокод #8664

    +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
    function naq(a:integer;n:integer;m:integer):string;
    var astr:string;
    begin
      astr:=inttostr(a);
         case m of
           1: naq:=astr+'*p^'+inttostr(n)+'-'+inttostr(a*1)+'*p^'+inttostr(n+1);
           2: naq:=astr+'*p^'+inttostr(n)+'-'+inttostr(a*2)+'*p^'+inttostr(n+1)+'+'+inttostr(a*1)+'*p^'+inttostr(n+2);
           3: naq:=astr+'*p^'+inttostr(n)+'-'+inttostr(a*3)+'*p^'+inttostr(n+1)+'+'+inttostr(a*3)+'*p^'+inttostr(n+2)+'-'+inttostr(a*1)+'*p^'+inttostr(n+3);
           4: naq:=astr+'*p^'+inttostr(n)+'-'+inttostr(a*4)+'*p^'+inttostr(n+1)+'+'+inttostr(a*6)+'*p^'+inttostr(n+2)+'-'+inttostr(a*4)+'*p^'+inttostr(n+3)+'+'+inttostr(a*1)+'*p^'+inttostr(n+4);
           5: naq:=astr+'*p^'+inttostr(n)+'-'+inttostr(a*5)+'*p^'+inttostr(n+1)+'+'+inttostr(a*10)+'*p^'+inttostr(n+2)+'-'+inttostr(a*10)+'*p^'+inttostr(n+3)+'+'+inttostr(a*5)+'*p^'+inttostr(n+4)+'-'+inttostr(a*1)+'*p^'+inttostr(n+5);
           6: naq:=astr+'*p^'+inttostr(n)+'-'+inttostr(a*6)+'*p^'+inttostr(n+1)+'+'+inttostr(a*15)+'*p^'+inttostr(n+2)+'-'+inttostr(a*20)+'*p^'+inttostr(n+3)+'+'+inttostr(a*15)+'*p^'+inttostr(n+4)+'-'+inttostr(a*6)+'*p^'+inttostr(n+5)+'+'+inttostr(a*1)+'*p^'+inttostr(n+6);
           7: naq:=astr+'*p^'+inttostr(n)+'-'+inttostr(a*7)+'*p^'+inttostr(n+1)+'+'+inttostr(a*21)+'*p^'+inttostr(n+2)+'-'+inttostr(a*35)+'*p^'+inttostr(n+3)+'+'+inttostr(a*35)+'*p^'+inttostr(n+4)+'-'+inttostr(a*21)+'*p^'+inttostr(n+5)+'+'+inttostr(a*7)+'*p^'+inttostr(n+6)+'-'+inttostr(a*1)+'*p^'+inttostr(n+7);
           8: naq:=astr+'*p^'+inttostr(n)+'-'+inttostr(a*8)+'*p^'+inttostr(n+1)+'+'+inttostr(a*28)+'*p^'+inttostr(n+2)+'-'+inttostr(a*56)+'*p^'+inttostr(n+3)+'+'+inttostr(a*70)+'*p^'+inttostr(n+4)+'-'+inttostr(a*56)+'*p^'+inttostr(n+5)+'+'+inttostr(a*28)+'*p^'+inttostr(n+6)+'-'+inttostr(a*8)+'*p^'+inttostr(n+7)+'+'+inttostr(a*1)+'*p^'+inttostr(n+8);
           9: naq:=astr+'*p^'+inttostr(n)+'-'+inttostr(a*9)+'*p^'+inttostr(n+1)+'+'+inttostr(a*36)+'*p^'+inttostr(n+2)+'-'+inttostr(a*84)+'*p^'+inttostr(n+3)+'+'+inttostr(a*126)+'*p^'+inttostr(n+4)+'-'+inttostr(a*126)+'*p^'+inttostr(n+5)+'+'+inttostr(a*84)+'*p^'+inttostr(n+6)+'-'+inttostr(a*36)+'*p^'+inttostr(n+7)+'+'+inttostr(a*9)+'*p^'+inttostr(n+8)+'+'+inttostr(a*1)+'*p^'+inttostr(n+9);
         end;
      end;

    Лень было искать алгоритм раскрытия (1-q)^n

    rob1nzon, 28 Ноября 2011

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