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

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

    −4

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

    COWuTEJIbTBOEuMAMKu, 17 Ноября 2017

    Комментарии (31)
  3. 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)
  4. 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)
  5. 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)
  6. Куча / Говнокод #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)
  7. 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)
  8. C# / Говнокод #19990

    −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
    _colorFlashlightAnimation = compositor.CreateExpressionAnimation(
                      "1.0 - min("
                    + "    1.0,"
                    + "    ("
                    + "        ("
                    + "            ( frame.Offset.x + (frame.Size.x * 0.5) + grid.Offset.x - (windowWidth * 0.5) )"
                    + "          * ( frame.Offset.x + (frame.Size.x * 0.5) + grid.Offset.x - (windowWidth * 0.5) )"
                    + "        ) + ("
                    + "            ( frame.Offset.y + (frame.Size.y * 0.5) + grid.Offset.y - (windowHeight * 0.5) )"
                    + "          * ( frame.Offset.y + (frame.Size.y * 0.5) + grid.Offset.y - (windowHeight * 0.5) )"
                    + "        )"
                    + "    ) / ( radius * radius )"
    + ")");

    Удивитесь, но это Microsoft
    https://github.com/Microsoft/WindowsUIDevLabs/blob/master/Demos/SlideShow/SlideShow/TransitionLibrary.cs

    cherepets, 12 Мая 2016

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

    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
    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
    function floatToStringPrec(f, precisionDigits)
    {
        var PRECISION = Math.pow(10, precisionDigits);
        
        var integerPart = Math.floor(f);
        var fractionalPart = f % 1;
        if (fractionalPart == 0)
        {
            return integerPart.toString();
        }
        
        var zeroesInFracPart = -Math.log10(fractionalPart);
        if (Math.floor(zeroesInFracPart) == zeroesInFracPart)
        {
            zeroesInFracPart--;
        }
        else
        {
            zeroesInFracPart = Math.floor(zeroesInFracPart);
        }
        
        fractionalPart = Math.round(fractionalPart * PRECISION);
    
        while (fractionalPart % 10 == 0)
        {
             fractionalPart /= 10;
        }
        
        var zeroes = '';
        
        if (zeroesInFracPart > 0)
        {
            zeroes = Array(zeroesInFracPart + 1).join('0');
        }
        
        return integerPart.toString() + '.' + zeroes + fractionalPart.toString();
    }

    Преобразовать плавающего питуха в строку; сохранить не более precisionDigits цифр после запятой (остальные - округлить).

    gost, 05 Мая 2016

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

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    static void DelayNZOKParse(string filename)
    {
        ThreadPool.QueueUserWorkItem(new WaitCallback(startNZOKParseFile), filename);
    }
    static void startNZOKParseFile(object state)
    {
        Thread.Sleep(1000);
        startNZOKParseFile(state as string);
    }

    вот это

    apostolovd, 14 Апреля 2016

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

    −89

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    КолЯ=	ЦЕЛ(колБутДлчЯщ/20) ;
    колЯщ=колЯЩ+ КолЯ;
    если колЯ< колБутДлчЯщ/20 Тогда
    	колЯщ=  колЯщ+1;
    конецЕсли;

    Что будет, если пустить в конфигуратор беременную женщину? В коде окажется Коля.

    onden, 09 Марта 2016

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