1. Куча / Говнокод #19188

    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
    <?xml version="1.0" encoding="utf-8"?>
    <!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
    <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
    	 viewBox="0 0 77.1 97.7" style="enable-background:new 0 0 77.1 97.7;" xml:space="preserve">
    <style type="text/css">
    	.st0{fill:#010101;}
    	.st1{fill:#FFC627;}
    	.st2{fill:#FFD432;}
    	.st3{fill:#231F20;}
    	.st4{fill:#FFFFFF;}
    </style>
    <g>
    	<g>
    		<g>
    			<g>
    				<path class="st0" d="M6.1,71.6c-3.3,0-6.1,2.7-6.1,6.1v13.9c0,3.3,2.7,6.1,6.1,6.1h61.3c3.3,0,6.1-2.7,6.1-6.1V77.7
    					c0-3.3-2.7-6.1-6.1-6.1H6.1z"/>
    				<path class="st1" d="M67.3,73.5H6.1c-2.3,0-4.1,1.9-4.1,4.1v13.9c0,2.3,1.8,4.1,4.1,4.1h61.3c2.3,0,4.1-1.8,4.1-4.1V77.7
    					C71.5,75.4,69.6,73.5,67.3,73.5 M69.5,91.6c0,1.2-1,2.2-2.2,2.2H6.1c-1.2,0-2.2-1-2.2-2.2V77.7c0-1.2,1-2.2,2.2-2.2h61.3
    					c1.2,0,2.2,1,2.2,2.2V91.6z"/>
    				.........
    			</g>
    		</g>
    	</g>
    	<path class="st1" d="M73.4,73.4c0-1.1,0.9-1.8,1.8-1.8c1,0,1.8,0.7,1.8,1.8c0,1.1-0.9,1.8-1.8,1.8C74.3,75.2,73.4,74.5,73.4,73.4
    		 M75.3,72c-0.8,0-1.4,0.6-1.4,1.4c0,0.8,0.6,1.4,1.4,1.4c0.8,0,1.4-0.6,1.4-1.4C76.6,72.5,76,72,75.3,72 M74.9,74.4h-0.4v-2h0.8
    		c0.5,0,0.8,0.2,0.8,0.6c0,0.4-0.2,0.5-0.5,0.5l0.5,0.9h-0.4l-0.4-0.9h-0.2V74.4z M74.9,73.2h0.3c0.3,0,0.4-0.1,0.4-0.3
    		c0-0.2-0.1-0.3-0.4-0.3h-0.3V73.2z"/>
    </g>
    </svg>

    а вы когда-нибудь заглядывали в SVG?

    makc3d, 15 Декабря 2015

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

    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
    DateTime minDate = DateTime.MinValue;
    
    if (IsSaving)
        return mPrognozStartDate;
    
    if (Children.Count > 0)
    {
        var childrens = Children.Cast<BaseDesignObject>().Where(p => p.PrognozStartDate != DateTime.MinValue);
        if (childrens.Count() > 0)
        {
            minDate = childrens.Min(t => t.PrognozStartDate);
        }
    
        return minDate;
    }
    else
    {
        return mPrognozStartDate;
    }

    При наличии детей выдаем минимальную дату, если их нет то собственную...

    Enelar, 15 Декабря 2015

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

    +7

    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
    96. 96
    //скрытно убираем левых гидов по их ид. Id с релиза.
            $select->where('self.id NOT IN (
                        1054063,
                        1054065,
                        1054232,
                        1054233,
                        1054220,
                        1054213,
                        1054212,
                        1054201,
                        1054199,
                        1054198,
                        1054197,
                        1054053,
                        1054058,
                        1054395,
                        1054445,
                        1054069,
                        1055221,
                        1055241,
                        1055386,
                        1055405,
                        1055406,
                        1055407,
                        1055408,
                        1055409,
                        1055410,
                        1055411,
                        1055412,
                        1054279,
                        1055259,
                        1054066,
                        1054067,
                        1054068,
                        1054070,
                        1054072,
                        1054075,
                        1054064,
                        1054073,
                        1054059,
                        1054060,
                        1054061,
                        1054062,
                        1054071,
                        1054077,
                        1054078,
                        1054079,
                        1054080,
                        1054081,
                        1054187,
                        1054128,
                        1054144,
                        1054129,
                        1054082,
                        1054076,
                        1054119,
                        1054118,
                        1054117,
                        1054116,
                        1054108,
                        1054106,
                        1054103,
                        1054111,
                        1054113,
                        1054102,
                        1054100,
                        1054098,
                        1054096,
                        1054095,
                        1054094,
                        1054093,
                        1054092,
                        1054120,
                        1054152,
                        1054150,
                        1054149,
                        1054148,
                        1054142,
                        1054141,
                        1054140,
                        1054139,
                        1054143,
                        1054138,
                        1054137,
                        1054136,
                        1054130,
                        1054126,
                        1054125,
                        1054186,
                        1054185,
                        1054184,
                        1054158,
                        1054182,
                        1054181,
                        1054180,
                        1054179,

    Это код из контроллера. И это примерно 1/20 всей простыни.

    seladir, 15 Декабря 2015

    Комментарии (0)
  4. C++ / Говнокод #19184

    +3

    1. 1
    2. 2
    3. 3
    try{
          throw Exception();
    }

    Мне в сонном бреду пришла мысль, а нахера обязательный catch?
    finally везде необязательно.
    try{ //исключения не пройдут
    }
    //вполне по крестоблядски

    3.14159265, 15 Декабря 2015

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

    +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
    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
    96. 96
    97. 97
    98. 98
    99. 99
    public static CategoryAttribute Build(string category_name, string attribute_type, string attribute_name, object attribute_value)
            {
                try
                {
                    CategoryAttribute document_attribute;
    
                    switch(attribute_type)
                    {
                        case "string":
                        case "double_as_string":
                            document_attribute = new CategoryAttribute(category_name, attribute_name, TypeEnum.String);
                            break;
                        case "string_as_date":
                            document_attribute = new CategoryAttribute(category_name, attribute_name, TypeEnum.DateTime);
                            break;
                        case "int":
                        case "double_as_int":
                            document_attribute = new CategoryAttribute(category_name, attribute_name, TypeEnum.Integer);
                            break;
                        case "double":
                            document_attribute = new CategoryAttribute(category_name, attribute_name, TypeEnum.Double);
                            break;
                        default:
                            throw new ApplicationException("Не верно настроен тип данных атрибута '" + attribute_name + "' категории '" + category_name + "'.");
                    }
    
                    if (attribute_value == null)
                        return document_attribute;// атрибут остался неопределенным
    
                  switch (document_attribute.Type)
                  {
                      case TypeEnum.String:
                            {
                                switch (attribute_type)
                                {
                                    case "string":
                                        {
                                            if (!(attribute_value is string))
                                                throw new ApplicationException("Тип данных '" + attribute_value.GetType() + "' входного значения атрибута '" + attribute_name
                                                                               + "' категории '" + category_name + "' не может быть приведен к требуему типу данных '" +
                                                                               attribute_type + "'.");
    
                                            document_attribute.sValue = attribute_value as string;
                                        } break;
                                    case "double_as_string":
                                        {
                                            if (!(attribute_value is double))
                                                throw new ApplicationException("Тип данных '" + attribute_value.GetType() + "' входного значения атрибута '" + attribute_name
                                                                               + "' категории '" + category_name + "' не может быть приведен к требуему типу данных '" +
                                                                               attribute_type + "'.");
    
                                            document_attribute.sValue = ((double)attribute_value).ToString();
                                        } break;
                                }
                            }
                            break;
                            case TypeEnum.Integer:
                            {
                                switch (attribute_type)
                                {
                                    case "int":
                                    {
                                        if (!(attribute_value is int))
                                            throw new ApplicationException("Тип данных '" + attribute_value.GetType() + "' входного значения атрибута '" + attribute_name
                                                                           + "' категории '" + category_name + "' не может быть приведен к требуему типу данных '" +
                                                                           attribute_type + "'.");
    
                                        document_attribute.iValue = (int)attribute_value;
                                    }   break;
                                    case "double_as_int":
                                    {
                                        if (!(attribute_value is double))
                                            throw new ApplicationException("Тип данных '" + attribute_value.GetType() + "' входного значения атрибута '" + attribute_name
                                                                           + "' категории '" + category_name + "' не может быть приведен к требуему типу данных '" +
                                                                           attribute_type + "'.");
    
                                        document_attribute.iValue = (int)(double)attribute_value;
                                    }   break;
                                }
                            }
                            break;
                          case TypeEnum.Double:
                            {
                                if (!(attribute_value is float || attribute_value is double || attribute_value is int || attribute_value is long))
                                    throw new ApplicationException("Тип данных '" + attribute_value.GetType() + "' входного значения атрибута '" + attribute_name
                                        + "' категории '" + category_name + "' не может быть приведен к требуему типу данных '" + attribute_type + "'.");
    
                                document_attribute.dValue = (double)attribute_value;
                            }
                            break;
                    }
    
                    return document_attribute;
    
                    catch (Exception e)
                       {
                         //...
                       }
                  }

    Создание объекта типа CategoryAttribute.

    algore, 15 Декабря 2015

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

    +8

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if(user.pass = pass_to_hash(password)){
           return done(null, user);
    }else{
           return done('incorrect password');
    }

    Факир был пьян, и запер дверь, забыв ее закрыть)

    Darth, 15 Декабря 2015

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

    +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
    namespace ConsoleApplication
    {
        public static class Program
        {
            private static void Main( string[] args )
            {
                new Random().Next( -100, 100 )
                    .Execute( x => Console.Write( $"{x} это " ) )
                    .IfElse( x => x % 2 == 0, () => Console.Write( "четное " ), () => Console.Write( "нечетное " ) )
                    .Execute( () => Console.Write( "число " ) )
                    .IfElse( x => x > 0, () => Console.Write( "больше " ), () => Console.Write( "меньше " ) )
                    .Execute( () => Console.Write( "нуля" ) )
                    .Execute( () => Console.WriteLine() );
            }
        }
    }

    вывод в консоли (прим.): "-88 это четное число меньше нуля"

    Адские экстеншены

    anweledig, 14 Декабря 2015

    Комментарии (12)
  8. PHP / Говнокод #19178

    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
    public function callCost($fromCity, $fromStreet, $fromHouse, $fromHousing, $fromBuilding, $fromPorch, $fromLat, $fromLon, $toCity, $toStreet, $toHouse, $toHousing, $toBuilding, $toPorch, $toLat, $toLon, $clientName, $phone, $priorTime, $customCarId, $customCar, $carType, $carGroupId, $tariffGroupId, $comment, $additional = '')
        {
            if ($json = $this->reqCache->getValue($fromLat . $fromLon . $toLat . $toLon . $phone . $priorTime . $tariffGroupId . $comment . $additional)) {
                $data = json_decode($json);
                return $data;
            } else {
    			$tariffGroupId = $this->findTariffOnCarType($carType);
    			$additional = explode(';', $additional);
    			$route = new TaxiRouteAnalyzer($this->dbHost, $this->database, $this->dbLogin, $this->dbPass);
    			$this->writeLog($tariffGroupId);
    			$data = $route->analyzeRoute(1, $fromCity, $fromStreet, $fromHouse, $fromHousing, $fromLat, $fromLon, $toCity, $toStreet, $toHouse, $toHousing, $toLat, $toLon, $additional, $tariffGroupId, $this->isDay(), 1);
                $res = json_encode($data);
                $this->reqCache->setValue($fromLat . $fromLon . $toLat . $toLon . $phone . $priorTime . $tariffGroupId . $comment . $additional, $res, $this->cacheTime);
    			return $data; 
            }
        }

    человеку доверили сделать кэширование данных...

    akanit, 14 Декабря 2015

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

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    var cloths = {
      <?php foreach ($clothList as $cloth): ?>
        "<?=$cloth->id()?>": {
          "id": <?=$cloth->id()?>,
          "name": "<?=$cloth->name()?>",
          "public_name": "<?=str_replace('"', '\"', $cloth->public_name())?>"
        },
      <?php endforeach; ?>
      "dummy": {}
    };

    kgm-rj, 14 Декабря 2015

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

    +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
    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
    if (dlgOpen.ShowDialog() != DialogResult.OK) return;
    
                txtLog.Clear();
                string customXMLFileName = dlgOpen.FileName;
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(customXMLFileName);
               
                foreach (XmlNode node in xmlDoc.DocumentElement.ChildNodes)
                {
                   
                    if (node.Name == "Surfaces")
                       {
    
                        foreach (XmlNode childNode in node.ChildNodes)
                        {
                            txtLog.AppendText(childNode.Name.ToString() + Environment.NewLine);
    
                            foreach (XmlNode _childNode in childNode.ChildNodes)
                            {
                                if (_childNode.Name == "SourceData")
                                {
                                    foreach (XmlNode __childNode in _childNode.ChildNodes)
                                    {
                                        txtLog.AppendText(__childNode.Name.ToString() + Environment.NewLine);
                                        if (__childNode.Name == "Breaklines")
                                        {
                                            foreach (XmlNode ___childNode in __childNode.ChildNodes)
                                            {
                                                txtLog.AppendText(___childNode.Name.ToString() + Environment.NewLine);
                                                XmlNode dataNode = ___childNode.LastChild;
                                                string txtData = dataNode.InnerText;
                                                txtLog.AppendText(txtData + Environment.NewLine);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                   }
                }

    Невнимательное чтение MSDN привело к такому плачевному результату. А всего лишь хотелось прочитать значение дочерних нод Breaklines....
    GetElementsByTagName в помощь....

    Thrasher1980, 12 Декабря 2015

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