1. Си / Говнокод #8911

    +142

    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
    static inline gboolean is_alt(const gchar* string)
    {
    	return ((string[0] == '<') &&
    		(string[1] == 'a' || string[1] == 'A') &&
    		(string[2] == 'l' || string[2] == 'L') &&
    		(string[3] == 't' || string[3] == 'T') &&
    		(string[4] == '>'));
    }
    
    static inline gboolean is_ctl (const gchar* string)
    {
    	return ((string[0] == '<') &&
    		(string[1] == 'c' || string[1] == 'C') &&
    		(string[2] == 't' || string[2] == 'T') &&
    		(string[3] == 'l' || string[3] == 'L') &&
    		(string[4] == '>'));
    }
    
    static inline gboolean is_modx(const gchar* string)
    {
    	return ((string[0] == '<') &&
    		(string[1] == 'm' || string[1] == 'M') &&
    		(string[2] == 'o' || string[2] == 'O') &&
    		(string[3] == 'd' || string[3] == 'D') &&
    		(string[4] >= '1' && string[4] <= '5') &&
    		(string[5] == '>'));
    }
    
    static inline gboolean is_ctrl(const gchar* string)
    {
    	return ((string[0] == '<') &&
    		(string[1] == 'c' || string[1] == 'C') &&
    		(string[2] == 't' || string[2] == 'T') &&
    		(string[3] == 'r' || string[3] == 'R') &&
    		(string[4] == 'l' || string[4] == 'L') &&
    		(string[5] == '>'));
    }
    
    static inline gboolean is_shft (const gchar* string)
    {
    	return ((string[0] == '<') &&
    		(string[1] == 's' || string[1] == 'S') &&
    		(string[2] == 'h' || string[2] == 'H') &&
    		(string[3] == 'f' || string[3] == 'F') &&
    		(string[4] == 't' || string[4] == 'T') &&
    		(string[5] == '>'));
    }
    
    // ... (ещё 100500 подобных функций)
    // ... а тем временем где-то ниже:
    
    	  if (len >= 9 && is_release (accelerator))
    	    {
    	      accelerator += 9;
    	      len -= 9;
    	      mods |= EGG_VIRTUAL_RELEASE_MASK;
    	    }
    	  else if (len >= 9 && is_control (accelerator))
    	    {
    	      accelerator += 9;
    	      len -= 9;
    	      mods |= EGG_VIRTUAL_CONTROL_MASK;
    	    }
    	  else if (len >= 9 && is_primary (accelerator))
    	    {
    	      accelerator += 9;
    	      len -= 9;
    	      mods |= EGG_VIRTUAL_CONTROL_MASK;
    	    }
    	  else if (len >= 7 && is_shift (accelerator))
    	    {
    	      accelerator += 7;
    	      len -= 7;
    	      mods |= EGG_VIRTUAL_SHIFT_MASK;
    	    }
    	  else if (len >= 6 && is_shft (accelerator))
    	    {
    	      accelerator += 6;
    	      len -= 6;
    	      mods |= EGG_VIRTUAL_SHIFT_MASK;
    	    }
    	  else if (len >= 6 && is_ctrl (accelerator))
    	    {
    	      accelerator += 6;
    	      len -= 6;
    	      mods |= EGG_VIRTUAL_CONTROL_MASK;
    	    }
    
    // ... и так далее. код целиком сюда просто не влезет.

    шедевр. что сравнение строк, что цепочка if-else. все хороши.

    полной версией можно насладиться тут:
    https://github.com/mate-desktop/mate-control-center/blob/master/capplets/keybindings/eggaccelerators.c

    angry C nerd, 06 Января 2012

    Комментарии (15)
  2. JavaScript / Говнокод #8910

    +163

    1. 1
    CsaTracker_Init('01/01/2011", "12/31/2011');

    Получил в наследство. Потратил на поиск больше 2 часов

    Mr_GOD, 06 Января 2012

    Комментарии (14)
  3. SQL / Говнокод #8909

    −108

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    update People
             set PeopleIsJunior='N'
           where PeopleIsJunior='Y'
             and month(BirthDay)=(select month(getdate()))
             and year(BirthDay)=(select year(getdate())-18) 
             and day(BirthDay)=(select day(getdate()))

    Еженочно часа 3 делаем людей совершеннолетними. людей много , миллионы, и с табличкой активно работают.
    Наличие индекса по BirthDay не играет никакого рояля, т.к. функции.
    t-sql если чо.

    bliznezz, 06 Января 2012

    Комментарии (15)
  4. Objective C / Говнокод #8908

    −121

    1. 1
    2. 2
    3. 3
    4. 4
    -(BOOL) isShuffleOn {
    	return iPodPlayer? iPodPlayer.shuffleMode != MPMusicShuffleModeOff
    					 : NO;
    }

    СУКА, САМЫЙ УМНЫЙ ДА, а я думаю чо оно нет даже если оно ДА.

    Psionic, 05 Января 2012

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

    +1008

    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
    QPainter painter(this);
    int a1;
    int a2;
    int a3;
    int a4;
    //.......
    int a999;
    int a1000;
    
    a1 = 1;
    a2 = 1;
    a3 = 1;
    a4 = 1;
    //.......
    a999 = 1;
    a1000 = 1;
    
    while (a1 != 500)
    {         painter.drawLine(a1, a1, a1, a1); a1 ++; 
    }
    
    while (a2 != 500)
    {         painter.drawLine(a2, a2, a2, a2); a2 ++; 
    }
    while (a3 != 500)
    {         painter.drawLine(a3, a3, a3, a3); a3 ++; 
    }
    while (a4 != 500)
    {         painter.drawLine(a4, a4, a4, a4); a1 ++; 
    }
    //........
    while (a999 != 500)
    {         painter.drawLine(a999, a999, a999, a999); a999 ++; }
    }
    while (a1000 != 500)
    {         painter.drawLine(a1000, a1000, a1000, a1000); a1000 ++; }
    }

    ПРИКИНЬТЕ такое в paintevente!!!!!!! Qt

    VProger, 05 Января 2012

    Комментарии (16)
  6. Pascal / Говнокод #8906

    +89

    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
    unit DllUnit; interface
    
    uses windows, sysutils;
    
    Procedure GuPrcA(var p:PAnsiChar;const l:integer); StdCall;
    Procedure GuPrcW(var p:PWideChar;const l:integer); StdCall;
    
    Exports GuPrcA,GuPrcW;
    
    implementation
    
    procedure GuMes(s:string);
    begin
    MessageBox(0,pchar(s),'From dll',mb_iconinformation);
    end;
    
    Procedure GuPrcW(var p:PWideChar;const l:integer); // wide
    var s:widestring;
    begin
    if (p=nil)or(l<1) then begin p:=nil;exit;end;
    SetLength(s,trunc(l/sizeof(widechar)));Move(p^,Pointer(s)^,l);
    gumes('l: '+inttostr(l)+', nl: '+inttostr(length(s))+#10+'-'+s+'-');
    s:=widestring(Uppercase(s));Move(Pointer(s)^,p^,l);
    end;
    
    Procedure GuPrcA(var p:Pansichar;const l:integer); // ansi
    var s:ansistring;
    begin
    if (p=nil)or(l<1) then begin p:=nil;exit;end;
    SetLength(s,l);Move(p^,Pointer(s)^,l);
    gumes('l: '+inttostr(l)+', nl: '+inttostr(length(s))+#10+'-'+s+'-');
    s:=ansistring(AnsiUppercase(s));Move(Pointer(s)^,p^,l);
    end;
    
    Initialization
    
    ReportMemoryLeaksOnShutdown:=true;
    
    end.
    
    (* выше - DLL, ниже импорт из неё *)
    ...
    implementation
    
    {$R *.dfm}
    
    Procedure GuPrcA(var p:PansiChar;const l:cardinal); StdCall; external 'mydll.dll' name 'GuPrcA';
    Procedure GuPrcW(var p:PwideChar;const l:cardinal); StdCall; external 'mydll.dll' name 'GuPrcW';
    
    procedure TForm1.Button6Click(Sender: TObject);
    var p:pwidechar;c:cardinal;s:widestring;
    begin
    s:=widestring(memo1.Text);
    c:=length(s)*sizeof(widechar);
    p:=allocmem(c);
    Move(Pointer(s)^,p^,c);
    GuPrcW(p,c);
    s:='';setlength(s,trunc(c/sizeof(widechar)));
    Move(p^,Pointer(s)^,c);
    Freemem(p,c);
    memo1.Text:='='+s+'= l:'+inttostr(c);
    end;
    
    procedure TForm1.Button7Click(Sender: TObject);
    var p:pansichar;c:cardinal;s:ansistring;
    begin
    s:=ansistring(memo1.text);
    c:=length(s);
    p:=allocmem(c);
    Move(Pointer(s)^,p^,c);
    GuPrcA(p,c);
    s:='';setlength(s,c);
    Move(p^,Pointer(s)^,c);
    Freemem(p,c);
    memo1.Text:='='+s+'= l:'+inttostr(c);
    end;
    
    Initialization
    
    ReportMemoryLeaksOnShutdown:=true;
    
    end.

    На стековерфловочке завелся некий GuSoft (sic!), который регулярно постит свои высеры через гоогле транслате. Сегодня вот таким шедевром разродился, хочет бесплатных консультаций чтобы в этой херне ему поискали ошибки и «оптимизировали».

    bugmenot, 05 Января 2012

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

    +155

    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
    <?
    if ($id != "") {
    	$id--;
    	$file=file("file.txt"); 
    
    	for($i=0;$i<sizeof($file);$i++)
    		if($i==$id) unset($file[$i]); 
    
    	$fp=fopen("file.txt","w"); 
    	fputs($fp,implode("",$file)); 
    	fclose($fp);
    	}
    ?>

    http://www.codenet.ru/webmast/php/delstr.php вот нарыл говнокод.
    OMG!WTF?!
    Неужели,люди забыли про file_put_contents ?

    An0nimous, 05 Января 2012

    Комментарии (14)
  8. Java / Говнокод #8904

    +78

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    while (entityIterator.hasNext()) {
        Object[] results = entityIterator.next();
        Long policyId = ((PolicyEntity) results[0]).getId();
        PolicyEntity policy = (PolicyEntity) policyDao.findById(policyId);
        processPolicy(policy);
    }

    Спецально не рефакторил этот шедевр, ждал, пока ГК поднимется.

    roman-kashitsyn, 05 Января 2012

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

    +98

    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
    if RadioGroup1.ItemIndex=0   then cpr:=cpr+1;
    if RadioGroup1.ItemIndex=1   then cth:=cth+1;
    if RadioGroup2.ItemIndex=0   then cch:=cch+1;
    if RadioGroup2.ItemIndex=1  then czs:=czs+1;
    if RadioGroup3.ItemIndex=0   then chd:=chd+1;
    if RadioGroup3.ItemIndex=1  then cpr:=cpr+1;
    if RadioGroup4.ItemIndex=0   then  cth:=cth+1;
    if RadioGroup4.ItemIndex=1  then cch:=cch+1;
    if RadioGroup5.ItemIndex=0   then czs:=czs+1;
    if RadioGroup5.ItemIndex=1  then chd:=chd+1;
    if RadioGroup6.ItemIndex=0   then cpr:=cpr+1;
    if RadioGroup6.ItemIndex=1  then cch:=cch+1;
    if RadioGroup7.ItemIndex=0   then chd:=chd+1;
    if RadioGroup7.ItemIndex=1  then cth:=cth+1;
    ....// Это всё в 60 строк
    if (cpr>cth) and (cpr>cch) and (cpr>czs) and (cpr>chd) then cpr1:=+1
    else
    if (cth>cpr) and (cth>cch) and (cth>czs) and (cth>chd) then cth1:=+1
    else
    if (cch>cpr) and (cch>cth) and (cch>czs) and (cch>chd) then cch1:=+1
    else
    if (czs>cpr) and (czs>cch) and (czs>cth) and (czs>chd) then czs1:=+1
    else
    if (chd>cpr) and (chd>cch) and (chd>czs) and (chd>cth) then chd1:=+1;
    
    if cpr>chd or czs or cth or cch     then
    begin
    ShowMessage('человек-природа – все профессии, связанные с растениеводством, животноводством и лесным хозяйством;')   ;
    Datamodule4.ADOTable1.Edit;
    Datamodule4.ADOTable1.FieldValues['test2']:=('человек-природа – все профессии, связанные с растениеводством, животноводством и лесным хозяйством;');
    Datamodule4.ADOTable1.Post;
    end
    else
    if chd>cpr or cth or cch or czs   then   begin
    ShowMessage('человек-техника – все технические профессии;')   ;
    Datamodule4.ADOTable1.Edit;
    Datamodule4.ADOTable1.FieldValues['test2']:=('человек-техника – все технические профессии;');
    Datamodule4.ADOTable1.Post;
    ...... И далее результаты в общем их 5
    отдельная кнопка для вывода остальных 10 вопросов х)
    procedure TForm1.Button1Click(Sender: TObject);
    begin
    Radiogroup11.Visible:=true;
    Radiogroup12.Visible:=true;
    Radiogroup13.Visible:=true;
    Radiogroup14.Visible:=true;
    Radiogroup15.Visible:=true;
    Radiogroup16.Visible:=true;
    Radiogroup17.Visible:=true;
    Radiogroup18.Visible:=true;
    Radiogroup19.Visible:=true;
    Radiogroup20.Visible:=true;
    Button2.Visible:=True;
    end;

    Программа тестирования на профориентацию
    хД сколько он radiogroup создал)

    Ryuko, 05 Января 2012

    Комментарии (8)
  10. JavaScript / Говнокод #8902

    +151

    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
    001           // Определяем наборы изображений
    002	        var images = {
    003	    'Набор 1' : [
    004	        'pic1.jpg',
    005	        'pic2.jpg',
    006	        'pic3.jpg',
    007	        'pic4.jpg',
    008	        'pic5.jpg',
    009	        'pic6.jpg',
    010	        'pic7.jpg',
    011	        'pic8.jpg',
    012	        'pic9.jpg',
    013	        'pic10.jpg'
    014	    ],
    015	    'Набор 2' : [
    016	        'pic2.jpg',
    017	        'pic3.jpg',
    018	        'pic4.jpg',
    019	        'pic5.jpg',
    020	        'pic6.jpg',
    021	        'pic7.jpg',
    022	        'pic8.jpg',
    023	        'pic9.jpg',
    024	        'pic10.jpg',
    025	        'pic11.jpg',
    026	        'pic12.jpg',
    027	        'pic5.jpg',
    028	        'pic6.jpg',
    029	        'pic7.jpg',
    030	        'pic8.jpg'
    031	    ],
    032	    'Набор 3' : [
    033	        'pic1.jpg',
    034	        'pic2.jpg',
    035	        'pic3.jpg',
    036	        'pic4.jpg',
    037	        'pic5.jpg',
    038	        'pic6.jpg',
    039	        'pic7.jpg',
    040	        'pic8.jpg',
    041	        'pic9.jpg',
    042	        'pic10.jpg',
    043	        'pic11.jpg',
    044	        'pic12.jpg',
    045	        'pic4.jpg',
    046	        'pic5.jpg',
    047	        'pic6.jpg'
    ...

    О_О Шок...

    Takasu, 05 Января 2012

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