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

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

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    ...
         F = fun(S) ->
                  ets:give_away(Table, NewOwner),
                  S
              end,
          sys:replace_state(OldOwner, F)
    ...

    Паттерн steal

    CHayT, 15 Мая 2018

    Комментарии (31)
  3. JavaScript / Говнокод #23688

    0

    1. 1
    2. 2
    var lol = (timeout) => setTimeout(lol, setTimeout(console.log, timeout, 'kek'), timeout);
    lol();

    inho, 30 Января 2018

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

    0

    1. 1
    2. 2
    3. 3
    https://imgur.com/a/UoyMX
    
    Планирую вести себя как прикрелейтед, какие подводные?

    Давайте обсудим в ИТТ треде git, работу с ним, почему каждый раз всё превращается в пикрелейтед и как этого избежать.

    А лоу-левелщики, кстати юзают? Есть вообще тенденция, что веб-макаки используют сабж чаще крестобогов, или наоборот?

    Отдельно предлагаю обсудить алгоритм, по которому gitk рисует историю коммитов. Никак не могу придумать, что ж там за алгоритм, коммити не отсортированы жестко по даже, а если слишком долго в какой-то ветке нет коммитов, то она прерывается стрелочкой, а потом продолжается выше, но трудно сказать, по каким правилам. Причем схожие утилиты рисуют историю по-разному. В код ещё не смотрел.

    З.Ы. Капча 2k16

    vistefan, 22 Января 2018

    Комментарии (31)
  5. Куча / Говнокод #23548

    −4

    1. 1
    2. 2
    3. 3
    https://news.mail.ru/society/31667144/?frommail=1
    
    Как думаете, соски, могут ли семь поездов по шесть вагонов каждый стоить четыре миллиарда рублей? Или это какая-то наёбка?

    COWuTEJIbTBOEuMAMKu, 17 Ноября 2017

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

    +5

    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
    #include <iostream>
    #include <type_traits>
    #include <list>
    #include <vector>
    
    using std::cout;
    using std::endl;
    using function = int;
    
    struct Console {
    private:
        template<typename SS, typename TT>
        static auto test(int)
            -> decltype(std::declval<SS&>() << std::declval<TT>(), std::true_type());
        template<typename, typename>
        static auto test(...) -> std::false_type;
        template<typename T>
        static const bool canCout = decltype(test<decltype(cout), T>(0))::value;
    public:
        template<typename T>
        typename std::enable_if<std::is_same<decltype(std::declval<T>().begin()),
            decltype(std::declval<T>().end())>::value && !canCout<T>>::type
        log(T arg) {
            log('[');
            for (typename T::const_iterator it = arg.begin(); it != arg.end(); ++it) {
                auto nextIt = it;
                ++nextIt;
                if (nextIt != arg.end()) {
                    log(*it);
                    log(", ");
                } else {
                    log(*it);
                    log(']');
                }
            }
        }
        template<typename T>
        typename std::enable_if<canCout<T>>::type
            log(T arg) {
            cout << arg;
        }
        template<typename H, typename ... T>
        void log(H arg, T... rest) {
            log(arg);
            log(' ');
            log(rest...);
        }
    };
    static Console console;
    
    function main()
    {
        console.log(std::vector<int>({ 1, 2, 3 }), "Hello World!", 100.1, "\n");
        console.log(std::string("std::string"), std::list<std::string>({ "one", "two", "three" }), '\n');
    
        return 0;
    }

    Javascript++.
    https://ideone.com/NykL0u

    gost, 21 Октября 2017

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

    +1

    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
    #include <iostream>
    #include <restinho/all.hpp>
    
    int main()
    {
      restinho::http_server_t<> http_server{
        restinho::create_child_io_context(1),
        [](auto & settings) {
          settings.port(8080).address("localhost")
            .request_handler([](auto req) {
              req->create_response().set_body("answer").done();
              return restinho::request_accepted();
            });
        }};
    
      http_server.open();
      std::cin.ignore();
      http_server.close();
    
      return 0;
    }

    https://habrahabr.ru/company/yandex/blog/336264/#comment_10444326

    C++ начинает напоминать какой-то нодежс.

    inho, 29 Сентября 2017

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

    −12

    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
    using System;
    
    
    namespace Aquapear.StringTools
    {
    	
    	/// <summary> Объединяет строки, вставляя между ними разделитель, но в конце разделитель не ставится. </summary>
    	public static class StringsJoiner
    	{
    		
    		public static String Join(String[] bits, String separator) {
    			/*if(separator.Length==0) {
    				int bitsLength = bits.Length;
    				StringBuilder builder = new StringBuilder(bits.Length);
    					for(int i = 0; i < bitsLength; i++) {
    						builder.AddLast( bits[i] );
    					}
    				return builder.Build();
    			}*/
    			return String.Join(separator, bits);
    			/*
    			int bitsLength = bits.Length;
    
    			if(bitsLength == 0) return "";
    			if(separator.Length==0) return CloseJoin(bits);
    			
    			int allCharsLength = separator.Length*(bits.Length-1);
    			for(int i = 0; i < bitsLength; i++) {
    				allCharsLength += bits[i].Length;
    			}						
    			char[] chrs = new char[allCharsLength];
    			int wordIndex = 0, wordProgress = 0;
    			bool separatorMode = false;
    
    			string word = bits[0];
    			int wordLength = word.Length;
    				
    				for(int i = 0; i < allCharsLength; i++) {
    					if(separatorMode) {
    						chrs[i] = word[wordProgress];
    						wordProgress++;
    						if(wordProgress>=wordLength) {
    							separatorMode = false;
    							wordProgress = 0;
    							word = bits[wordIndex];
    							wordLength = word.Length;
    						}
    
    					} else {
    						chrs[i] = (wordLength >= 1) ? word[wordProgress] : '\0';
    						wordProgress++;
    						if(wordProgress >= wordLength) {
    							separatorMode = true;
    							wordProgress = 0;
    							wordIndex++;
    							if(word.Length == 0) i--;
    							word = separator;
    							wordLength = word.Length;
    						}
    					}
    				}
    			return new String(chrs); */
    		}
    
    
    		static String CloseJoin(String[] bits) {
    			return String.Join("", bits);
    		}
    
    	}
    }

    d_fomenok, 07 Октября 2016

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

    +102

    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
    95. 95
    string sql = "select " + (sender == sbFind_Phone ? "distinct " : "") +
    									 "orders.id, orders.dat_add, users.family, orders.status, " +
    									 "clients.name, clients.phone, " +
    									 "orders.adress, orders.note_adress, orders.dat, orders.time_, orders.\"SUM\", orders.skidka, " +
    									 "factories.name, " +
    									 "drivers.family || ' ' || drivers.name, orders.actions, " +
    									 "orders.pay, orders.enter, clients.note, orders.website " + // website: 0 - сайт 1, 1 - сайт 2
    									 (
    										 bPrimeCost || bRolly ? ", orders.subitems || ';' || orders.actions || ';' " : ""
    										 ) +
    									 "from orders " +
    									 "left outer join users     on users.id     = orders.id_user_in " +
    									 "left outer join clients   on clients.id   = orders.id_client " +
    									 "left outer join factories on factories.id = orders.factory " +
    									 "left outer join drivers   on drivers.id   = orders.driver " +
    									 (
    										 bFrom_Site ? //---- поиск заказов с сайта ---------
    											 "where factory = " + Factorys[cbFactories.SelectedIndex - 1].id.ToString()
    											 : sender == sbMobil ? //---- поиск заказов, поступивших с моб./устройств
    												 "where '" + (bDataDelivery
    													 ? dataFrom.ToShortDateString() + "'<= dat     and dat     < '" + dtTo.AddDays(1).ToShortDateString() + "'"
    													 : // дата доставки попадает в интервал      или
    													 dataFrom.ToShortDateString() + "'<= dat_add and dat_add < '" + dtTo.AddDays(1).ToShortDateString() +
    													 "'" // дата приема заказа попадает в интервал
    													 ) +
    												 "  and (orders.note_adress containing 'Android' or orders.note_adress containing 'IOS')"
    												 : sender == sbFind_Phone ? //---- поиск по номеру телефона ------
    													 "where orders.id_client = " + ((id_client_Phone as int?)?.ToString() ?? "0")
    													 : sender == sbFind_Order // так быстрее
    														 ? //---- поиск заказов по номеру -------
    														 "where orders.id in (" + sOrders + ")"
    														 : "where '" + //---- поиск заказов по фильтрам  ----
    															 (bDataDelivery
    																 ? dataFrom.ToShortDateString() + "'<= dat     and dat     < '" + dtTo.AddDays(1).ToShortDateString() +
    																	 "'"
    																 : // дата доставки попадает в интервал      или
    																 dataFrom.ToShortDateString() + "'<= dat_add and dat_add < '" + dtTo.AddDays(1).ToShortDateString() +
    																 "'" // дата приема заказа попадает в интервал
    																 )
    															 + //---- вид оплаты --------------------
    															 (!chPayNal.Checked ? " and orders.pay != 0 " : "") + //  0 - нал.
    															 (!chPayOnl.Checked ? " and orders.pay != 1 " : "") + //  1 - онлайн
    															 (!chPayMt.Checked ? " and orders.pay != 3 " : "") + //  3 - моб/терминал
    															 (!chPayNull.Checked ? " and orders.pay != 2 " : "") //  2 - б/о
    
    															 + //---- откуда поступил ---------------
    															 (!chFromPhone.Checked ? " and orders.enter != 0 " : "") + //  0 - телефон
    															 (!chFromSite.Checked ? " and orders.enter != 1 " : "") + //  1 - сайт
    															 (!chFromClub.Checked ? " and orders.enter != 2 " : "") //  2 - delivery club
    															 +
    															 (rbTake.Checked
    																 ? " and orders.status = 0"
    																 : // принят
    																 rbKitchen.Checked
    																	 ? " and orders.status = 1"
    																	 : // на кухне
    																		 //                  rbReady.Checked ?   " and orders.status = 2":          // готов     - убрал, не хватает места
    																	 rbShip.Checked
    																		 ? " and orders.status = 3"
    																		 : // в пути
    																			 //                  rbDelive.Checked ?  " and orders.status = 4":          // доставлен - убрал, не хватает места
    																		 rbPay.Checked
    																			 ? " and orders.status = 5"
    																			 : // оплачен
    																			 rbCancel.Checked ? " and orders.status = 6" : "" // отменен
    																 )
    															 + // производство
    															 (cbFactories.SelectedIndex <= 0
    																 ? ""
    																 : " and factory = " + Factorys[cbFactories.SelectedIndex - 1].id.ToString()
    																 )
    															 + // акция
    															 (cbActions.SelectedIndex <= 0
    																 ? ""
    																 : " and substring(actions from 1 for " +
    																	 Actions[cbActions.SelectedIndex - 1].id.ToString().Length.ToString() + ") = '"
    																	 + Actions[cbActions.SelectedIndex - 1].id.ToString() + "'"
    																 )
    															 + // манагеры
    															 (cbManagers.SelectedIndex <= 0
    																 ? ""
    																 : " and orders.id_user_in = " + Managers[cbManagers.SelectedIndex - 1].id.ToString()
    																 )
    															 + // водители
    															 (cbDrivers.SelectedIndex <= 0
    																 ? ""
    																 : " and orders.driver = " + Drivers[cbDrivers.SelectedIndex - 1].id.ToString()
    																 )
    															 + // сайт заказа: первый(0) или второй(1)
    															 (rbSiteAll.Checked
    																 ? ""
    																 : " and orders.website = " +
    																	 (rbSitePirogu.Checked ? FLogo.LOGO_1 : FLogo.LOGO_2).ToString()
    																 )
    );

    Абсолютно коричневый код одного пожилого разработчика с 20-летним стажем и кандидатской степенью (прямо в классе формы).

    BigRussianSOS, 27 Августа 2016

    Комментарии (31)
  10. Куча / Говнокод #20111

    +2

    1. 1
    2. 2
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><meta name="format-detection" content="telephone=no"/><title>MINI-MBA Professional</title></head><body style="-webkit-text-size-adjust: none; margin: 0; padding: 0; background-color: #f5f5f5"><img src="http://outlineagency.go2cloud.org/aff_i?offer_id=14&aff_id=1004&aff_sub=release_1&source=mailing" width="1" height="1" />
    <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#f5f5f5"><tr><td valign="top" style="border-collapse: collapse"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td style="border-collapse: collapse"><table width="600" border="0" align="center" cellpadding="0" cellspacing="0"><tr>

    всего-то две строчки поправить
    https://gyazo.com/1a9d5a74da2212b7f758adbf908d2c1c

    ngc-598, 01 Июня 2016

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

    +2

    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
    using System;
    using System.Collections.Generic;
    using System.Linq;
    
    namespace Lens.Stdlib
    {
    	/// <summary>
    	/// Standard library randomizer methods.
    	/// </summary>
    	public static class Randomizer
    	{
    		#region Fields
    
    		/// <summary>
    		/// Random seed.
    		/// </summary>
    		public static readonly Random m_Random = new Random();
    
    		#endregion
    
    		#region Methods
    
    		/// <summary>
    		/// Gets a random floating point value between 0.0 and 1.0.
    		/// </summary>
    		/// <returns></returns>
    		public static double Random()
    		{
    			return m_Random.NextDouble();
    		}
    
    		/// <summary>
    		/// Gets a random integer value between 0 and MAX.
    		/// </summary>
    		public static int Random(int max)
    		{
    			return m_Random.Next(max);
    		}
    
    		/// <summary>
    		/// Gets a random integer value between MIN and MAX.
    		/// </summary>
    		public static int Random(int min, int max)
    		{
    			return m_Random.Next(min, max);
    		}
    
    		/// <summary>
    		/// Gets a random element from the list.
    		/// </summary>
    		public static T Random<T>(IList<T> src)
    		{
    			var max = src.Count - 1;
    			return src[Random(max)];
    		}
    
    		/// <summary>
    		/// Gets a random element from the list using a weighter function.
    		/// </summary>
    		public static T Random<T>(IList<T> src, Func<T, double> weighter)
    		{
    			var rnd = m_Random.NextDouble();
    			var weight = src.Sum(weighter);
    			if (weight < 0.000001)
    				throw new ArgumentException("src");
    
    			var delta = 1.0/weight;
    			var prob = 0.0;
    			foreach (var curr in src)
    			{
    				prob += weighter(curr) * delta;
    				if (rnd <= prob)
    					return curr;
    			}
    
    			throw new ArgumentException("src");
    		}
    
    		#endregion
    	}
    }

    Ну что сказать, 3,4-Метилендиоксиамфетамин

    dm_fomenok, 26 Мая 2016

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