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

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

    +116

    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
    public delegate IEnumerable<int> ProcessStrategy();
    
            public class ProcessEventArgs: EventArgs
            {
                public ProcessStrategy { get; set; }
            }
    
            public IEnumerable<int> GetSelectedDocuments()
            {
                var args = new ProcessEventArgs();
    
                if (args.Strategy == null)
                {
                    args.Strategy = delegate()
                                        {
                                            var result = new HashSet<int>();
                                            WalkThrough(
                                                delegate(ConceptInfo concept, CancelEventArgs cargs)
                                                {
                                                    foreach (var doc in concept.Documents)
                                                        result.Add(doc);
                                                }, State.Selected);
                                            return result;
                                        };
                }
    
                return args.Strategy();
            }

    Обьявляем делегат, потом обьявляем класс от EventArgs в котором (в EventArgs!) будет передаваться этот самый делегат.
    Потом в нужном методе создаем экземпляр класса ProcessEventArgs, проверяем делегат на null - откуда он берется не null в только что созданном непонятно, но помним про прикол с Manager singleton того же автора :), присваеваем его делегату собственно код который и совершает необходимые операции, а потом....
    Потом просто вызываем свежесозданый делегат.

    eval_2009, 06 Января 2011

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

    +97

    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
    var sum,x1,x2,y1,y2,i,k,l,m,n:longint;
    a:array[1..1000,1..2] of longint;
    b:array[1..100,1..100] of longint;
    
    procedure ws(x,y,c:longint);
    var k:longint;
    begin
      if (not((x-2<1)or(y-1<1)or(x-2>n)or(y-1>N))and(b[x-2,y-1]=0)) then begin inc(m);a[m,1]:=x-2;a[m,2]:=y-1;b[x-2,y-1]:=b[x,y]+1;end;
      if (not((x+2<1)or(y-1<1)or(x+2>n)or(y-1>N))and(b[x+2,y-1]=0)) then begin inc(m);a[m,1]:=x+2;a[m,2]:=y-1;b[x+2,y-1]:=b[x,y]+1;end;
      if (not((x-1<1)or(y-2<1)or(x-1>n)or(y-2>N))and(b[x-1,y-2]=0)) then begin inc(m);a[m,1]:=x-1;a[m,2]:=y-2;b[x-1,y-2]:=b[x,y]+1;end;
      if (not((x+1<1)or(y-2<1)or(x+1>n)or(y-1>N))and(b[x+1,y-2]=0)) then begin inc(m);a[m,1]:=x+1;a[m,2]:=y-2;b[x+1,y-2]:=b[x,y]+1;end;
      if (not((x-2<1)or(y+1<1)or(x-2>n)or(y+1>N))and(b[x-2,y+1]=0)) then begin inc(m);a[m,1]:=x-2;a[m,2]:=y+1;b[x-2,y+1]:=b[x,y]+1;end;
      if (not((x+2<1)or(y+1<1)or(x+2>n)or(y+1>N))and(b[x+2,y+1]=0)) then begin inc(m);a[m,1]:=x+2;a[m,2]:=y+1;b[x+2,y+1]:=b[x,y]+1;end;
      if (not((x-1<1)or(y+2<1)or(x-1>n)or(y+2>N))and(b[x-1,y+2]=0)) then begin inc(m);a[m,1]:=x-1;a[m,2]:=y+2;b[x-1,y+2]:=b[x,y]+1;end;
      if (not((x+1<1)or(y+2<1)or(x+1>n)or(y+2>N))and(b[x+1,y+2]=0)) then begin inc(m);a[m,1]:=x+1;a[m,2]:=y+2;b[x+1,y+2]:=b[x,y]+1;end;
    end;
    
    begin
    reset(input,'input.txt');
    rewrite(output,'output.txt');
    read(n);
    read(x1,y1);
    read(x2,y2);
    b[1,1]:=0;
    a[1,1]:=x1;a[1,2]:=y1;
    i:=0;m:=1;l:=1;
    while i<=m do begin inc(i);
      ws(a[i,1],a[i,2],i);
    end;
    write(b[x2,y2]);
    close(input);
    close(output);
    end.

    вот он, венец человеческого ума - рабочий поиск в ширину без использования рекурсии, написал сам, меня очень просили запостить тут))

    faraon124, 24 Декабря 2010

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

    +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
    15. 15
    16. 16
    17. 17
    18. 18
    <?php
    switch(func_num_args())
    {
        case 1:
            $$class = new $class(func_get_arg(0));
        break;
        
        # .... 
                    
        case 7:
            $$class = new $class(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6));
        break;
                    
        default:
            $$class = new $class();
        break;
    } 
    ?>

    Боюсь подумать о 10 и более передаваемых переменных в конструктор класса

    MoLe-X, 23 Декабря 2010

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

    +104

    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
    procedure TForm1.FormCreate(Sender: TObject);   
    begin  
    RS[0]:='а'; PRS[0]:='@';   
    RS[1]:='б'; PRS[1]:='6';   
    RS[2]:='в'; PRS[2]:='B';   
    RS[3]:='г'; PRS[3]:='r';   
    RS[4]:='д'; PRS[4]:='g';   
    RS[5]:='е'; PRS[5]:='e';   
    RS[6]:='ё'; PRS[6]:='e';   
    RS[7]:='ж'; PRS[7]:='}|{';   
    RS[8]:='з'; PRS[8]:='3';   
    RS[9]:='и'; PRS[9]:='u';   
    RS[10]:='й'; PRS[10]:='u';   
    RS[11]:='к'; PRS[11]:='k';   
    RS[12]:='л'; PRS[12]:='JI';   
    RS[13]:='м'; PRS[13]:='M';   
    RS[14]:='н'; PRS[14]:='H';   
    RS[15]:='о'; PRS[15]:='o';   
    RS[16]:='п'; PRS[16]:='n';   
    RS[17]:='р'; PRS[17]:='p';   
    RS[18]:='с'; PRS[18]:='c';   
    RS[19]:='т'; PRS[19]:='T';   
    RS[20]:='у'; PRS[20]:='y';   
    RS[21]:='ф'; PRS[21]:='%';   
    RS[22]:='х'; PRS[22]:='x';   
    RS[23]:='ц'; PRS[23]:='?';   
    RS[24]:='ч'; PRS[24]:='4';   
    RS[25]:='ш'; PRS[25]:='III';   
    RS[26]:='щ'; PRS[26]:='III,';   
    RS[27]:='ъ'; PRS[27]:='b';   
    RS[28]:='ы'; PRS[28]:='bI';   
    RS[29]:='ь'; PRS[29]:='b';   
    RS[30]:='э'; PRS[30]:='&';   
    RS[31]:='ю'; PRS[31]:='I-o';   
    RS[32]:='я'; PRS[32]:='9I';   
    RS[33]:='А'; PRS[33]:='A';   
    RS[34]:='Б'; PRS[34]:='6';   
    RS[35]:='В'; PRS[35]:='B';   
    RS[36]:='Г'; PRS[36]:='r';   
    RS[37]:='Д'; PRS[37]:='g';   
    RS[38]:='Е'; PRS[38]:='E';   
    RS[39]:='Ё'; PRS[39]:='E';   
    RS[40]:='Ж'; PRS[40]:='}|{';   
    RS[41]:='З'; PRS[41]:='3';   
    RS[42]:='И'; PRS[42]:='U';   
    RS[43]:='Й'; PRS[43]:='U';   
    RS[44]:='К'; PRS[44]:='K';   
    RS[45]:='Л'; PRS[45]:='JL';   
    RS[46]:='М'; PRS[46]:='M';   
    RS[47]:='Н'; PRS[47]:='H';   
    RS[48]:='О'; PRS[48]:='O';   
    RS[49]:='П'; PRS[49]:='n';   
    RS[50]:='Р'; PRS[50]:='p';   
    RS[51]:='С'; PRS[51]:='c';   
    RS[52]:='Т'; PRS[52]:='T';   
    RS[53]:='У'; PRS[53]:='Y';   
    RS[54]:='Ф'; PRS[54]:='%';   
    RS[55]:='Х'; PRS[55]:='X';   
    RS[56]:='Ц'; PRS[56]:='?';   
    RS[57]:='Ч'; PRS[57]:='4';   
    RS[58]:='Ш'; PRS[58]:='III';   
    RS[59]:='Щ'; PRS[59]:='III,';   
    RS[60]:='Ъ'; PRS[60]:='b';   
    RS[61]:='Ы'; PRS[61]:='bI';   
    RS[62]:='Ь'; PRS[62]:='b';   
    RS[63]:='Э'; PRS[63]:='&';   
    RS[64]:='Ю'; PRS[64]:='I-O';   
    RS[65]:='Я'; PRS[65]:='9I';   
    ES[0]:='a'; PPS[0]:='@';   
    ES[1]:='b'; PPS[1]:='6';   
    ES[2]:='c'; PPS[2]:='|_|,';   
    ES[3]:='d'; PPS[3]:=',^,';   
    ES[4]:='e'; PPS[4]:='e';   
    ES[5]:='f'; PPS[5]:='%';   
    ES[6]:='g'; PPS[6]:='|"';   
    ES[7]:='h'; PPS[7]:='][';   
    ES[8]:='i'; PPS[8]:='|/|';   
    ES[9]:='j'; PPS[9]:='>|<';   
    ES[10]:='k'; PPS[10]:='K';   
    ES[11]:='l'; PPS[11]:='/\';   
    ES[12]:='m'; PPS[12]:='M';   
    ES[13]:='n'; PPS[13]:='|-|';   
    ES[14]:='o'; PPS[14]:='0';   
    ES[15]:='p'; PPS[15]:='n';   
    ES[16]:='q'; PPS[16]:='k|3';   
    ES[17]:='r'; PPS[17]:='P';   
    ES[18]:='s'; PPS[18]:='$';   
    ES[19]:='t'; PPS[19]:='T';   
    ES[20]:='u'; PPS[20]:='Y';   
    ES[21]:='v'; PPS[21]:='\/';   
    ES[22]:='w'; PPS[22]:='|3';   
    ES[23]:='x'; PPS[23]:='kc';   
    ES[24]:='y'; PPS[24]:='9';   
    ES[25]:='z'; PPS[25]:='3';   
    ES[26]:='A'; PPS[26]:='@';   
    ES[27]:='B'; PPS[27]:='6';   
    ES[28]:='C'; PPS[28]:='|_|,';   
    ES[29]:='D'; PPS[29]:=',^,';   
    ES[30]:='E'; PPS[30]:='E';   
    ES[31]:='F'; PPS[31]:='%';

    Найдено в DRKB. Double F@$EР@LM.

    Govnocoder#0xFF, 13 Декабря 2010

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

    +163

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    $('div').each(function (i) {
    if(i==0)$(this).css('display', 'none');
    else
    for(j=0;j<=1;j++)break;
    });

    Вместо $("div:first").hide();

    fuckyounoob, 08 Декабря 2010

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

    −141

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    public function getToBrick(brick:Point):void
    {
    	function f():void {
    		scale_sliderbar.position = scale_sliderbar.position;
    		view_wall.x = (brick.x * -300) * view_wall.scaleX + 150;
    		view_wall.y = (brick.y * -178) * view_wall.scaleY + 258;
    		testWallPosition();
    	}
    	f();
    	f();
    	f();
    }

    Бог любит троицу! =)
    Самое смешное, если убрать троекратный вызов f(); - то все работает как-то коряво..
    Функция testWallPosition(); проверяет min&&max координаты у стены, там также нет никаких математических просчетов.
    Хоть убейте - не пойму - но аффору +100500 за потрясный кусок кода:)

    KirAmp, 08 Декабря 2010

    Комментарии (9)
  8. C# / Говнокод #4847

    +145

    1. 1
    поставьте  пожалуйста +1 к этому говнотексту на этом говносайте. )))

    плиззз )))

    Maxim546, 07 Декабря 2010

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

    +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
    ...
    	<target name="killServer">
    	   <exec executable="pkill">
    	      <arg line=" java"/>
    	   </exec>
    	   <sleep seconds="1"/>
    	</target> 
    
    
    	<target name="zipBuild">
    	  <zip destfile="${home}/zipContent_${current.time}.zip"
           basedir="${home}/${dir}"
           update="true"
    	  />
    	</target>
    
           <target name="all" depends="killServer, zipBuild" />
    ...

    it's ant but... no ant in drop down (killing java with ant itself)

    shchavla, 06 Декабря 2010

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

    +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
    <?if (is_array($GLOBALS['cart_content'])):?>
    	<?foreach ($GLOBALS['cart_content'] as $item_id=>$odin):?>
    		<?if (isset($arResult['ITEMS'][$item_id])):?>
    			$('#product-order-<?=$item_id?>').html('<a href="/personal/cart/" class="buy" style="padding-left:20px">В корзине</a>').parent().addClass('bought');
    		<?endif;?>
    	<?endforeach;?>
    <?endif;?>
    
    
    <?if (is_array($GLOBALS['wishlist_content'])):?>
    	<?foreach ($GLOBALS['wishlist_content'] as $item_id=>$odin):?>
    		<?if (isset($arResult['ITEMS'][$item_id])):?>
    			$('#product-wishlist-<?=$item_id?>').html('<a href="/personal/wishlist/" class="reserve">Отложено</a>');
    		<?endif;?>
    	<?endforeach;?>
    <?endif;?>

    Довелось переделывать шаблон магазина на злополучном битриксе. Нашёл в старом шаблоне такую красоту, этот кусок вставляется в основной шаблон внутри тега <script>, предназначение его — на товарах которые в корзине отображать вместо ссылки купить надпись в корзине.

    sickuenser, 03 Декабря 2010

    Комментарии (9)
  11. bash / Говнокод #4797

    −145

    1. 1
    2. 2
    $ if [ "0" != "0" ]; then make i8086gui;else echo "GTK GUI is disabled - may be you lack of gtk!";fi;
    GTK GUI is disabled - may be you lack of gtk!

    Странная какая-то проверка наличия GTK в мєйкфайле...

    Anderson, 01 Декабря 2010

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