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

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

    +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
    15. 15
    16. 16
    17. 17
    $(document).ready(function()
    	{
    	var flag=true;
    	$("#reg").click(function()
    		{
    			if(flag==true)
    			{
    				$("#reg2").slideUp();
    				flag=!flag;
    			}
    			else
    			{
    				$("#reg2").slideDown();
    				flag=!flag;
    			}
    	});
    });

    Новейшие технологии позволяют показывать элемент, если он скрыть и скрывать, если показан. Найдено здесь http://javascript.ru/forum/62011-post4.html

    eval, 03 Июля 2010

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

    +120

    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
    protected void GridView1_PreRender(object sender, EventArgs e)
        {         
             System.Drawing.Color OddGridColor = new System.Drawing.Color();
             OddGridColor = System.Drawing.Color.FromArgb(0xD3, 0xDE, 0xEF);
             System.Drawing.Color EvenGridColor = new System.Drawing.Color();
             EvenGridColor = System.Drawing.Color.FromArgb(0xEC, 0xE9, 0xD8);
    
                for (int i = 0; i < GridView1.Rows.Count; i++)
                {
                      if (i % 2 == 1)
                      {
                          GridView1.Rows[i].BackColor = OddGridColor;
                      }
                      else
                      {
                          GridView1.Rows[i].BackColor = EvenGridColor;
                      }
                 }
        }

    the way of change GridView color through one ...
    Why do not use <AlternatingRowStyle> ?!!

    O_O, 23 Июня 2010

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

    +164

    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
    list::list(FILE*f,FILE*f1){
        first=(starosta*)new student;
        rea=first;
        int i=0,j;
        for(j=0;j<5;j++){
            if (i) {
                rea->next=(starosta*)new student;
                rea=rea->next;
            }
            i=1;
            fscanf(f,"%d",&(rea->num));
            fscanf(f,"%s",rea->fam);
            fscanf(f,"%d",&(rea->stip));
            rea->flag=0;
        }
        cur=(starosta*)rea;
        for(j=0;j<3;j++){
            cur->next=new starosta;
            cur=(starosta*)cur->next;
            cur->flag=1;
            fscanf(f1,"%d",&(cur->num));
            fscanf(f1,"%s",cur->fam);
            fscanf(f1,"%d",&(cur->stip));
            fscanf(f1,"%d",&(cur->kolvo));
            cur->next=NULL;
        }
    }

    классный конструктор... тут много приколов

    tony, 22 Июня 2010

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

    +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
    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
    // ==UserScript==
    // @name           govnokod.ru.user.js
    // @description    highlight for new comments
    // @author         [email protected]
    // @include        http://govnokod.ru/*
    // ==/UserScript==
    
    if(!jQuery.cookie)
    jQuery.cookie = function(name, value, options) {
        if (typeof value != 'undefined') { // name and value given, set cookie
            options = options || {};
            if (value === null) {
                value = '';
                options.expires = -1;
            }
            var expires = '';
            if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
                var date;
                if (typeof options.expires == 'number') {
                    date = new Date();
                    date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
                } else {
                    date = options.expires;
                }
                expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
            }
            var path = options.path ? '; path=' + (options.path) : '';
            var domain = options.domain ? '; domain=' + (options.domain) : '';
            var secure = options.secure ? '; secure' : '';
            document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
        } else { // only name given, get cookie
            var cookieValue = null;
            if (document.cookie && document.cookie != '') {
                var cookies = document.cookie.split(';');
                for (var i = 0; i < cookies.length; i++) {
                    var cookie = jQuery.trim(cookies[i]);
                    // Does this cookie string begin with the name we want?
                    if (cookie.substring(0, name.length + 1) == (name + '=')) {
                        cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                        break;
                    }
                }
            }
            return cookieValue;
        }
    };
    
    var there_href = document.location.href.match(/govnokod\.ru\/(\d+)/);
    if ( there_href ) // in topic
    	$(document).ready(function() {
    		var govnokod_n = there_href[1];
    		var cookiename = 'gk'+govnokod_n
    		var lastvisit = new Date(parseInt($.cookie(cookiename)));
    		var now = new Date();
    		var comments = $(".hcomment abbr").filter(function(index,elem) {
    			var date=new Date(elem.title.replace("T"," ").replace(/\+(\d\d):(\d\d)$/," GMT+$1$2"));
    			return date>lastvisit;
    		});
    		for (var i=0;i<comments.length;i++)
    		{
    			var elem = comments[i];
    			var header = elem.parentElement;
    			var block = elem.parentElement.parentElement;
    			block.style.background = '#FACE8D';
    			var anchor = document.createElement("a");
    			anchor.setAttribute('name','new_'+i);
    			block.insertBefore(anchor,block.firstChild);
    			
    			var prevlink = document.createElement("a");
    			if (i!=0)
    				prevlink.setAttribute('href','#new_'+(i-1));
    			prevlink.appendChild(document.createTextNode('⟵'));
    			header.insertBefore(prevlink,elem.nextSibiling);
    			
    			header.insertBefore(document.createTextNode(' '),elem.nextSibiling);
    			
    			var nextlink = document.createElement("a");
    			if (i!=comments.length-1)
    				nextlink.setAttribute('href','#new_'+(i+1));
    			nextlink.appendChild(document.createTextNode('⟶'));
    			header.insertBefore(nextlink,elem.nextSibiling);
    
    		}
    		
    		var new_comments_count = document.createElement("a");
    		if (comments.length)
    			new_comments_count.setAttribute('href','#new_0');
    		new_comments_count.appendChild(document.createTextNode(''+comments.length+' новых'));
    		var comments_count = $(".enrty-comments-count");
    		comments_count.text(comments_count.text().replace(/\)$/,', '));
    		comments_count.append(new_comments_count);
    		comments_count.append(')');
    		$.cookie(cookiename, now.valueOf(), { 'expires': 3 }); //помним, что имеется ограничение на размер куков.
    	});

    Наговнокодил подсвечивалку новых комментариев для говногод.ру. Смесь из обычного DOM и тутошнего jQuery. Сохранить как govnokod.ru.user.js. Тестировал только в опере.

    legolegs, 06 Июня 2010

    Комментарии (17)
  6. Java / Говнокод #3343

    +86

    1. 1
    2. 2
    int memory = (int)Runtime.getRuntime().freeMemory();
    if (memory < 163840) bydlophone = true;

    Встретил в коде одного мидлета.

    odd, 28 Мая 2010

    Комментарии (17)
  7. Java / Говнокод #3336

    +144

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if (digitsStr.length() < 7) {
    	return "+" + digitsStr.substring(0, 1) + "-" + digitsStr.substring(1, 2) + "-" + digitsStr.substring(2);
    } else {
    	return "+" + digitsStr.substring(0, 3) + "-" + digitsStr.substring(3, 6) + "-" + digitsStr.substring(6);
    }

    свежий кал коллеги

    Lure Of Chaos, 27 Мая 2010

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

    +169

    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
    htaccess:
    
    DirectoryIndex index.php
    RewriteEngine on
    RewriteBase /
    RewriteRule ^0.html$ style/index.php
    RewriteRule ^1.html$ style/index.php?id=register
    RewriteRule ^2.html$ style/index.php?id=download
    RewriteRule ^3.html$ style/index.php?id=top_chars
    RewriteRule ^4.html$ style/index.php?id=who_online
    RewriteRule ^5.html$ style/index.php?id=top_zeny
    RewriteRule ^6.html$ style/index.php?id=top_mvp
    RewriteRule ^7.html$ style/index.php?id=top_pvp
    RewriteRule ^8.html$ style/index.php?id=top_guild
    RewriteRule ^9.html$ style/index.php?id=who_sell_buy
    RewriteRule ^10.html$ style/index.php?id=first_class
    
    
    php:
    
    <?php
    $url = $REQUEST_URI;
    $url2 = strlen($url);
    if($url2 > 14) { 
    header("location: ./");
    exit;
    }
        
    ?>

    Комментарий от автора:

    "Да тут реврайт для того, чтобы превратить ссылки в одинаковую длину, а потом уже проверять длину ссылки, если больше нормы переадресиция на главную..."

    xynta, 26 Мая 2010

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

    +173

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    # текст сообщений об ошибке
    $errDescr[1] = NETCAT_MODERATION_MSG_ONE;
    $errDescr[2] = NETCAT_MODERATION_MSG_TWO;
    $errDescr[6] = NETCAT_MODERATION_MSG_SIX;
    $errDescr[7] = NETCAT_MODERATION_MSG_SEVEN;
    $errDescr[8] = NETCAT_MODERATION_MSG_EIGHT;
    $errDescr[21] = NETCAT_MODERATION_MSG_TWENTYONE;

    Чьорт, я обожаю этих ребят. Они мои герои.

    telnet, 21 Мая 2010

    Комментарии (17)
  10. C++ / Говнокод #3126

    +87

    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
    98. 98
    float Chislo(char *a, int i)
      {
       int j=i;
       int k=0;
       int r;
       float chis=0;
       while (a[j-1]!=' ' && a[j-1]!='>' && a[j-1]!='-' && a[j-1]!='+' && a[j-1]!='(')
         {j--;
                 //тут перегоняем символ a[j] в цифру r
          if (int(a[j]==48)) r=0;
           else if (int(a[j]==49)) r=1;
            else if (int(a[j]==50)) r=2;
             else if (int(a[j]==51)) r=3;
              else if (int(a[j]==52)) r=4;
               else if (int(a[j]==53)) r=5;
                else if (int(a[j]==54)) r=6;
                 else if (int(a[j]==55)) r=7;
                  else if (int(a[j]==56)) r=8;
                   else if (int(a[j]==57)) r=9;
                     else goto lab8;
          //ShowMessage(a[j]);
    
          chis=chis + r*pow(10,k);
          k++;
         };
       //j--;            //дальше надо обратно до точки и дольше до пробела
       while (a[j]!='.')
         {if (a[j]==' ' || a[j]==':') goto lab8;
          j++;
         };
       j++;
       r=0;
       k=-1;
       
          k--;
          j++;
         };
    
       lab8:
    
       return chis;
      }
    
    // была еще и похощая функция возвращающая результат в виде AnsiString
    
    // вот сколько переменных понадобивлось автору в более чем 700-строчной процедуре
    
    void Progon()
    {
     //
      AnsiString TempR1, TempR2, TempR3, Com,Sport,Team1,Team2, Team, URL1, URL2, page,Champ,Date;
      AnsiString day, month, year, Res, temp, otdyh1, otdyh2;
      int dat;
      //TempR1 = NMHTTP1->Body;
    
       float tot,TM,TB,bol1,bol2,srbol,ver,value,proc;
       AnsiString totS,f1S,ind1S,ind2S, f1ch1S, t_ch1S, f1ch2S, t_ch2S, f1ch3S, t_ch3S, f1ch4S, t_ch4S;
       float fora1,ind1,ind2, f1ch1, t_ch1, f1ch2, t_ch2, f1ch3, t_ch3, f1ch4, t_ch4;
       AnsiString Score1, Score2, s1ch1S, s2ch1S, s1ch2S, s2ch2S, s1ch3S, s2ch3S, s1ch4S, s2ch4S;
    
       AnsiString FIO, ScoreS, RebS, AstS, MinS, Amplua, BlkS, StlS;
       AnsiString TotalS, RebBookS, AstBookS, StlBookS, BlkBookS;
       float Total, RebBook, AstBook, BlkBook, StlBook;
       float PtssNRebsBook, PtssNAstsBook, RebsNAstsBook, PtssNRebsNAstsBook, Book3ptTeam1, Book3ptTeam2;
       int Score, count;
    
       int str1, str2, ind, indd, ig_pos;
       bool win;
    
    // В коде куча такого
    
     while (bukva2[i2]!='/') i2++;
                          i2++;
                          while (bukva2[i2]!='/') i2++;
                          i2++;
                          while (bukva2[i2]!='/') i2++;       // // обошли stl
    
    int *Ptss;
      Ptss = new int[count];
    
      int *Rebs;
      Rebs = new int[count];
    
      int *Asts;
      Asts = new int[count];
    
      int *Blks;
    
    
    while ( ! ( ((bukva[i]=='H') &&(bukva[i+1]=='o') && (bukva[i+2]=='m') && (bukva[i+3]=='e')) || ((bukva[i]=='R') &&(bukva[i+1]=='o') && (bukva[i+2]=='a') && (bukva[i+3]=='d')))) i--;
             while (bukva[i]!='a') i--;
             while ((bukva[i-1]!='>') && (bukva[i-1]!=' ')) i--;
    
    // Внутри циклов всюду работа с экселем
     else
                                 {Form1->App.OlePropertyGet("ActiveSheet").OlePropertyGet("Cells", str1, str2+14).OlePropertyGet("Font").OlePropertySet("Color", -16777216);
                                  Form1->App.OlePropertyGet("ActiveSheet").OlePropertyGet("Cells", str1, str2+15).OlePropertyGet("Font").OlePropertySet("Color", -16777216);
                                 };

    Как -то по фрилансу заказчик хотел доработать то ли парсер, то ли еще что-то (по предоставленным исходникам я так и не смог понять что это за прога, названная "Автониггер" и написанная каким -то студентом толи специально ради выноса мозгов, то ли по еще каким-то причинам вышеобозначенными выкладками, которые вполне возможно содержат в себе какойто гипнотический смысл).

    fenryr, 29 Апреля 2010

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

    +901

    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
    char * b = new char[100];
                    int Length = 0;
                    while ( a[++Length] );
                        for ( int i = 0; i<= 10; i++ )
                          {
                                b[i] = a[i];
                          }
    
    
                        for ( int i = 0; i<= Length; i++ )
                          {
                                move ( y, x+i );
                                printw ( "%c", b[i] );
                          }
                     delete b;
                     return;

    вывод строки в ncurses.
    доставляет школота?

    MyParanoya, 17 Апреля 2010

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