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

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

    +109

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    BusinessLogic.Entity_InheritanceSetting.Save(
                        Session.SessionSettings.Settings.ContactID.Value,
                        Session.SessionSettings.Settings.SessionID.Value, copyID.Value,
                        true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
                        true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
                        true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
                        true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
                        true, true, true, true, true, true, true, true, true, true, true, true, true, true, true);

    kore_sar, 30 Сентября 2013

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

    +109

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    static void Main()
    {
      int i = 0;
      Console.WriteLine(String.Format("{0} {1} {2}", i, i, i));
    }

    Я долго не видел там немного гoвна, но оказалось оно там есть

    taburetka, 02 Августа 2013

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

    +109

    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
    static void Main(string[] args)
            {
     
                Console.WriteLine("Как желаете заполнить?");
                Console.WriteLine("Цифра 1  = в столбик, цифра 2 = в строчку");
                int valMethod = Convert.ToInt32(Console.ReadLine());
     
                Console.Clear();
     
     
                Console.SetCursorPosition(1, 0);
                for (int index = 1; index != 22; index++)
                {
                    Console.CursorLeft = 1;
                    Console.WriteLine('║');
                    if (index < 21)
                    {
                        Console.CursorLeft = 19;
                        Console.Write('&#9553;');
                    }
                }
     
     
     
     
                Console.SetCursorPosition(1, 0);
                for (int index = 1; index != 62; index++)
                    Console.Write('&#9552;');
     
                Console.SetCursorPosition(35, 1);
     
                int valueRow = 0;
                for (int i = 0; i < 4; i++)
                {
                    for (int index = 1; index != 20; index++)
                    {
                        Console.SetCursorPosition(28 + valueRow, 1 + index);
                        Console.WriteLine('&#9553;');
                    }
                    valueRow += 8;
     
                }
     
                for (int index = 1; index != 20; index++)
                {
                    Console.SetCursorPosition(29 + valueRow, 0 + index);
                    Console.WriteLine('&#9553;');
                }
     
     
     
                Console.SetCursorPosition(20, 2);
                for (int index = 1; index != 43; index++)
                    Console.Write('&#9552;');
     
                int value = 4;
                for (int i = 0; i < 9; i++)
                {
                    Console.SetCursorPosition(1, value);
                    for (int index = 1; index != 62; index++)
                        Console.Write('&#9552;');
                    value += 2;
                }
     
                Console.SetCursorPosition(6, 2);
                Console.WriteLine("Спортсмен");
     
                Console.SetCursorPosition(25, 1);
                Console.WriteLine("Вид спорта");
     
     
                int value1 = 5;
                for (int i = 1; i < 9; i++)
                {
                    Console.SetCursorPosition(6, value1);
                    Console.WriteLine("{0}", i);
                    value1 += 2;
                }
     
                int value2 = 2;
                for (int i = 1; i < 6; i++)
                {
                    Console.SetCursorPosition(22 + value2, 3);
                    Console.Write("{0}", i);
                    value2 += 8;
                }
     
                Console.SetCursorPosition(1, 0);
                Console.Write("&#9556;");
     
                Console.SetCursorPosition(61, 0);
                Console.Write("&#9559;");
     
                Console.SetCursorPosition(1, 20);
                Console.Write("&#9562;");
                 
                Console.SetCursorPosition(61, 20);
                Console.Write("&#9565;");
    
    ...

    Мы так любим магические числа...

    Psilon, 29 Июля 2013

    Комментарии (13)
  5. PHP / Говнокод #12570

    +109

    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
    public function __get($name){          
            if(isset($this->fields[$name])){            
                if(class_exists($this->fields[$name]) && 
                   strcasecmp($this->fields[$name], $this->vals[$name]['mdl']) == 0 && 
                   strcasecmp(get_parent_class($this->fields[$name]), __CLASS__) == 0){    
                    $class = $this->fields[$name];
                    $id = (string)$this->vals[$name]['id'];
                    if(!$this->refsCache[$id])
                        $this->refsCache[$id] = $class::findById($this->vals[$name]['id']);
                    return $this->refsCache[$id];
                }else                
                    return $this->vals[$name];
            }elseif(isset($this->fieldsRev[$name])) 
                return $this->vals[$name];
            else throw new Exception('Not found field "'.$name.'" when reading in model');
        }
    
        public function __set($name, $value){    
            if(isset($this->fields[$name])){  
                if(class_exists($this->fields[$name]) && 
                   strcasecmp($this->fields[$name], get_class($value)) == 0 && 
                   strcasecmp(get_parent_class($this->fields[$name]), __CLASS__) == 0)
                    $this->vals[$name] = array('id' => $value->getId(), 'mdl' => strtolower($this->fields[$name]));
                else                
                    $this->vals[$name] = $value;
            }elseif(isset($this->fieldsRev[$name])) 
                $this->vals[$name] = $value;
            else throw new Exception('Not found field "'.$name.'" when writing in model');        
        }

    Пример реализации через жопу полей для базового класс модели, с ужасным оформлением кода.

    haker, 11 Февраля 2013

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

    +109

    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
    string New_naim = E.Remove(0, (NameGR(E.Trim()).Length)).Trim() + " " + Na;
                                    New_naim = New_naim.Trim();
                                    string check_naim =
                                        (E+Na).ToUpper().Replace(" ", "").Replace(",", ".").Replace("-", "").Replace("Е", "E")
                                        .Replace(";", "").Replace("*", "").Replace("Х", "X").Replace("О", "O").Replace("А", "A")
                                        .Replace("В", "B").Replace("М", "M").Replace("Н", "H").Replace("С", "C").Replace("Т", "T").Replace("З", "3")
                                        .Replace("Р", "P").Replace("Q", "G").Replace("К", "K").Replace("О", "O").Replace("0", "O").Replace("%", "").Replace("И", "U");
                                    string check_gosttu = GU.ToUpper().Replace(" ", "").Replace(",", ".").Replace("Е", "E").Replace(".", "")
                                        .Replace("З", "3").Replace(";", "").Replace("*", "").Replace("Х", "X").Replace("О", "O").Replace("А", "A")
                                        .Replace("И", "U").Replace("В", "B").Replace("М", "M").Replace("Н", "H").Replace("С", "C").Replace("Т", "T").Replace("-", "")
                                        .Replace("Р", "P").Replace("Q", "G").Replace("К", "K").Replace("О", "O").Replace("0", "O").Replace("+", "");
                                    /*quer = "SELECT PIN From dbo.Tb_Element Where (Id = '" + Id_el + "') AND "+
                                        "replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(UPPER(GOSTTU)" +
                                        ",' ',''),',','.') ,'Е','E'),'Х','X'),'Т','T'),'К','K'),'О','O'),';',''),'*',''),'А','A'),'В','B'),'М','M'),'Н','H'),'С','C'),'Р','P'),'Q','G'),'О','O'),'0','O'),'.','') = '"+ check_gosttu+   
                                        "' AND replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(UPPER(naim)" +
                                        ",' ',''),',','.') ,'Е','E'),'-',''),'Х','X'),'Т','T'),'К','K'),'О','O'),';',''),'*',''),'А','A'),'В','B'),'М','M'),'Н','H'),'С','C'),'Р','P'),'Q','G'),'О','O'),'0','O') = '" + check_naim + "'";*/
                                    quer = "SELECT e.PIN From dbo.Tb_Element e, dbo.tb_elementname n Where e.id = n.id AND "+
                                        "replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(UPPER(GOSTTU)" +
                                        ",' ',''),',','.') ,'Е','E'),'Х','X'),'Т','T'),'К','K'),'О','O'),';',''),'*',''),'А','A'),'В','B'),'М','M'),'Н','H'),'С','C'),'Р','P'),'Q','G'),'О','O'),'0','O'),'.',''),'И','U'),'З','3'),'+',''),'-','') = '" + check_gosttu +
                                        "' AND replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(UPPER(LTRIM(RTRIM(n.element))+RTRIM(LTRIM(e.naim)))" +
                                        ",' ',''),',','.') ,'Е','E'),'-',''),'Х','X'),'Т','T'),'К','K'),'О','O'),';',''),'*',''),'А','A'),'В','B'),'М','M'),'Н','H'),'С','C'),'Р','P'),'Q','G'),'О','O'),'0','O'),'%',''),'З','3'),'И','U') = '" + check_naim + "'";

    Читаю старый код и радуюсь, что больше с ним не работаю. Правим результаты кривых рук операторов, заводящих данные.

    Grover, 04 Декабря 2012

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

    +109

    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
    GLOBAL _start
        SEGMENT .text
    _start:
         mov eax,4 ; N function=write
         mov ebx,1 ; N handle=1 (stdout)
         mov ecx, txt ; address of buf
         mov edx,16 ; number of byte
         int 80h
    
         mov eax,3 ; N function=read
         mov ebx,0 ; 0 handle=0 (stdin)
         mov ecx, buf ; address of buf
         mov edx,80 ; number of byte
         int 80h
    
         mov [len],eax ;save length buf
         mov byte [buf+1],'!'
    
         mov eax,4 ; N function=write
         mov ebx,1 ; N handle=1 (stdout)
         mov ecx, buf ; address of buf
         mov edx,[len] ; number of byte
         int 80h
    
         mov eax,1 ; function=exit
         int 80h 
         
    SEGMENT .data
    	buf times 80 db 0 ;
    	len dd 0
    	txt db 'Enter the text '

    dos_, 15 Ноября 2012

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

    +109

    1. 1
    Хочу книгу прикупить http://www.ozon.ru/context/detail/id/126954/. Кто нить читал подскажете стоит ли она прочтения ?

    Vasiliy, 01 Августа 2012

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

    +109

    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
    public static MyResultData SqlReturnDataset(string sql, string connection)
                {
                    MyResultData result = new MyResultData();
                    try
                    {
                        MySql.Data.MySqlClient.MySqlConnection connRC = new MySql.Data.MySqlClient.MySqlConnection(connection);
                        MySql.Data.MySqlClient.MySqlCommand commRC = new MySql.Data.MySqlClient.MySqlCommand(sql, connRC);
                        connRC.Open();
    
                        try
                        {
                            MySql.Data.MySqlClient.MySqlDataAdapter AdapterP = new MySql.Data.MySqlClient.MySqlDataAdapter();
                            AdapterP.SelectCommand = commRC;
                            DataSet ds1 = new DataSet();
                            AdapterP.Fill(ds1);
                            result.ResultData = ds1.Tables[0];
                        }
                        catch (Exception ex)
                        {
                            result.HasError = true;
                            result.ErrorText = ex.Message;
                        }
                        connRC.Close();
                    }
                    catch (Exception ex)//Этот эксепшн на случай отсутствия соединения с сервером.
                    {
                        result.ErrorText = ex.Message;
                        result.HasError = true;
                    }
                
                    return result;
    
                }

    Govnisti_Diavol, 26 Марта 2012

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

    +109

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    private IEnumerable<CharacteristicValue> GetCharacteristicValues(IQueryable<CharacteristicValue> allCharacteristicValues, int characteristicId)
    {
          var characteristicValues = new CharacteristicValue[userIds.Length];
    
           for (var i = 0; i < userIds.Length; i++)
           {
               characteristicValues[i] = allCharacteristicValues.FirstOrDefault(cv => cv.UserId == userIds[i] && cv.CharacteristicId == characteristicId); // Todo: Try to replace with a single query.
           }
    
           return characteristicValues;
    }

    Драсьте, нашёл в коде такую вот какашку. Как видите параметр allCharacteristicsValues реализует интерфейс IQuarable из EF. То бишь каждый раз, когда будет вызываться метод FirstOrDefault будет делаться запрос к базе. В идеале это должно было бы выглядеть так:

    var characteristicValues = allCharacteristicValues.Where(cv => cv.CharacteristicId == characteristicId && userIds.Contains(cv.UserId));

    Но при такой реализации размер масива пользователей и значение может разниться:

    Values:
    val1
    val2
    val3

    Users:
    1
    2
    3
    4
    5

    Для первого же варианта результат будет выглядеть так:
    Values:
    val1
    val2
    val3
    null
    null

    Users:
    1
    2
    3
    4
    5


    Собственно всё )))) Надеюсь подсоветуете чего-нибудь хорошего ;)

    walash, 20 Марта 2012

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

    +109

    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
    namespace ChemicalLabs
    {
        public partial class MediaViewer : Form
        {
            public static string XPath;
            
            public MediaViewer(string ObjectMediaRef, string ObjectMediaName)
            {
                InitializeComponent();
    
                try
                {
                    this.Text = ObjectMediaName;
                    axWindowsMediaPlayer.settings.volume = 100;
                    ObjectMediaRef = (Convert.ToInt16(ObjectMediaRef) + 1).ToString();
                    XPath = ObjectMediaRef;
    
                    StreamReader DataStream = new StreamReader("c://ChemicalData/" + ObjectMediaRef + "/" + ObjectMediaRef + ".txt", Encoding.GetEncoding(1251));
                    _MEDIA_DATA_AREA.Text = DataStream.ReadToEnd();
    
                    
                    object[] MediaFiles = Directory.GetFiles(
                    @"c://ChemicalData/" + ObjectMediaRef + "/" + "Media", "*.mp4", SearchOption.TopDirectoryOnly);
    
                    for (int i = 0; i < MediaFiles.Length; i++)
                    {FileInfo a = new FileInfo(MediaFiles[i].ToString());MediaFilesList.Items.Add(a.Name.Remove(a.Name.Length - 4));}
                }
                
                catch (Exception Ex)
                {MessageBox.Show(Ex.ToString(),(Ex.Message).ToString(),buttons: MessageBoxButtons.OK,icon: MessageBoxIcon.Information);}
            }
    
            private void MD_Click(object sender, EventArgs e)
            {
    
                if (MediaFilesList.SelectedItem == null)
                {MessageBox.Show("Вы не выбрали материал! Просмотр невозможен.","Сами не знаете, что хотите...",buttons: MessageBoxButtons.OK,icon: MessageBoxIcon.Information);}
                else
                {
                    string MediaPath;
                    MediaPath = MediaFilesList.SelectedItem.ToString();
                    MediaPath = "c://ChemicalData/" + XPath + "/" + "Media" + "/" + MediaPath + ".mp4";
                    axWindowsMediaPlayer.close();
                    axWindowsMediaPlayer.URL = MediaPath;
                }
            }
            private void MediaStreamClose_Click(object sender, EventArgs e)
            {this.axWindowsMediaPlayer.close();}
            private void _MediaForm_Close_Click(object sender, EventArgs e)
            {this.axWindowsMediaPlayer.close(); MediaViewer.ActiveForm.Close();}
            private void MediaViewer_FormClosed(object sender, FormClosedEventArgs e)
            {this.axWindowsMediaPlayer.close();MediaViewer.ActiveForm.Close();}
            private void axWindowsMediaPlayer_MouseDownEvent(object sender, AxWMPLib._WMPOCXEvents_MouseDownEvent e)
            {MessageBox.Show("MediaPlayer - ver 0.0.1 for .NET Platform (By Kirill Sancharov)","MediaPlayer for Windows .NET",buttons: MessageBoxButtons.OK,icon: MessageBoxIcon.Information);}
     }
    }

    Удивляй меня полностью.

    Govnisti_Diavol, 19 Марта 2012

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