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

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

    −853

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    SELECT a.*,r.rating_count,r.rating_sum,cc.params AS catparams,cc.title AS cattle,cc.alias AS category_alias FROM gn_content AS a INNER JOIN gn_categories AS cc ON cc.id = a.catid LEFT JOIN gn_content_rating AS r ON r.content_id = a.id WHERE a.state = 1 AND cc.published = 1 
    
                    AND ( a.publish_up = '2011-10-07 21:02:32' OR a.publish_up <= '2011-10-07 18:02:38' ) 
    
                    AND ( a.publish_down = '2011-10-07 21:02:32' OR a.publish_down >= '2011-10-07 18:02:38' ) 
    
                    AND (cc.id = 105 OR cc.id = 106 OR cc.id = 107 OR cc.id = 108 OR cc.id = 109 OR cc.id = 110 OR cc.id = 111 OR cc.id = 106 OR cc.id = 107 OR cc.id = 108 OR cc.id = 109 OR cc.id = 110 OR cc.id = 111) 
                    ORDER BY a.created DESC

    Это код модуля adinews2 для joomla

    Используются всегда только 2 даты: начало, конец

    uadeveloper, 07 Октября 2011

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

    +146

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    <?php 
    
    $sasha = new Person('Sasha', 23, array('hangover', 'sad')); 
    $sasha->walking(); 
    Sun::getInstance()->shining(); 
    $beer = $sasha->buy('beer'); 
    $sasha->drink($beer); 
    $sasha->fillingGood(); 
    include STORY_PATH.'/next/part.php';
    php?>

    Копипаст (http://vk.com/note3292968_11375263)
    Пиздец - это как ебануццо, только пиздец (с)

    QarezZ, 01 Октября 2011

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

    −84

    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
    def getListOf(points):
        i=1
        f=open('Welcome_sub.srt', 'a')
        for point in points:
                print "%d" % i
                f.write(str(i)+'\n')
                begin = point.getAttribute('begin').split(':')
                dur = point.getAttribute('dur').split(':')
                h=str( (int(begin[0])+int(dur[0])) if (int(begin[0])+int(dur[0]))>10 else '0'+str(int(begin[0])+int(dur[0])) )
                m=str(int(begin[1])+int(dur[1])) if (int(begin[1])+int(dur[1]))>10 else '0'+str(int(begin[1])+int(dur[1]))
                f.write(point.getAttribute('begin')+' --> '+''.join(h+':'+m+':'+str(float(begin[2])+float(dur[2])) )+'\n')
                print "%s -->%s" % (point.getAttribute('begin'), ''.join(h+':'+m+':'+str(float(begin[2])+float(dur[2])) ))
                f.write(getText(point.childNodes)+'\n')
                print "%s" % getText(point.childNodes)
                i+=1

    nyators, 30 Сентября 2011

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

    +159

    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
    var resizeTimer,calWidth,$BlockPath,widthLeftPart,widthRightPart,count;
    var $headBlock = $('div.hdr');
    var $rightBlock = $('li.userFullName');
    var $leftBlock = $('li.subMenu-title');
    
    $(document).ready(resizeLabels);
    $(window).resize(resizeLabels);
    
    function doResizeLabels($typeBlock) {
            count = 2;
            resultWidth = 0;
            if ($typeBlock==$leftBlock) {
                    $BlockPath=$('ul.subMenu li:not(.subMenu-title)');
            } else {
                    $BlockPath=$('ul.usersLink li:not(.userFullName)');
            };    
            $BlockPath.each(function() {
            eachPosition = $(this).position(); 
            eachWidth = $(this).width();  
            eachOuterWidth = $(this).outerWidth();
            count++;
            if ($typeBlock==$leftBlock) {
                    widthLeftPart = eachPosition.left + eachWidth;
                    widthPadding = eachOuterWidth - eachWidth;
            } else {
                    if (count==3) widthPadding = eachPosition.left;
                    widthRightPart = widthRightPart + eachOuterWidth;
            };              
            });    
            if ($typeBlock==$leftBlock) {
                    widthLeftPart = widthLeftPart + ((widthPadding / 2) * count);
                    resultWidth = headWidth/2 - widthLeftPart;
            } else {
                    rightWidth = headWidth/2 - widthRightPart;
                    resultWidth = rightWidth-(headWidth/2-widthPadding/2)/2;
            };        
            $typeBlock.width(resultWidth);
    }
    function resizeLabels() {
            $leftBlock.width(0);
            $rightBlock.width(0);
            headWidth = $headBlock.width();
            widthLeftPart = widthRightPart = 0;        
            headWidth = $headBlock.width();
            
            doResizeLabels($leftBlock);
            doResizeLabels($rightBlock);				
    };

    Serious_Andy, 30 Сентября 2011

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

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    $c = (int)(bool)$_POST['chat'];
    
    // через сто строк
    
    $q = 'UPDATE ....., `chat`='.$c.' WHERE ....';

    интригующе

    jokz, 16 Сентября 2011

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

    −84

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    $sth = $dbh->prepare("select *,DATE(DTime),DATE(RDTime),MONTH(DTime),DAY(DTime),HOUR(DTime),MINUTE(DTime),UNIX_TIMESTAMP(DTime) 
    from tt_list where Type!=0  $where order $order");
    ...
    if ($row->{'HOUR(DTime)'}<10) {$row->{'HOUR(DTime)'}="0$row->{'HOUR(DTime)'}"};
    if ($row->{'MINUTE(DTime)'}<10) {$row->{'MINUTE(DTime)'}="0$row->{'MINUTE(DTime)'}"};
    ...
    print "...<td width=60 nowrap><img src=../images/icon_clock.gif width=16 height=16 border=0>
     $row->{'HOUR(DTime)'}:$row->{'MINUTE(DTime)'}</td>...";

    Выводим время...

    Raynor, 07 Сентября 2011

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

    +160

    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
    function addParam(iId)
    {   
        var sData = '';
    
        //Контрольная работа
        if (iId==1) 
            sData = '';
        // Реферат
        else if (iId==2) 
            sData = '';
        // Курсовая
        else if (iId==3) 
            sData = '';
        // Решение задач
        else if (iId==4) 
            sData = '';
        else {
            $('#addParam').hide().html('');
            return false;
        }
        
        $('#addParam').html('').append('<td colspan="2">'+sData+'</td>').show();
    }

    lot's of code, govnocode, govnocode, govnocode...

    kaspvar, 02 Сентября 2011

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

    +138

    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
    error LNK2001: unresolved external symbol "private: static class std::map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class 
    std::map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class
     std::map<__int64,class k3bufferblock,struct std::less<__int64>,class std::allocator<struct 
    std::pair<__int64 const ,class k3bufferblock> > >,struct std::less<class std::basic_string<char,struct 
    std::char_traits<char>,class std::allocator<char> > >,class std::allocator<struct std::pair<class 
    std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class 
    std::map<__int64,class k3bufferblock,struct std::less<__int64>,class std::allocator<struct 
    std::pair<__int64 const ,class k3bufferblock> > > > > >,struct std::less<class 
    std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class 
    std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class 
    std::allocator<char> > const ,class std::map<class std::basic_string<char,struct 
    std::char_traits<char>,class std::allocator<char> >,class std::map<__int64,class k3bufferblock,struct 
    std::less<__int64>,class std::allocator<struct std::pair<__int64 const ,class k3bufferblock> > >,struct 
    std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > 
    >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class 
    std::allocator<char> > const ,class std::map<__int64,class k3bufferblock,struct 
    std::less<__int64>,class std::allocator<struct std::pair<__int64 const ,class k3bufferblock> > > > > > 
    > > > k3entity_cache::buffercache" (?buffercache@k3entity_cache@@0V?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$map@V?$basic_string@DU?
    $char_traits@D@std@@V?$allocator@D@2@@std@@V?$map@_JVk3bufferblock@@U?$less@_J@std@@V?$allocator@U?$pair@$$CB_JVk3bufferblock@@@std@@@3@@2@U?$less@V?
    $basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?
    $map@_JVk3bufferblock@@U?$less@_J@std@@V?$allocator@U?$pair@$$CB_JVk3bufferblock@@@std@@@3@@2@@std@@@2@@2@U?$less@V?$basic_string@DU?
    $char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$map@V?$basic_string@DU?
    $char_traits@D@std@@V?$allocator@D@2@@std@@V?$map@_JVk3bufferblock@@U?$less@_J@std@@V?$allocator@U?$pair@$$CB_JVk3bufferblock@@@std@@@3@@2@U?$less@V?
    $basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?
    $map@_JVk3bufferblock@@U?$less@_J@std@@V?$allocator@U?$pair@$$CB_JVk3bufferblock@@@std@@@3@@2@@std@@@2@@2@@std@@@2@@std@@A)

    CPPGovno, 02 Сентября 2011

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

    +163

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    function addNewUpload()
            {
                $('#button_'+i).remove();
                i++;
                $('<div id="field_'+i+'"><input id="file_'+i+'" name="file_'+i+'" type="file"><input type="button" value="+" id="button_'+i+'" onClick="addNewUpload()"></div>').appendTo("#loadmore_files");
                $('#hidden_count').attr('value', i);
            }

    Учись, студент.

    varg242, 23 Августа 2011

    Комментарии (3)
  11. Python / Говнокод #7564

    −92

    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
    def clean_node(node, debug=False):
        """
            Этот пример скопипащен из книги
            "Как не должен выглядеть код"
        """
        if node['sub']:
            sub = []
            num = 1
            for item in node['sub']:
                i = clean_node(item, debug)
                if i:
                    sub.append(i)
                    num += i['num']
            node['sub'] = sub
            node['num'] = num
        else:
            node['num'] = 1
        if node['deleted']:
            if node['sub']:
                return node
        else:
            return node
    
        return None

    Мне достался в наследство большой проект, в котором порой встречается вот такое. Единственное, что радует это подобные комментарии )

    kvex, 17 Августа 2011

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