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

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

    −864

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    SELECT COUNT(*) FROM apteka.cache_offers WHERE ORG_ID = '21963' AND `subject_id` IN (35,30052,20262,20263,20001,30488,30776,22099,22044,21982,21938,21823,
    (еще триста чисел),
    26313,26358,26478,23381,27430,26367,26418,23433,23404,23372,23289,23321,23285,23315,23282,23406,23287,
    26356,23429,23263,23349,23399,23356,23291,23346,23351,23250,23198,23194,23319,23238,23296,23259,23167,23268,23130,23052,23119,22430,23146,22315,23069,23083,23
    127,23189,23023,23014,23059,22988,23020,23007,22989,22949,22937,22939,22941,22979,22786,22842,22849,22758,22913,22919,22833,22718,22753,22779,22724,22857,2276
    8,22761,22733,22823,22759,22764,22658,22681,22674,22706,22599,22698,22667,22627,22776,22654,22655,22601,22619,22598,22694,22696,22603,22541,22570,22469,22534,
    22515,22676,22516,22477,22491,22677,22513,22421,22537,22451,22507,22482,22440,22353,22523,22422,22510,22397,22473,22348,22383,22424,22333,22380,22359,22508,22
    486,22456,22330);

    Стандартный запрос. При формировании страницы конструкция встречается многократно (>10 раз)

    deadwire, 05 Апреля 2011

    Комментарии (24)
  3. Си / Говнокод #5997

    +105

    1. 1
    int c = ((i-(i%(int)pow(10,p)))/(int)pow(10,p))%10;

    Выделение из числа I цифры, стоящей на месте P с конца.
    =>
    i = 1234, p = 2, c => 2

    danilissimus, 16 Марта 2011

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

    +120

    1. 1
    2. 2
    3. 3
    4. 4
    string tmpS;
    //идут всякие монипуляции с этой строкой
    //. . .
    tmpS.Remove(0, tmpS.Length);

    Реальный код из коммерческого продукта.

    inser, 04 Марта 2011

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

    +164

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    <?php
     $Options = file("OPTIONS.txt");
     foreach ($Options as $opt)
            {
            $opt = trim($opt);
            eval("$".$opt.";");
            }

    qbasic, 28 Февраля 2011

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

    +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
    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
    function get_sel_values(index){
                    var test = eval('typeof opt_val'+index);
                    if ( test != 'undefined' ){
                      eval('var sel_values = opt_val'+index);
                      return sel_values;
                    }
        else { return false; }
    }
    //**************************************************************
    function get_sel_text(index){
                    var test = eval('typeof opt_text'+index); 
                    if ( test != 'undefined' ){
                      eval('var sel_text = opt_text'+index);
                      return sel_text;
                    }
        else { return false; }              
    }
    //**************************************************************
    function show_select(index, lev, dv){
        if ( dv == 'jdc1'){ var tr = "jdc2";}
        if ( dv == 'jdc2'){ var tr = "jdc3";}
        if ( dv == 'jdc3'){ var tr = "jdc4";}
        var curr_sel_text = get_sel_text(index);
        var curr_sel_value = get_sel_values(index);
                    if ( curr_sel_value != false && curr_sel_text != false ){
          if ( dv == 'jdc1'){
            document.getElementById('jdc1').style.visibility = "visible";
            document.getElementById('jdc2').style.visibility = "hidden";
            document.getElementById('jdc3').style.visibility = "hidden";
            document.getElementById('jdc4').style.visibility = "hidden";
                              document.forms["form1"].elements['cc2'].length = 0;
                              document.forms["form1"].elements['cc3'].length = 0;
                              document.forms["form1"].elements['cc4'].length = 0;
                      }
          if ( dv == 'jdc2'){
            document.getElementById('jdc1').style.visibility = "visible";
            document.getElementById('jdc2').style.visibility = "visible";
            document.getElementById('jdc3').style.visibility = "hidden";
            document.getElementById('jdc4').style.visibility = "hidden";
                              document.forms["form1"].elements['cc3'].length = 0;
                              document.forms["form1"].elements['cc4'].length = 0;
                      }
          if ( dv == 'jdc3'){
            document.getElementById('jdc1').style.visibility = "visible";
            document.getElementById('jdc2').style.visibility = "visible";
            document.getElementById('jdc3').style.visibility = "visible";
            document.getElementById('jdc4').style.visibility = "hidden";
                              document.forms["form1"].elements['cc4'].length = 0;
                      }
          var count_values = curr_sel_value.length;
          var category_list = document.forms["form1"].elements[lev];
          var count_category_list = category_list.options.length;
          category_list.length = 0; 
          for (i = 0; i < count_values; i++){
            if (document.createElement){
                var newCategoryListOption = document.createElement("OPTION");
                newCategoryListOption.text = curr_sel_text[i];
                newCategoryListOption.value = curr_sel_value[i];
                (category_list.options.add) ? category_list.options.add(newCategoryListOption) : category_list.add(newCategoryListOption);
            }else{
                category_list.options[i] = new Option(curr_sel_text[i], curr_sel_value[i], false, false);
            }
          }
          document.getElementById(tr).style.visibility = "visible";
              }
                    else{
          document.getElementById(tr).style.visibility = "hidden";
                    }
      }
    //-->

    qbasic, 23 Февраля 2011

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

    +146

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    class GridPanel extends JPanel {
    
      protected Point myLocation;
    
      @Override
      public Point location() {
        return this.myLocation;
      }
    
      }

    убивал бы за такое.

    Lure Of Chaos, 07 Февраля 2011

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

    +159

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    std::ostringstream s;
    for( std::list< Candidate* >::iterator it = order_by_priority.begin(); 
    		it != order_by_priority.end(); ){
    	s << (*it)->id << "/" << priorityDesc((*it)->priority());
    	it++;
    	if( it!= order_by_priority.end() )
    		s << ", ";
    }
    return s.str();

    Странное обращение с циклом for.

    panter_dsd, 04 Февраля 2011

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

    +118

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    public class TWriteableForEach
    	{
    		public delegate void TForEachDelegate<TItem>(TItem item);
    
    		public static void Exec<TItem>(IList<TItem> itemsCollection, TForEachDelegate<TItem> forEachDelegate)
    		{
    			for (int i = 0; i < itemsCollection.Count(); ++i)
    				forEachDelegate(itemsCollection[i]);
    		}
    	} ;

    Велосипед с квадратными колёсами?

    Говногость, 03 Февраля 2011

    Комментарии (24)
  10. ActionScript / Говнокод #5334

    −117

    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
    private function formatCallResult(data : String) : URLVariables 
    {
    	try
    	{
    		var urlVariables 	: URLVariables  = new URLVariables(data);
    		MonsterDebugger.trace(this,[urlVariables.msgdesc,urlVariables.msgbody]);
    		var pattern			: RegExp 		= /\[s](.+)\[\/s\]/ig  //*new RegExp("\\[s\\]([\\w\\s]+)\\[/s\\]", "ig");*/
    		var msgdescReady	: String 		= urlVariables.msgdesc.replace(pattern, "<b>$1</b>");
    		var msgbodyReady	: String 		= urlVariables.msgbody.replace(pattern, "<b>$1</b>");
    		var pattern2		: RegExp 		= /\[n](.+)\[\/n\]/ig;
    		//TODO Write nice regexp instead !
    		urlVariables.msgdesc = msgdescReady;				
    		urlVariables.msgbody = msgbodyReady;
    		msgdescReady 		= urlVariables.msgdesc.replace(pattern2, "<b>$1</b>");	
    		msgbodyReady 		= urlVariables.msgbody.replace(pattern2, "<b>$1</b>");	
    		urlVariables.msgdesc = msgdescReady;				
    		urlVariables.msgbody = msgbodyReady;				
    		MonsterDebugger.trace(this,[urlVariables.msgdesc,urlVariables.msgbody]);
    	}
    	catch (e : Error)
    	{
    		
    	}
    	return urlVariables;
    }

    Я уже минут 10 силюсь понять, что же оно должно было делать...

    wvxvw, 19 Января 2011

    Комментарии (24)
  11. SQL / Говнокод #5321

    −858

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    FUNCTION get_yesterday
          RETURN DATE
       AS
          dd   VARCHAR2 (2);
          mm   VARCHAR2 (2);
          yy   VARCHAR2 (4);
       BEGIN
          SELECT TO_CHAR (SYSDATE - 1, 'yyyy')
            INTO yy
            FROM DUAL;
       END get_yesterday;

    Вычисляем вчерашнюю дату на PL/SQL

    mshogin, 18 Января 2011

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