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

    В номинации:
    За время:
  2. PHP / Говнокод #2979

    +144.8

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    <?php
    if(!@isset($_POST[submit]))
    {
    ...
    ?>

    DmitryDick, 09 Апреля 2010

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

    +144.8

    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
    /**
     * Helper classes for computing window query on rectangles
     */
    
    class VerticalSegmentIntersect : public std::unary_function < PRGlyph, ptrdiff_t > {
      ptrdiff_t m_Lhs;
      ptrdiff_t m_Rhs;
    public:
      VerticalSegmentIntersect ( ptrdiff_t top, ptrdiff_t bottom ) throw() : m_Lhs(top+top), m_Rhs(bottom+bottom) {}
      ptrdiff_t operator() ( PRGlyph inpGlyph ) const throw() { 
        QRect const* area = inpGlyph->GetGlyphArea();
        ptrdiff_t x = area->bottom() + area->top(), y = area->bottom() - area->top();
        
        if (y < x - m_Rhs ) return 0;
        if (y < m_Lhs - x ) return 0;
        
        return 1;
      }
    };
    
    class HorisontalSegmentIntersect : public std::unary_function < PRGlyph, ptrdiff_t > {
      ptrdiff_t m_Lhs;
      ptrdiff_t m_Rhs;
    public:
      HorisontalSegmentIntersect ( ptrdiff_t left, ptrdiff_t right ) throw() : m_Lhs(left+left), m_Rhs(right+right) {}
      ptrdiff_t operator() ( PRGlyph inpGlyph ) const throw() { 
        QRect const* area = inpGlyph->GetGlyphArea();
        ptrdiff_t x = area->right() + area->left(), y = area->right() - area->left();
        
        if (y < x - m_Rhs ) return 0;
        if (y < m_Lhs - x ) return 0;
        return 1;
      }
    };
    
    /**
     * Helper classes for computing containment query on rectangles
     */ 
    
    class VerticalSegmentContains : public std::unary_function < PRGlyph, ptrdiff_t > {
      ptrdiff_t m_Lhs;
      ptrdiff_t m_Rhs;
    public:
      VerticalSegmentContains ( ptrdiff_t top, ptrdiff_t bottom ) throw() : m_Lhs(top+top), m_Rhs(bottom+bottom) {}
      ptrdiff_t operator() ( PRGlyph inpGlyph ) const throw() {
        QRect const* area = inpGlyph->GetGlyphArea();    
        ptrdiff_t x = area->bottom() + area->top(), y = area->bottom() - area->top();
        
        if ( y > x - m_Lhs ) return 0;
        if ( y > m_Rhs - x ) return 0;
        return 1;
      }
    };
    
    class HorisontalSegmentContains : public std::unary_function < PRGlyph, ptrdiff_t > {
      ptrdiff_t m_Lhs;
      ptrdiff_t m_Rhs;
    public:
      HorisontalSegmentContains ( ptrdiff_t left, ptrdiff_t right ) throw() : m_Lhs(left+left), m_Rhs(right+right) {}
      ptrdiff_t operator() ( PRGlyph inpGlyph ) const throw() {
        QRect const* area = inpGlyph->GetGlyphArea();    
        ptrdiff_t x = area->right() + area->left(), y = area->right() - area->left();
        
        if ( y > x - m_Lhs ) return 0;
        if ( y > m_Rhs - x ) return 0;
        return 1;
      }
    };
    
    // compute the window query on m_GlyphData rectangles
      QVector<PRGlyph> :: iterator windowq = m_Selection.isValid() ?
                                            std::partition ( m_GlyphData.begin(),
                                                             std::partition ( m_GlyphData.begin(), m_GlyphData.end(), VerticalSegmentIntersect ( m_Selection.top(), m_Selection.bottom() ) ),
                                                             HorisontalSegmentIntersect ( m_Selection.left(), m_Selection.right() )
                                                           ) : m_GlyphData.begin();
      // compute the containment query on window query rectangles (the containment query resuls is always subset of window query )
      QVector<PRGlyph> :: iterator containq = std::partition ( m_GlyphData.begin(),
                                                               std::partition ( m_GlyphData.begin(), windowq, VerticalSegmentContains ( m_Selection.top(), m_Selection.bottom() ) ),
                                                               HorisontalSegmentContains ( m_Selection.left(), m_Selection.right() )
                                                             );

    Способ быстренько находить прямоугольники, пересекающиеся с входным и содержимые им же. Применимо для прямоугольных параллелепипедов любой размерности.

    ngry, 01 Апреля 2010

    Комментарии (27)
  4. PHP / Говнокод #2275

    +167.8

    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
    function returnDate($stamp){
    global $settings;
    $day = strftime("%d",$stamp+($settings['timeoffset']*3600));
    $month = strftime("%m",$stamp+($settings['timeoffset']*3600));
    $year = strftime("%Y",$stamp+($settings['timeoffset']*3600));
    switch ($month){
    case 01 : $month = "01"; break;
    case 02 : $month = "02"; break;
    case 03 : $month = "03"; break;
    case 04 : $month = "04"; break;
    case 05 : $month = "05"; break;
    case 06 : $month = "06"; break;
    case 07 : $month = "07"; break;
    case 08 : $month = "08"; break;
    case 09 : $month = "09"; break;
    case 10 : $month = "10"; break;
    case 11 : $month = "11"; break;
    case 12 : $month = "12"; break;
    }
    return "$day.$month.$year";
    }

    Взято из чешского шаблона под одну цмску. Автору, наверно, платят как Маяковскому - за каждую строчку :-)

    |)3F, 13 Декабря 2009

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

    +109.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
    <script type="text/javascript">
    <!--
    if (window.screen)
    {
    if (screen.width < 1024)
    {
    document.write('<td height="35" width="11"><img src="img0800/indx/indx_0_0.png" title="" alt="" style="width: 11px; height: 35px;"></td>\n');
    document.write('<td height="35" width="43"><a href="en/index.html"><img src="img0800/indx/indx_1_0.png" title="" alt="" style="width: 43px; height: 35px;"></a></td>\n');
    document.write('<td height="35" width="76"><img src="img0800/indx/indx_2_0.png" title="" alt="" style="width: 76px; height: 35px;"></td>\n');
    document.write('<td height="35" width="32"><img src="img0800/indx/indx_3_0.png" title="" alt="" style="width: 32px; height: 35px;"></td>\n');
    document.write('<td height="35" width="27"><img src="img0800/indx/indx_4_0.png" title="" alt="" style="width: 27px; height: 35px;"></td>\n');
    document.write('<td height="35" width="39"><img src="img0800/indx/indx_5_0.png" title="" alt="" style="width: 39px; height: 35px;"></td>\n');
    document.write('<td height="35" width="103"><img src="img0800/indx/indx_6_0.png" title="" alt="" style="width: 103px; height: ................
    document.write('<td height="31" width="21"><img src="img1024/indx/indx_15_19.png" title="" alt="" style="width: 21px; height: 31px;"></td>\n');
    }
    else if (screen.width < 1600)
    {
    document.write('<td height="59" width="18"><img src="img1280/indx/indx_0_0.png" title="" alt="" style="width: 18px; height: 59px;"></td>\n');
    document.write('<td height="59" width="72"><a href="en/index.html"><img src="img1280/indx/indx_1_0.png" title="" alt="" style="width: 72px; height: 59px;"></a></td>\n');
    document.write('<td height="59" width="127"><img src="img1280/indx/indx_2_0.png" title="" alt="" style="width: 127px; height: 59px;"></td>\n');
    document.write('<td height="59" width="53"><img src="img1280/indx/indx_3_0.png" title="" alt="" style="width: 53px; height: 59px;"></td>\n');
    document.write('<td height="59" width="46"><img src="img1280/indx/indx_4_0.png" title="" alt="" style="width: 46px; height: 59px;"></td>\n');
    document.write('<td height="59" width="64"><img src="img1280/indx/indx_5_0.png" title="" alt="" style="width: 64px; height: 59px;"></td>\n');
     .......

    Сайт с фоном из таблицы с картинками. Картинки нарезаны на мелкие кусочки и, внимание, сайт подстраивается под разные разрешения мониторов! Есть наборы картинок для ширины 800, 1024, 1280 и 1600. Посмотреть можно на http://old.abvi.redsolution.ru/

    summer.is.gone, 09 Декабря 2009

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

    +167.7

    1. 1
    $('div[id="myid"]')

    fuckyounoob, 14 Ноября 2009

    Комментарии (27)
  7. JavaScript / Говнокод #1898

    +150

    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
    var currentDate = new Date();
    var currentDay = currentDate.getDay();
    var currentMonth = currentDate.getMonth();
    var currentYear = currentDate.getYear();
    var currentHour = currentDate.getHours();
    var currentMinute = currentDate.getMinutes();
    var currentSecond = currentDate.getSeconds();
    if (currentMonth < 10) {
    	currentMonth = '0' + currentMonth;
    }
    if (currentDay < 10) {
    	currentDay = '0' + currentDay;
    }
    if (currentHour < 10) {
    	currentHour = '0' + currentHour;
    }
    if (currentMinute < 10) {
    	currentMinute = '0' + currentMinute;
    }
    if (currentSecond < 10) {
    	currentSecond = '0' + currentSecond;
    }

    говно

    Sadie, 25 Сентября 2009

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

    +53.4

    1. 1
    void (* signal(int __sig, void (* __func)(int))) (int)

    Объявление типа, представляющего собой указатель на функцию, возращающей указатель на функцию (может я не так понял?) из хедера signal.h.

    Говногость, 24 Сентября 2009

    Комментарии (27)
  9. Pascal / Говнокод #1000

    +136

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    procedure Button1Click(Sender:TObject)
      begin
      if (TreeView1.Selected<>Nil) then
        if (TreeView1.Selected.ImageIndex = 5) then
          begin
          {выбран лист дерева - обрабатываем}
          ........
          end;
      end;

    Написано мною на втором курсе. Тип узла в дереве определялся по ImageIndex - узел каждого типа имел свою картинку.

    guest, 04 Мая 2009

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

    +11.2

    1. 1
    2. 2
    3. 3
    Сделайте пожалуйста в RSS полный вариант кода,
    а то обрезается и приходится лезть на сайт, а это не удобно.
    Спасибо.

    Простите, не нашел формы обратной связи, поэтому пишу тут.

    guest, 16 Января 2009

    Комментарии (27)
  11. Си / Говнокод #318

    +15.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
    #define begin {
    #define end   }
    
    ....
    
    //==================================
    // put a big character on the screen
    // c is index into bitmap
    void video_putchar(char x, char y, char c)  
    begin 
        v7 = x;
        for (v6=0;v6<7;v6++) 
        begin
            v1 = bitmap[c][v6]; 
            v8 = y+v6;
            ...
        end
    end

    паскалист пишет на си

    guest, 31 Декабря 2008

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