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

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

    +114

    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
    static Queue<string> getProxiesFromFile(string filename)
            {
                Queue<string> temp=new Queue<string>();
                System.IO.StreamReader file;
                string line;
                // Read the file and display it line by line.
                if (filename == null)
                {
                    file = new System.IO.StreamReader("proxy.txt");
                }
                else
                {
                    try
                    {
                        file = new System.IO.StreamReader(filename);
                    }
                    catch (FileNotFoundException)
                    {
                        throw;
                    }
                }
                while ((line = file.ReadLine()) != null)
                {
                    temp.Enqueue (line);
                    Console.WriteLine(line);
                }
                return temp;
            }

    Считываем файл построчно и заносим в Queue<string> .

    gg123, 27 Июня 2011

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

    +114

    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
    procedure TForm1.Button1Click(Sender: TObject);
      var
        a,b,c,x:integer;
        chas, nedel1,nedel2,nedel3:integer;
    begin
      a:=0;
      b:=0;
      c:=0;
      repeat
        chas:= strtoint (edit1.text);
        nedel1:= strtoint (edit2.text);
        nedel2:= strtoint (edit3.text);
        nedel3:= strtoint (edit4.text);
        x:=((nedel1*a)+(nedel2*b)+(nedel3*c));
        if chas<>((nedel1*a)+(nedel2*b)+(nedel3*c)) then
          a:=a+1;
        if chas<>((nedel1*a)+(nedel2*b)+(nedel3*c)) then
          b:=b+1;
        if chas<>((nedel1*a)+(nedel2*b)+(nedel3*c)) then
          c:=c+1;
      until chas=x;
      label1.Caption:=inttostr (a);
      label2.Caption:=inttostr (b);
      label3.Caption:=inttostr (c);
    end;
    end.

    евклид плачет

    bugmenot, 27 Мая 2011

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

    +114

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    if (defaultOrderType == OrderType.NoCharge || defaultOrderType == OrderType.Claims)
    {
        noChargeItemEntry.Style.Add(HtmlTextWriterStyle.Display, "block");
        itemEntryPanel.Style.Add(HtmlTextWriterStyle.Display, "none");
        items.Style.Add(HtmlTextWriterStyle.Display, "none");
    }
    else
    {
        noChargeItemEntry.Style.Add(HtmlTextWriterStyle.Display, "none");
        itemEntryPanel.Style.Add(HtmlTextWriterStyle.Display, "block");
        items.Style.Add(HtmlTextWriterStyle.Display, "block");
    }

    abatishchev, 18 Марта 2011

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

    +114

    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
    [Serializable()]
    	public class Vendor
    	{
    		#region Constructors
    
    		public Vendor(long vendorID)
    		{
    			LoadData(vendorID);
    		}
    
    		internal Vendor(Vendor argVendor)
    		{
    			if (argVendor != null)
    			{
    				this.ID = argVendor.ID;
    				this.VendorName = argVendor.VendorName;
    				this.Account = argVendor.VendorAccount;
    				this.EIN = argVendor.VendorEIN;
    				this.Address = argVendor.VendorAddress;
    				this.City = argVendor.VendorCity;
    				this.State = argVendor.VendorState;
    				this.PostalCode = argVendor.VendorZip;
    				this.Phone = argVendor.VendorPhone;
    				this.ContactName = argVendor.VendorContact;
    				this.VendorCode = argVendor.VendorCode;
    				this.Country = argVendor.VendorCountry;
    				this.FaxNumber = argVendor.VendorFax;
    				this.Email = argVendor.Email;
    			}
    		}
    		#endregion
    
    		public void LoadData(long vendorID)
    		{
    			POMRepositoryDataClassesDataContext db = new POMRepositoryDataClassesDataContext();
    			var ven = (from v in db.Vendors
    					   where v.ID == vendorID
    					   select v).SingleOrDefault();
    			if (ven != null)
    			{
                    populateMe(ven);
    			}
    		}
            public void LoadDataByVendorCode(string argVendorCode)
            {
                POMRepositoryDataClassesDataContext db = new POMRepositoryDataClassesDataContext();
                var ven = (from v in db.Vendors
                           where v.VendorCode == argVendorCode
                           select v).Take(1).SingleOrDefault();
                if (ven != null)
                {
                    populateMe(ven);
                }
            }
            private void populateMe(Vendor ven)
            {
                this.ID = ven.ID;
                this.VendorName = ven.VendorName;
                this.Account = ven.VendorAccount;
                this.EIN = ven.VendorEIN;
                this.Address = ven.VendorAddress;
                this.City = ven.VendorCity;
                this.State = ven.VendorState;
                this.PostalCode = ven.VendorZip;
                this.Phone = ven.VendorPhone;
                this.ContactName = ven.VendorContact;
                this.VendorCode = ven.VendorCode;
                this.Country = ven.VendorCountry;
    	    this.FaxNumber = ven.VendorFax;
    	    this.Email = ven.Email;
            }
    }

    No comments!!!

    Arterius, 16 Марта 2011

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

    +114

    1. 1
    2. 2
    var panel = (StackPanel)((FrameworkElement)button.Parent).FindName("addContactPanel");
    panel.Visibility = Visibility.Collapsed;

    вместо простого addContactPanel.Visibility = Visibility.Collapsed;

    McElroy, 04 Февраля 2011

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

    +114

    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
    public IQueryable<Log> Select(Context context)
            {
                // Return list of entities
                return (from l in context.Logs select l);
            }
    
            /// <summary>
            /// Fetch page from Log table
            /// </summary>
            /// <param name="nStartRowIndex">Starting index of rows to fetch</param>
            /// <param name="nMaxRows">Max number of rows</param>
            /// <returns>IEnumerable of Log</returns>
            public List<Log> SelectPage(int nStartRowIndex, int nMaxRows, 
                                        string strProperty, string strKeyword,
                                        string strSort, string strSortDirection, 
                                        out int nTotalCount)
            {            
                using (Context context = new Context())
                {
                    var q = Select(context).Take (1000);
                 }
          }

    Коллега на работе наворотил...

    Katsy, 04 Февраля 2011

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

    +114

    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
    TMapObj = record
        Size: integer;
        Selected, Valid: boolean;
        case Kind: TKind of
    // дохрена пропущено
       koTxr: (
            TxrFileName: string [31];
            tLast: integer;
            TxrCorrect: boolean;
            LODS: array [0 .. 3] of TBitmap;
            Pixel: TBitmap;
          );
          koItem: (
            Location: TLocation;
            ItemEndSel: boolean;        // выделена ли для перетаскивания
            TimeBeforeReborn: integer;  // времени до восстановления
            DescrIndex: integer;        // индекс описателя
            Rotation: integer;
    
            TeamColor, EnemyColor: integer;
    
            iLast: integer;
    
            CannotGet: boolean;
    
            case TKindItem of
              kiWeapon: (
                iwpFallen: boolean;
                iwpBulletsLeft: integer;
                iwpState: TWeaponState;
              );
              kiHuman: (
                ihState: integer;
              );
              kiFlag: (
                ifState: TFlagState;
                ifHome: integer;
              );
              kiScepter: (
                isState: TScepterState;
              );
          );
          koItemDescr: (
            ItemFileName: string [31];  // файл с описанием предмета
            idLast: integer;
            ItemCorrect: boolean;
            ItemName: string [31];      // название предмета
            SpriteIndName: string [31];
            SpriteInd: integer;         // картинка
            RebornTime: integer;        // время перерождения
            case KindItem: TKindItem of
              kiHealth: (
                hlCount: integer;
              );                          
              kiShield: (
                shCount: integer;
              );
              kiFlag: (
                flTeam: integer;
              );        
              kiSL: (
                slTeam: integer;
              );
              kiAmmo: (
                amCount: integer;
                amIndex: integer;       // тип патрона
              );
              kiWeapon: (                          // всё про пушку
                wpAmmoIndex: integer;              // тип патронов
                wpKeyNumber: integer;              // кнопка на клавиатуре
                wpBulletsInCharge: integer;        // патронов в обойме
                wpInitBullets: integer;            // изначальное число патронов
                wpMaxBullets: integer;             // максимальное число патронов
                wpShotBullets: integer;            // патронов за раз
                wpReloadTime, wpShotTime: integer; // время перезарядки, скорострельность (скорострельность в миллисекундах)
                wpDispersion, wpKickBack: integer; // разброс самого оружия и отдача
                wpBasic: integer;       // базовое ли
                wpDamage: integer;      // урон
                wpDistance, wpBulletSpeed: integer;    // предельная дальность выстрела, скорость пуль
                wpSound: integer;       // номер ноты
                wpColor: TColor;        // цвет
              );
          );   
          koBullet: (
            bLast: integer;
    
            BLocP: array [0 .. 1] of TPoint;
            BLocRoom: integer;
    
            BVector: TPoint;           // нормализованный вектор направления
    
            BDamage: integer;          // параметры, которые надо передавать в процедуру создания пули
            BSpeed: integer;
            BLengthLeft: integer;
            BOwner: integer;
            Bn, Bm: TDistFunc;
            BColor: TColor;
        );
    end;

    Меня попросили показать, до чего может довести структурное программирование при отрицании ООП. Разветвлённая структура с кучей ветвей.
    Для лучшего эффекта обмазываться вместе с http://govnokod.ru/4249

    TarasB, 13 Января 2011

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

    +114

    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 new int? OperatorCode
            {
                get
                {
                    int result = 0;
                    if (!String.IsNullOrEmpty(Request.QueryString["OperatorCode"]) && Int32.TryParse(Request.QueryString["OperatorCode"].ToString(), out result) == true)
                        OPERATOR_CODE = result;
                    return OPERATOR_CODE;
                }
                set
                {
                    if (value.HasValue)
                        OPERATOR_CODE = value.Value;
                    else
                        OPERATOR_CODE = null;
                }
            }

    Вот такое свойство мне встретилось

    Othello, 03 Января 2011

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

    +114

    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
    protected void Page_Load(object sender, EventArgs e)
        {
            String a = Convert.ToString(max);
            RangeValidator1.MinimumValue = "0";
            RangeValidator1.MaximumValue = "3333";
              
            int ind=Convert.ToInt16(DropDownList1.SelectedIndex);
            
            if ((curind < 0)||(ind<0))
            {
                WareHouse WH = new WareHouse();
                string[] list = WH.RefreshList(curProd);
                int i = 0;
                int len = list.Length;
                DropDownList1.Items.Clear();
                while (i < len)
                {
                    if (curProd != list)
                    {
                        DropDownList1.Items.Add(list);
                    }
                    i++;
                }
            
            }
        }

    Чувак прислал резюме и пример проекта ASP.NET. А в нем это. Особо забавляет строка 7 и цикл while

    Terran, 16 Декабря 2010

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

    +114

    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
    Ссылка ниже, там много всего, наиболее яркие моменты:
    1. 
    String Conn = (String)((NameValueCollection)Context.GetConfig("system.web/dsnstore"))["sql_site"];
    
    2. 
    qGetSum = new SqlCommand("select abs(ISNULL(sum(doc_bonus),0)) from vdoc where card_id = " + Session["card_id"] + " and dbo.Get_storno(doc_id) = 1", cGetSum);
    
    3. 
    SqlConnection cDiscount2 = new SqlConnection(Conn);
    SqlConnection cDiscount3 = new SqlConnection(Conn);
    
    4.
     log.Text = "Вы определены как:<br><b>" + Session["login"] + "<br><br></b>Бонус:<b>" + Session["bonus"] + "<br><br><a href=\"default.aspx?page=cardedit\">Личная карточка</a></b><br><br>";
    
    5. 
    Имена переменных: card_prefix, error_login_count, logoCMD, 
    
    6. 
    Session["access"] = 1;
    Session["access"] = -1;
    Session["access"] = -2;

    http://www.cyberforum.ru/asp-net/thread195915.html

    HIMen, 23 Ноября 2010

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