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

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

    +97

    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
    using System;
    using Microsoft.Win32;
     
    namespace Reester
    {
        class Program
        {
            static void Main(string[] args)
            {
                RegCreatySubKey();
            }
     
            private static void RegCreatySubKey()
            {
                RegistryKey regKey = Registry.LocalMachine;
                string[] shell = new[] { "SOFTWARE", "Microsoft", "Windows", "CurrentVersion", "Explorer", "CommandStore", "shell" };
     
                string prog = "Programma";
    1)            using (regKey = Registry.LocalMachine.OpenSubKey(shell[0],true))// тут regKey равно{HKEY_LOCAL_MACHINE}
    2)                {                                                    //сдеть уже regKey   равно {HKEY_LOCAL_MACHINE\SOFTWARE}
     
     
    3)                    if (regKey != null)//и тут уже regkey равно Null.А дальше программа не идет.
                        {
                            using (regKey = Registry.LocalMachine.OpenSubKey(shell[1], true))
                            {
                                if (regKey != null)
                                {
                                    using (regKey = Registry.LocalMachine.OpenSubKey(shell[2], true))
                                    {
                                        if (regKey != null)
                                        {
                                            using (regKey = Registry.LocalMachine.OpenSubKey(shell[3], true))
                                            {
                                                if (regKey != null)
                                                {
                                                    using (regKey = Registry.LocalMachine.OpenSubKey(shell[4], true))
                                                    {
                                                        if (regKey != null)
                                                        {
                                                            using (regKey = Registry.LocalMachine.OpenSubKey(shell[5], true))
                                                                
                                                            {
                                                                if (regKey != null)
                                                                {
                                                                    using (regKey = Registry.LocalMachine.OpenSubKey(shell[6], true))
                                                                    {
                                                                        if (regKey != null)
                                                                        {
                                                                            regKey.CreateSubKey(prog);
                                                                        }
                                                                    }
                                                                 }
     
                                                              }
                                                          }
                                                      }
                                                    }
                                                 }
                                               }
                                            }
                                          }
                                        }
                                     }
                                  }
                              }
                        
                       }
                  }

    Работаем с реестром

    Psilon, 31 Декабря 2014

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

    +97

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    if (((((length > 4) && ((anUrl[0] == 'h') || (anUrl[0] == 'H'))) && 
    ((anUrl[1] == 't') || (anUrl[1] == 'T'))) && 
    (((anUrl[2] == 't') || (anUrl[2] == 'T')) &&
    ((anUrl[3] == 'p') || (anUrl[3] == 'P')))) && 
    ((anUrl[4] == ':') || (((length > 5) && 
    ((anUrl[4] == 's') || (anUrl[4] == 'S'))) && (anUrl[5] == ':'))))

    Нашел в коде проверку на http(s)

    logman, 26 Декабря 2014

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

    +97

    1. 1
    2. 2
    var
       TCPLength: boolean;

    Ага. Длина либо есть, либо нет.

    youmych, 07 Августа 2014

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

    +97

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    Сегодня был приятно удивлен тем, что цикл
    
    for i:=0 to memo1.lines.count -1 do
    ...
    
    приостанавливает работу, когда идет обращение к мемо (пользователь выделяет текст или печатает в этом мемо) до тех пор, пока идет обращение. 
    Очевидно, это такая фишка компилятора. Приятно, когда компилятор прикрывает спину.

    Stertor, 10 Августа 2013

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

    +97

    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
    {$APPTYPE CONSOLE} {$IFDEF FPC}{$MODE DELPHI}{$ENDIF}
    uses SysUtils, Classes, IniFiles, Variants;
    
    type TGetToken = function(var p: pointer): LongInt;
    procedure ParseData(var p: pointer; isKey: boolean); forward;
    procedure AdvanceIndex(var i: LongInt); forward;
    
    function GetIntegerToken(var p: pointer): LongInt;
    var value: LongInt = 0;
        negative: boolean;
    begin
      Inc(p);
      negative := PByte(p)^ = ord('-');
      if negative then Inc(p);
      repeat
        value := value * 10 + LongInt(PByte(p)^ - $30);
        Inc(p)
      until PChar(p)^ = 'e';
      Inc(p);
      if negative then value := - value;
      Result := value
    end;
    
    function GetListToken(var p: pointer): LongInt;
    var index: Integer = 0;
    begin
      Inc(p);
      while PChar(p)^ <> 'e' do begin
        AdvanceIndex(index);
        ParseData(p, false);
      end;
      Inc(p);
      Result := -1
    end;
    
    function GetDictToken(var p: pointer): LongInt;
    begin
      Inc(p);
      while PChar(p)^ <> 'e' do begin
        ParseData(p, true);
        ParseData(p, false);
      end;
      Inc(p);
      Result := -1
    end;
    
    function ParseError(var p: pointer): LongInt;
    begin
      Writeln('TYIIINTE CBET');
      Result := -1;
      Halt(Result)
    end;
    
    const FuncTable: array[0..3] of TGetToken = (ParseError, GetDictToken, GetIntegerToken, GetListToken);
    
    function GetStringToken(var p: pointer): string;
    var value: ShortString;
        length: LongInt = 0;
    begin
      repeat
        length := length * 10 + LongInt(PByte(p)^ - $30);
        Inc(p)
      until PChar(p)^ = ':';
      if length in [1..255] then begin
        PByte(p)^ := length;
        Move(p^, value, length+1);
        Result := value;
      end else Result := 'BINARY DATA';
      Inc(p, length + 1);
    end;
    
    var sl: TStringList;
        outf: TIniFile;
    
    procedure AdvanceIndex(var i: LongInt);
    begin
      sl.Add(IntToStr(i));
      Inc(i);
    end;

    type TSaveData = procedure(value: Variant);

    procedure SaveData(value: Variant);
    var
    key: string = '';
    i: LongInt;
    begin
    for i := 0 to sl.Count - 1 do key := key + '.' + sl[i];
    Delete(key, 1, 1);
    outf.WriteString('Torrent', key, VarToStr(value));
    if sl.Count > 0 then sl.Delete(sl.Count - 1);
    end;

    procedure PushKey(value: Variant);
    begin
    sl.Add(value)
    end;

    procedure PopKey(value: Variant);
    begin
    if sl.Count > 0 then sl.Delete(sl.Count - 1);
    end;

    procedure NOP(value: Variant);
    begin
    end;

    const SaveDataTable: array[0..3] of TSaveData = (SaveData, PushKey, PopKey, NOP);

    procedure ParseData(var p: pointer; isKey: boolean);
    var
    OpCode: ShortInt;
    value: Variant;
    begin
    OpCode := PByte(p)^;
    if OpCode >= $60 then value := FuncTable[OpCode shr 2 and 3](p)
    else if Opcode in [$30..$39] then value := GetStringToken(p)
    else ParseError(p);

    SaveDataTable[ord(isKey) + 2*ord(chr(OpCode) in ['d', 'l'])](value);
    end;

    var f: TFileStream;
    s: LongInt;
    p, cp: pointer;
    begin
    if ParamCount <> 1 then Writeln('Usage: ', ParamStr(0), ' filename.torrent')
    else
    try
    f := TFileStream.Create(ParamStr(1), fmOpenRead);
    s:= f.Size;
    GetMem(p, s + 1);
    f.ReadBuffer(p^, s);
    cp := p;
    outf := TIniFile.Create(ChangeFileExt(ParamStr(1), '.ini'));
    sl := TStringList.Create;
    ParseData(cp, false);
    finally
    if sl <> nil then sl.Destroy();
    if outf <> nil then outf.Destroy();
    if p <> nil then FreeMem(p);
    if f <> nil then f.Destroy()
    end
    end.

    Парсер torrent-файлов и сохранялка в INI-файл (пока без сумм фрагментов). Опа-лаба-стайл, писано левой ногой анскильного питуха.

    inkanus-gray, 09 Июля 2013

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

    +97

    1. 1
    2. 2
    3. 3
    Integer [] jh = new Integer [1];
    Integer j0 = new Integer(17);
    jh[0]= j0;

    Заполняем массив.

    3.14159265, 30 Января 2013

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

    +97

    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
    SetLength(s,N);
      SetLength(Y,N);
      SetLength(U,N);
      SetLength(Z,N);
      SetLength(E,N);
      for i:=0 to N do  //какбэ на выход за границы даже не смотрим, не в этом суть
        begin
          SetLength(S[i],M);
          SetLength(Y[i],M);
          SetLength(U[i],M);
          SetLength(Z[i],M);
          SetLength(E[i],M);
        end;

    Переделывал чужой консольный проект под форму, не сразу понял, что происходит.
    Так вот, Вы, наверное, думаете, что знаете, как задавать размер динамического массива? Нет, нихрена вы не знаете.

    SkuII, 29 Мая 2012

    Комментарии (33)
  9. PHP / Говнокод #10351

    +97

    1. 1
    $date_sys=date("20y-m-d");

    Код из Марокко. Действительно, зачем юзать Y-m-d, если Y = 20y.

    howl, 23 Мая 2012

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

    +97

    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
    enum TheComponentsOfLanguage 
    {
    	Glottis, 					//— голосовая щель;
    	FerreinsCord, 				//— голосовая складка;
    	VestibularFold, 				//— складка преддверия;
    	EpiglotticFold, 				//— черпалонадгортанная складка;
    	BaseOfTongue, 				//— корень языка;
    	PalatineTonsils, 			//— небные миндалины;
    	BlindHoleLanguage, 			//— слепое отверстие языка;
    	BorderFurrow,				//— пограничная бороздка;
    	LeafBuds,				//— листовидные сосочки;
    	PapillaeSurroundedTheShaf,		//— сосочки, окруженные валом;
    	MushroomShapedPapillae,		//— грибовидные сосочки;
    	BodyLanguage,				//— корпус языка;
    	FiliformPapillae,			//— нитевидные сосочки;
    	DorsumOfTongue,			//— спинка языка;
    	TheTipOfTheTongue			//— верхушка языка;
    }

    KusokGovna, 17 Мая 2012

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

    +97

    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
    namespace Interface.module1
    {  class Sort_text
        { private string[] str;
            public Sort_text(string[] astr)
            { if (astr.Length == 0)
                {   str = new String[1];
                    str[0] = "";
                }
                else
                {   str = new String[astr.Length];
                    str = astr; }
    
            }
            public string[] Str
            {   get { return str; }
                set { this.str = value; }
            }
            public void sort_poslovno_pryamoi()
            {   string ss = "";
                List<string> t = new List<string>();
                for (int i = 0; i < Str.Count(); i++)
                    for (int j = 0; j < Str[i].Length; j++)
                    {  if (Str[i][j] == ' ')
                        { if (ss == "")
                                continue;
                            t.Add(ss);
                            ss = "";
                        }
                        else
                        {   ss = ss + Str[i][j];
                            if (j + 1 == Str[i].Length && ss != "")
                            {   t.Add(ss);
                                ss = ""; }
                        }
                    }
                t.Sort();
                Str = t.ToArray();
            }
            public void sort_poslovno_obratnyi()
            {   string ss = "";
                List<string> t = new List<string>();
                for (int i = 0; i < Str.Count(); i++)
                    for (int j = 0; j < Str[i].Length; j++)
                    { if (Str[i][j] == ' ')
                        {   if (ss == "")
                                continue;
                            t.Add(ss);
                            ss = ""; }
                        else
                        {   ss = ss + Str[i][j];
                            if (j + 1 == Str[i].Length && ss != "")
                            {   t.Add(ss);
                                ss = "";  }
                        }
                    }
                t.Sort();
                t.Reverse();
                Str = t.ToArray();
            }
            public void sort_postrochno_pryamoi()
            {   string ss = "";
                List<string> t = new List<string>();
                for (int i = 0; i < Str.Count(); i++)
                { t.Add(Str[i]);
                }
                t.Sort();
                Str = t.ToArray();
            }
            public void sort_postrochno_obratnyi()
            {   string ss = "";
                List<string> t = new List<string>();
                for (int i = 0; i < Str.Count(); i++)
                { t.Add(Str[i]);
                }
                t.Sort();
                t.Reverse();
                Str = t.ToArray();
            }
    
        }
        class Sort_bin
        {   private byte[] b;
            public Sort_bin(byte[] ab)
            {  b = ab; }
            public byte[] B
            {   get { return b; }
                set { this.b = value; }
            }
            public void sort_bin_pryamoi()
            {   List<byte> t = new List<byte>(B.ToList());
                t.Sort();
                B = t.ToArray();
            }
            public void sort_bin_obratnyi()
            {   List<byte> t = new List<byte>(B.ToList());
                t.Sort();
                t.Reverse();
                B = t.ToArray();  }
        }
    }

    legati, 12 Мая 2012

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