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

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

    +74

    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
    public void removeFromBase()
                throws SQLException{
            for(ServiceInstance serv: getServiceInstances())
                serv.removeFromBase();
            for(Pay pay: pays)
                pay.removeFromBase();
            String query;
            PreparedStatement ps = null;
            Connection connection = null;
            try{
                connection = TIDatasource.getInstance().getConnection();
                query = "DELETE FROM orders WHERE id=?";
                ps = connection.prepareStatement(query);
                ps.setLong(1, getId());
                int res = ps.executeUpdate();
                if(res != 1)
                    throw new SQLException("Unexpected number of orders have deleted: " + res);
            }catch(SQLException sqlex){
                throw new SQLException("Can't remove order from base because of error: " + sqlex);
            }finally{
                ps.close();
                connection.close();
            }
        }

    PRIMARY KEY(`id`)

    volatile, 13 Июня 2011

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

    +166

    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)
    }

    Функция для посимвольного вывода надписи «Hello word» (каждая буква выводится с интервалом в одну секунду).

    Найдено на www.html.by.

    ZI_DAN, 11 Июня 2011

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

    +157

    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
    $blocks = $this->dsp->db->select_array("select distinct B.*, BS.ALIGN_, BS.ORDER_, BS.PARAM_, BS.HTML_CLASS as HTML_CLASS, BS.HTML_TYPE as HTML_TYPE, SC.SYS_CLASS_FILE, SC.SYS_CLASS_VARNAME, SC.SYS_CLASS_CLASSNAME,BS.EXCLUSION, BS.ID
                       from BLOCKS_SECTION BS
                       inner join BLOCKS B on (BS.BLOCKS_ID=B.BLOCKS_ID and B.STATUS=1)
                       left join SYS_CLASS SC ON SC.SYS_CLASS_ID=B.SYS_CLASS_ID
                       where $add and SITE_ID=? and B.BLOCKS_ID=? order by BS.EXCLUSION desc, BS.ORDER_",$site_id,$call_id);
           $arr_block_id = array();             
           while (!empty($blocks)) {
                   foreach ($blocks as $idx => $block) {
                           if($block['EXCLUSION']){
                                           if(!in_array($block['BLOCKS_ID'],$arr_block_id)) array_push($arr_block_id,$block['BLOCKS_ID']);
                           }else{
                                           if(!in_array($block['BLOCKS_ID'],$arr_block_id) or $block['ID'])
                                                   $ret .= $this->CallPrepareBlock($VARS,$VARS_init,$block);
                           }
                           unset($blocks[$idx]);
                        } // foreach
              } // while

    Функция, кстати называется GetOneBlock )))

    a_lebedev, 02 Июня 2011

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

    +166

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    $('#protesters-open').click(function() {
    	if ($('#protesters').hasClass('hidden'))
    	{
    		$('#protesters').removeClass('hidden');
    	}
    	else
    	{
    		$('#protesters').addClass('hidden');
    	}
    });

    http://nsk.2gis.ru/media/js/main.js
    вроде серьезная компания, а такого говна там навалом
    раз уж используется jQuery, то можно и toggleClass использовать

    Back, 31 Мая 2011

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

    +165

    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 func($microsoft,$corn)
    {
    	$tomato=array();
    	if(!isset($corn[$microsoft])) return NULL;
    	foreach($corn[$microsoft] as $potato=>$pizza)
    	{
    		$tomato[]=$pizza;
    		$wine=$this->func($microsoft.$pizza['name'].'/',$corn);
    		if($wine)
    			foreach($wine as $anchouses)
    				$tomato[]=$anchouses;
    	}
    	return $tomato; //Где мой тамат СУКА!
    }

    Функция выполняет рекурсивную сортировку масива по ассоциативному индексу.

    dvduser, 30 Мая 2011

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

    +147

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    class TTestLib
    {
    public:
      char* Name; 
      unsigned int TotalTime; 
    
      TTestLib(char* AName): TotalTime(0), Name(AName) {}
    ...
    }

    char* Name - убило.

    Try, 25 Мая 2011

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

    +77

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    protected String getResponseFaultCode(Map<String, Object> response) {
    		Object faultCode = response.get("FAULTCODE");
    		if (null != faultCode){
    			return faultCode.toString();
    			}	
    		return null;
    	}

    alopen, 25 Мая 2011

    Комментарии (15)
  9. Java / Говнокод #6688

    +147

    1. 1
    2. 2
    3. 3
    4. 4
    public boolean intersects(final Range range) {
          return (((range.indexFrom >= this.indexFrom) ? range.indexFrom : this.indexFrom) <=
            ((range.indexTo <= this.indexTo) ? range.indexTo : this.indexTo));
        }

    проверка пересечения двух диапазонов

    Lure Of Chaos, 17 Мая 2011

    Комментарии (15)
  10. Java / Говнокод #6681

    +118

    1. 1
    return EVIL_PAGE;

    извините

    3.14159265, 16 Мая 2011

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

    +162

    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 db {
        //...
        function query($sql) {
            //...
            if ($error_no) {
                display_error($error_no, $error_msg, $sql);
                throw new Exception('Error in query');
                return FALSE;
            }
            return $result;
        }
    
        function display_error($error_no, $error_msg, $sql) {
            //...
            exit;
        }
    
    }

    А я думай, какого ___ оно не перехватывается:).

    Lowezar, 12 Мая 2011

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