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

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

    +119

    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
    cMap.put("Cn", new Category(1<<0));        // UNASSIGNED
                cMap.put("Lu", new Category(1<<1));        // UPPERCASE_LETTER
                cMap.put("Ll", new Category(1<<2));        // LOWERCASE_LETTER
                cMap.put("Lt", new Category(1<<3));        // TITLECASE_LETTER
                cMap.put("Lm", new Category(1<<4));        // MODIFIER_LETTER
                cMap.put("Lo", new Category(1<<5));        // OTHER_LETTER
                cMap.put("Mn", new Category(1<<6));        // NON_SPACING_MARK
                cMap.put("Me", new Category(1<<7));        // ENCLOSING_MARK
                cMap.put("Mc", new Category(1<<8));        // COMBINING_SPACING_MARK
                cMap.put("Nd", new Category(1<<9));        // DECIMAL_DIGIT_NUMBER
                cMap.put("Nl", new Category(1<<10));       // LETTER_NUMBER
                cMap.put("No", new Category(1<<11));       // OTHER_NUMBER
                cMap.put("Zs", new Category(1<<12));       // SPACE_SEPARATOR
                cMap.put("Zl", new Category(1<<13));       // LINE_SEPARATOR
                cMap.put("Zp", new Category(1<<14));       // PARAGRAPH_SEPARATOR
                cMap.put("Cc", new Category(1<<15));       // CNTRL
                cMap.put("Cf", new Category(1<<16));       // FORMAT
                cMap.put("Co", new Category(1<<18));       // PRIVATE USE
                cMap.put("Cs", new Category(1<<19));       // SURROGATE
                cMap.put("Pd", new Category(1<<20));       // DASH_PUNCTUATION
                cMap.put("Ps", new Category(1<<21));       // START_PUNCTUATION
                cMap.put("Pe", new Category(1<<22));       // END_PUNCTUATION
                cMap.put("Pc", new Category(1<<23));       // CONNECTOR_PUNCTUATION
                cMap.put("Po", new Category(1<<24));       // OTHER_PUNCTUATION
                cMap.put("Sm", new Category(1<<25));       // MATH_SYMBOL
                cMap.put("Sc", new Category(1<<26));       // CURRENCY_SYMBOL
                cMap.put("Sk", new Category(1<<27));       // MODIFIER_SYMBOL
                cMap.put("So", new Category(1<<28));       // OTHER_SYMBOL
                cMap.put("L", new Category(0x0000003E));   // LETTER
                cMap.put("M", new Category(0x000001C0));   // MARK
                cMap.put("N", new Category(0x00000E00));   // NUMBER
                cMap.put("Z", new Category(0x00007000));   // SEPARATOR
                cMap.put("C", new Category(0x000D8000));   // CONTROL
                cMap.put("P", new Category(0x01F00000));   // PUNCTUATION
                cMap.put("S", new Category(0x1E000000));   // SYMBOL
                cMap.put("LD", new Category(0x0000023E));   // LETTER_OR_DIGIT

    в целях дальнейшего бугурта у ((школоты)|(быдлокодеров)) не осиливших ((циклов)|(массивов, листов, сетов, мапов))
    source is same #3976 #3975 #3940 #3998 #3999

    3.14159265, 17 Августа 2010

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

    +110

    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
    // At the maximum, no match found
                    if (j >= cmax)
                        return false;
                    // Okay, must try one more atom
                    if (!atom.match(matcher, i, seq))
                        return false;
                    // If we haven't moved forward then must break out
                    if (i == matcher.last)
                        return false;
    
                if (type == GREEDY)
                    return match0(matcher, i, j, seq);
                else if (type == LAZY)
                    return match1(matcher, i, j, seq);
                else
                    return match2(matcher, i, j, seq);

    to be continued....

    3.14159265, 16 Августа 2010

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

    +144

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-s
    RewriteCond %{REQUEST_FILENAME} !-l
    
    RewriteRule \.(jpeg|gif|bmp|png|jpg|css|js)$ - [L]
    
    RewriteRule ^([a-z]+)$ index.php?param1=$1 [L,QSA]

    abcee, 15 Августа 2010

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

    +162

    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
    <script language="JavaScript">
    	// Если JavaScript выключен, то объявы WMLink'а не видны, след-но, обрамление 
    	// не нужно. Поэтому его заскриптуем, и рефку тоже:
    	o=document.links.length;
    	document.write("<div style='border-top:solid 2px white;border-bottom:solid 2px white;margin-top:2px;'>");
    </script>
    
    <script language="JavaScript" src="http://r1.wmlink.ru/?id=2664"></script>
    <script language=JavaScript>
    	document.write("</div>");
    	if(document.links.length>o){
    		document.write("<p style='margin:0px;font-size:8pt;font-family:Verdana;' align=right><a href='http://wmlink.ru/index.php?ref=4186' id='wmlinkref'>$$$ <i>размести такой же блок ссылок на своём сайте и получай деньги!</i></a></p>");
    	}
    </script>

    :) логика предикатов отдыхает!!!!
    http://delajdengi.ru/
    пояснения:
    строка 4 - запоминаем кол-во ссылок в документе во время загрузки документа. по документу их 5.
    строка 11 - если скриптом подгрузились еще сслыки с сервиса ВМЛИНК => JavaScript не отключен и можно JavaScript'ом обогатить население!

    А ты!? "разместил такой же блок ссылок на своём сайте и получил деньги!"

    Alfred, 13 Августа 2010

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

    +113

    1. 1
    2. 2
    3. 3
    Guid RespondentId = Guid.NewGuid();
    
    if (RespondentId != Guid.Empty)

    ReFlexOn, 11 Августа 2010

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

    +112

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    private List<String> tList = new ArrayList<String>();
                ...........
    	for (String refAttr : refAttrs) {
    		t = tag.getAttribute(refAttr);
    		if (!tList.contains(t))
    			if (isCorrect(t))
    				tList.add(t);
            }

    как-то позабыл я о Сетах

    3.14159265, 09 Августа 2010

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

    +115

    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
    public void F2()
            {
                Console.Clear();
                try
                {
                    Console.Write("Введите имя файла для добавления данных:");
                    string str1 = Console.ReadLine();
                    try
                    {
                        FileStream dd = new FileStream("C:\\" + str1 + ".txt", FileMode.Open);
                        dd.Close();
                    }
                    catch
                    {
                        Console.WriteLine(" Файл с таким именем не существует ");
                        Console.WriteLine(" Будет создан новый файл");
                        Console.WriteLine();
                        Console.WriteLine(" Нажмите Enter для продолжения");
                        Console.ReadLine();
                        
                    }
                    
                    Console.Clear();
                    FileStream f = new FileStream("C:\\" + str1 + ".txt", FileMode.Append);
                    StreamWriter zapis = new StreamWriter(f);
                    Console.WriteLine("вводите текст , 'стоп' для завершения");
                    string s;
                    do
                    {
                        Console.Write(": ");
                        s = Console.ReadLine();
                        if (s != "стоп")
                        {
                            s = s + "\r\n";
                            zapis.Write(s);
                        }
                    }
                    while (s != "стоп");
                    zapis.Close();
                    f.Close();
                    Console.WriteLine("Файл успешно добавлен");
                    
                }
                   
                catch
                {
                    Console.WriteLine("error");
                }
            }

    Проверка на существования файла

    Nigma143, 08 Августа 2010

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

    +167

    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
    if ($avtoritet >= 0 and $avtoritet < 5) { 
    $avtr = 'Зеленый'; 
    } 
    elseif ($avtoritet >= 5 and $avtoritet < 10) { 
    $avtr = 'Чайник'; 
    } 
    elseif ($avtoritet >= 10 and $avtoritet < 15) { 
    $avrt = 'Наш чел'; 
    } 
    elseif ($avtoritet >= 15 and $avtoritet < 20) { 
    $avtr = 'Уважаемый'; 
    } 
    elseif ($avtoritet >= 20 and $avtoritet < 30) { 
    $avtr = 'Почётный'; 
    } 
    elseif ($avtoritet >= 30 and $avtoritet < 50) { 
    $avtr = 'Вышибало'; 
    } 
    elseif ($avtoritet >= 50) { 
    $avtr = 'Независимый'; 
    } 
    else 
    { 
    if ($avtoritet1 >= 1 and $avtoritet1 < 5) { 
    $avtr = 'Салага'; 
    } 
    elseif ($avtoritet1 >= 5 and $avtoritet1 < 10) { 
    $avtr = 'Барыжко'; 
    } 
    elseif ($avtoritet1 >= 10 and $avtoritet1 < 15) { 
    $avtr = 'Кидалко'; 
    } 
    elseif ($avtoritet1 >= 15 and $avtoritet1 < 25) { 
    $avtr = 'Мего_кидало'; 
    } 
    }

    http://forum.wen.ru/?p=3&f=6&t=366964&w=htm

    GoodTalkBot, 08 Августа 2010

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

    +156

    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
    [...]
        YMaps.Events.observe(map, map.Events.Click, function (map, mEvent) {
    	if (ymap_canmark) {
    	var newtip = mapAddTip('Новая метка', '');
    	newtip.setGeoPoint(mEvent.getGeoPoint());
            newtip.openBalloon();
            newtip.closeBalloon();
    	}    
        }, map);
    [...]
    
    function mapAddTip(head, body) {
        var olay = new YMaps.Placemark(map.getCenter(), {draggable: true});
    	
        olay.isfirstlaunch = 1;
    	
        tip_links++;
        olay.edlink = tip_links;
    
        tip_dbids++;
        olay.dbid = tip_dbids;
    		
        olay.setBalloonContent("<div id='hdr-"+tip_links+"' style='font-weight:bold;'>"+head+"</div><div id='txt-"+tip_links+"'>"+
    	body+"</div><!--<div id='edit-link-"+tip_links+"'><br>[ <a href='#'>Редактировать</a> ]</div>-->");
    		
        olay.setIconContent(head);
    		
        YMaps.Events.observe(olay, olay.Events.BalloonOpen, function () {		
    	if (olay.isfirstlaunch > 0) {
        	    YMaps.jQuery('#edit-link-' + olay.edlink).bind('click', function() { EditTip(olay, this) });
    	    if (olay.isfirstlaunch == 1) { dbAddTip(olay); } 
    	    olay.isfirstlaunch = 0;
            }}, map);
    	
        YMaps.Events.observe(olay, olay.Events.BalloonClose, function () {		
    	olay.setIconContent(GetTipHead(olay));
        }, map);
    
        YMaps.Events.observe(olay, olay.Events.DragStart, function () {		
    	var ddiv = document.createElement('div');
            ddiv.style.position = 'absolute';
            var pel = document.getElementById('ui-view');
            ddiv.style.left = parseInt(pel.style.left) + parseInt(pel.style.width) - 235;
            ddiv.style.top = pel.offsetTop+5;
            ddiv.style.zIndex = '10000001';
            ddiv.style.padding = '0px';		
            ddiv.style.margin = '0px';
            ddiv.style.color = 'gray';
            ddiv.style.fontSize = '10px';
            ddiv.setAttribute('id', 'drag-coords');
            document.body.appendChild(ddiv);
        }, map);
    
        YMaps.Events.observe(olay, olay.Events.Drag, function () {		
            YMaps.jQuery('#drag-coords').html('x='+olay.getGeoPoint().getX()+'; y='+olay.getGeoPoint().getY());
        }, map);		
    
        YMaps.Events.observe(olay, olay.Events.DragEnd, function () {		
    	YMaps.jQuery('#drag-coords').remove();
            if (olay.isfirstlaunch != 1) { olay.openBalloon(); dbSaveTip(olay); olay.closeBalloon(); }
        }, map);
    
        map.addOverlay(olay);
        return olay;
    }
    
    function dbAddTip(tip) { /* [...] */
    try {
    var test = document.getElementById("m_id");
    test.setAttribute("test", "success");
    if (test.getAttribute("test") == "success") {
    
    try {
    var t_id = document.getElementById("m_id").value;
    var t_x = tip.getGeoPoint().getX();
    var t_y = tip.getGeoPoint().getY();
    var t_head = GetTipHead(tip);
    var t_body = GetTipBody(tip);
    
    var XmlHttp = newXmlHttp();
    XmlHttp.open("GET", maps_cgi+"?tip=new"+t_id+"&x="+t_x+"&y="+t_y+"&head="+t_head+"&body="+t_body, false);
    XmlHttp.send(null);
    test.parentNode.removeChild(test);
    } catch (e) {}
    
    }
    } catch (e) { }
    }
    
    function GetTipBody(tip) { return YMaps.jQuery('#txt-'+tip.edlink).html(); }
    function GetTipHead(tip) { return YMaps.jQuery('#hdr-'+tip.edlink).html(); }
    
    function dbSaveTip(tip) { 
    /*
    [...]
    */
    }

    Почти шедевральне :D http://www.virtual.donetsk.ua/serv/maps.js

    kainwinterheart, 07 Августа 2010

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

    +119

    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
    List<ArestDates> dates = new List<ArestDates>();
       ...
       ...
      #region Sort by ArestDate
            
                for (int i = 1; i < dates.Count; i++)
                {
                    for (int j = i + 1; j <= dates.Count; j++)
                    {
                        if (dates[j - 1].ArestDate < dates[i - 1].ArestDate)
                        {
                            ArestDates ads = dates[j - 1];
    
                            dates[j - 1] = dates[i - 1];
                            dates[i - 1] = ads;
                        }
                    }
                }

    Крутая сортировка :) по заявлению автора :) вместо этого ---
    dates.Sort((x, y) => DateTime.Compare(x.ArestDate, y.ArestDate)); ???

    David_M, 02 Августа 2010

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