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

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

    +151

    1. 1
    var GetUrl = /\[(.*)\]/g.exec("$SECTION_NAME$")[1].replace(/\-/i, '~').replace(/\-/i, '~');

    фу ;(

    substr, 02 Июля 2011

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

    +155

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if($inc == true){
         $counter_val = $cat[$this->FileCounterKey] + 1;
    }else{
         $counter_val = $cat[$this->FileCounterKey] - 1;
    }

    Класс деревьев в одной русской CMS. Метод пересчитывает кол-во файлов в категории после добавления/удаления.

    Мартин, 02 Июля 2011

    Комментарии (2)
  4. Java / Говнокод #7133

    +75

    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
    <% ServicePackage servicePackage = null; %>
    	<% char fi [] = {'g', 'v', 'p'}; %>
    	<% int  ni [] = {3, 7, 11}; %>
    	
    	<% for(int i = 0; i < fi.length; i++)
    		 for(int j = 1; j <= ni[i]; j++)
    		 	{
    		 		String id = "", name = null, brief = null, price = null;
    		 		id += (char)fi[i];
    		 		if (j >= 10) 
    		 			id += (char)('0' + j / 10);
    		 		id += (char)('0' + j % 10);
    		 		
    		 		servicePackage = AllServicePackages.map.get(id);
    		 		if (servicePackage != null)
    		 		{
    		 			name = servicePackage.getName();
    		 			brief = servicePackage.getBrief();
    		 			price = servicePackage.getPrise();
    		 		}
    		 		%>
    		 <%	} %>

    Автору хотелось перебрать все эл-ты map'а.

    qweqweqwe, 02 Июля 2011

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

    +151

    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
    $currN = 0;
            $countN = count($news);        
            $currW = 0;
            $countW = count($wall);
            $time = time();
            $date = date('Y-m-d H:i:s');
    
            // Жестянка в сферическом ваккуме куба
    		foreach($lenta as $k => &$v)
    		{
    		    while (($v['DZ'] <= $news[$currN]['DZ']))
    		    {
    		        while (($news[$currN]['DZ'] <= $wall[$currW]['DZ']) && ($currW < $countW))
    		        {
    		            $this->create_time($wall[$currW]['DZ'], $time, $date);
    		            $this->display_wall($wall[$currW]);
    		            ++$currW;		            
    		        }
    		        $this->create_time($news[$currN]['DZ'], $time, $date);
    		        $this->display_news($news[$currN]);
    		        ++$currN;
    		    }
    		    $this->create_time($v['DZ'], $time, $date);
    			$this->display_lenta($v, $usr);
    		}
    		
    		while ($currN < $countN)
    		{
    		    while (($news[$currN]['DZ'] <= $wall[$currW]['DZ']) && ($currW < $countW))
    		    {
    		        $this->create_time($wall[$currW]['DZ'], $time, $date);
    		        $this->display_wall($wall[$currW]);
    		        ++$currW;
    		    }		
    		    $this->create_time($news[$currN]['DZ'], $time, $date);
    		    $this->display_news($news[$currN]);
    		    ++$currN;		
    		}
    		
    		while ($currW < $countW)
    		{
    		    $this->create_time($wall[$currW]['DZ'], $time, $date);
    		    $this->display_wall($wall[$currW]);
    		    ++$currW;
    		}

    Просто и со вкусом.

    advvzlol, 01 Июля 2011

    Комментарии (2)
  6. SQL / Говнокод #7066

    −108

    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
    function t()
    {
         setTimeout('document.getElementById("qwezxc").innerHTML+="H"',1000)
         setTimeout('document.getElementById("qwezxc").innerHTML+="e"',2000)
         setTimeout('document.getElementById("qwezxc").innerHTML+="l"',3000)
         setTimeout('document.getElementById("qwezxc").innerHTML+="l"',4000)
         setTimeout('document.getElementById("qwezxc").innerHTML+="o"',5000)
         setTimeout('document.getElementById("qwezxc").innerHTML+=","',6000)
         setTimeout('document.getElementById("qwezxc").innerHTML+="W"',7000)
         setTimeout('document.getElementById("qwezxc").innerHTML+="o"',8000)
         setTimeout('document.getElementById("qwezxc").innerHTML+="r"',9000)
         setTimeout('document.getElementById("qwezxc").innerHTML+="l"',10000)
         setTimeout('document.getElementById("qwezxc").innerHTML+="d"',11000)
    }

    yasosiska, 26 Июня 2011

    Комментарии (2)
  7. PHP / Говнокод #7051

    +147

    1. 1
    dirname(__FILE__)

    peinguin, 25 Июня 2011

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

    +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
    $this->addException(Mage::helper('dataflow')->__('Found %d rows.', $this->_countRows));
    $this->addException(Mage::helper('dataflow')->__('Starting %s :: %s', $adapterName, $adapterMethod));
    
    $batchModel->setParams($this->getVars())
        ->setAdapter($adapterName)
        ->save();
    
    // $adapter->$adapterMethod();
    
    return $this;
    
    $dom = new DOMDocument();
    // $dom->loadXML($this->getData());
    if (Mage::app()->getRequest()->getParam('files')) {
        $path = Mage::app()->getConfig()->getTempVarDir().'/import/';
        $file = $path.urldecode(Mage::app()->getRequest()->getParam('files'));
        if (file_exists($file)) {
            $dom->load($file);
        }
    } else {
    
        $this->validateDataString();
        $dom->loadXML($this->getData());
    }

    Magento 1.5 stable. после return'a идёт около 70 строк... Насладиться можно тут http://svn.magentocommerce.com/source/branches/1.5/app/code/core/Mage/Dataflow/Model/Convert/Parser/Xml/Excel.php

    message, 17 Июня 2011

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

    +131

    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
    /*здесь заданы значения листов x и y соответственно*/
    x: [...] $
    y: [...] $
    ...
    /*и понеслась*/
    xx: [-10] $
    for i in create_list(i,i, 2,length(h)) do
    	xx: append(xx, [i,i]) $
    xx: append(xx, [10]) $
    
    yy: [ first(x) ] $
    for i in create_list(i,i, 2,length(h)) do
    	yy: append(yy, [x[i-1],x[i]]) $
    yy: append(yy, [last(yy)]) $
    
    plot2d( [discrete, xx,yy] ) $

    maxima. рисуем кусочно-заданную функцию О_о

    ilardm, 31 Мая 2011

    Комментарии (2)
  10. ActionScript / Говнокод #6725

    −115

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    for(var name:String in parameters) {
    	postData = BOUNDARY(postData);
    	postData = LINEBREAK(postData);
    	bytes = 'Content-Disposition: form-data; name="' + name + '"';
    	for ( i = 0; i < bytes.length; i++ ) {
    		postData.writeByte( bytes.charCodeAt(i) );
    	}
    	postData = LINEBREAK(postData);
    	postData = LINEBREAK(postData);
    	postData.writeUTFBytes(parameters[name]);
    	postData = LINEBREAK(postData);
    }

    Еще один очень простой способ решить проблему многобайтовых кодировок :)

    wvxvw, 22 Мая 2011

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

    +143

    1. 1
    2. 2
    3. 3
    4. 4
    for (int i = 0; i < ptr->len; i++)
    {
    	*(((unsigned char *) ptr->payload) + i) = (unsigned char) toupper(*(((unsigned char *) ptr->payload) + i));
    }

    Перевод символов, находящихся в строке по адресу ptr->payload (типа void *) в верхний регистр.

    Fellrond, 21 Апреля 2011

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