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

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

    +10

    1. 1
    typedef boost::shared_ptr<LPDIRECT3D9> Direct3dShared;

    Те кто знают, что такое в гейдеве LPDIRECT3D9 и IDirect3D9 - поймут.
    Думаю сегодня даже не нужно писать с какого это сайта.

    LispGovno, 22 Января 2014

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

    +133

    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
    var firstLocation = new Tuple<Point, Point>(new Point(12, 444 - 38), new Point(30, 446 - 38));
    var secondLocation = new Tuple<Point, Point>(new Point(12, 464 - 38), new Point(30, 464 - 38));
    var thirdLocation = new Tuple<Point, Point>(new Point(12, 486 - 38), new Point(30, 484 - 38));
    
    var first = new Tuple<Control, Control>(chbDimaGaugeNewContractPS, lblDimaGaugeNewContractPS);
    var second = new Tuple<Control, Control>(chbDimaGaugeNewContractIBanking, lblDimaGaugeNewContractIBanking);
    var third = new Tuple<Control, Control>(chbDimaGaugeNewContractActivePS, lblDimaGaugeNewContractActivePS);
    
    var controls = new List<Tuple<Control, Control>> { first, second, third };
    var points = new List<Tuple<Point, Point>> { firstLocation, secondLocation, thirdLocation };
    
    int i = 0;
    
    foreach (var t in controls.Where(x => !x.Item1.Enabled))
    {
      t.Item1.Location = points[i].Item1;
      t.Item2.Location = points[i].Item2;
      i++;
    }

    кортежи в .NET - хорошо или плохо?

    taburetka, 06 Декабря 2013

    Комментарии (13)
  4. Куча / Говнокод #14134

    +131

    1. 1
    http://bolknote.ru/files/dogfight/

    Возбуждает

    Stertor, 24 Ноября 2013

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

    −152

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    protected function get_resource_getter(xml:XML,name:String):Function {
            try {
                var getter:Function = this["get_"+name+"_xml"] as Function;
    
                return function():int{ return getter(xml)};
            } catch (e:*) {}
            if(xml.attribute(name).length()==0){
                return null;
            }
            return function():int{ return get_resource_xml(xml,name)};
        }

    Задача стояла предельно простая: получить количество некоторого игрового ресурса.
    Автор подошел к решению неординарно.

    strax, 07 Ноября 2013

    Комментарии (13)
  6. Java / Говнокод #13968

    +74

    1. 1
    if (!(bundle == null))

    byob, 18 Октября 2013

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

    +129

    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
    #region Work with massive slovo
    
    public string sFileNameMassiveSlovar = "";
    public bool flChangeSlovo = false;
    public int nCountSavedSlovo { get; private set; }
    public int nCountAllSlovo { get; private set; }
    public int nCountAddSlovo { get; private set; }
    public void ClearMassiveSlovo()
    {
      slovo = slovo.Select(n => (byte)0).ToArray();
    }
    
    public int GetCountAllSlovo()
    {
      int npock = nLengthSlovo;
      return slovo.Where((n, index) => index % npock == 0 && n != 0).Count();
    }
    
    public bool WriteMassiveSlovo()
    {
      bool res = false;
      FileStream fs = null;
      try
      {
        fs = File.Open(sFileNameMassiveSlovar, FileMode.Create, FileAccess.Write);
        if (fs != null)
        {
          fs.Write(slovo, 0, nSizeMassiveSlova);
        }
        res = true;
      }
      catch (Exception e1)
      {
        res = false;
        System.Windows.Forms.MessageBox.Show(e1.Message);
      }
      finally
      {
        if (fs != null) fs.Close();
      }
      return res;
    }
    
    #endregion

    just_nameless, 14 Октября 2013

    Комментарии (13)
  8. JavaScript / Говнокод #13854

    +157

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    window.SYSTEM_LOCALE ='ru';
    if ((/ru/i).test(window.SYSTEM_LOCALE)) {
        window.SYSTEM_LOCALE = "ru";
    } else if ((/en/i).test(window.SYSTEM_LOCALE)) {
        window.SYSTEM_LOCALE = "en";
    } else if ((/uk|ua/i).test(window.SYSTEM_LOCALE)) {
        window.SYSTEM_LOCALE = "uk";
    };

    wtf?

    SSSandman, 26 Сентября 2013

    Комментарии (13)
  9. VisualBasic / Говнокод #13779

    −106

    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
    Всякий раз наводя курсор на кнопку "Пуск" в Windows 7 вы видели как она менялась. 
    И вы наверно думали: а как реолизовать такой эффект в VB6? Давайте попробуем
    Код:
    
    Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Image1.Picture = LoadPicture("C:Безымянный.bmp") ' при наведении курсора на имейдж в него загрузится картинка
    End Sub
    
    Ну теперь запускаем. Чтож мы видим? Навели курсор - картинка в имейдже измнилась.
     Но ведь она должна изменятся обратно при отведении курсора. Но почему-то MuseMove этого не поддерживает. 
    Тогда придётся втянуть в это дело форму. Наведением курсора на форму мы будем имитировать отведение курсора от имейджа.
    
    Вот код вместе с первым примером. 
    
    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Image1.Picture = LoadPicture("C:Безымянный1.bmp")' при наведении курсора на форму в имейдж загрузится картинка которая была раньше
    End Sub
    
    Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Image1.Picture = LoadPicture("C:Безымянный.bmp")' при наведении курсора на имейдж в него загрузится картинка
    End Sub

    Еще пара таких кодов, и мне начнет нравиться Борис М.
    А че, интересный парень.

    Stertor, 11 Сентября 2013

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

    +105

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    if (App.TimerClock != null)
    {
      App.TimerClock.Enabled = false;
      App.TimerClock.Close();
      App.TimerClock.Dispose();
      App.TimerClock = null;
     }

    taburetka, 11 Сентября 2013

    Комментарии (13)
  11. 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('&#9553;');
                    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)