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

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

    +135

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    (***************************************************************************
       _____          _ _          __          __        _     _   _____       
     / ____|        | (_)         \ \        / /       | |   | | |  __ \      
    | |     ___   __| |_ _ __   __ \ \  /\  / /__  _ __| | __| | | |__) |   _ 
    | |    / _ \ / _` | | '_ \ / _` \ \/  \/ / _ \| '__| |/ _` | |  _  / | | |
    | |___| (_) | (_| | | | | | (_| |\  /\  / (_) | |  | | (_| |_| | \ \ |_| |
     \_____\___/ \__,_|_|_| |_|\__, | \/  \/ \___/|_|  |_|\__,_(_)_|  \_\__,_|
                                __/ |                                         
                               |___/                                          
    *****************************************************************************)
    (*****************************************************************************
    
     Автор программы - CraftR14
     Исходники предоставлены для форума CodingWorld.Ru
    
    
    *****************************************************************************)
    unit Unit1;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
       gsvThread, idhttp,  Spin,  ShellAPI, Menus, CoolTrayIcon, Dialogs,
      ExtCtrls, StdCtrls;
         type
      TForm1 = class(TForm)
        Memo1: TMemo;
        SpinEdit1: TSpinEdit;
        Button1: TButton;
        Memo2: TMemo;
        Label5: TLabel;
        Label6: TLabel;
        Timer1: TTimer;
        SpinEdit2: TSpinEdit;
        Label1: TLabel;
        Label4: TLabel;
        Label2: TLabel;
        Label3: TLabel;
        Button2: TButton;
        Button3: TButton;
        GroupBox1: TGroupBox;
        GroupBox2: TGroupBox;
        Button4: TButton;
        Button5: TButton;
        GroupBox3: TGroupBox;
        GroupBox4: TGroupBox;
        Label7: TLabel;
        Label8: TLabel;
        GroupBox5: TGroupBox;
        SaveDialog1: TSaveDialog;
        OpenDialog1: TOpenDialog;
        Bevel1: TBevel;
        Button6: TButton;
        CoolTrayIcon1: TCoolTrayIcon;
        PopupMenu1: TPopupMenu;
        PopupMenu2: TPopupMenu;
        Show1: TMenuItem;
        SaveGood1: TMenuItem;
        ClearGood1: TMenuItem;
        CloseChecker1: TMenuItem;
        Label9: TLabel;
        procedure Button1Click(Sender: TObject);
        procedure Timer1Timer(Sender: TObject);
        procedure Button2Click(Sender: TObject);
        procedure Button4Click(Sender: TObject);
        procedure Button5Click(Sender: TObject);
        procedure Button3Click(Sender: TObject);
        procedure Button6Click(Sender: TObject);
        procedure Show1Click(Sender: TObject);
        procedure SaveGood1Click(Sender: TObject);
        procedure ClearGood1Click(Sender: TObject);
        procedure CloseChecker1Click(Sender: TObject);
        procedure CoolTrayIcon1DblClick(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
      TMyTr = class(TgsvThread)
        http:TidHttp;
      protected
        procedure Execute; override;
      end;
    
    var
      Form1: TForm1;
      ind:integer=-1;
      thr: array [1..900] of TMyTr;
      checked:Integer=0;
    implementation
    
    {$R *.dfm}
    
    function getnumberproxy:integer;
    begin
      if ind<>form1.Memo1.Lines.Count then
      inc(ind);
      result:=ind;
    end;

    Вот эта вот, херня ходит по интернету и называется "Прокси-чеккер". Особо умилило то, что автор каким-то макаром приплел сюда GSVthreads.

    Stertor, 06 Июля 2013

    Комментарии (13)
  3. Си / Говнокод #13183

    +135

    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
    #include <stdio.h>
     
    typedef void(* file_handler_t)(FILE* fileHandle);
     
    void using_file(FILE* fileHandle, file_handler_t fileHandler/*a*/)
    {
        if(!fileHandle)
            return;
        fileHandler(fileHandle);
        fclose(fileHandle);
    }
     
    int main(void) {
        using_file(fopen("myfile.txt","w"),
            ({void body(FILE* fileHandle) {
                /*пишем в fileHandle;*/
            }; body;})//b
        );
            return 0;
    }

    Постю код в защиту курочки от нападок Тараса про автодестукторы. Уникальные виды куриц нужно оберегать, сохранять и защищать.
    Курочка об gnuцицизмы уже зашкварился так что будем стоять на своем до конца. Главное чтобы он свой не отстоял, а то потом не встанет.
    http://ideone.com/2zRuK0

    В позицию /*a*/ можно добавить параметр, деструктирующий объект должным образом. И соответственно оформить using_file как USING макросом, чтобы можно было деструктить объекты не только типа FILE* но и любых других. В макросе вполне при этом может понадобится гнутый typeof, но у нас и так зашквар, так что уже не важно. Так же для полной универсальности можно добавить параметр, определяющий неуспешность открытия объекта, чтобы вместо if(!fileHandle) был if(predicate(fileHandle)). Но конечно при этом лучше просто сделать 2 варианта макроса: обобщенный и с предикатом по умолчанию логическое отрицание.

    Вместо некрасивой позиции //b лучше завести макрос, эмитирующий нормальную красивую человеческую лямбду.

    LispGovno, 16 Июня 2013

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

    +135

    1. 1
    #define __click_window_chkarmor (!((inventory==plr->inventory)&&(((slot==5)&&!hasflag(consts.item_flags[plr->holdingitem->type],ITEM_FLAG_ARMOR_HEAD))||((slot==6)&&!hasflag(consts.item_flags[plr->holdingitem->type],ITEM_FLAG_ARMOR_CHEST))||((slot==7)&&!hasflag(consts.item_flags[plr->holdingitem->type],ITEM_FLAG_ARMOR_FEET))||((slot==8)&&!hasflag(consts.item_flags[plr->holdingitem->type],ITEM_FLAG_ARMOR_BOOTS)))))

    Форматирование сохранено

    kostoprav, 05 Июня 2013

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

    +135

    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
    public bool IsSupportServerVersion()
        {
          if (this._connMaster.State == ConnectionState.Closed)
            this._connMaster.Open();
          if (int.Parse(((object) this._connMaster.ServerVersion.Split(new char[1]
          {
            '.'
          })[0]).ToString()) >= 9)
          {
            if (int.Parse(((object) this._connMaster.ServerVersion.Split(new char[1]
            {
              '.'
            })[0]).ToString()) <= 10)
              return true;
          }
          return false;
        }

    Проверка версии MSSQL. На фоне того, что писателями заявлена работа с 2005, смотрится особенно хорошо.

    croacker, 08 Мая 2013

    Комментарии (2)
  6. C# / Говнокод #12962

    +135

    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
    string t = label1.Text;
    char[] bits = t.ToCharArray();
    int a1 = (Convert.ToInt16(bits[0]) - 48) + (Convert.ToInt16(bits[1]) - 48) + (Convert.ToInt16(bits[2]) - 48) + (Convert.ToInt16(bits[3]) - 48) + (Convert.ToInt16(bits[4] - 48));
                    char[] hemming = { '0', '0', bits[0], '0', bits[1], bits[2], bits[3], '0', bits[4] };
                    if (a1 == 1 || a1 == 2 || a1 == 4)
                    {
                        hemming[0] = '0';
                    }
                    else
                    { hemming[0] = '1'; }
                    int a2 = (Convert.ToInt16(hemming[2] - 48) + Convert.ToInt16(hemming[5] - 48) + Convert.ToInt16(hemming[6] - 48));
                    if (a2 == 1 || a2 == 2 || a2 == 4)
                    {
                        hemming[1] = '0';
                    }
                    else
                    { hemming[1] = '1'; }
                    int a3 = (Convert.ToInt16(hemming[4] - 48) + Convert.ToInt16(hemming[5] - 48) + Convert.ToInt16(hemming[6] - 48));
                    if (a3 == 1 || a3 == 2 || a3 == 4)
                    {
                        hemming[3] = '0';
                    }
                    else
                    { hemming[3] = '1'; }
                    if (hemming[7] == '1')
                    {
                        hemming[8] = '1';
                    }
                    else
                    { hemming[8] = '0'; }

    Реализация кода Хемминга (орфография и пунктуация сохранены)

    Psilon, 03 Мая 2013

    Комментарии (14)
  7. Си / Говнокод #12961

    +135

    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
    /*
        * Now do an in-place copy.
        * Map (R) to (r) and (TM) to (tm).
        * The era of teletypes is long gone, and there's
        * -really- no need to shout.
        */
    while (*src != '\0') {
        if (src[0] == '(') {
            if (strncmp(src + 1, "R)", 2) == 0) {
                (void) strncpy(dst, "(r)", 3);
                src += 3;
                dst += 3;
                continue;
            }
            if (strncmp(src + 1, "TM)", 3) == 0) {
                (void) strncpy(dst, "(tm)", 4);
                src += 4;
                dst += 4;
                continue;
            }
        }
        *dst++ = *src++;
    }
    *dst = '\0';

    Не говнокод, но забавно.
    Инициализация процессоров (и сбор cpuid) в Solaris
    http://src.illumos.org/source/xref/illumos-gate/usr/src/uts/i86pc/os/cpuid.c#2488

    myaut, 03 Мая 2013

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

    +135

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

    ыыы

    taburetka, 28 Марта 2013

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

    +135

    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
    private uint IdOnTrackServer
            {
                get
                {
                    try
                    {
                        if (m_IdOnTrackServer == null || m_IdOnTrackServer == uint.MaxValue)
                        {
                            ConnectToTrackServer();
                        }
                        //if (m_IdOnTrackServer == null)
                        //{
                        //    // асинхронно подключаемся к серверу треков
                        //    // если сразу подключиться не получилось, то в фоновом потоке стартим reconnect
                        //    if (!TryToConnectToTrackServer_UseResults())
                        //    {
                        //        ConnectToTrackServer();
                        //    }
                        //}
                        //else if (m_IdOnTrackServer == uint.MaxValue)
                        //{
                        //    TryToConnectToTrackServer_UseResults();
                        //}
                        return m_IdOnTrackServer.Value;
                    }
                    catch
                    {
                        return uint.MaxValue;
                    }
                }
            }

    HLW, 02 Марта 2013

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

    +135

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    // где-то в коде нашлось
    PRIVATE IdxArray* idx_array_append_val_dyn(IdxArray* arr, PlmIndex idx)
    
    // private.h
    #ifdef PLM_TEST
    #define PRIVATE extern
    #else
    #define PRIVATE static
    #endif

    внезапно...

    Try, 26 Февраля 2013

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

    +135

    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
    namespace CuttingBox
    {
    
        class Program
        {
            static public Tuple<int[], String> getProperty()
            {
                int[] itemDimensionProperty = new int[3];
                String itemColorProperty;
                String[] parseResult = new String[4];
                parseResult = (Console.ReadLine().Split(' '));
                for (int counter = 0; counter < 3; counter++)
                {
                    itemDimensionProperty[counter] = Convert.ToInt32(parseResult[counter]);
                }
                itemColorProperty = parseResult[3];
                Tuple<int[], String> itemProperty = new Tuple<int[], string>(itemDimensionProperty, itemColorProperty);
                return itemProperty;
            }
    
            static void Main(string[] args)
            {
                List<Tuple<int[], String>> itemProperty = new List<Tuple<int[], String>>();
                itemProperty.Add(getProperty());
                int numberOfBoxes = Convert.ToInt32(Console.ReadLine());
                for (int counter=1; counter<=numberOfBoxes; counter++){
                    itemProperty.Add(getProperty());
                }
            }
        }
    }

    Парсим строки правильно...

    javanesovsemgovno, 11 Февраля 2013

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