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

    В номинации:
    За время:
  2. Куча / Говнокод #15955

    +126

    1. 1
    2. 2
    put = "hello"
    put put # Гениально!

    Ну что же, открылся онлайн интерпретатор Lapis-а на отдельном сайте!
    http://lapis.at.ua/Lapis.htm

    Mobac, 10 Мая 2014

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

    +12

    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
    AttachmentService::MimeType AttachmentService::mimeTypeByCodeKey(const QString &codeKey) const
     {
         if(codeKey.toLower() == QString("MimeType_PDF").toLower())       return MimeType_PDF;
         if(codeKey.toLower() == QString("MimeType_JPEG").toLower())      return MimeType_JPEG;
         if(codeKey.toLower() == QString("MimeType_PNG").toLower())       return MimeType_PNG;
         if(codeKey.toLower() == QString("MimeType_HTML").toLower())      return MimeType_HTML;
         if(codeKey.toLower() == QString("MimeType_ZHTML").toLower())     return MimeType_ZHTML;
         if(codeKey.toLower() == QString("MimeType_TEXT").toLower())      return MimeType_TEXT;
         if(codeKey.toLower() == QString("MimeType_XLS").toLower())       return MimeType_XLS;
         if(codeKey.toLower() == QString("MimeType_DOC").toLower())       return MimeType_DOC;
         if(codeKey.toLower() == QString("MimeType_PPT").toLower())       return MimeType_PPT;
         if(codeKey.toLower() == QString("MimeType_GIF").toLower())       return MimeType_GIF;
         if(codeKey.toLower() == QString("MimeType_BMP").toLower())       return MimeType_BMP;
         if(codeKey.toLower() == QString("MimeType_MPEG").toLower())      return MimeType_MPEG;
         if(codeKey.toLower() == QString("MimeType_MP4").toLower())       return MimeType_MP4;
         if(codeKey.toLower() == QString("MimeType_MP3").toLower())       return MimeType_MP3;
         return MimeType_UNKNOWN;
    }

    Коллега откопал в моём коде, написанном под какими-то веществами по ходу.
    Изначально было сравнение строк как есть, без приведения в нижний регистр, а потом понадобилось подстраховаться от левого регистра символов.

    FlySnake, 09 Мая 2014

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

    +146

    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
    .text:08104D0B                 mov     ebx, [ebp+arg_0]
    .text:08104D0E                 mov     ecx, [ebp+var_C]
    .text:08104D11                 mov     eax, 51EB851Fh
    .text:08104D16                 imul    ecx
    .text:08104D18                 sar     edx, 4
    .text:08104D1B                 mov     eax, ecx
    .text:08104D1D                 sar     eax, 1Fh
    .text:08104D20                 sub     edx, eax
    .text:08104D22                 mov     [ebp+var_C], edx
    .text:08104D25                 mov     ecx, [ebx+38h]
    .text:08104D28                 mov     eax, 51EB851Fh
    .text:08104D2D                 imul    ecx
    .text:08104D2F                 sar     edx, 4
    .text:08104D32                 mov     eax, ecx
    .text:08104D34                 sar     eax, 1Fh
    .text:08104D37                 sub     edx, eax
    .text:08104D39                 mov     [ebx+38h], edx
    .text:08104D3C                 cmp     [ebp+var_C], 0
    .text:08104D40                 jg      short loc_8104D55
    .text:08104D42                 mov     [ebp+var_C], 1
    .text:08104D49                 nop
    .text:08104D4A                 nop
    .text:08104D4B                 nop
    .text:08104D4C                 nop
    .text:08104D4D                 nop
    .text:08104D4E                 nop
    .text:08104D4F                 nop
    .text:08104D50                 nop
    .text:08104D51                 nop
    .text:08104D52                 nop
    .text:08104D53                 nop
    .text:08104D54                 nop
    .text:08104D55
    .text:08104D55 loc_8104D55:                            ; CODE XREF: session_skill::StartSession(bool)+222j
    .text:08104D55                 mov     eax, [ebp+arg_0]
    .text:08104D58                 cmp     byte ptr [eax+29h], 0
    .text:08104D5C                 jz      short loc_8104D74
    .text:08104D5E                 mov     ebx, [ebp+arg_0]
    .text:08104D61                 sub     esp, 0Ch
    .text:08104D64                 push    offset g_timer
    .text:08104D69                 call    _ZN5abase5timer8get_tickEv ; abase::timer::get_tick(void)
    .text:08104D6E                 add     esp, 10h
    .text:08104D71                 mov     [ebx+40h], eax
    .text:08104D74
    .text:08104D74 loc_8104D74:                            ; CODE XREF: session_skill::StartSession(bool)+23Ej
    .text:08104D74                 sub     esp, 0Ch
    .text:08104D77                 push    [ebp+var_C]
    .text:08104D7A                 push    0
    .text:08104D7C                 push    14h
    .text:08104D7E                 push    offset g_timer
    .text:08104D83                 mov     eax, [ebp+arg_0]
    .text:08104D86                 add     eax, 10h
    .text:08104D89                 push    eax
    .text:08104D8A                 call    _ZN5abase10timer_task8SetTimerERNS_5timerEiii ; abase::timer_task::SetTimer(abase::timer &,int,int,int)
    .text:08104D8F                 add     esp, 20h
    .text:08104D92                 sub     esp, 8
    .text:08104D95                 sub     esp, 4
    .text:08104D98                 push    18h             ; size
    .text:08104D9A                 call    _ZN5abase12ASmallObjectnwEj ; abase::ASmallObject::operator new(uint)
    .text:08104D9F                 add     esp, 8
    .text:08104DA2                 mov     [ebp+ptr], eax
    .text:08104DA5                 mov     [ebp+var_19], 1
    .text:08104DA9                 sub     esp, 8
    .text:08104DAC                 push    0Dh
    .text:08104DAE                 mov     eax, [ebp+arg_0]
    .text:08104DB1                 push    dword ptr [eax+8]
    .text:08104DB4                 mov     eax, [ebp+arg_0]
    .text:08104DB7                 push    dword ptr [eax+4]
    .text:08104DBA                 push    [ebp+ptr]
    .text:08104DBD                 call    _ZN22skill_interrupt_filterC1EP11gactive_impii ; skill_interrupt_filter::skill_interrupt_filter(gactive_imp *,int,int)
    .text:08104DC2                 add     esp, 18h
    .text:08104DC5                 mov     [ebp+var_19], 0
    .text:08104DC9                 mov     eax, [ebp+ptr]
    .text:08104DCC                 push    eax
    .text:08104DCD                 mov     eax, [ebp+arg_0]
    .text:08104DD0                 mov     eax, [eax+4]
    .text:08104DD3                 add     eax, 100h
    .text:08104DD8                 push    eax
    .text:08104DD9                 call    _ZN10filter_man9AddFilterEP6filter ; filter_man::AddFilter(filter *)
    .text:08104DDE                 add     esp, 10h
    .text:08104DE1                 jmp     short loc_8104E13

    вот собсно

    myWeb, 03 Мая 2014

    Комментарии (24)
  5. PHP / Говнокод #15862

    +153

    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
    if (!empty($_POST["favoriteColor"])) {
        switch($_POST["favoriteColor"]) {
            case "Lightred":
                $strBackgroundColor = "#FFDAB9";
                break;
            case "Lightgreen":
                $strBackgroundColor = "Lightgreen";
                break;
            case "Lightblue":
                $strBackgroundColor = "Lightblue";
                break;
            case "Lightgray":
                $strBackgroundColor = "Lightgray";
                break;
            default:
                $strBackgroundColor = "Gray";
                break;
        }
    } else {
        $strBackgroundColor = "Gray";
    }

    jkhne4pijgberg, 29 Апреля 2014

    Комментарии (24)
  6. Си / Говнокод #15200

    +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
    int mainCRTStartup()
    {
      int argc = 0;
      char* argv[MAX_CMD_ARGS + 1];
      char** pargv = argv;
      char* cmdLine = strdup(GetCommandLineA());
      int result = 0;
    
      g_module = GetModuleHandle(NULL);
      g_process = GetCurrentProcess();
      g_thread = GetCurrentThread();
      g_heap = GetProcessHeap();
    
      for (*pargv = strtok(cmdLine, " "); *pargv && argc < MAX_CMD_ARGS; *pargv = strtok(NULL, " "))
      {
        ++argc;
        ++pargv;
      }
    
      *pargv = NULL;
      result = main(argc, argv);
      free(cmdLine);
      return result;
    }

    LispGovno, 27 Февраля 2014

    Комментарии (24)
  7. Pascal / Говнокод #14674

    +92

    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
    procedure TForm1.BitBtn1Click(Sender: TObject);
    begin
      with message1 do
      begin
        Subject:='Test subject';
        From := '[email protected]';
        To := '[email protected]';
        Textbody:='Text body';
      [. . .]
        Configuration.Fields.Update;
        Send;
    end;
    
    Лососнул тунца.

    with message1 do
    begin
    Subject:='Test subject';
    From := '[email protected]';
    To := '[email protected]';
    Textbody:='Text body';


    'To' - ключевое слово, смирись, смертный, и забудь о 'with'
    p.s. капча сейчас - 4 семерки.

    Stertor, 19 Февраля 2014

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

    +153

    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
    php_sapi_name() === 'cli' or exit('Only CLI mode allowed');
    
    getenv('API_HOST') or exit(<<<EOT
    
      To run tests you should setup "API_HOST" environment variable.
      Try follow in bash command line:
    
      $ export API_HOST=<api_host>
      cd path/to/tests
      php direct_report_problem.php
    
    
    EOT
    );
    
    defined('API_ENDPOINT') || define('API_ENDPOINT', getenv('API_HOST') . '/webservice/index.php');
    
    $method = API_ENDPOINT . '?op=...';
    
    $describe = function ($msg, $test) {
        printf("\n\n[%s]\n\n%s\n\n", $msg, shell_exec($test()));
        sleep(2);
    };
    
    $describe('Cannot upload empty report', function() use ($method) {
        return 'curl'
        . ' -F user_id=61'
        . ' ' . $method;
    });
    
    $describe('Can upload only direct report note', function() use ($method) {
        return 'curl'
        . ' -F user_id=61'
        . ' -F problem_note=NOTE'
        . ' ' . $method;
    });
    
    $describe('Can upload only direct report sound', function() use ($method) {
        return 'curl'
        . ' -F user_id=61'
        . ' -F [email protected]'
        . ' ' . $method;
    });
    
    $describe('Can upload only direct report image', function() use ($method) {
        return 'curl'
        . ' -F user_id=61'
        . ' -F [email protected]'
        . ' ' . $method;
    });
    
    $describe('Can upload all data direct report note, image, sound', function() use ($method) {
        return 'curl'
        . ' -F user_id=61'
        . ' -F problem_note=NOTE'
        . ' -F [email protected]'
        . ' -F [email protected]'
        . ' ' . $method;
    });

    __proto__, 10 Декабря 2013

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

    +122

    1. 1
    2. 2
    3. 3
    Не смог выделить 100 строк, объединённых общей логикой, да и всей картины это бы не передавало.
    Для любителей покопаться в. 
    Ссылка в описании.

    https://github.com/KustoSoft/ru2ch-toolset
    © Корпорация KustoSoft

    jsgovno, 08 Декабря 2013

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

    +137

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    catch(Exception ex)
    {
        try
        {
            insertAction(TXTextControl.StringStreamType.PlainText);
            GcmExceptionHandlerForm.ShowException(ex);
        }
        catch (Exception ex2)
        {
                GcmExceptionHandlerForm.ShowException(ex2);
        }
    }

    Что-то пошло не так...

    minuzZ, 29 Ноября 2013

    Комментарии (24)
  11. PHP / Говнокод #13840

    +169

    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
    ?><tr><?
        ?><script><?
            ?>$(function(){<?
                ?>$('tr[_hash]').find('#smalllinks').click(function(){<?
                    ?>$(this).parent(0).html($(this).parent(0).find('#fulllinks').html());<?
                ?>});<?
                ?>$('tr[_hash] #rm').click(function(){<?
                    ?>var _hash=$(this).parent(0).parent(0).attr('_hash');<?
                    ?>$.ajax({<?
                        ?>url:'?a&st&rm='+_hash,<?
                        ?>success:function(data){<?
                            ?>if(data=='1')get('st');<?
                        ?>}<?
                    ?>});<?
                ?>});<?
                ?>$('tr[_hash]').find('#stat_domain').click(function(){<?
                    ?>P_domain=$(this).html();<?
                    ?>get('st');<?
                ?>});<?
            ?>});<?
            ?>function rm_all()<?
            ?>{<?
                ?>if(confirm('Удалить всю статистику?'))<?
                ?>{<?
                    ?>$.ajax({<?
                        ?>url:'?a&st&rmall',<?
                        ?>success:function(data){<?
                            ?>if(data=='1')get('st');<?
                        ?>}<?
                    ?>});<?
                ?>}<?
            ?>}<?
            ?>function refresh_dom()<?
            ?>{<?
                ?>var _i='<img src="?i=ld"> ';_i+=_i;_i+=_i;_i+=_i;<?
                ?>$('table#c').prepend('<td class=n align=center colspan=999>'+_i+'</td>');<?
                
                ?>$.ajax({<?
                    ?>url:'?a&st&rdom',<?
                    ?>success:function(data){<?
                            ?>if(data=='1')get('st');<?
                    ?>}<?
                ?>});<?
            ?>}<?
            ?>function update_pr_tic()<?
            ?>{<?
                ?>var _i='<img src="?i=ld"> ';_i+=_i;_i+=_i;_i+=_i;<?
                ?>$('table#c').prepend('<td class=n align=center colspan=999>'+_i+'</td>');<?
                
                ?>$.ajax({<?
                    ?>url:'?a&st&upd_pr_tic',<?
                    ?>success:function(data){<?
                            ?>if(data=='1')get('st');<?
                    ?>}<?
                ?>});<?
            ?>}<?
        ?></script><?
        ?><td class=n colspan=5><?
            ?><input type=button value='   Обновить домены   ' onclick='refresh_dom()'/> <?
            ?><input type=button value='   Удалить все   ' onclick='rm_all()'/> <?
            ?><input type=button value='   Обновить PR, тИЦ   ' onclick='update_pr_tic()'/> <?
            ?>(доменов: <b><?=$result_domains_count?></b>) <?
            ?>Количество: <b><?=$result_count?></b><?
                if (!empty($domain))
                {
                    ?>, домен <b><?=$domain?></b><?
                }
        ?></td><?
        ?><td class=n><?
            if ($pages_count > 1)
            {
                ?><select id="selpage"><?
                for($i=1; $i<=$pages_count; $i++)
                {
                    ?><option <?=$i==($page_num+1)?'selected':''?>><?=$i?></option><?
                }
                ?></select><?
            }
        ?></td><?
    ?></tr><?

    Такой вот необычный код мне попался в одном скрипте.

    Itareo, 21 Сентября 2013

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