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

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

    −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
    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
    item1.clear();
    item2.clear();
    item3.clear();
    item4.clear();
    item5.clear();
    item6.clear();
    item7.clear();
    item8.clear();
    item9.clear();
    item10.clear();
    ...
    for each (var item:Object in acData){
    	switch (item.ageProfileIndex.toString()){
    		case "1":
    			item1.itemData = item;
    			break;
    		case "2":
    			item2.itemData = item;
    			break;
    		case "3":
    			item3.itemData = item;
    			break;
    		case "4":
    			item4.itemData = item;
    			break;
    		case "5":
    			item5.itemData = item;
    			break;
    		case "6":
    			item6.itemData = item;
    			break;
    		case "7":
    			item7.itemData = item;
    			break;
    		case "8":
    			item8.itemData = item;
    			break;
    		case "9":
    			item9.itemData = item;
    			break;
    		case "10":
    			item10.itemData = item;
    			break;
    	}
    }

    вот такая вот легко расширяемая система :)

    dimas_art, 07 Апреля 2011

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

    −99

    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
    Было (плохо):
    
    <% @collection.each_with_index do |item, counter| -%>
      <%= "<div class='group'>" if ((counter)/items_in_block).to_i*items_in_block == (counter) %>
      <%= render :partial => 'item', :locals => { :item => item} %>
      <%= "</div>" if (counter > 0 and (((counter+1)/items_in_block).to_i*items_in_block == (counter+1)) or ((counter+1) == @collection.size)) %>
    <% end -%>
    
    Стало (чуть лучше ;):
    
    <% @collection.in_groups_of(items_in_block).each do |items| %>
      <div class="group">
        <% items.each do |item| %>
          <%= render :partial => 'item', :locals => { :item => item} %>
        <% end %>
      </div>
    <% end %>

    Группировка элементов в группы div'ов.

    e2718, 07 Апреля 2011

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

    +164

    1. 1
    2. 2
    3. 3
    4. 4
    public function __destruct()
        {
            unset($this);
        }

    greevex, 07 Апреля 2011

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

    +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
    String filler = "";
      int tot = text.length();
      int til = 18 - (tot/100);
      for(int i = 0; i < tot; i++)
      {
        if(text.charAt(i) == '\n')
        {
          text = text.substring(0, i) + "<br/>" + text.substring(i+1);
          tot += 3; i += 3;
          til--;
        }
      }

    Продакшн. Форматирование текста - вставка перевода строки.

    a4060276, 05 Апреля 2011

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

    +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
    if(($n=func_num_args())>1)
    		{
    			$args=func_get_args();
    			if($n===2)
    				$object=new $type($args[1]);
    			else if($n===3)
    				$object=new $type($args[1],$args[2]);
    			else if($n===4)
    				$object=new $type($args[1],$args[2],$args[3]);
    			else
    			{
    				unset($args[0]);
    				$class=new ReflectionClass($type);
    				// Note: ReflectionClass::newInstanceArgs() is available for PHP 5.1.3+
    				// $object=$class->newInstanceArgs($args);
    				$object=call_user_func_array(array($class,'newInstance'),$args);
    			}
    		}

    yii :)

    manyrus, 04 Апреля 2011

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

    +164

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    $result = array(
                'clips' => $clips,
                'block_title' => $title,
                'clips_count' => sizeof($clips),
            );
            
            $this->view->assign('clips', $result['clips']);
            $this->view->assign('block_title', $result['block_title']);
            $this->view->assign('clips_count', $result['clips_count']);

    Оптимизируя читабельность :)

    kovel, 04 Апреля 2011

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

    +135

    1. 1
    ^(?:[^<>]*<[^<>]+>)+?[ \n\t]*Вопрос №\d+\:[ \n\t]*((?:<[^<>]+>[^<>]*)+?)(?:<table>|<table [^<>]*>)[ \n\t]*(?:<tr>|<tr [^<>]*>)[ \n\t]*(?:<td>|<td [^<>]*>)[^<>]*(?:(?:(?:(?:<div>|<div[ \n\t]*[^<>]*>)|</div>|<div[ \n\t]*?/[ \n\t]*?>)|(?:(?:<p>|<p[ \n\t]*[^<>]*>)|</p>|<p[ \n\t]*?/[ \n\t]*?>)|(?:(?:<font>|<font[ \n\t]*[^<>]*>)|</font>|<font[ \n\t]*?/[ \n\t]*?>)|(?:(?:<html>|<html[ \n\t]*[^<>]*>)|</html>|<html[ \n\t]*?/[ \n\t]*?>)|(?:(?:<body>|<body[ \n\t]*[^<>]*>)|</body>|<body[ \n\t]*?/[ \n\t]*?>)|(?:(?:<head>|<head[ \n\t]*[^<>]*>)|</head>|<head[ \n\t]*?/[ \n\t]*?>)|(?:(?:<span>|<span[ \n\t]*[^<>]*>)|</span>|<span[ \n\t]*?/[ \n\t]*?>)|(?:(?:<style>|<style[ \n\t]*[^<>]*>)|</style>|<style[ \n\t]*?/[ \n\t]*?>)|(?:(?:<title>|<title[ \n\t]*[^<>]*>)|</title>|<title[ \n\t]*?/[ \n\t]*?>)|(?:(?:<br>|<br[ \n\t]*[^<>]*>)|</br>|<br[ \n\t]*?/[ \n\t]*?>)|(?:(?:<img>|<img[ \n\t]*[^<>]*>)|</img>|<img[ \n\t]*?/[ \n\t]*?>)|(?:(?:<meta>|<meta[ \n\t]*[^<>]*>)|</meta>|<meta[ \n\t]*?/[ \n\t]*?>))[^<>]*)*Вариан

    Продолжение (8 килобайт, сюда не влазит): http://pastie.org/1750060
    Регулярка безусловно генерится, но всё равно ГК.

    burdakovd, 03 Апреля 2011

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

    +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
    function callback($html, $callback, $params = array()) { 
    /*--- cssource-mods.ucoz.ru -*/ 
    
    
    $ret = false; 
    if ($ret !== false) $html = $ret; 
    
    
    list($obj, $func) = is_array($callback) ? $callback : array(null, $callback); 
    if ($obj and is_object($obj) and method_exists($obj, $func)) { 
    $html = $obj->$func($html); 
    } elseif (function_exists($func)) { 
    $html = $func($html,$params); 
    }

    Искал как пофиксить проблему с психостатсом и новой версией php , а нашёл забавный индускод.
    Взято из http://cssource-mods.ucoz.ru/forum/67-296-1
    страна должна знать своих героеф.

    Evil_Wolf, 02 Апреля 2011

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

    +163

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    if(!$timeless) {
        if($event['_hup'] > $event['_hdn']) 
            echo $time_start; 
        else
            echo $time_start.' - '.$time_end;
    } else { 
        if($event['_hup'] > $event['_hdn']) 
            echo $time_start; 
        else 
            echo $time_start;
    }

    Я не пишу запутанный код.

    SunnyMagadan, 01 Апреля 2011

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

    +111

    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
    public List<Zone> IncludedZones {
    	get {
    		var result = new List<Zone>();
    		if (CarreerToHeap.Career.Name != null)
    			result.Add(CarreerToHeap.Career);
    		if (CarreerToHeap.UnLoading.Name != null)
    			result.Add(CarreerToHeap.UnLoading);
    
    		if (CarreerToBank.Career.Name != null)
    			result.Add(CarreerToBank.Career);
    		if (CarreerToBank.UnLoading.Name != null)
    			result.Add(CarreerToBank.UnLoading);
    
    		if (RT3110ToHeap.Career.Name != null)
    			result.Add(RT3110ToHeap.Career);
    		if (RT3110ToHeap.UnLoading.Name != null)
    			result.Add(RT3110ToHeap.UnLoading);
    
    		if (RT3110ToBank.Career.Name != null)
    			result.Add(RT3110ToBank.Career);
    		if (RT3110ToBank.UnLoading.Name != null)
    			result.Add(RT3110ToBank.UnLoading);
    
    		if (WestSubZoneToHeap.Career.Name != null)
    			result.Add(WestSubZoneToHeap.Career);
    		if (WestSubZoneToHeap.UnLoading.Name != null)
    			result.Add(WestSubZoneToHeap.UnLoading);
    
    		if (WestSubZoneToBank.Career.Name != null)
    			result.Add(WestSubZoneToBank.Career);
    		if (WestSubZoneToBank.UnLoading.Name != null)
    			result.Add(WestSubZoneToBank.UnLoading);
    
    		if (RemZone.Name != null)
    			result.Add(RemZone);
    		if (ParkingZone.Name != null)
    			result.Add(ParkingZone);
    		return result;
    	}
    }

    Охрененное свойство

    Guid, 01 Апреля 2011

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