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

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

    +159

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    protected function readConfig($configPath) {
        $ini = parse_ini_file($configPath);
        foreach ($ini as $key => $value) {
            $config[$key] = $value;
        }
        return $config;
    }

    xarper, 21 Июня 2011

    Комментарии (34)
  3. PHP / Говнокод #7011

    +147

    1. 1
    2. 2
    3. 3
    if ($a = 1) {
    	...бла-бла-бла
    }

    nislova, 20 Июня 2011

    Комментарии (34)
  4. VisualBasic / Говнокод #6861

    −99

    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
    Dim byteOut(64) As Byte
            Dim i As Integer
            Try
                byteOut(0) = Len(outCName) + 5 'number bytes in output message
                byteOut(1) = &H0 'should be 0 for NXT
                byteOut(2) = &H80 '&H0 = reply expected &H80 = no reply expected
                byteOut(3) = &H9 'Send Bluetooth
                byteOut(4) = &H0 'Box Number - 1
                byteOut(5) = Len(outCName) + 1 'message size with null terminator
                For i = 1 To Len(outCName) 'copy bytes into output array
                    byteOut(i + 5) = Asc(Mid(outCName, i, 1))
                Next
                byteOut(Len(outCName) + 6) = &H0 'add null terminator
                SerialPort1.Write(byteOut, 0, Len(outCName) + 7) 'send message
    
            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try
            '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            Try
                byteOut(0) = Len(outWState) + 5 'number bytes in output message
                byteOut(1) = &H0 'should be 0 for NXT
                byteOut(2) = &H80 '&H0 = reply expected &H80 = no reply expected
                byteOut(3) = &H9 'Send Bluetooth
                byteOut(4) = &H1 'Box Number - 1
                byteOut(5) = Len(outWState) + 1 'message size with null terminator
                For i = 1 To Len(outWState) 'copy bytes into output array
                    byteOut(i + 5) = Asc(Mid(outWState, i, 1))
                Next
                byteOut(Len(outWState) + 6) = &H0 'add null terminator
                SerialPort1.Write(byteOut, 0, Len(outWState) + 7) 'send message
    
            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try
    
    <..ещё один раз..>
    
       '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            Try
                byteOut(0) = Len(outWindC) + 5 'number bytes in output message
                byteOut(1) = &H0 'should be 0 for NXT
                byteOut(2) = &H80 '&H0 = reply expected &H80 = no reply expected
                byteOut(3) = &H9 'Send Bluetooth
                byteOut(4) = &H3 'Box Number - 1
                byteOut(5) = Len(outWindC) + 1 'message size with null terminator
                For i = 1 To Len(outWindC) 'copy bytes into output array
                    byteOut(i + 5) = Asc(Mid(outWindC, i, 1))
                Next
                byteOut(Len(outWindC) + 6) = &H0 'add null terminator
                SerialPort1.Write(byteOut, 0, Len(outWindC) + 7) 'send message
    
            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try
    
            '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            Try
                byteOut(0) = Len(outHum) + 5 'number bytes in output message
                byteOut(1) = &H0 'should be 0 for NXT
                byteOut(2) = &H80 '&H0 = reply expected &H80 = no reply expected
                byteOut(3) = &H9 'Send Bluetooth
                byteOut(4) = &H4 'Box Number - 1
                byteOut(5) = Len(outHum) + 1 'message size with null terminator
                For i = 1 To Len(outHum) 'copy bytes into output array
                    byteOut(i + 5) = Asc(Mid(outHum, i, 1))
                Next
                byteOut(Len(outHum) + 6) = &H0 'add null terminator
                SerialPort1.Write(byteOut, 0, Len(outHum) + 7) 'send message
    
            Catch ex As Exception
                MsgBox(ex.ToString)
            End Try

    Говнокод почти трёхлетней давности. Понадобилось мне посмотреть, как я реализовывал "общение" по блютусу с Mindstorms NXT, и напоролся на вот это...

    RaZeR, 04 Июня 2011

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

    +154

    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
    function sajax_get_common_js() {
        global $sajax_debug_mode;
        global $sajax_request_type;
        global $sajax_remote_uri;
    
        $t = strtoupper($sajax_request_type);
        if ($t != "GET" && $t != "POST")
          return "// Invalid type: $t.. \n\n";
    
        ob_start();
        ?>
    
        // remote scripting library
        // (c) copyright 2005 modernmethod, inc
        var sajax_debug_mode = <?php echo $sajax_debug_mode ? "true" : "false"; ?>;
        var sajax_request_type = "<?php echo $t; ?>";
    
        function sajax_debug(text) {
          if (sajax_debug_mode)
            alert("RSD: " + text)
        }
        function sajax_init_object() {
          sajax_debug("sajax_init_object() called..")
    
          var A;
          try {
            A=new ActiveXObject("Msxml2.XMLHTTP");
          } catch (e) {
            try {
              A=new ActiveXObject("Microsoft.XMLHTTP");
            } catch (oc) {
              A=null;
            }
          }
          if(!A && typeof XMLHttpRequest != "undefined")
            A = new XMLHttpRequest();
          if (!A)
            sajax_debug("Could not create connection object.");
          return A;
        }
        function sajax_do_call(func_name, args) {
          var i, x, n;
          var uri;
          var post_data;
    
          uri = "<?php echo $sajax_remote_uri; ?>";
          if (sajax_request_type == "GET") {
            if (uri.indexOf("?") == -1)
              uri = uri + "?rs=" + escape(func_name);
            else
              uri = uri + "&rs=" + escape(func_name);
            for (i = 0; i < args.length-1; i++)
              uri = uri + "&rsargs[]=" + escape(args[i]);
            uri = uri + "&rsrnd=" + new Date().getTime();
            post_data = null;
          } else {
            post_data = "rs=" + escape(func_name);
            for (i = 0; i < args.length-1; i++)
              post_data = post_data + "&rsargs[]=" + escape(args[i]);
          }
    
          x = sajax_init_object();
          x.open(sajax_request_type, uri, true);
          if (sajax_request_type == "POST") {
            x.setRequestHeader("Method", "POST " + uri + " HTTP/1.1");
            x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
          }
          x.onreadystatechange = function() {
            if (x.readyState != 4)
              return;
            sajax_debug("received " + x.responseText);
    
            var status;
            var data;
            status = x.responseText.charAt(0);
            data = x.responseText.substring(2);
            if (status == "-")
              alert("Error: " + data);
            else
              args[args.length-1](data);
          }
          x.send(post_data);
          sajax_debug(func_name + " uri = " + uri + "/post = " + post_data);
          sajax_debug(func_name + " waiting..");
          delete x;
        }
    
        <?php
        $html = ob_get_contents();
        ob_end_clean();
        return $html;
      }

    Из PHPList
    PHP и JS в перемешку.

    Это печально...

    rO_ot, 12 Апреля 2011

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

    +136

    1. 1
    particleEmitter.particleEmitter.particleEmitter.particleEmitter.particleEmitter.particleEmitter.particleEmitter.particleEmitter.particleEmitter.emit = Mathf.Sin(Random.value*Mathf.PI*2) <= 1;

    Строчка из кода в Unity3D.

    semens, 28 Марта 2011

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

    +131

    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
    static public int IIF(bool condition, int a, int b)
            {
                int x = 0;
                if (condition)
                {
                    x = a;
                }
                else
                {
                    x = b;
                }
                return x;
            }
    
            static public bool IIF(bool condition, bool a, bool b)
            {
                bool x = false;
                if (condition)
                {
                    x = a;
                }
                else
                {
                    x = b;
                }
                return x;
            }
    
            static public Single IIF(bool condition, Single a, Single b)
            {
                float x = 0;
                if (condition)
                {
                    x = a;
                }
                else
                {
                    x = b;
                }
                return x;
            }
    
            static public Double IIF(bool condition, double a, double b)
            {
                double x = 0;
                if (condition)
                {
                    x = a;
                }
                else
                {
                    x = b;
                }
                return x;
            }
    
            static public decimal IIF(bool condition, decimal a, decimal b)
            {
                decimal x = 0;
                if (condition)
                {
                    x = a;
                }
                else
                {
                    x = b;
                }
                return x;
            }

    inser, 03 Марта 2011

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

    +167

    1. 1
    var war;

    Объявляем войну :)
    Не говнокод, но весело.

    fuckyounoob, 04 Февраля 2011

    Комментарии (34)
  9. Си / Говнокод #5220

    +130

    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
    char unsigned c;
    DWORD m;
    DWORD n;
    int i = 0;
    BOOL b = TRUE;
    
    HANDLE hFile = CreateFile(szFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
    if (hFile == INVALID_HANDLE_VALUE) 
    { 
    	printf("Could not open File");
    	return NULL;
    } 
    // узнаем размер файла
    while (b)
    {
    	b = ReadFile(hFile, &c, 1, &m, NULL);
    	if (m == 0)
    	{
    		printf("STOP ");
    		printf("%i\n", i);
    		break;
    	}
    	i++;
    }

    собственно узнаем размер файла, что тут еще скажешь)

    dIsoVi, 11 Января 2011

    Комментарии (34)
  10. PHP / Говнокод #5123

    +143

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    Hello, <em>ujkbktj</em>!<br />
    <br />
    Пользователь <a href="http://govnokod.ru/user/1997">istem</a> ответил на Ваш комментарий к <a href="http://govnokod.ru/5120">говнокоду #5120</a>!<br />
    <br />
    Напомним, Вы <a href="http://govnokod.ru/5120#comment66331">написали</a>:<br />
    
    <em><span style="text-decoration:blink;">это не код!!</span></em><br />
    <br />
    На что получили <a href="http://govnokod.ru/5120#comment66347">ответ</a>:<br />
    <em>И чё ж у Вас айдишник-то не 666...</em>
    <br /><br /><br />
    С уважением, Ваш <a href="http://govnokod.ru">Говнокод</a>.

    ...

    ujkbktj, 31 Декабря 2010

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

    +161

    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
    // If iMode!=0, non-blocking mode is enabled.
    	u_long iMode=1;
    	ioctlsocket(Socket,FIONBIO,&iMode);
    	
    	// Main loop
    	for(;;)
    	{
    		// Display message from server
    		char buffer[1000];
    		memset(buffer,0,999);
    		int inDataLength=recv(Socket,buffer,1000,0);
    		std::cout<<buffer;
    		
    		int nError=WSAGetLastError();
    		if(nError!=WSAEWOULDBLOCK&&nError!=0)
    		{
    			std::cout<<"Winsock error code: "<<nError<<"\r\n";
    			std::cout<<"Server disconnected!\r\n";
    			// Shutdown our socket
    			shutdown(Socket,SD_SEND);
    
    			// Close our socket entirely
    			closesocket(Socket);
    
    			break;
    		}
    		Sleep(1000);
    	}

    http://www.win32developer.com/tutorial/winsock/winsock_tutorial_3.shtm
    Вот как нада работать с сокетами... (строка 27).

    fddpro, 26 Декабря 2010

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