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

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

    +160.6

    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
    // всё ещё Wakaba Extension http://userscripts.org/scripts/review/23705
    function optionValue(optionName)
    {
    	var optionsString = (doOptionsPanel) ? get_cookie('wkExtOptions') : '';
    	if (optionsString == '')
    	{
    		switch (optionName)
    		{
    			case 'doQuickReply':
    				return doQuickReply;
    				break;
    			case 'doThreadExpansion':
    				return doThreadExpansion;
    				break;
    			case 'doPostExpansion':
    				return doPostExpansion;
    				break;
    /*... еще 12 условий ... */
    			default:
    				return 0;
    		}
    	}
    	else
    	{
    		var optionsArray = optionsString.split(/,/);
    		switch (optionName)
    		{
    			case 'doQuickReply':
    				return parseInt(optionsArray[0]); // parseInt ensures that 0 is handled as an integer. lol, weak types
    				break;
    			case 'doThreadExpansion':
    				return parseInt(optionsArray[1]);
    				break;
    			case 'doPostExpansion':
    				return parseInt(optionsArray[2]);
    				break;
    /*... еще 12 условий ... */
    			default:
    				return 0;
    		}
    	}
    }

    Естественно, я бы сделал это хэшами.
    Но кому-то код, что выше понятнее...
    function optionValue(optionName)
    {
    var optionsString = (doOptionsPanel) ? get_cookie('wkExtOptions') : '';
    if(!optionsString){
    return options[optionName]; // не установлена опция - возвращается undefined
    }else{
    return defaultOptions[optionName];
    }
    }

    m1el, 14 Февраля 2010

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

    +112.1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    public IEnumerator GetEnumerator()
                {
                    for (int CurID = 0; CurID < (controls.Count + animations.Count) / 2; CurID++)
                    {
                        KeyValuePair<Control, Animation> kvp = new KeyValuePair<Control, Animation>(controls[CurID], animations[CurID]);
                        yield return kvp;
                    }       
                }

    Писал я код, и задумался. А когда очнулся - уже было это.
    ЗЫ. controls.Count == animations.Count

    psina-from-ua, 14 Февраля 2010

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

    +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
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    import java.util.*;
     
    public class Shell {
        Shell(){
                   main();
            }
            private void main(){
             boolean flag=true;
                String c;
                   while(flag){
                      c=Kernel.stdin("#");
                         String out=exec(c);
                      Kernel.stdout(out);
              }
            }
            public static String exec(String cmd){
                 String tmp="";
                  Lib_parse.line(cmd," ");
               String c=Lib_parse.get(0).toLowerCase();
                    if(c=="help"){
                        tmp.concat("uname - get the OC version \n");
                          tmp.concat("echo - echo input phraze \n");
                    }
                    if(c=="uname"){
                       tmp.concat("L2ME Kernel v1.3 - Linux 2 Java ME (c) new_user \n");
             }
                    if(c=="echo"){
                        tmp.concat(cmd.substring(4,cmd.length()-1)+"\n");
                   }
            return tmp;
         }
    }

    Правда мило? :)

    Pyth_ON, 10 Февраля 2010

    Комментарии (5)
  5. Pascal / Говнокод #2581

    +94.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
    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
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    unit uboot;
    
    	procedure boot;
    
    	begin
    
    	delay(100);
    
    	output_buffer:='Uboot v0.1'+chr(10)+'Status: ...Ready!';
    
    	uboot_shell;
    
    	end;
    
    	procedure uboot_shell;
    
    	begin
    
    	showForm;
    
    	removeCommand(enter_cmd);
    
    	input_buffer_num:=formAddString(output_buffer);
    
    	enter_cmd:=createCommand('ok', CM_ITEM, 1);
    
    	input_buffer_num:=formAddTextField('boot >>', '', 256, TF_ANY);
    
    	addCommand(enter_cmd);
    
    	repaint;
    
    	repeat
    
    	delay(100);
    
    	until getClickedCommand=enter_cmd;
    
    	uboot_parse;
    
    	end;
    
    	procedure uboot_parse;
    
    	//Получаем буфер ввода в нижнем регестре
    
    	input_buffer:=locase(formGetText(input_buffer_num));
    
    	if input_buffer='shutdown' then shutdown;
    
    	else if input_buffer='help' then output_buffer:='shutdown, help, boot, clear';
    
    	else if input_buffer='boot' then	os_boot;
    
    	else if input_buffer='clear' then clear;
    
    	else output_buffer:='Unsupported command';
    
    	uboot_shell;
    
    	end;
    
    	procedure shutdown;
    
    	begin
    
    	clearForm;
    
    	halt;
    
    	end;
    
    	procedure clear;
    
    	begin
    
    	clearForm;
    
    	output_buffer:='';
    
    	delay(100);
    
    	uboot_shell;
    
    	end;
    
    	procedure os_boot;
    
    	begin
    
    	input_buffer:='';
    
    	output_buffer:='';
    
    	clearForm;
    
    	kernel.kernel_start('');

    SieMaster, 09 Февраля 2010

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

    +176.5

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    e=0.55;
    c=e.toString().split('.')[0];
    k=e.toString().split('.')[1].substr(0, 1);
    r=parseInt(c);
    if (k > 4) r=r+1;

    Округление числа старинным индусским способом

    fuckyounoob, 09 Февраля 2010

    Комментарии (5)
  7. ActionScript / Говнокод #2557

    −184.5

    1. 1
    2. 2
    3. 3
    4. 4
    override public function toString():String
        {
            return Object(container).toString() + "." + super.toString();
        }

    Еще одно украшение Флексового фреймворка: mx.core::Repeater.
    Для тех, кто не в курсе: toString() вызываетйса автоматически когда мы пытаемся вывести информацию об объекте в консоль. (Т.е. жизненно необходим для тестирования). Свойство container у репитера радко, но может буть null, но изза того, что флексовые разработчики не категорически никогда не кастуют ничего, то это должно было бы выкинуть исключение, но, конвертация используемая в примере (вместо каста) в силу особенностей языка вместо того чтобы просто умереть с исключением создаст новый динамический объект, врезультате получим что-то типа:
    "[Object object].имяКомпонента".
    т.е. на самом деле код должен был выглядеть примерно так:

    return (this.container ? this.container.toString() + "." : "") + super.toString();

    wvxvw, 05 Февраля 2010

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

    +149.8

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    <? error_reporting(E_ALL);
    session_start();
    if (isset($_SESSION['user_id']))
    {}else{	die('Доступ закрыт, даём ссылку на авторизацию. — <a href="index.php">Авторизоваться</a>');}
    include("../blocks/bd.php");
    
    $result = mysql_query ("SELECT title, meta_d, meta_k, text FROM settings WHERE page='index'",$db);
    if(!$result)
    {
    echo "<p>запрос на выборку из базы данных не проконал. наябедняйче одминчегу, ога. <br><strong>кот ошипки:</strong></p>";
    exit(mysql_error());
    }
    if(mysql_num_rows($result)>0)
    {
    $myrow = mysql_fetch_array($result);
    }
    else 
    {
    echo "<p>инфа по запросу не может быть извлечена, в таблице нет записей наверное.</p>";
    exit();
    } 
    //cfg
    $maxmsg="600"; // Максимальное кол-во символов в сообщении   
    $back="<center>Вернитесь <a href='javascript:history.back(1)'><B>назад</B></a>"; // Удобная строка                  
    ?>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <META CONTENT="5" HTTP-EQUIV="refresh">
    <title><? echo $myrow["title"]; ?></title>
    <link href="../style.css" rel="stylesheet" type="text/css" />
    <meta name="description" content="<? echo $myrow["meta_d"]; ?>" />
    <meta name="keywords" content="<? echo $myrow["meta_k"]; ?>" />
    </head>
    
    <body>
    
    <? 	
    $t= $_SESSION['user_id'];		
    $a=1;
    $queryz = "UPDATE
    					    `users`
    					SET
    						`online`='{$a}'
    					WHERE 
    						id='$t'";		
    $sql = mysql_query($queryz) or die(mysql_error());
    	
    $querye	= mysql_query ("SELECT * FROM `users` WHERE `id`=$t LIMIT 1");			
    $sqlz = mysql_fetch_assoc($querye);
    //echo "oline = "; echo $sqlz["online"];
     ?> 
     <table width="690" border="1" align="center" bgcolor="#FFFFFF" class="main_border">
      <tr>
        <td valign="top">
    <a href="../index.php"><img src="../img/header.jpg" width="690" height="100%" border=0/></a>    </td>
      </tr>
    <tr><td align="left">
    <table border=2><tr><td>
    <table width="514" height="500" border=1>
      <tr>
        <td>
          <? if (isset($_GET['sob_id'])) {$to=$_GET['sob_id']; 
    	  $queryto = mysql_query 
    ("SELECT * FROM `users` WHERE `id` = $to");
    $sqlto = mysql_fetch_assoc($queryto);
    	  
    	  echo "чат с <b>",$sqlto["user_name"],"</b>"; echo "&nbsp id: ",$sqlto["id"];} 
    	  else {$to=2; echo "to: ",$to;} ?>
    	
    	  </td>
          </tr>
      <tr>
        <td><? $me=$sqlz["user_name"]." =>   ";
    if (!empty($_POST['message']) || isset($_POST['message']) != "") {
    $message=$me.$_POST['message'];
    $h=fopen("history/$t-$to.txt","a+");
    fwrite($h,"\r\n".$message."\n");  
    fclose($h); 
    $h=fopen("history/$t-$to.txt","a+"); 
    $a = filesize("history/$t-$to.txt"); $n =15;  $b = $n * 30;
     fseek($h,$a-$b); 
    while (!feof ($h)) {
        $content = fgets($h);
        echo $content,"<br>";
    }
    unset ($_POST['message']);
    fclose($h);} ?> </td>
        
      </tr>
      <tr>
        <td valign="bottom" height="100%"><form action="chatmy.php" method = "post">
          <textarea wrap="on" id="message" name="message" cols="60" rows="5"></textarea>
          <input type="hidden" name="to" value="<?php echo $to; ?>" />
          <input name="submit" type="submit" value="send" />
        </form></td>
      </tr>
      <tr>
        <td>e</td>

    op19, 01 Февраля 2010

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

    +148.2

    1. 1
    if (top.location != self.location) top.location = self.location;

    встретил тут
    http://1.bp.blogspot.com/_be9EPlH_ckc/SJ_Js9NcQiI/AAAAAAAAFJk/YCBnTV8devw/s1600-h/c852510e1c9beaaa718746e5e18e322e_full.jp g
    ссмотреть надо в исходный код страницы

    danilissimus, 31 Января 2010

    Комментарии (5)
  10. Куча / Говнокод #2456

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    Как корабль назовешь, как говорится...
    Кто сможет объяснить, почему пользователь sbb (т.е. я) на говнокоде присутствует 2 раза?
    
    http://www.govnokod.ru/user/92
    http://www.govnokod.ru/user/91

    sbb, 20 Января 2010

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

    +144.5

    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
    #include <iostream>
    using namespace std;
    int print_out(int num);
    int main() {
    int n;
    cout << "Введите число: " << endl;
    cin >> n;
    cout << "Целые числа до " << n << ":" << endl;
    cout << print_out(n);
    }
    int print_out(int n) {
    int i;
    for (i=1; i<n;++i)
    cout << i << " ";
    return i;
    }

    Как это работает?

    BiLLy, 18 Января 2010

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