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

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

    +54

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    $postitle = str_replace (' ', '-', $title);
    				$postitle = str_replace ('/', '', $postitle);
    				$postitle = str_replace ('\\', '', $postitle);
    				$postitle = str_replace (':', '', $postitle);
    				$postitle = str_replace ('<', '', $postitle);
    				$postitle = str_replace ('>', '', $postitle);
    				$postitle = str_replace ('*', '', $postitle);
    				$postitle = str_replace ('?', '', $postitle);
    				$postitle = str_replace ('|', '', $postitle);
    				$postitle = str_replace ('"', '', $postitle);
    				$postitle = preg_replace ('#\[.*?\]#isu', '', $postitle);

    aleksey, 14 Ноября 2012

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

    +43

    1. 1
    2. 2
    3. 3
    4. 4
    public static function create(AdGroupVO $vo)
    {
        UtilLog::debug('FUCK');
        ...

    avixyu, 08 Ноября 2012

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

    +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
    jQuery('#text div.catalog_light div.num input[type="text"]').spinner({max: 999, min: 1});
    jQuery('#text div.catalog_light div.num .ui-spinner-up').html('').css({'width' : '22px'}).css({'height' : '22px'});
    jQuery('#text div.catalog_light div.num .ui-spinner-down').html('').css({'width' : '22px'}).css({'height' : '22px'});
           
    jQuery('#text div.catalog_item_right div.line div.spinner input[type="text"]').spinner({max: 999, min: 1});
    jQuery('#text div.catalog_item_right div.line div.spinner .ui-spinner-up').html('').css({'width' : '22px'}).css({'height' : '22px'});
    jQuery('#text div.catalog_item_right div.line div.spinner .ui-spinner-down').html('').css({'width' : '22px'}).css({'height' : '22px'});
           
    jQuery('#text div.catalog_item_additional div.double table div.spinner input[type="text"]').spinner({max: 999, min: 1});
    jQuery('#text div.catalog_item_additional div.double table div.spinner .ui-spinner-up').html('').css({'width' : '22px'}).css({'height' : '22px'});
    jQuery('#text div.catalog_item_additional div.double table div.spinner .ui-spinner-down').html('').css({'width' : '22px'}).css({'height' : '22px'});
           
    jQuery('#text div.catalog div.content div.text div.spinner input[type="text"]').spinner({max: 999, min: 1});
    jQuery('#text div.catalog div.content div.text div.spinner .ui-spinner-up').html('').css({'width' : '22px'}).css({'height' : '22px'});
    jQuery('#text div.catalog div.content div.text div.spinner .ui-spinner-down').html('').css({'width' : '22px'}).css({'height' : '22px'});

    Zapix, 02 Ноября 2012

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

    +175

    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
    public static IEnumerable<float> Single(float from, float to, float step)
            {
                if (step <= 0.0f) step = (step == 0.0f) ? 1.0f : -step;
     
                if (from <= to)
                {
                    for (float f = from; f <= to; f += step) yield return f;
                }
                else
                {
                    for (float f = from; f >= to; f -= step) yield return f;
                }
            }
     
    public static IEnumerable<double> Double(double from, double to, double step)
            {
                if (step <= 0.0) step = (step == 0.0) ? 1.0 : -step;
     
                if (from <= to)
                {
                    for (double d = from; d <= to; d += step) yield return d;
                }
                else
                {
                    for (double d = from; d >= to; d -= step) yield return d;
                }
            }

    Такие методы накопированы для всех типов данных, которые известны поциенту.
    Но особо интересны эти джва метода

    Unlike some other programmimg languages (notably F#), C# doesn't have any built-in support for dealing with ranges of numbers. The .NET Framework does have the Enumerable.Range() method.
    - It can only deal with Int32's.
    - You can't specify a 'step' from one element of the range to the next. In effect, the step is always one. In this article, I'd therefore like to present a static Range class to deal with these deficiencies.

    http://www.c-sharpcorner.com/uploadfile/b942f9/dealing-with-ranges-of-numbers-in-C-Sharp

    3.14159265, 26 Октября 2012

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

    +63

    1. 1
    Лех, разве код <?php  CREATE DATABASE tbl_name; ?> не должен создать БД?

    Пришло в аське

    kindofbear, 18 Октября 2012

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

    +34

    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
    void
    XmlRpcDispatch::work(double timeout)
    {
        ...
        nEvents = select(maxFd+1, &inFd, &outFd, &excFd, NULL);
        ...
    }
    
    void XmlRpcDispatch::terminate() {
        ...
        XmlRpcSocket::connect(_cmd_sock, "127.0.0.1", port);
        ...
    }

    Не то чтобы говнокод, но забавный костыль. А как еще корректно выйти из select'a, ждущего входящих соединений? Создать соединение самому.

    Steve_Brown, 12 Октября 2012

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

    −102

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
           obj_l = list()
            for obj, obj_id in [(QuizQuestion, quest_id), (QuizAssigment, ass_id), (QuizQuestionAnswer, answ_id)]:
                q_set = getattr(getattr(obj, 'objects'), 'filter')(id=obj_id)
                obj_l.append(getattr(q_set, 'count')() > 0 and q_set[0] or False)
            (False in obj_l or obj_l[2].question != obj_l[0] or (user and obj_l[0].user)) and abort(IntegrityError())

    1) хер такое прочтешь
    2) для осмысления прочитанного нужно выпить
    3) за осмысление такого нужно выпить еще раз
    4) чувак узнал про getattr, хотя стоило вызвать напрямую obj.objects.filter(id=obj_id)
    5) q_set.count() > 0 and q_set[0] or false
    пятая строка поддается пониманию но катастрофически быстро начинает от этого терять смысл

    nimnull, 12 Октября 2012

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

    +55

    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
    function GetNumberOfLinks ($cat){ 
      $queue[] = intval($cat);
      $query = "select count(*) from #__jxlspp_prices  where ( 0!=0";
       while (list($key, $cat) = each($queue)) {
         $query .= " or catid = $cat";
       }
     $query = $query . " ) and published=1";
    	$database->setQuery($query);//это от Джумлы
      $result = $database->query();//и это от Джумлы
    	$val = mysql_fetch_row($result);//а это с бодуна
      return $val[0];
    
    }

    Сижу, скучаю, ковыряю очередной говносайт и, вдруг!
    Аж от души отлегло.

    virtual_cia, 07 Октября 2012

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

    −94

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    def __call__(self, *args, **kw):
        # ...
        if args and len(args) > 1 and args[0] is args[1][0]:
            # fml...
            temp = list(args)
            temp.pop(1)
            args = tuple(temp)
        return self._execute(*args, **kw)

    Быль про архитектуру.

    wvxvw, 06 Октября 2012

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

    +122

    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
    class xxxxxxxxxx
    {
    	
    	private $string_services;
    	
    	public  function init() {
    		$this->string_services  = '<script type="text/javascript" src="//yandex.st/share/share.js" charset="utf-8"></script>
    		<div class="yashare-auto-init" data-yashareL10n="ru" data-yashareType="none" data-yashareQuickServices="yaru,vkontakte,facebook,twitter,odnoklassniki,moimir,lj,friendfeed,moikrug,gplus"></div> ';
    	}
    	
    	public function run() {
    		if(empty($this->string_services))
    		{
    			$this->init();
    		}
    		echo $this->string_services;
    	}
    }

    В нашел в проекте над которым работаю.

    Vasiliy, 05 Октября 2012

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