1. C# / Говнокод #19794

    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
    public enum EventType {
                Error,
                Notification,
                Success
            }
    ...
                            String sEventType = String.Empty;
                            switch (eType) {
                                case EventType.Error:
                                    sEventType = "Error: ";
                                    break;
                                case EventType.Notification:
                                    sEventType = "Notification: ";
                                    break;
                                case EventType.Success:
                                    sEventType = "Success: ";
                                    break;
                            }

    Lokich, 11 Апреля 2016

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if (collection == null) collection = Rows.Where(r => r.ParentId == 0);
    foreach (var row in collection.Where(r => r.ParentId > 0))
    {
         //немного кода
    }

    Сам писал. Вчера. Трезвый.
    Сейчас вот думаю, а чо эта оно не работает?

    kerman, 11 Апреля 2016

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

    −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
    <figure class="highlight"><pre><code class="language-html" data-lang="html"><span class="nt"><nav</span> <span class="na">class=</span><span class="s">"navbar navbar-default"</span><span class="nt">></span>
      <span class="nt"><div</span> <span class="na">class=</span><span class="s">"container-fluid"</span><span class="nt">></span>
        <span class="c"><!-- Brand and toggle get grouped for better mobile display --></span>
        <span class="nt"><div</span> <span class="na">class=</span><span class="s">"navbar-header"</span><span class="nt">></span>
          <span class="nt"><button</span> <span class="na">type=</span><span class="s">"button"</span> <span class="na">class=</span><span class="s">"navbar-toggle collapsed"</span> <span class="na">data-toggle=</span><span class="s">"collapse"</span> <span class="na">data-target=</span><span class="s">"#bs-example-navbar-collapse-1"</span> <span class="na">aria-expanded=</span><span class="s">"false"</span><span class="nt">></span>
            <span class="nt"><span</span> <span class="na">class=</span><span class="s">"sr-only"</span><span class="nt">></span>Toggle navigation<span class="nt"></span></span>
            <span class="nt"><span</span> <span class="na">class=</span><span class="s">"icon-bar"</span><span class="nt">></span></span>
            <span class="nt"><span</span> <span class="na">class=</span><span class="s">"icon-bar"</span><span class="nt">></span></span>
            <span class="nt"><span</span> <span class="na">class=</span><span class="s">"icon-bar"</span><span class="nt">></span></span>
          <span class="nt"></button></span>
          <span class="nt"><a</span> <span class="na">class=</span><span class="s">"navbar-brand"</span> <span class="na">href=</span><span class="s">"#"</span><span class="nt">></span>Brand<span class="nt"></a></span>
        <span class="nt"></div></span>
    
        <span class="c"><!-- Collect the nav links, forms, and other content for toggling --></span>
        <span class="nt"><div</span> <span class="na">class=</span><span class="s">"collapse navbar-collapse"</span> <span class="na">id=</span><span class="s">"bs-example-navbar-collapse-1"</span><span class="nt">></span>
          <span class="nt"><ul</span> <span class="na">class=</span><span class="s">"nav navbar-nav"</span><span class="nt">></span>
            <span class="nt"><li</span> <span class="na">class=</span><span class="s">"active"</span><span class="nt">><a</span> <span class="na">href=</span><span class="s">"#"</span><span class="nt">></span>Link <span class="nt"><span</span> <span class="na">class=</span><span class="s">"sr-only"</span><span class="nt">></span>(current)<span class="nt"></span></a></li></span>
            <span class="nt"><li><a</span> <span class="na">href=</span><span class="s">"#"</span><span class="nt">></span>Link<span class="nt"></a></li></span>
            <span class="nt"><li</span> <span class="na">class=</span><span class="s">"dropdown"</span><span class="nt">></span>
              <span class="nt"><a</span> <span class="na">href=</span><span class="s">"#"</span> <span class="na">class=</span><span class="s">"dropdown-toggle"</span> <span class="na">data-toggle=</span><span class="s">"dropdown"</span> <span class="na">role=</span><span class="s">"button"</span> <span class="na">aria-haspopup=</span><span class="s">"true"</span> <span class="na">aria-expanded=</span><span class="s">"false"</span><span class="nt">></span>Dropdown <span class="nt"><span</span> <span class="na">class=</span><span class="s">"caret"</span><span class="nt">></span></a></span>
              <span class="nt"><ul</span> <span class="na">class=</span><span class="s">"dropdown-menu"</span><span class="nt">></span>
                <span class="nt"><li><a</span> <span class="na">href=</span><span class="s">"#"</span><span class="nt">></span>Action<span class="nt"></a></li></span>
                <span class="nt"><li><a</span> <span class="na">href=</span><span class="s">"#"</span><span class="nt">></span>Another action<span class="nt"></a></li></span>
                <span class="nt"><li><a</span> <span class="na">href=</span><span class="s">"#"</span><span class="nt">></span>Something else here<span class="nt"></a></li></span>
                <span class="nt"><li</span> <span class="na">role=</span><span class="s">"separator"</span> <span class="na">class=</span><span class="s">"divider"</span><span class="nt">></li></span>
                <span class="nt"><li><a</span> <span class="na">href=</span><span class="s">"#"</span><span class="nt">></span>Separated link<span class="nt"></a></li></span>
                <span class="nt"><li</span> <span class="na">role=</span><span class="s">"separator"</span> <span class="na">class=</span><span class="s">"divider"</span><span class="nt">></li></span>
                <span class="nt"><li><a</span> <span class="na">href=</span><span class="s">"#"</span><span class="nt">></span>One more separated link<span class="nt"></a></li></span>
              <span class="nt"></ul></span>
            <span class="nt"></li></span>
          <span class="nt"></ul></span>
          <span class="nt"><form</span> <span class="na">class=</span><span class="s">"navbar-form navbar-left"</span> <span class="na">role=</span><span class="s">"search"</span><span class="nt">></span>
            <span class="nt"><div</span> <span class="na">class=</span><span class="s">"form-group"</span><span class="nt">></span>
              <span class="nt"><input</span> <span class="na">type=</span><span class="s">"text"</span> <span class="na">class=</span><span class="s">"form-control"</span> <span class="na">placeholder=</span><span class="s">"Search"</span><span class="nt">></span>
            <span class="nt"></div></span>

    С сайта bootstrap

    d_fomenok, 10 Апреля 2016

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

    +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
    public class Man
        {
            public Man(string id, string name, IEnumerable<Brother> brothers, Guid id, int year, int age) : base(id, year)
            {
                this.Name = name;
                this.Brothers = brothers;
                this.Id = id;
                this.Age = age;
            }
    
            public Man(string id, string name, string note, IEnumerable<Brother> brothers, Guid id, int year, int age) : base(id, note, year)
            {
                this.Name = name;
                this.Brothers = brothers;
                this.Id = id;
                this.Age = age;
            }
    
            public Man(string id, string name, IEnumerable<Brother> brothers, Guid id, int year, int age) : base(id, year)
            {
                this.Name = name;
                this.Brothers = brothers;
                this.Id = id;
                this.Age = age;
            }
    
            public Man(string id, string name, string note, IEnumerable<Brother> brothers, Guid id, int year, int age) : base(id, note, year)
            {
                this.Name = name;
                this.Brothers = brothers;
                this.Id = id;
                this.Age = age;
            }
    
            public Man(string id, string name, Guid id, int year, int age) : base(id, year)
            {
                this.Name = name;
                this.Brothers = new List<Brother>() { new Brother(Guid.NewGuid().ToString()) };
                this.Id = id;
                this.Age = age;
            }
    
            public Man(string id, string name, string note, Guid id, int year, int age) : base(id, note, year)
            {
                this.Name = name;
                this.Brothers = new List<Brother>() { new Brother(Guid.NewGuid().ToString()) };
                this.Id = id;
                this.Age = age;
            }
    
            public Man(string id, string name, Guid id, int year, int age) : base(id, year)
            {
                this.Name = name;
                this.Brothers = new List<Brother>() { new Brother(Guid.NewGuid().ToString()) };
                this.Id = id;
                this.Age = age;
            }
    
            public Man(string id, string name, string note, Guid id, int year, int age) : base(id, note, year)
            {
                this.Name = name;
                this.Id = id;
                this.Brothers = new List<Brother>() { new Brother(Guid.NewGuid().ToString()) };
                this.Age = age;
            }
    
            public string Name { get; }
    
            public Guid Id { get; }
    
            public IEnumerable<Brother> Brothers { get; }
    
            public int Age { get; }
    
        }

    Человек знал, но нехотел использовать значение параметра конструктора по умолчанию, потому что это усложняет структуру.
    Переменные переназвал почеловечнее.

    homk, 10 Апреля 2016

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

    +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
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    function op_v($n0 = NULL,$n1 = NULL,$n2 = NULL,$n3 = NULL,$n4 = NULL,$n5 = NULL,$n6 = NULL,$n7 = NULL,$n8 = NULL,$n9 = NULL, $sql) {
    //быдлокод гг
    if ($sql==0){
     if(!empty($n0)) $x0 = '<option value="0">'.$n0.'</option>';
     if(!empty($n1)) $x1 = '<option value="1">'.$n1.'</option>';
     if(!empty($n2)) $x2 = '<option value="2">'.$n2.'</option>';
     if(!empty($n3)) $x3 = '<option value="3">'.$n3.'</option>';
     if(!empty($n4)) $x4 = '<option value="4">'.$n4.'</option>';
     if(!empty($n5)) $x5 = '<option value="5">'.$n5.'</option>';
     if(!empty($n6)) $x6 = '<option value="6">'.$n6.'</option>';
     if(!empty($n7)) $x7 = '<option value="7">'.$n7.'</option>';
     if(!empty($n8)) $x8 = '<option value="8">'.$n8.'</option>';
     if(!empty($n9)) $x9 = '<option value="9">'.$n9.'</option>';
    
     $res = $x0.$x1.$x2.$x3.$x4.$x5.$x6.$x7.$x8.$x9;
     }
     if ($sql==1){
     if(!empty($n1)) $x0 = '<option value="1">'.$n1.'</option>';
     if(!empty($n0)) $x1 = '<option value="0">'.$n0.'</option>';
     if(!empty($n2)) $x2 = '<option value="2">'.$n2.'</option>';
     if(!empty($n3)) $x3 = '<option value="3">'.$n3.'</option>';
     if(!empty($n4)) $x4 = '<option value="4">'.$n4.'</option>';
     if(!empty($n5)) $x5 = '<option value="5">'.$n5.'</option>';
     if(!empty($n6)) $x6 = '<option value="6">'.$n6.'</option>';
     if(!empty($n7)) $x7 = '<option value="7">'.$n7.'</option>';
     if(!empty($n8)) $x8 = '<option value="8">'.$n8.'</option>';
     if(!empty($n9)) $x9 = '<option value="9">'.$n9.'</option>';
    
     $res = $x0.$x1.$x2.$x3.$x4.$x5.$x6.$x7.$x8.$x9;
     }
     
     if ($sql==2){
     if(!empty($n2)) $x0 = '<option value="2">'.$n2.'</option>';
     if(!empty($n0)) $x1 = '<option value="0">'.$n0.'</option>';
     if(!empty($n1)) $x2 = '<option value="1">'.$n1.'</option>';
     if(!empty($n3)) $x3 = '<option value="3">'.$n3.'</option>';
     if(!empty($n4)) $x4 = '<option value="4">'.$n4.'</option>';
     if(!empty($n5)) $x5 = '<option value="5">'.$n5.'</option>';
     if(!empty($n6)) $x6 = '<option value="6">'.$n6.'</option>';
     if(!empty($n7)) $x7 = '<option value="7">'.$n7.'</option>';
     if(!empty($n8)) $x8 = '<option value="8">'.$n8.'</option>';
     if(!empty($n9)) $x9 = '<option value="9">'.$n9.'</option>';
     
     $res = $x0.$x1.$x2.$x3.$x4.$x5.$x6.$x7.$x8.$x9;
     }
    
    if ($sql==3){
     if(!empty($n3)) $x0 = '<option value="3">'.$n3.'</option>';
     if(!empty($n0)) $x1 = '<option value="0">'.$n0.'</option>';
     if(!empty($n1)) $x2 = '<option value="1">'.$n1.'</option>';
     if(!empty($n2)) $x3 = '<option value="2">'.$n2.'</option>'; 
     if(!empty($n4)) $x4 = '<option value="4">'.$n4.'</option>';
     if(!empty($n5)) $x5 = '<option value="5">'.$n5.'</option>';
     if(!empty($n6)) $x6 = '<option value="6">'.$n6.'</option>';
     if(!empty($n7)) $x7 = '<option value="7">'.$n7.'</option>';
     if(!empty($n8)) $x8 = '<option value="8">'.$n8.'</option>';
     if(!empty($n9)) $x9 = '<option value="9">'.$n9.'</option>';
    
     $res = $x0.$x1.$x2.$x3.$x4.$x5.$x6.$x7.$x8.$x9;
     }
    
    if ($sql==4){
     if(!empty($n4)) $x0 = '<option value="4">'.$n4.'</option>';
     if(!empty($n0)) $x1 = '<option value="0">'.$n0.'</option>';
     if(!empty($n1)) $x2 = '<option value="1">'.$n1.'</option>';
     if(!empty($n2)) $x3 = '<option value="2">'.$n2.'</option>';
     if(!empty($n3)) $x4 = '<option value="3">'.$n3.'</option>';
     if(!empty($n5)) $x5 = '<option value="5">'.$n5.'</option>';
     if(!empty($n6)) $x6 = '<option value="6">'.$n6.'</option>';
     if(!empty($n7)) $x7 = '<option value="7">'.$n7.'</option>';
     if(!empty($n8)) $x8 = '<option value="8">'.$n8.'</option>';
     if(!empty($n9)) $x9 = '<option value="9">'.$n9.'</option>';
    
     $res = $x0.$x1.$x2.$x3.$x4.$x5.$x6.$x7.$x8.$x9;
     }
    
    if ($sql==5){
     if(!empty($n5)) $x0 = '<option value="5">'.$n5.'</option>';
     if(!empty($n0)) $x1 = '<option value="0">'.$n0.'</option>';
     if(!empty($n1)) $x2 = '<option value="1">'.$n1.'</option>';
     if(!empty($n2)) $x3 = '<option value="2">'.$n2.'</option>';
     if(!empty($n3)) $x4 = '<option value="3">'.$n3.'</option>';
     if(!empty($n4)) $x5 = '<option value="4">'.$n4.'</option>';
     if(!empty($n6)) $x6 = '<option value="6">'.$n6.'</option>';
     if(!empty($n7)) $x7 = '<option value="7">'.$n7.'</option>';
     if(!empty($n8)) $x8 = '<option value="8">'.$n8.'</option>';
     if(!empty($n9)) $x9 = '<option value="9">'.$n9.'</option>';
    и так далее...

    привет из wap'а

    odoviez, 10 Апреля 2016

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

    +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
    #if defined(OSVR_WINDOWS)
        static const auto SEARCH_PATH_ENV = "PATH";
        static const auto SEARCH_PATH_SEP = ";";
    #else
        static const auto SEARCH_PATH_ENV = "LD_LIBRARY_PATH";
        static const auto SEARCH_PATH_SEP = ":";
    #endif
    
    
    void wrappedPutenv(std::string const &val) {
    #ifdef _MSC_VER
                _putenv_s(SEARCH_PATH_ENV, val.c_str());
    #else // not microsoft runtime specific
                auto newValue = SEARCH_PATH_ENV + "=" + val;
                // Have to allocate new string because it becomes part of the
                // environment.
                char *newString = static_cast<char *>(malloc(newValue.size() + 1));
                std::copy(begin(newValue), end(newValue), newString);
    #endif
    }

    Момент, когда я считаю, что C++-ный auto -- чистое зло(строка 14).
    Код из OSVR-Vive, плагина к OSVR, который работает с HTC Vive.

    a1batross, 08 Апреля 2016

    Комментарии (21)
  7. PHP / Говнокод #19784

    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
    <script type="text/javascript">
            var currentLeveler = 0;
            var currentPrefix = 'povorot_';
            var currentPart = 0;
            var partsCount = [];
            var oldPart, oldLeveler;
            languagePrefix = "<?php echo $lang; ?>";
            partsCount[0] = 5;
            partsCount[1] = 4;
            partsCount[2] = 3;
    
            var levelersInfo = [[], [], []];
            var levelerParts = [[], [], []];
            var content = [];
    
            <?php
                while($row = mysql_fetch_array($tmp)){
                    $content[$row['block_id']] = $row['cont'];
                    echo "content[\"" .$row['block_id']. "\"] = '".$row['cont']."';\n";
                }
                for($j = 0; $j < 3; $j++)
                    for($i = 0; $i < 5; $i++){
    
                        $val1 = $content[$lang."_tech_leveler_info_".$j.$i];
                        $val2 = $content[$lang."_tech_part_info_".$j.$i];
                  
                        echo "levelersInfo[".$j."].push('".$val1."');";
                        echo "levelerParts[".$j."].push('".$val2."');";
                    }
            ?>
            $(document).ready(function () {
                $.each($(".changeable"), function () {
                    $(this).html(content[$(this).attr("id")]);
                });
            });
        </script>

    Формируем js код, через PHP на основе данных из базы данных... или в жопку аякс

    perryutkonos, 08 Апреля 2016

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

    +6

    1. 1
    2. 2
    function pageOutput() {
    	foreach($GLOBALS as $var => $val) $$var = &$GLOBALS[$var];

    очередная находка..
    ...для тех, кто не уверен, какие переменные из global scope понадобятся...

    paulrudy, 08 Апреля 2016

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    // 1188 references
    internal static string CombinePaths(string firstPath, string secondPath)
    {
        return Path.Combine(firstPath, secondPath);
    }

    - Шо это было?!!
    - Cэкономили точку. 1188 раз )))))

    RadChand, 08 Апреля 2016

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

    +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
    public class FileStorage {
            public FileStorage() {
                try {
                    if (String.IsNullOrEmpty(Common.GlobalVariables.FileStorage)) {
                        throw new Exception(Common.GuiHelper.ShowErrorMessage("FileStorage", String.Empty));
                    }
    
                    if (!Directory.Exists(Common.GlobalVariables.FileStorage)) {
                        DirectoryInfo di = Directory.CreateDirectory(Common.GlobalVariables.FileStorage);
                        if (!di.Exists) {
                            throw new Exception(Common.GuiHelper.ShowErrorMessage("FileStorageDir", String.Empty));
                        }
                    }
                } catch (Exception er) {
                    throw new Exception(er.Message);
                }
            }
    
            public String CreateFileDirectory() {
                try {
                    int iIdx = 0;
                    Boolean bIsCreated = false;
                    while (!bIsCreated && iIdx < 10) {
                        String sDir = Guid.NewGuid().ToString("N").ToLower();
                        sDir = sDir.Substring(0, 2);
                        if (!Directory.Exists(Common.GlobalVariables.FileStorage + sDir + @"\")) {
                            DirectoryInfo di = Directory.CreateDirectory(Common.GlobalVariables.FileStorage + sDir + @"\");
                            if (di.Exists) {
                                return Common.GlobalVariables.FileStorage + sDir + @"\";
                            }
                        }
    
                        iIdx++;
                    }
    
                    return null;
                } catch (Exception er) {
                    throw new Exception(er.Message);
                }
            }
        }

    может я чего не понимаю, но зачем?

    Lokich, 08 Апреля 2016

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