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

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

    +102

    1. 1
    return (m.Id == Id) ? (true) : (false);

    походу платят за символы

    MegaZver, 29 Мая 2012

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

    +102

    1. 1
    2. 2
    3. 3
    <html class="html">
    .............
    </html>

    Бывает и такое

    Hits, 27 Апреля 2012

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

    +102

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    $compareCost = 0;
    $countGacha = 0;
    for($i=0; $i<10; ++$i): 
        $compareCost += $this->freeGacha->getCost();
        if( $this->player->getSocialPoint() > $compareCost )        continue;
        else break;
        $countGacha = $i+1;
    endfor;

    Korean style ;)

    nidkor, 24 Апреля 2012

    Комментарии (8)
  5. 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)
  6. Си / Говнокод #8650

    +102

    1. 1
    #define HESHELME_BESHELME(x, y) (((x)>0)<<2 | ((y)>0)<<1 | ((x) > ((x)*(y) > 0 ? (y) : -(y))))

    двумерное "квантование" точки

    orion, 26 Ноября 2011

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

    +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
    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
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    const n = 50;
    type vec = array [1..n*4] of system.word;
    function vprod(const a, b: vec): Cardinal;
      var i: longInt;
      begin
        result := 0;
        for i := 1 to high(vec) do inc(result, a[i] * b[i]);
      end;
    function vprod_asm1(const a, b: vec): Cardinal; assembler;
      asm
         push ebx
         push ecx
         push edx
         push esi
         push edi
         xor ebx, ebx
         mov ecx, n*4
         mov esi, a
         mov edi, b
         xor eax, eax
         cld
      @@l:
         mov   ax, word ptr [esi]
         lea   esi, [esi+2]
         mul   word ptr [edi]
         lea   edi, [edi+2]
         shl   edx, 16
         mov   dx, ax
         add   ebx, edx
         dec   ecx
         jne   @@l
         mov   eax, ebx
         pop edi
         pop esi
         pop edx
         pop ecx
         pop ebx
      end;
    function vprod_asm2(const a, b: vec): Cardinal; assembler;
      asm
        push ebx
        push ecx
        push edx
        push esi
        push edi
        xor ebx, ebx
        mov ecx, n*4
        mov esi, a
        mov edi, b
        xor eax, eax
        cld
      @@l:
        lodsw
        movzx   edx, WORD PTR [edi]
        imul    edx
        lea     edi, [edi+2]
        add     ebx, eax
        loop  @@l
        mov   eax, ebx
        pop edi
        pop esi
        pop edx
        pop ecx
        pop ebx
      end;
    function vprod_mmx (const a, b: vec): Cardinal; assembler;
      var muls: record l, h: Cardinal end;
      asm
        push ebx
        push ecx
        push esi
        push edi
        mov ecx, n
        mov esi, a
        mov edi, b
        xor eax, eax
        lea     ebx, muls
      @@l:
        db $0F,$6F,$06  // movq    mm0, [esi]
        db $0F,$F5,$07  // pmaddwd mm0, [edi]
        lea     esi, [esi+8]
        db $0F,$7F,$03  // movq    [ebx], mm0
        lea     edi, [edi+8]
        add     eax, [ebx]
        add     eax, [ebx+4]
        loop    @@l
        db $0F,$77 // emms
        pop edi
        pop esi
        pop ecx
        pop ebx
      end;

    По просьбам трудящихся публикую модифицированную версию примера MMXTEST.PAS из комплекта компилятора TMT Pascal. Программа находит скалярное произведение двух векторов. Далее должен быть основной блок с фрагментами типа for i := 1 to 100000 do vprod(a, b); , которые я не стал публиковать ввиду ограничений. Функция vprod_asm1 — почти оригинальный код TMT, функция vprod_asm2 — мой оптимизированный вариант. Результаты запуска на двух машинах (таймер получал по RDTSC):
    AMD K6-2-333 МГц, FSB 66 МГц.

    Delphi7:
    Pascal = 0.550 sec.
    Asm x86 (original) = 1.034 sec.
    Asm x86 (optimized) = 0.490 sec.
    Asm MMX = 0.130 sec.
    С директивой $O- первый результат 0.853 sec.
    Замена loop на dec ecx + jne увеличивает результаты на 0,015 c.

    FPC:
    Pascal = 1.387 sec.
    Asm x86 (original) = 1.199 sec.
    Asm x86 (optimized) = 0.510 sec.
    Asm MMX = 0.124 sec.

    TMT:
    Pascal = 0.914 sec.
    Asm x86 (original) = 1.037 sec.
    Asm x86 (optimized) = 0.494 sec.
    Asm MMX = 0.126 sec.

    VP:
    Pascal = 0.520 sec.
    Asm x86 (original) = 1.033 sec.
    Asm x86 (optimized) = 0.493 sec.
    Asm MMX = 0.146 sec.
    С директивами $Q+,R+ первый результат 1.032 sec.
    С директивой $Speed- первый результат 0.731 sec.

    ------------------------------
    Celeron 1,86 ГГц, FSB 533 МГц.

    Delphi7:
    Pascal = 0.025 sec.
    Asm x86 (original) = 0.091 sec.
    Asm x86 (optimized) = 0.082 sec.
    Asm MMX = 0.044 sec.

    TMT:
    Pascal = 0.109 sec.
    Asm x86 (original) = 0.087 sec.
    Asm x86 (optimized) = 0.079 sec.
    Asm MMX = 0.042 sec.

    inkanus-gray, 25 Сентября 2011

    Комментарии (26)
  8. Куча / Говнокод #7473

    +102

    1. 1
    org.quartz.jobStore.dontSetAutoCommitFalse=true

    config boolshit

    3.14159265, 06 Августа 2011

    Комментарии (11)
  9. Си / Говнокод #7043

    +102

    1. 1
    #define SEVEN_DAYS_SECONDS  ((7 * 24 * 60 * 60) + 2)

    Нашел в одном проектике.
    SEVEN_DAYS_SECONDS используется планировщике заданий.

    ossa, 24 Июня 2011

    Комментарии (22)
  10. Си / Говнокод #6540

    +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
    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
    if (nchan == 1)
      {
        fprintf(commands_ptr,(char *)"StaNoise sta=%s start_time=%14.3f chan_list=%s window_type=nutall4a sub_window_length=%5.1f main_window_length=%6.1f out_dir=%s plot=yes record=yes decon=%s\n",sta,gmttime,chan_list[0],sub_window_length,main_window_length,out_dir,decon_c);
      }
      if (nchan == 2)
      {
        fprintf(commands_ptr,(char *)"StaNoise sta=%s start_time=%14.3f chan_list=%s,%s window_type=nutall4a sub_window_length=%5.1f main_window_length=%6.1f out_dir=%s plot=yes record=yes decon=%s\n",sta,gmttime,chan_list[0],chan_list[1],sub_window_length,main_window_length,out_dir,decon_c);
      }
      if (nchan == 3)
      {
        fprintf(commands_ptr,(char *)"StaNoise sta=%s start_time=%14.3f chan_list=%s,%s,%s window_type=nutall4a sub_window_length=%5.1f main_window_length=%6.1f out_dir=%s plot=yes record=yes decon=%s\n",sta,gmttime,chan_list[0],chan_list[1],chan_list[2],sub_window_length,main_window_length,out_dir,decon_c);
      }
      if (nchan == 4)
      {
        fprintf(commands_ptr,(char *)"StaNoise sta=%s start_time=%14.3f chan_list=%s,%s,%s,%s window_type=nutall4a sub_window_length=%5.1f main_window_length=%6.1f out_dir=%s plot=yes record=yes decon=%s\n",sta,gmttime,chan_list[0],chan_list[1],chan_list[2],chan_list[3],sub_window_length,main_window_length,out_dir,decon_c);
      }
      if (nchan == 5)
      {
        fprintf(commands_ptr,(char *)"StaNoise sta=%s start_time=%14.3f chan_list=%s,%s,%s,%s,%s window_type=nutall4a sub_window_length=%5.1f main_window_length=%6.1f out_dir=%s plot=yes record=yes decon=%s\n",sta,gmttime,chan_list[0],chan_list[1],chan_list[2],chan_list[3],chan_list[4],sub_window_length,main_window_length,out_dir,decon_c);
      }
      if (nchan == 6)
      {
        fprintf(commands_ptr,(char *)"StaNoise sta=%s start_time=%14.3f chan_list=%s,%s,%s,%s,%s,%s window_type=nutall4a sub_window_length=%5.1f main_window_length=%6.1f out_dir=%s plot=yes record=yes decon=%s\n",sta,gmttime,chan_list[0],chan_list[1],chan_list[2],chan_list[3],chan_list[4],chan_list[5],sub_window_length,main_window_length,out_dir,decon_c);
      }
      if (nchan == 7)
      {
        fprintf(commands_ptr,(char *)"StaNoise sta=%s start_time=%14.3f chan_list=%s,%s,%s,%s,%s,%s,%s window_type=nutall4a sub_window_length=%5.1f main_window_length=%6.1f out_dir=%s plot=yes record=yes decon=%s\n",sta,gmttime,chan_list[0],chan_list[1],chan_list[2],chan_list[3],chan_list[4],chan_list[5],chan_list[6],sub_window_length,main_window_length,out_dir,decon_c);
      }
    ...
      }
      if (nchan >= 14)
      {
        fprintf(commands_ptr,(char *)"StaNoise sta=%s start_time=%14.3f chan_list=%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s window_type=nutall4a sub_window_length=%5.1f main_window_length=%6.1f out_dir=%s plot=yes record=yes decon=%s\n",sta,gmttime,chan_list[0],chan_list[1],chan_list[2],chan_list[3],chan_list[4],chan_list[5],chan_list[6],chan_list[7],chan_list[8],chan_list[9],chan_list[10],chan_list[11],chan_list[12],chan_list[13],sub_window_length,main_window_length,out_dir,decon_c);
      }

    Тяжело в сях работать со строками и переменным числом параметров...

    Eyeless, 04 Мая 2011

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

    +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
    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
    var zaxita, ataka, zaxitacomp, atakacomp, yron, yroncomp: integer;
    begin
    Label3.Caption := IntToStr(healt);
    Label4.Caption := IntToStr(healtcomp);
    If Radiobutton1.Checked = True then
    begin
    zaxita := 1;
    yron := 3;
    end;
    If Radiobutton2.Checked = True then
    begin
    zaxita := 2;
    yron := 2;
    end;
    If Radiobutton3.Checked = True then
    begin
    zaxita := 3;
    yron := 1;
    end;
    If Radiobutton4.Checked = True then ataka := 3;
    If Radiobutton5.Checked = True then ataka := 2;
    If Radiobutton6.Checked = True then ataka := 1;
    zaxitacomp := Random(4);
    atakacomp := Random(4);
    If zaxita <> atakacomp then
    begin
    healt := healt - yron;
    Label3.Caption := IntToStr(healt);
    If healt <= 0 then
    begin
    MessageBeep(48);
    ShowMessage('Вы проиграли. Ваш труп скормят крысам!');
    Close;
    end;
    If zaxitacomp <> ataka then
    begin
    healtcomp := healtcomp - ataka;
    Label4.Caption := IntToStr(healtcomp);
    If healtcomp <= 0 then
    begin
    MessageBeep(48);
    ShowMessage('Вы выйграли! Поздравляю! Теперь можете разграбить своего врага! О, что это?!');
    end;
    end;
    end;
    end;
    end.

    Это оффлайн симулятор игры карнаж. Игра такая игра

    Govnocoder#0xFF, 18 Апреля 2011

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