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

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

    +155

    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
    jQuery.each(elems, function(i, elem) {
                    if (typeof elem === "number") {
                        elem += "";
                    }
                    if (!elem) {
                        return;
                    }
                    if (typeof elem === "string" && !rhtml.test(elem)) {
                        elem = context.createTextNode(elem);
                    } else if (typeof elem === "string") {
                        elem = elem.replace(rxhtmlTag, fcloseTag);
                        var tag = (rtagName.exec(elem) || ["", ""])[1].toLowerCase(),
                            wrap = wrapMap[tag] || wrapMap._default,
                            depth = wrap[0],
                            div = context.createElement("div");
                        div.innerHTML = wrap[1] + elem + wrap[2];
                        while (depth--) {
                            div = div.lastChild;
                        }
                        if (!jQuery.support.tbody) {
                            var hasBody = rtbody.test(elem),
                                tbody = tag === "table" && !hasBody ? div.firstChild && div.firstChild.childNodes : wrap[1] === "<table>" && !hasBody ? div.childNodes : [];
                            for (var j = tbody.length - 1; j >= 0; --j) {
                                if (jQuery.nodeName(tbody[j], "tbody") && !tbody[j].childNodes.length) {
                                    tbody[j].parentNode.removeChild(tbody[j]);
                                }
                            }
                        }
                        if (!jQuery.support.leadingWhitespace && rleadingWhitespace.test(elem)) {
                            div.insertBefore(context.createTextNode(rleadingWhitespace.exec(elem)[0]), div.firstChild);
                        }
                        elem = jQuery.makeArray(div.childNodes);
                    }
                    if (elem.nodeType) {
                        ret.push(elem);
                    } else {
                        ret = jQuery.merge(ret, elem);
                    }
                });

    mark, 24 Июля 2011

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

    −86

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    {% if field.help_text %}
    <tr>
    <td></td>
    <td colspan="2" style="padding-top: 0px; padding-bottom: 10px;">{{ field.help_text|safe }}</td>
    <td>
    <img id="captcha_img" src="<?php echo $absolute_page_path; ?>captcha/captcha.php?ref=register"/>
    </td>
    {% endif %}

    Вот такую веселую хрень встретил в джанговских темплейтах =)

    de_orion, 23 Июля 2011

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

    +147

    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
    Рефакторинг всего сайта. 
    
    В html:
    <a class="gal" href="ссылка">
    	<p><img width="96" height="63" alt="" src="image.jpg"></p>
    	<p>Название</p>
        </a>
    
    В админке уже сделал ресайс изображений! 
    
    И вдруг оказывается  в CSS:
    .gal img {
      border: 1px solid #F4EDDC;
      display: block;
      height: 100px;
      margin: 0 auto;
      width: 160px;
    }

    Изменить дело 5 сек.. Но зло берет.

    De-Luxis, 23 Июля 2011

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

    +147

    1. 1
    sticky: <?php if(isset($gritter->sticky)) echo ($gritter->sticky?'true':'false'); else echo ('false');?>,

    часть json'а

    Lure Of Chaos, 22 Июля 2011

    Комментарии (8)
  6. Си / Говнокод #7300

    +142

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    /* Standard streams.  */
    extern struct _IO_FILE *stdin;		/* Standard input stream.  */
    extern struct _IO_FILE *stdout;		/* Standard output stream.  */
    extern struct _IO_FILE *stderr;		/* Standard error output stream.  */
    /* C89/C99 say they're macros.  Make them happy.  */
    #define stdin stdin
    #define stdout stdout
    #define stderr stderr

    А смысл?

    intelfx, 21 Июля 2011

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

    +153

    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
    function preview(e,id,b){
    		e.stopPropagation();
    		var post;
    		if(b!=board||!$('#post_'+id).attr('id')){
    		$.getJSON('/getpost/'+b+'/'+id,function(data,status){
    			if(data){
    				post=$.tmpl(postmpl, {post:data,lng:'',info:''});
    			}else{
    				post=$('<div id="post_'+id+'" class="reply poststyle"> 404 </div>');
    			}
    			post.css({display:'block', width: '450px', position: 'absolute', top: e.pageY, left: e.pageX})
    				.mouseleave(function(evt){
    					if(!/cloned_/i.test(evt.relatedTarget.id)||evt.relatedTarget.id>p.attr('id')){
    						post.remove();
    					}
    			})
    			.attr('id','cloned_'+id).appendTo($(doc.body))
    		});
    		}else{
    			post=$('#post_'+id).clone();
    			post.css({display:'block', width: '450px', position: 'absolute', top: e.pageY, left: e.pageX})
    				.mouseleave(function(evt){
    					if(!/cloned_/i.test(evt.relatedTarget.id)||evt.relatedTarget.id>p.attr('id')){
    						post.remove();
    					}
    			})
    			.attr('id','cloned_'+id).appendTo($(doc.body))
    		}
    	}

    хуита, 16 Июля 2011

    Комментарии (8)
  8. Java / Говнокод #7254

    +129

    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
    public static String forHTML(String aText){
         final StringBuilder result = new StringBuilder();
         final StringCharacterIterator iterator = new StringCharacterIterator(aText);
         char character =  iterator.current();
         while (character != CharacterIterator.DONE ){
           if (character == '<') {
             result.append("&lt;");
           }
           else if (character == '>') {
             result.append("&gt;");
           }
           else if (character == '&') {
             result.append("&amp;");
          }
           else if (character == '\"') {
             result.append("&quot;");
           }
           else if (character == '\t') {
             addCharEntity(9, result);
           }
           else if (character == '!') {
             addCharEntity(33, result);
           }
           else if (character == '#') {
             addCharEntity(35, result);
           }
           else if (character == '$') {
             addCharEntity(36, result);
           }
    ........................................
           else if (character == '|') {
             addCharEntity(124, result);
           }
           else if (character == '}') {
             addCharEntity(125, result);
           }
           else if (character == '~') {
             addCharEntity(126, result);
           }
           else {
             //the char is not a special one
             //add it to the result as is
             result.append(character);
           }
           character = iterator.next();
         }
         return result.toString();
      }

    Escape special characters for wiseguys.
    http://www.javapractices.com/topic/TopicAction.do?Id=96

    3.14159265, 15 Июля 2011

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

    +161

    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
    /*
    * Получаем категории из массива ЭКСПЕРЕМЕНТАЛЬНАЯ ФУНКЦИЯ :D
    * $fp - файл
    * $content - то что запишем
    */
    function save_conf($fp, $content) 
    {
    	$file_name = basename($fp);
    	if(!file_exists($fp))
    	{
    		file_put_contents($fp,'');
    		@chmod(ROOT . $fp, 0666 );
    	}
    	if (file_exists($fp) && $content) 
    	{
    		$fp = fopen($fp, "wb");
    		$content = "<?php
    if (!defined('ACCESS')) 
    {
        header('Location: /');
        exit;
    }
    \n\n".$content."\n";
    		fwrite($fp, $content);
    		fclose($fp);
    	}
    }

    И как же он тут получит категории остаётся загадкой, и поржать он любит в комментариях смотрю)
    * BY Toogle CMS

    nethak, 12 Июля 2011

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

    +157

    1. 1
    2. 2
    3. 3
    $a = '123456789';
    $b = str_replace('8','9',preg_replace('6','7',str_replace('1','2',str_replace('2','3',str_replace('3','4',str_replace('5','6',$a))))));
    $b = substr($b,str_replace('123456789','one|two|three|four|five|six|seven|eight|nine'$a))

    Так и не понял, чего хотел добиться автор

    substr, 11 Июля 2011

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

    +158

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    if ($category) {
            $api_categories = $category['api_categories'];
            $params['categories'] = $category['api_categories'];
    } else {
        $api_categories = array();
        foreach ($categories as $category_data) {
            $api_categories = array_merge($api_categories, $category_data['api_categories']);
        }
    }
            
    $params['categories'] = $api_categories;

    Вот нафигачил то

    striker, 07 Июля 2011

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