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

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

    +118

    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
    SqlCommand command = new SqlCommand ();
    command.Connection = connection;
    command.CommandText = "select data from filestorage where id=@id;";            
    command.Parameters.AddWithValue ("@id", fileId);
    command.CommandType = CommandType.Text;
    
    byte [] data = (byte []) command.ExecuteScalar ();
    
    System.IO.Stream outStream = Response.OutputStream;
    
    Response.ContentType = "Application/octet-stream";
    Response.AppendHeader ("Connection", "keep-alive");
    
    Response.AppendHeader ("Content-Disposition", " attachment; filename = \"" + fName+"\"" );
    
    outStream.Write (data, 0, data.Length);
    Response.End ();

    продолжение http://govnokod.ru/4227

    akai_mirror, 12 Сентября 2010

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

    +118

    1. 1
    2. 2
    <td>&nbsp;  </td>
    <td><br/><br/></td>

    До чео техника то дошла. Авно передают и тут и там.

    n0ne, 15 Августа 2010

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

    +118

    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
    void Say(bool work)
            {
                if (work)
                {
                    r = new Random();
                    i = r.Next(100);
                    textBlock1.Text = i.ToString();
    
                    textBlock1.Dispatcher.BeginInvoke(new AsyncSay(this.Say), DispatcherPriority.SystemIdle, null);
                }
            }
    
    void BtnSay_Click(object sender, RoutedEventArgs e)
            {
                Say(true);
            }
    
            private void BtnStopSay_Click(object sender, RoutedEventArgs e)
            {
                Say(false);
            }

    sergylens, 22 Июля 2010

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

    +118

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    public void isCollideWith(gObj obj, ref bool xCollision, ref bool yCollision)
    {
    	xCollision = (obj.bounds.Top <= this.bounds.Center.Y && this.bounds.Center.Y <= obj.bounds.Bottom) &&
        		     (obj.bounds.Top > this.bounds.Top && obj.bounds.Top < this.bounds.Bottom) ||
    		     (obj.bounds.Bottom > this.bounds.Top && obj.bounds.Bottom < this.bounds.Bottom);
    	yCollision = (obj.bounds.Left <= this.bounds.Center.X && this.bounds.Center.X <= obj.bounds.Right) &&
    		     (obj.bounds.Left > this.bounds.Left && obj.bounds.Left < this.bounds.Right) ||
    		     (obj.bounds.Right > this.bounds.Left && obj.bounds.Right < this.bounds.Right);
    }

    Вот так я проверяю произошло ли столкновения двух(obj и this) прямоугольных объектов.

    FMB, 08 Июля 2010

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

    +118

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    public static IEnumerable<Tuple<A1, A2, A3, A4>> 
    			CrossProduct<A1, A2, A3, A4>
    			(IEnumerable<A1> arg1, IEnumerable<A2> arg2,
    			IEnumerable<A3> arg3, IEnumerable<A4> arg4)
    		{
    			foreach (var a1 in arg1)
    				foreach (var a2 in arg2)
    					foreach (var a3 in arg3)
    						foreach (var a4 in arg4)
    							yield return Make.Tuple(a1, a2, a3, a4);
    		}

    Интересно, а что этот человек будет делать, когда нужно будет n ступенек? :-)

    tinynick, 21 Июня 2010

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

    +118

    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
    #region копирование в буфер
            private void copia_Click(object sender, EventArgs e)
            {
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < listBox1.Items.Count; i++)
                {
                    sb.Append(listBox1.Items[i].ToString());//Добавляем строчку из листБокса
                    sb.Append((char)13);//Перенос строки
                    sb.Append((char)10);//Перевод каретки
                }
                Clipboard.SetText(sb.ToString());//Отправляем всё в КлипБорд
            }
            #endregion
    
            #region Сохранить в файл
    
            private void save_Click(object sender, EventArgs e)
            {
                saveFileDialog1.DefaultExt = ".txt";
                saveFileDialog1.OverwritePrompt = true;
                saveFileDialog1.Title = "Координаты";
                saveFileDialog1.Filter = "Text Files|*.txt";
    
                if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    StreamWriter sw = new StreamWriter(saveFileDialog1.FileName);
                    StringBuilder sb = new StringBuilder();
                    for (int i = 0; i < listBox1.Items.Count; i++)
                    {
                        sb.Append(listBox1.Items[i].ToString());//Добавляем строчку из листБокса
                        sb.Append((char)13);//Перенос строки
                        sb.Append((char)10);//Перевод каретки
                    }
                    sw.WriteLine(sb);
                    sw.Flush();
                    sw.Close();
                }
            }
            #endregion

    L5D, 12 Мая 2010

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

    +118

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    <asp:Repeater runat="server" ID="rpAccountType">
    	<ItemTemplate>
    		<input type="checkbox" name="cbGroupAccountType" id="cbAccountType_<%#((KeyValuePair<string, object>)Container.DataItem).Value %>" value="<%#((KeyValuePair<string, object>)Container.DataItem).Value %>" <asp:Literal Id="lAccountTypeChecked" runat="server" />/><label for="cbAccountType_<%#((KeyValuePair<string, object>)Container.DataItem).Value %>"><asp:Literal runat="server" ID="lAccountTypeName" /></label><br />
    	</ItemTemplate>
    </asp:Repeater>

    ASP.NET. Значения генерируемых чекбоксов, в задумке, еще и на code-behind сильно влияют.

    terR0Q, 23 Марта 2010

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

    +118

    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
    void govnofunction(int m)
    {
    	bool rigth = false, middle = false, left = false;
    	switch(m)
    	{
    		case 1: rigth = true; break
    		case 2: middle = true; break;
    		case 3: rigth = true; middle = true; break;
    		case 4: left = true; break;
    		case 5: left = true; rigth = true; break
    		case 6: left = true; middle = true; break;
    		case 7: left = true; rigth = true; middle = true; break;
    	}
    	
    	...
    }

    писал по памяти, но общая картина сохранилась

    guest, 12 Апреля 2009

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

    +117.4

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    string GetTextDiv2(string text)
        {
            int mid = text.Length / 2;
            int r = text.IndexOf(" ", mid); if (r < 0) r = 5000;
            int l = text.IndexOf(" ", 0, mid); if (l < 0) l = 5000;
            if (r - mid > mid - l) // to left is closer
                mid = l;
            else mid = r;
    
            if (mid == 5000) return "&nbsp" + text;
            return "&nbsp" + text.Substring(0, mid) + " <br/>&nbsp" + text.Substring(mid, text.Length - mid);
        }

    ASP.NET
    // это красота просто :) делим текст пополам там где пробел, а дальше добавляем между частями перенос на новую строку :)

    otvet_popravkodon, 13 Апреля 2010

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

    +117.4

    1. 1
    int? ipLong = ip != null ? (int?)ip.Address : null;

    Вот так взялись отрицательные IP в базе. А главное-то, правильно переменную назвать!

    Rom@nych, 09 Апреля 2010

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