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

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

    +96

    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
    Assign(F, FileName);
      IOResult;
      Reset(F);
      if IOResult = 0 then begin
        for i := 0 to MaxModelNamesCount-1 do ModelKind[i] := mkVagon;
        Result := True;
        BlockRead(F, W, 2);
        if W = OldWDim then begin // старый формат
          // 20 строк пропущено
        end else if W = WDim then begin // новый формат
          BlockRead(F, FormatVersion, 4); // версия нового формата
          if FormatVersion <= 4 then begin
            BlockRead(F, EditorDate, 4);
            BlockRead(F, C, 4);
            LCount := C;
            for i := 0 to LCount - 1 do begin
              BlockReadLine(F, Lines[i], 16);
              if (FormatVersion <= 2) and (Lines[i].Attr[3] and $0F = 5) then Lines[i].Attr[0] := 0
              else if (Lines[i].Attr[3] and $0F = k3DObject) then ModelKind[Lines[i].IntAttr[1]] := mkStatic;
            end;
            if FormatVersion <= 1 then begin
              ModelNamesCount := 8;  // для 1й версии список жёстко задан
              ModelNames[0] := 'ГЗРВ-10';
              ModelNames[1] := 'ГЗРВ-10М';
              ModelNames[2] := 'КТМ-5М3';
              ModelNames[3] := 'ЛМ-68';
              ModelNames[4] := 'ЛМ-68М';
              ModelNames[5] := 'ЛМ-68ММ';
              ModelNames[6] := 'ЛВС-86';
              ModelNames[7] := 'ЛВС-97';
              for i := 8 to MaxModelNamesCount-1 do ModelNames[i] := '';
            end else if FormatVersion <= 3 then begin
              ModelNamesCount := 0;
              for i := 0 to 255 do begin
                j := 0;
                BlockRead(F, j, 1);
                SetLength(ModelNames[i], j);
                for j := 1 to Length(ModelNames[i]) do Read(F, byte(ModelNames[i, j]));
                if ModelNames[i] <> '' then Inc(ModelNamesCount);
              end;
            end else begin
              BlockRead(F, ModelNamesCount, 4); // кол-во моделей
              for i := 0 to MaxModelNamesCount - 1 do ModelNames[i] := '';
              for i := 0 to ModelNamesCount-1 do begin
                BlockRead(F, k, 4); // номер считываемой модели
                j := 0;
                BlockRead(F, j, 1); // длина имени, не более 255
                SetLength(ModelNames[k], j);
                for j := 1 to Length(ModelNames[k]) do Read(F, byte(ModelNames[k, j]));
              end;
            end;
    
            for i := 0 to 8 do
              for j := 0 to 12 + Byte(FormatVersion >= 2) do with Routes[i, j] do begin
                BlockRead(F, PCount, 2);
                SetAllowedModels(Routes[i,j], 0, -1);
                if FormatVersion <= 1 then begin      
                  BS := [];
                  BlockRead(F, BS, 4);
                  AllowedModelsCount := 0;
                  for k := 0 to 255 do if k in BS then begin
                    Inc(AllowedModelsCount);
                    AllowedModels[k] := True;
                  end;
                end else if FormatVersion <= 3 then begin
                  BlockRead(F, BS, 32);
                  AllowedModelsCount := 0;
                  for k := 0 to 255 do if k in BS then begin
                    Inc(AllowedModelsCount);
                    AllowedModels[k] := True;
                  end;
                end else begin
                  BlockRead(F, AllowedModelsCount, 4);
                  for k := 0 to AllowedModelsCount-1 do begin
                    BlockRead(F, n, 4);           // номер модели
                    AllowedModels[n] := True;
                  end;
                end;
    
                for k := 0 to PCount - 1 do begin
                  if FormatVersion >= 3 then BlockRead(F, c, 4)
                  else begin
                    c := 0;
                    BlockRead(F, c, 2);
                  end;
                  Points[k] := c;
                end;
                BlockRead(F, DefVagons, 1);
                SpeedRoute := boolean(DefVagons shr 4);
                DefVagons := DefVagons and $0F;
                BlockRead(F, Interval, 1);
              end;
          end else Result := False;
        end else Result := False;
        Close(F);

    Короче, лапша из if FormatVesion такой-то...
    Обратная совместимость формата файла.
    Формату уже 4 года.

    TarasB, 05 Июня 2011

    Комментарии (52)
  3. Pascal / Говнокод #6410

    +96

    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
    function OnShape(sh: TShape; X, Y: Integer) : TBrushStyle;
    var r, cx, cy, d2: Integer;
    begin
    r := sh.Width div 2;
    cx := sh.Left + r;
    cy := sh.Top + r;
    d2 := (X - cx) * (X - cx) + (Y - cy) * (Y - cy);
    OnShape := bsClear;
    if d2 < r*r then OnShape := bsSolid;
    end;
    
    procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    begin
    Shape1.Brush.Color := clRed;
    Shape1.Brush.Style := OnShape(Shape1, X, Y);
    Shape2.Brush.Color := clLime;
    Shape2.Brush.Style := OnShape(Shape2, X, Y);
    Shape3.Brush.Color := clYellow;
    Shape3.Brush.Style := OnShape(Shape3, X, Y);
    end;

    Откуда бы вы думали это? Правильно, "Занимательное программирование Delphi". Глава 14. Светофор.

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

    Комментарии (5)
  4. Pascal / Говнокод #6343

    +96

    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
    procedure TForm1.FormCreate(Sender: TObject);
    begin
    Image1.Transparent:=true;
    Image1.Picture.LoadFromFile('ab.bmp');
    
    
    inbot:='1';
    wkbot:='1';
    Memo1.Text:='';
    
    with Form1 do
    SetWindowPos(Handle,
    HWND_TOPMOST,
    Left,
    Top,
    Width,
    Height,
    SWP_NOACTIVATE or SWP_NOMOVE or SWP_NOSIZE);
    
    statusbar1.Panels.Items[0].Text:='Клиент подключон'; 
    si:='log.txt';
    assignfile(fi,si);
    reset(fi);
    for i:=0 to 1590 do begin
    Readln(fi, a);
    b:=b+a;
    end;
    Memo1.Lines.Add(b);
    CloseFile(fi);
    statusbar1.Panels.Items[0].Text:='Ожидание подключения клиента';
    Button2.Enabled:=false;
    end;

    Ещё один говнокод от ВебКилла. MOAR!!!!111: http://3.webkill.ru/socket_messager.html

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

    Комментарии (29)
  5. Pascal / Говнокод #5829

    +96

    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
    procedure TForm1.RegHttpRedirect(Sender: TObject; var dest: String;
      var NumRedirect: Integer; var Handled: Boolean;
      var VMethod: TIdHTTPMethod);
    begin
    Log('Redirect № ' + IntToStr(NumRedirect)+ ' - '+ Dest ,  true, MainClr);
    end;
    
    procedure TForm1.HTTPCoreStatus(ASender: TObject; const AStatus: TIdStatus;
      const AStatusText: String);
    begin
    Log('Статус: '+ AStatusText, true, MainClr);
    end;
    
    {procedure TForm1.RegHttpW0rk(Sender: TObject; AWorkMode: TWorkMode;
      const AWorkCount: Integer);
    begin
    
    end;}

    лошарский код

    megaruliz, 28 Февраля 2011

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

    +96

    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
    procedure tnew.execute;
    var
    cod:utf8string;
    id:byte;
    
    captcha,sim,idc:string;
    ss:TStringStream;
    s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,
    s11,s12,s13,s14,s15,s16,s17,s18,
    s19,s20,s21,s22,s23,s24,s25,s26,
    s27,s28,s29,s30,s31,s32,s33:utf8string;
    FS:TFileStream;
    Antigate: TAntigate;
    begin
    form3.IdHTTP1.Request.Referer :='http://www.aboutlive.ru/phpBB2/profile.php?mode=register';
    
    cod:=form3.IdHTTP1.get('http://www.aboutlive.ru/phpBB2/profile.php?mode=register&agreed=true');
    
    function Pars (T_, ForS, _T: string): string;
    var
    a, b: integer;
    begin
    Result := '';
    if (T_ = '') or (ForS = '') or (_T = '') then
    Exit;
    a := Pos (T_, ForS);
    if a = 0 then
    Exit
    else
    a := a + Length (T_);
    ForS := Copy (ForS, a, Length (ForS) - a + 1);
    b := Pos (_T, ForS);
    if b > 0 then
    Result := Copy (ForS, 1, b - 1);
    end;
    
    
    idc:= pars('confirm_id" value="',cod,'" />');
    sim:= pars('sid" value="',cod,'" />');
    
    FS:=TFileStream.Create('captcha.png',FMCreate);
    form3.IdHTTP1.Get('http://www.aboutlive.ru/phpBB2/profile.php?mode=confirm&id='+idc, FS);
    FS.free;
    form3.Image1.Picture.LoadFromFile('captcha.png');
    
    Antigate := TAntigate.Create; // это разгадка капчи
    antigate.Calc:=1;
    antigate.MaxRetry:=3;
    Antigate.Key := '';
    Antigate.ImageFile := 'captcha.png';
    captcha:=Antigate.Recognize;
    Antigate.free;
    
    form3.RichEdit1.Lines.Add('Капча: '+AnsiUpperCase(captcha));
    
    form3.IdHTTP1.Request.Referer :='http://www.aboutlive.ru/phpBB2/profile.php?mode=register&agreed=true';
    ss := TStringStream.Create;
    
    s1:='username=sadsaddfsa12342';
    s2:='[email protected]';
    s3:='new_pasword=1234567';
    s4:='pasword_confirm=1234567';
    s5:='confirm_code='+captcha;
    s6:='icq=';
    s7:='aim=';
    s8:='msn=';
    s9:='yim=';
    s10:='website=';
    s11:='location=';
    s12:='occupation=';
    s13:='interests=';
    s14:='signature=';
    s15:='viewemail=0';
    s16:='hideonline=0';
    s17:='notifyreply=0';
    s18:='notifypm=1';
    s19:='popup_pm=1';
    s20:='attachsig=1';
    s21:='allowbbcode=1';
    s22:='allowhtml=1';
    s23:='allowsmilies=1';
    s24:='language=russian';
    s25:='style=1';
    s26:='timezone=4';
    s27:='dateformat=D M d, Y g:i a';
    s28:='mode=register';
    s29:='agreed=true';
    s30:='coppa=0';
    s31:='sid='+sim;
    s32:='confirm_id='+idc;
    s33:='submit=Отправить';
    ss.WriteString (s1+'&'+s2+'&'+s3+'&'+s4+'&'+s5+'&'+s6+'&'+s7+'&'+s8+'&'+s9+'&'+s10+'&'+s11+'&'+s12+'&'+s13+'&'+s14+'&'+s15+'&'+s16+'&'+s17+'&'+s18+'&'+s19+'&'+s20+'&'+s21+'&'+s22+'&'+s23+'&'+s24+'&'+s25+'&'+s26+'&'+s27+'&'+s28+'&'+s29+'&'+s30+'&'+s31+'&'+s32+'&'+s33);

    Что уж тут напишешь....

    Irdis, 11 Февраля 2011

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

    +96

    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
    procedure TForm1.Button2Click(Sender: TObject);
    var stSQL: string;
    i: integer;
    begin
    
    try
    SQLConnection1.Params.Values['HostName']:=Server; // имя сервера
    SQLConnection1.Params.Values['DataBase']:=MyBase ;
    SQLConnection1.Params.Values['OS Authentication']:= 'True';
    SQLConnection1.Open;
    except
    MessageDlg('Соединение с БД невозможно', mtError, [mbOK], 0);
    exit;
    end;
    
    SQLQuery1.SQL.Add('IF EXISTS (SELECT * FROM sysobjects WHERE name ='+''''+'MyTable'+''''+') DELETE FROM MyTable;');
    SQLQuery1.ExecSQL;
    SQLQuery1.SQL.Clear;
    SQLQuery1.SQL.Add('IF EXISTS (SELECT * FROM sysobjects WHERE name ='+''''+'MyTable'+''''+') DROP TABLE MyTable;');
    SQLQuery1.ExecSQL;
    SQLQuery1.SQL.Clear;
    SQLQuery1.SQL.Add('CREATE TABLE MyTable (VZPROJ varchar(50), PARTITION varchar(50), '+
    'MAKER varchar(50), STATE varchar(50), DATECRT varchar(50), DATEP varchar(50), '+
    'DATEF varchar(50), DATETOCRD varchar(50), DATECRD varchar(50), DATEPLN varchar(50), '+
    'DATEFIN varchar(50), DATECNCL varchar(50))');
    SQLQuery1.ExecSQL;
    
    cdsList.First;
    for i:=1 to cdsList.RecordCount do
    begin
    stSQL:='INSERT INTO MyTable VALUES(';
    if cdsList.FieldByName('VZPROJ').AsString<>'' then
    stSQL:=stSQL+' '''+cdsList.FieldByName('VZPROJ').AsString+''','
    else
    stSQL:=stSQL+' NULL,';
    if cdsList.FieldByName('PARTITION').AsString<>'' then
    stSQL:=stSQL+' '''+cdsList.FieldByName('PARTITION').AsString+''','
    else
    stSQL:=stSQL+' NULL,';
    if cdsList.FieldByName('MAKER').AsString<>'' then
    stSQL:=stSQL+' '''+cdsList.FieldByName('MAKER').AsString+''','
    else
    stSQL:=stSQL+' NULL,';
    if cdsList.FieldByName('STATE').AsString<>'' then
    stSQL:=stSQL+' '''+cdsList.FieldByName('STATE').AsString+''','
    else
    stSQL:=stSQL+' NULL,';
    if cdsList.FieldByName('DATECRT').AsString<>'' then
    stSQL:=stSQL+' '''+cdsList.FieldByName('DATECRT').AsString+''','
    else
    stSQL:=stSQL+' NULL,';
    if cdsList.FieldByName('DATEP').AsString<>'' then
    stSQL:=stSQL+' '''+cdsList.FieldByName('DATEP').AsString+''','
    else
    stSQL:=stSQL+' NULL,';
    if cdsList.FieldByName('DATEF').AsString<>'' then
    stSQL:=stSQL+' '''+cdsList.FieldByName('DATEF').AsString+''','
    else
    stSQL:=stSQL+' NULL,';
    if cdsList.FieldByName('DATETOCRD').AsString<>'' then
    stSQL:=stSQL+' '''+cdsList.FieldByName('DATETOCRD').AsString+''','
    else
    stSQL:=stSQL+' NULL,';
    if cdsList.FieldByName('DATECRD').AsString<>'' then
    stSQL:=stSQL+' "'+cdsList.FieldByName('DATECRD').AsString+''','
    else
    stSQL:=stSQL+' NULL,';
    if cdsList.FieldByName('DATEPLN').AsString<>'' then
    stSQL:=stSQL+' '''+cdsList.FieldByName('DATEPLN').AsString+''','
    else
    stSQL:=stSQL+' NULL,';
    if cdsList.FieldByName('DATEFIN').AsString<>'' then
    stSQL:=stSQL+' '''+cdsList.FieldByName('DATEFIN').AsString+''','
    else
    stSQL:=stSQL+' NULL,';
    if cdsList.FieldByName('DATECNCL').AsString<>'' then
    stSQL:=stSQL+' '''+cdsList.FieldByName('DATECNCL').AsString+''''
    else
    stSQL:=stSQL+' NULL';
    
    stSQL:=stSQL+');';
    
    SQLQuery1.SQL.Clear;
    SQLQuery1.SQL.Add(stSQL);
    SQLQuery1.ExecSQL;
    cdsList.Next;
    end;
    
    end;

    дельфипаста с гарниром

    bugmenot, 07 Декабря 2010

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

    +96

    1. 1
    [IMG]http://i9.fastpic.ru/big/2010/0816/9f/a3d5a2c8a4229835a1fca9dd79fca29f.jpg[/IMG]

    4 поне Апокалипсиса

    3.14159265, 16 Августа 2010

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

    +96

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    public static Entity read(final URI path) {
    	if(!(path.items!= null && (0 < path.items.size()))){
    		assert (false);
    	}
                     //дальше сам метод

    3.14159265, 02 Июля 2010

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

    +96

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    char str[STR_LEN + 1]; 
    
    strncpy(str, inpust_str, STR_LEN);
    xxx[STR_LEN] = '\0';
    
    str[ strlen(str) ] = ':';
    str[ strlen(str) + 1 ] = '1';
    str[ strlen(str) + 2 ] = '\0';

    Попытка добавить ":1" к строке.

    Первым же "str[ strlen(str) ] = ':';" гробим нулевой символ в конце строки. Дальнейшие вызовы "strlen" - просто фигня какая-то. Ну и портим память.

    benderlog, 23 Марта 2010

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

    +95.9

    1. 1
    2. 2
    3. 3
    string.Format("{1}/{0}/{2}", day.Day, day.Month, day.ToString("yy")
    
    string.Format("{0}", programm.Key)

    2 отличных метода превращения даты и числа в строку :)
    Человек когда-то драйвера писал на ЖД.
    ппц.

    medcom, 04 Февраля 2010

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