1. JavaScript / Говнокод #11341

    +159

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    try {
      //
     if(error)1/0;
    } catch (e) {
     //
    }

    Lure Of Chaos, 02 Июля 2012

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

    +125

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if (this.Game.GraphicsDevice != null)
    {
        DrawBaseTile(sb);
    }
    DrawBaseTile(sb);

    Надо больше спать...

    RaZeR, 02 Июля 2012

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

    +159

    1. 1
    2. 2
    3. 3
    if (($("#menu-main").find("li span").is(".active")) && ($("#nav-wrapper").find("nav").is("#children_for_" + $("#menu-main").find("li span.active").parent("li").attr("id")))) {
        ...
    }

    ...

    tir, 02 Июля 2012

    Комментарии (30)
  4. JavaScript / Говнокод #11338

    +152

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    if (canvas.cuserStatus == "yes") {
        this.changeUserContactByHash.pending = true;
        this.changeUserContactByHash.doCall();
    } else if (canvas.cuserStatus == "no") {
        this.changeUserContactByHash.pending = true;
        this.changeUserContactByHash.doCall();
    }

    Написано это на OpenLaszlo, но так как такого языка в выборе нет, то сойдёт и ЖС, главное подсветка и смысл.

    хуита, 02 Июля 2012

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

    +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
    class SumClass
    {
      int A, B;
      public:
      void Set_A(int A) {this->A = A;}
      void Set_B(int B) {this->B = B;}
    
      int Sum() {return A+B;}
    }
    
    class MultiSumClass
    {
      SumClass Sum;
      int count;
      public:
      void Set_A(int A) {Sum.Set_A(A);}
      void Set_B(int B) {Sum.Set_B(B);}
      void Set_Count(int count) {this->count = count;}
      
      int GetSum() {return Sum->Sum()*count;}
    }
    
    void main()
    {
       MultiSumClass MSC;
       MSC.Set_A(5); MSC.Set_B(10);
       MSC.Set_Count(2);
       cout << MSC.GetSum();
    }

    Вот зачем ООП нужно
    http://www.gamedev.ru/flame/forum/?id=164035

    извените за игрстрй

    TarasB, 02 Июля 2012

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

    +52

    1. 1
    2. 2
    $Qock = mysql_query("SELECT ...");
    $Cock = mysql_num_rows($Qock);

    Переменная $Cock - это ж надо так назвать!

    domaster, 02 Июля 2012

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

    −11

    1. 1
    rampage=1<<12;

    Видимо кто-то из буйных писал.

    HaskellGovno, 02 Июля 2012

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

    +67

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    if ($_GET['search'] == ' Поиск' || $_GET['search'] == 'Поиск') {
    	$_GET['search'] = '';
    }
    if ($_GET['date'] == ' Дата' || $_GET['date'] == 'Дата') {
    	$_GET['date'] = '';
    } else {
    	$_GET['date'] = preg_replace('/(\d+).(\d+).(\d+)/i','$3-$2-$1', $_GET['date']);
    }

    Уж не знаю, что и сказать... А вдруг перед текстом попадутся 2 пробела? Или 3?

    domaster, 02 Июля 2012

    Комментарии (19)
  9. Java / Говнокод #11333

    +121

    1. 1
    2. 2
    3. 3
    @SuppressWarnings("deprecation")
    // Stupid GWT doesn't have Calendar, so we have to use a deprecated method. :(
    final int year = new Date().getYear() + 1900;

    someone, 02 Июля 2012

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

    +58

    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
    //из Model_Menu:
    public $hierarchy = array(Model_Menu::AUTHOR, Model_Menu::YEAR, Model_Menu::GENRE);
    
    public function get()
        {
            try {
                return
                    DB::query(Database::SELECT,
                        'SELECT alias AS '.Model_Menu::ALIAS.',head AS '.Model_Menu::HEAD.',SUBSTRING(body,1,
                        128) AS '.Model_Menu::LINE.',
                        '.Model_Menu::AUTHOR.',
                        YEAR(date) AS '.Model_Menu::YEAR.',genre AS '.Model_Menu::GENRE.' FROM creations ORDER BY ' .
                            implode(',', $this->hierarchy) . ','.Model_Menu::ALIAS)->execute()->as_array();
            } catch (Exception $e) {
                return false;
            }
        }
    
    // views/menu.php:
    <?php
        $menu = Model::factory('menu');
        $hierarchy = $menu->hierarchy;
        $size = sizeof($hierarchy);
        $currentrow = $menu->creation();
        $xml = new MarkupBuilder();
        $last = array();
        $anchor = -1;
        $current = -1;
        $num = 0;
        $xml->tag('ul');
        $rows = $menu->get();
        foreach ($rows as $row) {
            $num++;
            $active=($row[Model_Menu::ALIAS] == $currentrow);
            while (true) {
                if ($current == $anchor) {
                    $pass = true;
                    for ($i = 0; $i < $size; $i++) {
                        if (empty($last[$i]) || $last[$i] != $row[$hierarchy[$i]]) {
                            $last[$i] = $row[$hierarchy[$i]];
                            $anchor = $i;
                            $pass = false;
                            for ($i = $anchor + 1; $i < sizeof($last); $i++) {
                                unset($last[$i]);
                            }
                            $anchor--;
                            break;
                        }
                    }
                    if ($pass) {
                        $anchor = $size;
                    }
                }
                if ($current < $anchor) {
                    $current++;
                    if ($current < $size) {
                        $xml->tag('li');
                        $xml->tag('span');
                        $xml->text($row[$hierarchy[$current]]);
                        $xml->end();
                        $xml->tag('ul',$active?array('class'=>'active'):array());
                    }
                } elseif ($current > $anchor) {
                    if ($current < $size) {
                        $xml->end();
                        $xml->end();
                    }
                    $current--;
                }
                elseif ($current == $anchor) {
                    if ($current == $size) {
                        $tooltip = $menu->tooltip($row);
                        $xml->tag('li', array(
                            'class' => 'item' . ($active ? 'highlight' : ''),
                            'title' => $tooltip
                        ));
                        $xml->tag('a', array(
                            'href' => (URL::base() . Route::get('creation')->uri(array('creation' => $row[Model_Menu::ALIAS])
                            )),
                            'class' => ($active ? 'highlight' : '')
                        ));
                        $xml->text($row[Model_Menu::HEAD]);
                        $xml->end();
                        $xml->end();
                        break;
                    }
                }
            }
        }
        $xml->end();
        while ($current > -1) {
            $xml->end();
            $current--;
        }
        echo $xml->asXML();
        ?>

    смысл данного ужаса в том, чтобы выбрать из таблицы данные (все в строковом формате) и вывести как меню UL\LI с иерархией, указанной в $hierarchy.

    Lure Of Chaos, 01 Июля 2012

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