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

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

    +58.1

    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
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    switch (_Event) 
      {
      case LEVEL_EVENT_Stomp:
        if (_Param1 == 53)
        {
          Level_BeginThread(0, 500);
        }
        break;
      }
      switch (_Event) 
      {
      case LEVEL_EVENT_Stomp:
        if (_Param1 == 54)
        {
          Level_BeginThread(1, 500);
        }
        break;
      }
      switch (_Event) 
      {
      case LEVEL_EVENT_Stomp:
        if (_Param1 == 57)
        {
          Level_BeginThread(2, 500);
        }
        break;
      }
      switch (_Event) 
      {
      case LEVEL_EVENT_Stomp:
        if (_Param1 == 58)
        {
          Level_BeginThread(3, 500);
        }
        break;
      }
      switch (_Event) 
      {
      case LEVEL_EVENT_Stomp:
        if (_Param1 == 58)
        {
          Level_BeginThread(3, 500);
        }
        break;
      }
      switch (_Event) 
      {
      case LEVEL_EVENT_Stomp:
        if (_Param1 == 59)
        {
          Level_BeginThread(4, 500);
        }
        break;
      }

    Кусочек скрипта уровня одной игрушки. Вот что значит, если дизайнер не знает языка... Копипаст форева!!!АдинАдинАдин

    JohnnyIpcom, 28 Августа 2009

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

    +150.9

    1. 1
    $date = mktime(0,0,0, date("m",time()), date("d",time()), date("Y",time()));

    gorvic, 28 Августа 2009

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

    −100.4

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    {% if not has_previous %}
                   <a class="prev" style="visibility:hidden" href=?page={{ previous }} title="">prev</a>
    {% else %}
                   <a class="prev" href=?page={{ previous }} title="">prev</a>
    {% endif %}

    Django template. Написал один знакомый.

    sbb, 28 Августа 2009

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

    +158.2

    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
    var TIWRECTANGLE14IWCL;
    var TIWRECTANGLE17IWCL;
    var TIWRECTANGLE18IWCL;
    var TIWRECTANGLE19IWCL;
    var TIWRECTANGLE16IWCL;
    var TIWRECTANGLE15IWCL;
    var TIWRECTANGLE10IWCL;
    var TIWRECTANGLE12IWCL;
    var TIWRECTANGLE13IWCL;
    var TIWRECTANGLE11IWCL;
    var TIWRECTANGLE9IWCL;
    var TIWRECTANGLE7IWCL;
    var TIWRECTANGLE8IWCL;
    var TIWRECTANGLE1IWCL;
    var TIWRECTANGLE4IWCL;
    var TIWRECTANGLE6IWCL;
    var TIWRECTANGLE5IWCL;
    var TIWRECTANGLE3IWCL;
    var TIWRECTANGLE2IWCL;
    var IWEDIT1IWCL;
    function IWEDIT2_OnKeyPress(ASender) {
    return CheckReturnKey(event.keyCode, 'IWEDIT2', true);
    }

    Массивы - исчадие прих.больниц для неполноценных программистов!
    Тру говнокодер пишет так!

    Код веб-страницы на Делфи. Продолжение - http://govnokod.ru/1709

    Taqi, 28 Августа 2009

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

    +48

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    while( !InputFileStream.atEnd() )
    {
    	QString Qstrtmp;
    	InputFileStream >> Qstrtmp;
    	ReadButton.bTag =  QString(QObject::tr( (Qstrtmp.toStdString()).c_str() ));
    	InputFileStream >> Qstrtmp;
    	ReadButton.iTag =  QString(QObject::tr( (Qstrtmp.toStdString()).c_str() ));
    	InputFileStream >> Qstrtmp;
    	ReadButton.Popup =  QString(QObject::tr( (Qstrtmp.toStdString()).c_str() ));
    	ReadButton.PartitionId = *iVar;
    	this->Buttons.push_back( ReadButton );
    }

    Код взят из совместного проекта 5-ти студентов.
    Это был начальный период нашего изучения Qt.

    k06a, 26 Августа 2009

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

    −105.1

    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
    def init_images():
        rect  = [[0,0],[0,0],[0,0],[0,0],[0,0]]
        image = [[0,0],[0,0],[0,0],[0,0],[0,0]]
        
        rect[0][0], image[0][0]=load_image('box.png')
        rect[0][1], image[0][1]=load_image('box.png')
        
        rect[1][0], image[1][0]=load_image('fpoint.png')
        rect[1][1], image[1][1]=load_image('freefpoint.png')
        
        rect[2][0], image[2][0]=load_image('spoint.png')    
        rect[2][1], image[2][1]=load_image('freespoint.png')
        
        rect[3][0], image[3][0]=load_image('fbox.png')
        rect[3][0], image[3][0]=load_image('fbox.png')
        
        rect[4][0], image[4][0]=load_image('sbox.png')
        rect[4][1], image[4][1]=load_image('sbox.png')
        
        return image, rect

    Процедура загрузки изображений. Т.к. программа писалась через силу (мозги не работали), получались вот такие жуткие куски кода...

    algor_1, 25 Августа 2009

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

    +155.8

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    function ValidatorEnable(val, enable) 
    {
        val.enabled = (enable != false);
        ValidatorValidate(val);
        ValidatorUpdateIsValid();
    }

    Обратите внимание на третью строку!
    (Сначала кажется, что она ничего не делает, но на самом деле она переводит тип в boolean), но обычно пишут все-таки
    val.enabled = !!enable

    Trams, 25 Августа 2009

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

    +158

    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
    for($i=$start; $i<$end; $i++) {
            $v=$items[$idx[$i]];
        }
        $start = 0;
        $end = count($items);
        if (is_array($idx))
        {
        }
        else 
        {
         unset($idx);
         $idx[0] = 0;
        }

    Хоть и вырвано из контекста, но общая красота от этого не теряется.

    stan, 24 Августа 2009

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

    −55.1

    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
    #Пример раз
    	my %parse_hash = (
    		$sub_dir       => $dir,
    		$sub_style_dir => $style_dir,
    		$sub_image_dir => $image_dir
    	);
    
    
    #Пример два
    ...
    elsif ($event eq $Event_View_Par){
      print &ViewPar(%Query);
    }
    elsif ($event eq $Event_View_All){
      print &ViewPar(%Query);
    }
    elsif ($event eq $Event_View_Asset){
      print &ViewAsset(%Query);
    }

    Пример 1: В качестве ключей хэша переменные, которые определены в другом файле.
    Пример 2: переменные $Event_View* определены в другом, используются только здесь и больше нигде

    И так по всему коду
    Задалбывает всё время переключаться alt-табом на файл, смотреть на определение переменных

    Oleg_quadro, 20 Августа 2009

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

    −109.3

    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
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    $in{item_name}=CGI::unescape($in{item_name});
    $in{item_number}=CGI::unescape($in{item_number});
    
    #убиваем пробелы сначала, с конца и двойные
    ###
    if($in{item_name}=~/^[\s]+([\s\S]+)/) {
      $in{item_name}=$1;
    }
    if($in{item_name}=~/([\s\S]+)[\s]+$/) {
      $in{item_name}=$1;
    }
    
    $in{item_name}=~s/[\s]{2,}/ /g;
      
    if($in{item_number}=~/^[\s]+([\s\S]+)/) {
      $in{item_number}=$1;
    }
    if($in{item_number}=~/([\s\S]+)[\s]+$/) {
      $in{item_number}=$1;
    }
    
    $in{item_number}=~s/[\s]{2,}/ /g;
    ####
    
    my @select_parent=db_select_list ['title','id'],"catalog_section","parent_id=0";
    
    
    
    ###########
    my $only_this_category_text;
    my $checked_only;
    if($in{action} eq 'filter' and !$in{only_this_cat}) { $checked_only=''; } else {$checked_only="checked"; }
    
    #############################
    my $selected_list_item;
    my $only_this_cat_string;
    my @selected_only;
    my $selected_parent;
    #die $in{only_this_cat_s};
    
    
    for(@select_parent)
    {my $name="index_sel_$$_{id}";
     if($in{action} eq 'filter' and ($in{only_this_cat_s} eq $$_{id})) {$selected_only[$$_{id}]='selected'; } else { $selected_only[$$_{id}]=''; }
     if(!$in{only_this_cat_s})
     { if(!$in{action} and ($in{s} eq $$_{id})) {$selected_only[$$_{id}]='selected'; } else { $selected_only[$$_{id}]=''; }
     }else{ if($in{only_this_cat_s} eq $$_{id}){ $selected_only[$$_{id}]='selected';}}
    }
    
    
    ############################
    
    
    if($in{s}) {
    
    #максимальная вложенность =3 - сформируем строку для чекбокса по-простому
      my %ha=db_select_row ['id','title','parent_id'],"catalog_section","id=$in{s}";
     if(%ha){$selected_only[$ha{parent_id}]='selected';}
    	my %parent=db_select_row ['title','parent_id'],"catalog_section","id=$ha{parent_id}";
      my %parent2=db_select_row ['title','parent_id'],"catalog_section","id=$parent{parent_id}";	
    	my $only_title=$ha{title};
    	
    	$only_title= "$parent{title} &mdash; $only_title" if %parent;
    	$only_title= "$parent2{title} &mdash; $only_title" if %parent2;
      $only_this_cat_string=""; 
    	if(%parent || %parent2) {#%ha
          $only_this_category_text=qq~
    			<span>
    			<input type="checkbox" name="only_this_cat" id="only_this_cat" $checked_only onchange="checkSelect();">
    			<label for="only_this_cat">Искать только в разделе &laquo;$only_title&raquo;</label>
    			</span>~;
    			    	
    	}
    	}
    	
    	
    $selected_list_item=qq~<select name="only_this_cat_s" id="only_this_cat_s"> <OPTION VALUE='none'>Все разделы</OPTION>~;
    										for(@select_parent)
    										{
    $selected_list_item.=qq~<OPTION VALUE='$$_{id}' $selected_only[$$_{id}]~;
    $selected_list_item.=qq~><label for="only_this_cat_s">$$_{title}</label>
                            </OPTION>~;
    										
    										}
    $selected_list_item.=qq~</select></td>~;
    $only_this_cat_string="Раздел каталога";

    Оригинальное форматирование сохранено

    nolka4, 17 Августа 2009

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