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

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

    +135

    1. 1
    static bool AlwaysTrue<T>(T obj) { return true; }

    ыыы

    taburetka, 28 Марта 2013

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

    +119

    1. 1
    <button type="button"

    Пятница в моей голове...

    nonamez, 22 Марта 2013

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

    +119

    1. 1
    2. 2
    3. 3
    if (request.getDate() != null && request.getDate().after(new Date())) {
    	throw new ApiException(HttpStatus.SC_BAD_REQUEST, "Great Scott! Time machine not invented yet");
    }

    someone, 21 Марта 2013

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

    +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
    class User {
    
      protected $login;
      protected $password;
      protected $email;
    
      public function __construct($login, $password, $email) {
        $this->login = $login;
        $this->password = $password;
        $this->email = $email;
      }
    
      public function __get($name) {
        $reflector = new ReflectionClass($this);
        return $reflector->hasProperty($name) ? $this->{$name} : null;
      }
    
    }

    __proto__, 10 Марта 2013

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

    +152

    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
    function getTestDataById ($testid) {
    
    	$query="select * from mdl_test where id=".$testid."";
    	$result = mysql_query($query) or die('getTestDataById query failed: ' . mysql_error());
    
    	while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
    
    	$courseid=$row['courseid'] ;
    	$moduleid=$row['moduleid'];
    	$name=$row['name'];
    	$maxscore=$row['maxscore'];
    	$successscore=$row['successscore'];
    	$attempts=$row['attempts'];
    	$dur=$row['dur'];
    	$showsuccessmessage=$row['showsuccessmessage'];
    	$successmessage=$row['successmessage'];
    	$showfailedmessage=$row['showfailedmessage'];
    	$failedmessage=$row['failedmessage'];
    	$showtestsuccessmessage=$row['showtestsuccessmessage'];
    	$testsuccessmessage=$row['testsuccessmessage'];
    	$showtestfailedmessage=$row['showtestfailedmessage'];
    	$testfailedmessage=$row['testfailedmessage'];
    	$freequestions=$row['freequestions'];
    	$questionsorder=$row['questionsorder'];
    	$defertest=$row['defertest'];
    	$totalperpage=$row['totalperpage'];
    	$showcorrectreply=$row['showcorrectreply'];
    	$showscore=$row['showscore'];
    	$limittype = $row['limittype'];
    	$annotation = $row['annotation'];
    
    	} // end while
    
    	$res=array('courseid'=>$courseid,
    			   'moduleid'=>$moduleid,
    			   'name'=>stripslashes($name),
    			   'maxscore'=>$maxscore,
    			   'successscore'=>$successscore,
    			   'attempts'=>$attempts,
    			   'dur'=>$dur,
    			   'showsuccessmessage'=>$showsuccessmessage,
    			   'successmessage'=>stripslashes($successmessage),
    			   'showfailedmessage'=>$showfailedmessage,
    			   'failedmessage'=>stripslashes($failedmessage),
    			   'showtestsuccessmessage'=>stripslashes($showtestsuccessmessage),
    			   'testsuccessmessage'=>stripslashes($testsuccessmessage),
    			   'showtestfailedmessage'=>stripslashes($showtestfailedmessage),
    			   'testfailedmessage'=>stripslashes($testfailedmessage),
    			   'freequestions'=>stripslashes($freequestions),
    			   'questionsorder'=>stripslashes($questionsorder),
    			   'defertest'=>stripslashes($defertest),
    			   'totalperpage'=>stripslashes($totalperpage),
    			   'showcorrectreply'=>stripslashes($showcorrectreply),
    			   'showscore'=>stripslashes($showscore),
    				'limittype' => stripslashes($limittype),  // Total 21 items
    				'annotation' => stripslashes($annotation));
    
    	return $res;
    
    	} // end of function

    От начальника отдела))) Как вам?))

    Krugly, 09 Марта 2013

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

    +75

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    public Double toDouble(String str){
    	if ((str==null)||(str.equals(""))) str = "0.0";
    	if ((str.contains(","))&&(!str.contains("."))) str = str.replace(",", ".");
    	return new Double(str);
    }

    Лишняя защита никогда не бывает лишней

    nafania217518, 06 Марта 2013

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

    +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
    std::vector<int> data;
    std::vector<int> indexes;
    
    // ...
    
    for (int i = 0; i < data.size(); ++i) {
    	if (data[i] == to_remove) {
    		indexes.push_back(i);
    	}
    }
    for (int i = 0; i < indexes.size(); ++i) {
    	data.erase(data.begin() + i);
    }

    "Эффективное" удаление элементов из вектора. Об <algorithm> человек не слышал...

    Cpp, 25 Февраля 2013

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

    +93

    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
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    99. 99
    begin
    if n=15 then
    begin
    a:=7200*56*99*12*13*14*15;
    end
    else
    begin
    if n=16 then
    begin
    a:=7200*56*99*12*13*14*15*16;
    end
    else
    begin
    if n=17 then
    begin
    a:=7200*56*99*12*13*14*15*16*17;
    end
    else
    begin
    if n=18 then
    begin
    a:=7200*56*99*12*13*14*15*16*17*18;
    end
    else
    begin
    if n=19 then
    begin
    a:=7200*56*99*12*13*14*15*16*17*18*19;
    end
    else
    begin
    if n=20 then
    begin
    a:=144000*56*99*12*13*14*15*16*17*18*19;
    end
    else
    begin
    if n=21 then
    begin
    a:=144000*56*99*12*13*14*15*16*17*18*19*21;
    end
    else
    begin
    if n=22 then
    begin
    a:=144000*56*99*12*13*14*15*16*17*18*19*21*22;
    end
    else
    begin
    if n=23 then
    begin
    a:=144000*56*99*12*13*14*15*16*17*18*19*21*22*23;
    end
    else
    begin
    if n=24 then
    begin
    a:=144000*56*99*12*13*14*15*16*17*18*19*21*22*23*24;
    end
    else
    begin
    if n=25 then
    begin
    a:=144000*56*99*12*13*14*15*16*17*18*19*21*22*23*24*25;
    end
    else
    begin
    if n=26 then
    begin
    a:=144000*56*99*12*13*14*15*16*17*18*19*21*22*23*24*25*26;
    end
    else
    begin
    if n=27 then
    begin
    a:=144000*56*99*12*13*14*15*16*17*18*19*21*22*23*24*25*26*27;
    end
    else
    begin
    if n=28 then
    begin
    a:=144000*56*99*12*13*14*15*16*17*18*19*21*22*23*24*25*26*27*28;
    end
    else
    begin
    if n=29 then
    begin
    a:=144000*56*99*12*13*14*15*16*17*18*19*21*22*23*24*25*26*27*28*29;
    end
    else
    begin
    if n=30 then
    begin
    a:=144000*56*99*12*13*14*15*16*17*18*19*21*22*23*24*25*26*27*28*29*30;
    end
    else
    begin
    if n=31 then
    begin

    crazy_horse, 25 Февраля 2013

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

    +124

    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
    import Control.Monad
    import Control.Arrow
    import Data.List
    
    solve' :: [String] -> [[String]]
    solve' = nub . filter (
                and . uncurry (
                    zipWith (
                        (.head) . (==) . last
                    )
                ) . (id &&& tail)
             ) . uncurry ($) . (
                last . (((
                    map (
                        last . fst &&& uncurry (++) . (init . fst &&& snd)
                    ) . tail . uncurry (zipWith (,)) . (inits &&& tails)
                ) >=> (uncurry map) . 
                    ((:) *** solve')
                ):
                ) . (uncurry takeWhile) . (
                        const . null &&& const [const [[]]]
                    ) &&& id
             )
    
    main = print $ solve' ["123","321","123"]

    HaskellGovno, 20 Февраля 2013

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

    +86

    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
    Function TMainForm.PrimGenerateMaze(Width, Height: Integer): Maze;
    
    Type Point = record
      x, y: Integer;
    end;
    
    Var
      TehMaze: Maze;
      Todo: array of Point;
      todonum: integer;
      x,y,n,d: integer;
    
    Const
      dx: array [0..3] of Integer = (0, 0, -1, 1);
      dy: array [0..3] of Integer = (-1, 1, 0, 0);
    
    BEGIN
      SetLength(TehMaze, Width, Height);
      SetLength(Todo, (Width * Height) - 1);
    
      For x:=0 to Width-1 do
        For y:=0 to Height-1 do
          If (x = 0) or (x = Width-1) or (y = 0) or (y = Height-1) then
            TehMaze[x][y]:=32
          Else TehMaze[x][y]:=63;
    
      Randomize;
      x := Random(Width-2)+1;
      y := Random(Height-2)+1;
      todonum := 0;
    
      TehMaze[x][y]:= TehMaze[x][y] and not 48; // Пометить клетку как принадлежащую лабиринту
    
       // Пока не обработаны все клетки
       Repeat
        Begin
           // Занести в список todo все ближайшие необработанные клетки
           For d:=0 to 3 do
               if (TehMaze[x + dx[d]][y + dy[d]] and 16) <> 0 then
               Begin
                 todo[todonum].x := x + dx[d];
                 todo[todonum].y := y + dy[d];
                 Inc(todonum);
                 TehMaze[x + dx[d]][y + dy[d]] := TehMaze[x + dx[d]][y + dy[d]] and not 16;
               End;
    
           // Выбрать из списка todo произвольную клетку
           n:= Random(todoNum);
           x:= ToDo[n].x;
           y:= ToDo[n].y;
    
           // Удалить из списка обработанную клетку
           Dec(todonum);
           ToDo[n]:= todo[todonum];
    
           // Выбрать направление, которое ведет к лабиринту
           Repeat
               d:=Random(4);
           Until ((TehMaze[x + dx[d]][y + dy[d]] and 32) = 0);
    
           // Присоединить выбранную клетку к лабиринту
           TehMaze[x][y] := TehMaze[x][y] and not ((1 shl d) or 32);
           TehMaze[x + dx[d]][y + dy[d]] := TehMaze[x + dx[d]][y + dy[d]] and not (1 shl (d xor 1));
        End;
       Until (todonum = 0);
    
       TehMaze[1][1] := TehMaze[1][1] and -2;                 // начало лабиринта - в левом верхнем углу
       TehMaze[Width-2][Height-2] := TehMaze[Width-2][Height-2] and not 2; // конец лабиринта - в правом нижнем углу
    
       Result := TehMaze;
    END;

    Генерация лабиринтов по алгоритму Прима.

    Govnocoder#0xFF, 10 Февраля 2013

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