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

    В номинации:
    За время:
  2. Куча / Говнокод #25435

    +1

    1. 1
    ДеФфЧоНаЧкИ с ПрАзДнИчКоМ вАс!

    Всем джвумерным, трёхмерным и прочим N-мерным няшкам с клювом и без шлю чмоки-чмоки!

    Kypumca, 08 Марта 2019

    Комментарии (63)
  3. Си / Говнокод #25188

    +3

    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
    #include <sys/types.h>
    #include <sys/socket.h>
    #include <netinet/in.h>
    #include <arpa/inet.h>
    #include <stdlib.h>
    #include <stdio.h>
    #include <string.h>
    
    enum {
        HOST = INADDR_LOOPBACK,
        PORT = 6666,
        MAX_BUF = 1024
    };
    
    struct sock {
        int sockfd;
        int addrlen;
        struct sockaddr_in addr;
    } host, client;
    
    int check(int x, char*msg)
    {
        if (!~x) {
            perror(msg);
            exit(1);
        }
        return x;
    }
    
    #define QUOTE_(...) #__VA_ARGS__
    #define QUOTE(...) QUOTE_(__VA_ARGS__)
    #define CHECK(...) check(__VA_ARGS__, QUOTE(line __LINE__: __VA_ARGS__))
    
    int main(int argc, char**argv)
    {
        struct sock host, client;
        host.sockfd = CHECK(socket(AF_INET, SOCK_STREAM, 0)),
        host.addr = (struct sockaddr_in){AF_INET, htons(PORT), htonl(HOST)};
        CHECK(bind(host.sockfd, &(struct sockaddr)host.addr, sizeof(host.addr)));
        CHECK(listen(host.sockfd, 1));
        CHECK(client.sockfd = accept(host.sockfd, (void*)&client.addr, &client.addrlen));
        printf("connected: %s\n", inet_ntoa(client.addr.sin_addr));
        
        struct {int len; char buf[MAX_BUF];} msg;
        while (CHECK(msg.len = recv(client.sockfd, msg.buf, MAX_BUF - 1, 0)) && msg.len) {
            msg.buf[msg.len] = 0;
            printf("%s", msg.buf);
            send(client.sockfd, msg.buf, msg.len, 0);
        }
        close(client.sockfd);
        close(host.sockfd);
        return 0;
    }

    Почему если закоментить 36-ю строчку адрес килента 0.0.0.0?

    666_N33D135, 13 Декабря 2018

    Комментарии (63)
  4. Java / Говнокод #25095

    +1

    1. 1
    source.setPropertyValue("phone", "фон");

    Фон

    vistefan, 19 Ноября 2018

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

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    // https://habr.com/company/JetBrains/blog/249479/
    
    Привет, Хабр!
    
    Некоторое время назад мы объявили конкурс — требовалось продолжить фразу:
    Бьёрн Страуструп создал С++ 36 лет назад, и он до сих пор востребован и пользуется популярностью у разработчиков, потому что...
    
    Спасибо всем участникам за массу положительных эмоций и разнообразные предположения о том, что же сделало C++ таким популярным.

    Посовещавшись, мы выбрали топ-6 ответов:

    j123123, 16 Июля 2018

    Комментарии (63)
  6. PHP / Говнокод #23698

    0

    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
    public static function Exception($message, $info = []) {
    			ob_clean();
    			?>
    			<!-- Пичалька какая-то произошла! Мы в грустяшке и огорчульке. -->
    			<center>
    				<div style="width: 600px; height: 140px; border: 1px #DDDDDD solid;">
    					<img style="width: 134px; margin: 14px; float: left;" src="/images/error-big.png">
    					<div style="display: table-cell; vertical-align: middle; height: 155px;">
    						<h4>
    							<?= $message; ?>
    						</h4>
    					</div>
    				</div>
    			</center>
    			<?
    			exit();
    		}

    Днище-кодинг.

    DAVIDhaker, 02 Февраля 2018

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

    +8

    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
    constexpr auto auto​()
    {
      return 1;
    }
    
    typedef decltype(auto​()) auto​​;
    const auto​​ auto​​​ = auto​();
    
    template <typename auto​​​​>
    constexpr auto auto​​​​​() {
        return auto​​​;
    }
    
    template <typename auto​​​​, typename auto​​​​​​, typename... auto​​​​​​​>
    constexpr auto auto​​​​​() {
        return auto​​​ + auto​​​​​<auto​​​​​​, auto​​​​​​​...>();
    }
    
    int main()
    {
      constexpr auto auto​​​​​​​ = auto​​​​​<auto​​,auto​​,auto​​,auto​​,auto​​,auto​​>();
      constexpr auto auto​​​​ = auto​​​​​<auto​​,auto​​,auto​​,auto​​,auto​​,auto​​,auto​​>();
      return auto​​​​​​​*auto​​​​; 
    }

    auto auto auto...
    https://twitter.com/RichardKogelnig/status/943497972481953792
    https://godbolt.org/g/Yvczo1

    Soul_re@ver, 20 Декабря 2017

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

    +3

    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
    void MyZKbMain::keyPressEvent(QKeyEvent* k)
    {
    	QPixmap pm; pm.load("ruleta_usr.png");
    	ZConfig Num(QString("numeros.cfg"), true);
    	ZConfig Hist(QString("historial.cfg"), true);
    
    	switch (k->key())
    	{
    	case 0x1046: //Boton Verde
    	break;
    
    	case 0x1030: //Boton Verde
    	calcular=0;
    	reboot = new ZMessageDlg("zRoulette", 
    		QString("Sistema Ubeda 0.5\nBasado en el Sistema de Cuadros\n\nwww.developermoto.com/es\nwww.modmymoto.com\n\n(C)2009 RacingLocura07, CepiPerez"), 
    		(ZMessageDlg::MessageDlgType)2, 0, this,"about", true, 0);
    	reboot->setTitleIcon(pm); reboot->show();
    	break;
    
    	case 0x1031: //Boton Rojo
    	calcular=0;
    	reboot = new ZMessageDlg("zRoulette", "Desea salir?", 
    			(ZMessageDlg::MessageDlgType)1, 0, this,"about", true, 0);
    	reboot->setTitleIcon(pm); reboot->show();
    	if(reboot->exec()==1) { exit(); }
    	else { update(); break; }
    	
    	case 0x1012: //Tecla de Navegacion De Izquierda
    	calcular=0;
    	if (current > 1 ) { --current; update(); break; } else { break; }
    
    	case 0x1013: //Tecla de Navegacion De Arriba
    	calcular=0;
    	if ( current > 3 ) { ------current; update(); break; } else { break; }
    
    	case 0x1014: //Tecla de Navegacion De Derecha
    	calcular=0;
    	if (current < 36 ) { ++current; update(); break; } else { break; }
    
    	case 0x1015: //Tecla de Navegacion De Abajo
    	calcular=0;
    	if (current < 34 ) { ++++++current; update(); break; } else { break; }
    
    	case 0x1038: //Softkey Izquierda
    	calcular=0;
    	reboot = new ZMessageDlg("zRoulette", "Desea reinciar la Ruleta?", (ZMessageDlg::MessageDlgType)1, 0, this,"about", true, 0);
    	reboot->setTitleIcon(pm); reboot->show();
    	if(reboot->exec()==1) { system("rm numeros.cfg"); system("rm historial.cfg"); current = 1; jugadas = 0; lista.clear(); update(); break; }
    	else { update(); break; }
    
    	case 0x103a: //Softkey Derecha
    	int temp = Hist.readNumEntry ( QString("HISTORIAL"), QString("18"), 0 );
    	if ( temp != 0 ) {
    		reboot = new ZMessageDlg("zRoulette", "Desea limpiar las jugadas dejando las ultimas 18 solamente?", 
    				(ZMessageDlg::MessageDlgType)1, 0, this,"about", true, 0); reboot->setTitleIcon(pm); reboot->show();
    		if(reboot->exec()==1) { 
    		  for ( int l=1; l<37; ++l) { Num.writeEntry ( QString("NUMEROS"), QString("%1").arg(l), QString("0") ); }
    		  for ( int j=1; j<19; ++j) {
    			int temp = Hist.readNumEntry ( QString("HISTORIAL"), QString("%1").arg(j), 0 );
    			if ( temp > 0 ) { Num.writeEntry ( QString("NUMEROS"), QString("%1").arg(temp), QString("1") ); }
    		  }	calcular=1; update(); break; 
    		} else { break; }
    	} else {
    		reboot = new ZMessageDlg("zRoulette", "Deben haber mas de 18 bolas jugadas para el reinicio parcial.", 
    			(ZMessageDlg::MessageDlgType)2, 0, this,"about", true, 0); reboot->setTitleIcon(pm); reboot->show(); break;
    	}
    
    	case 0x1004:  //Boton Central
    	valortemp = Num.readNumEntry(QString("NUMEROS"), QString("%1").arg(current), 0 );
    	if ( valortemp < 1 ) { valortemp=0; } ++valortemp;
    	Num.writeEntry(QString("NUMEROS"), QString("%1").arg(current), valortemp);
    
    	int lugar=0; for ( int j=18; j>0; --j)
    	{ int temp = Hist.readNumEntry ( QString("HISTORIAL"), QString("%1").arg(j), 0 ); if ( temp==0 ) { lugar=j; } }
    	
    	if ( lugar > 0 ) {
    	  Hist.writeEntry ( QString("HISTORIAL"), QString("%1").arg(lugar), QString("%1").arg(current) );
    	} else {
    	  for ( int j=1; j<18; ++j) {
    		int temp = Hist.readNumEntry ( QString("HISTORIAL"), QString("%1").arg(j+1), 0 ); 
    		Hist.writeEntry ( QString("HISTORIAL"), QString("%1").arg(j), QString("%1").arg(temp) ); 
    	  }
    	  Hist.writeEntry ( QString("HISTORIAL"), QString("18"), QString("%1").arg(current) ); 
    	}
    	calcular=1;
    	update();
    	}
    }

    Разработчики из солнечной Аргентины. Кусочек кода из кастомного "лаунчера" для телефонов Motorola на платформе MotoMAGX (Linux 2.6.10, Qt 2.3.8, gcc 3.4.3). АДИЩЕ С ЦАРСКИМИ АНРОЛЛАМИ: https://github.com/crutchwalkfactory/motocakerteam/blob/master/Projects/MotoDesk/MyZKbMain.cpp

    Что интересно, это всё как-то работало и даже довольно мило выглядело: http://exlmoto.ru/wp-content/Images/AOne/1.gif

    Tsiklonyashka, 26 Июня 2016

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

    −10

    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
    static bool IsPalindrome( int value ) { 
    int reverseValue = 0; 
    if(value < 0) value = -value; 
    int tempValue = value; 
    int reverseValueTens = 1; 
    while(tempValue > 0) { 
    reverseValueTens *= 10; 
    tempValue /= 10; 
    } 
    reverseValueTens /= 10; 
    tempValue = value; 
    while(tempValue > 0) { 
    //Alert( reverseAbsValueAddition ); 
    reverseValue += (tempValue - (tempValue/10)*10) * reverseValueTens; 
    reverseValueTens /= 10; 
    tempValue /= 10; 
    } 
    //Alert( reverseAbsValue ); 
    return reverseValue == value; 
    }

    d_fomenok, 17 Апреля 2016

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

    0

    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
    static void Main(string[] args)
    {
    	try
    	{
    		watcher.Path = TargetPath;
    		watcher.Created += Watcher_Created;
    		watcher.Renamed += Watcher_Created;
    		watcher.EnableRaisingEvents = true;
    		logger.Info("Сервис запущен.");
    		System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
    	}
    	catch(Exception ex)
    	{
    		logger.Error(ex, "Global error", null);
    		Main(null);
    	}
    }

    хуита, 15 Марта 2016

    Комментарии (63)
  11. Куча / Говнокод #19314

    +3

    1. 1
    Поднял форум.  Запилил чатик.

    Теперь можно грабить корованы чмокать всех в чатике.

    Vasiliy, 16 Января 2016

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