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

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

    +154

    1. 1
    $data_move = date("d.m.Y", mktime(0, 0, 0, (int)date("m",time()), (int)date("d",time()), (int)date("Y",time())));

    Вишенка даже не в том, что афтар - кармический индус, а в том, что теоретически возможна ситуация, при которой date("m",time()) выполняется в последнюю миллисекунду предыдущего месяца, а date("d",time()) - в первую следующего.

    catgav, 03 Июня 2014

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

    +156

    1. 1
    $result['BIRTHDATE'] = (($date['day'] < 10) ? '0'.$date['day'] : $date['day']).'.'.(($date['month'] < 10) ? '0'.$date['month'] : $date['month.'] ).'.'.$date['year'];

    Пых и даты.

    bormand, 28 Мая 2014

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

    +11

    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
    QString Factory::lifeEqual(WidgetEnum::SearchWidgetSet param) {
        switch (param) {
        case WidgetEnum::station:
            return "Станция";
        case WidgetEnum::water_area:
            return "Акватория";
        case WidgetEnum::station_coordinates:
            return "Координаты станции";
        case WidgetEnum::volume_of_filtered_water:
            return "Объем отфильтрованной воды";
        case WidgetEnum::chlorophyll_a_concentration:
            return "Концентрация хлорофила а";
        case WidgetEnum::chlorophyll_b_concentration:
            return "Концентрация хлорофила b";
        case WidgetEnum::chlorophyll_c_concentration:
            return "Концентрация хлорофила c";
        case WidgetEnum::A665k:
            return "A(665k";
        case WidgetEnum::pigment_index:
            return "Индекс пигмента";
        case WidgetEnum::pheopigments:
            return "Феопигменты";
        case WidgetEnum::upholding_sample_time:
            return "Время выдержки образца";
        case WidgetEnum::concetrated_sample_volume:
            return "Объемная концентрация образца";
        case WidgetEnum::cameras_viewed_number:
            return "Качество камеры";
        case WidgetEnum::total:
            return "Общая численость";
        case WidgetEnum::total_species:
            return "Число видов в пробе";
        case WidgetEnum::total_biomass:
            return "Общая биомасса";
        case WidgetEnum::total_percent:
            return "Итоговый процент";
        case WidgetEnum::biomass_percent:
            return "Процент биомасс";
        case WidgetEnum::percentage_of_total:
            return  "Процент от общего числа";
        case WidgetEnum::percentage_of_the_total_biomass:
            return "Процент от общего числа биомассы";
        case WidgetEnum::number:
            return "Номер";
        case WidgetEnum::biomass:
            return "Биомасса";
        case WidgetEnum::total_species_in_group:
            return "Всего видов в группе";
        case WidgetEnum::name:
            return "Название";
        case WidgetEnum::name_alt:
            return "Альтернативное название";
        case WidgetEnum::name_rus:
            return "Русское название";
        case WidgetEnum::fishing_gear:
            return "Рыболовный аппарат";
        case WidgetEnum::assessment_of_zooplankton:
            return "Оценка зоопланктона";
        case WidgetEnum::date:
            return "Дата";
        case WidgetEnum::Station_water_area:
            return "";
        case WidgetEnum::groupsOfPh_name:
            return "Название группы";
        case WidgetEnum::groups:
            return "Вид";
        case WidgetEnum::error:
            return "errorA";
        case WidgetEnum::chlorinity:
            return "chlorinity";
        case WidgetEnum::density:
            return "density";
        case WidgetEnum::volume:
            return "volume";
        case WidgetEnum::o2_mg_l:
            return "o2_mg_l";
        case WidgetEnum::o2_ml_l:
            return "o2_ml_l";
        case WidgetEnum::bod5:
            return "bod5";
        case WidgetEnum::ph:
            return "ph";
        case WidgetEnum::alk:
            return "alk";
        case WidgetEnum::no2:
            return "no2";
        case WidgetEnum::no3:
            return "no3";
        case WidgetEnum::total_n:
            return "total_n";
        case WidgetEnum::po4:
            return "po4";
        case WidgetEnum::total_p:
            return "total_p";
        case WidgetEnum::si:
            return "si";
    And etc.....

    В таком духе имеется строк 300, и если бы выход здравого смысла из спячки и наличие базы данных, 50 строчек которыми все это стало, с течением времени могло бы превратиться в 1000 строк, если не больше.
    И хоть это банальный гавногод, жалко трудов и времени на него затраченных. А так хоть канет в бездне говногода, а не в бездне моего винта.

    smith599, 25 Мая 2014

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

    +78

    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
    public static String[] Filtr( String[] mas )
    		{
    			for(int i=0;i<mas.length;i++)
    			{
    				if ("А".equals(mas[i])){
    					mas[i] = "а";
    				}
    				if ("Б".equals(mas[i])){
    					mas[i] = "б";
    				}
    				if ("В".equals(mas[i])){
    					mas[i] = "в";
    				}
    				if ("Г".equals(mas[i])){
    					mas[i] = "г";
    				}
    				if ("Д".equals(mas[i])){
    					mas[i] = "д";
    				}
    				if ("Е".equals(mas[i])){
    					mas[i] = "е";
    				}
    				if ("Ё".equals(mas[i])){
    
    
                                    .....//и т.д.
    
    
    	                        if ("Э".equals(mas[i])){
    					mas[i] = "э";
    				}
    				if ("Ю".equals(mas[i])){
    					mas[i] = "ю";
    				}
    				if ("Я".equals(mas[i])){
    					mas[i] = "я";
    				}
    				if ("Й".equals(mas[i])){
    					mas[i] = "й";
    				}
    			}
                            for(int i=0;i<mas.length;i++)
    				{
    				
    					if(
    						(mas[i].equals("а") == false) && 
    						(mas[i].equals("б") == false) && 
    						(mas[i].equals("в") == false) && 
    						(mas[i].equals("г") == false) && 
    						(mas[i].equals("д") == false) && 
    						(mas[i].equals("е") == false) && 
    						(mas[i].equals("ё") == false) && 
    						(mas[i].equals("ж") == false) && 
    						(mas[i].equals("з") == false) &&
    						(mas[i].equals("и") == false) && 
    						(mas[i].equals("к") == false) && 
    						(mas[i].equals("л") == false) && 
    						(mas[i].equals("м") == false) && 
    						(mas[i].equals("н") == false) && 
    						(mas[i].equals("о") == false) && 
    						(mas[i].equals("п") == false) && 
    						(mas[i].equals("р") == false) && 
    						(mas[i].equals("с") == false) && 
    						(mas[i].equals("т") == false) && 
    						(mas[i].equals("у") == false) && 
    						(mas[i].equals("ф") == false) && 
    						(mas[i].equals("х") == false) && 
    						(mas[i].equals("ц") == false) && 
    						(mas[i].equals("ч") == false) && 
    						(mas[i].equals("ш") == false) && 
    						(mas[i].equals("щ") == false) && 
    						(mas[i].equals("э") == false) && 
    						(mas[i].equals("ю") == false) && 
    						(mas[i].equals("я") == false) && 
    						(mas[i].equals("ъ") == false) && 
    						(mas[i].equals("ь") == false) && 
    						(mas[i].equals("ы") == false) && 
    						(mas[i].equals("й") == false) &&
    						(mas[i].equals(" ") == false))
    					{
    						mas = Del(mas, i);
    						i--;
    					}	;
    			for(int k=0;(k+1)<mas.length;k++)
    					{
    						if(mas[k].equals(" ") && mas[k+1].equals(" "))
    						{
    							mas = Del(mas, k);
    							k--;
    						}
    					}
    			}
    			return mas;	
    		}

    lispocoder, 18 Мая 2014

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

    +154

    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
    if($('.article-775-gallery')){
            $('.article-775-gallery').each(function(){
                get_images_by_building_gallery_id($(this).attr('id').replace(/gallery-/g,''));
            });
        }
    
        /* ************************************************************************************************************** */
    
        function get_building_details_by_property_id(id, size){
            $.get(urlprefix + "/ajax/nanar/" + id, function(data){
                var desc = jQuery.parseJSON(data);
                console.log(desc);
                if(desc.street && desc.zip && desc.town){
                    $('div[id="new-property-entry-id-' + id + '"] .house-item-head').html(desc.street + " <strong>" + desc.zip + " " + desc.town + " </strong>");
                    $('div[id="new-property-entry-id-' + id + '"] .house__item-descr').text(desc.description);
                    $('div[id="new-property-entry-id-' + id + '"] img').attr('src', desc.preview + size);
                    $('div[id="new-property-entry-id-' + id + '"] .verd').text(desc.verd);
                    $('div[id="new-property-entry-id-' + id + '"] .stard').text(desc.stard);
                    $('div[id="new-property-entry-id-' + id + '"] .tegund').text(desc.tegund);
                    $('div[id="new-property-entry-id-' + id + '"] .rooms').text(desc.rooms);
                    $('div[id="new-property-entry-id-' + id + '"]').slideDown();
                }
            });
        }
    
        if($('div[id^="new-property-entry-id-"]')){
            setTimeout(function(){
                $($('div[id^="new-property-entry-id-"]')).each(function(){
                    var size;
                    if($('div[id^="new-property-entry-id-"] div').hasClass('big-image')){
                        size = "180x140";
                        $('.new-property-entry-description').css('width','476px');
                        $('.time').css('display','block');
                    }else{size = "322x157";}
                    get_building_details_by_property_id($(this).attr('id').replace(/new-property-entry-id-/g,''), size);
                });
            },500);
        }

    код творит чудеса :), я его побоялся трогать.... знаю что функция на 9 строчке, это некое подобие шаблонизатора

    expert, 15 Мая 2014

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

    +152

    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
    protected function CreateClass($className, $params) {
    	switch (count($params)) {
    		case 0:
    			return new $className();
    			break;
    		case 1:
    			return new $className($params[0]);
    			break;
    		case 2:
    			return new $className($params[0], $params[1]);
    			break;
    		case 3:
    			return new $className($params[0], $params[1], $params[2]);
    			break;
    		case 4:
    			return new $className($params[0], $params[1], $params[2], $params[3]);
    			break;
    		case 5:
    			return new $className($params[0], $params[1], $params[2], $params[3], $params[4]);
    			break;
    		case 6:
    			return new $className($params[0], $params[1], $params[2], $params[3], $params[4], $params[5]);
    			break;
    		case 7:
    			return new $className($params[0], $params[1], $params[2], $params[3], $params[4], $params[5], $params[6]);
    			break;
    		case 8:
    			return new $className($params[0], $params[1], $params[2], $params[3], $params[4], $params[5], $params[6], $params[7]);
    			break;
    		case 9:
    			return new $className($params[0], $params[1], $params[2], $params[3], $params[4], $params[5], $params[6], $params[7], $params[8]);
    			break;
    		case 10:
    			return new $className($params[0], $params[1], $params[2], $params[3], $params[4], $params[5], $params[6], $params[7], $params[8], $params[9]);
    			break;
    		default:
    			echo "Too many arguments";
    			return null;
    			break;
    	}
    }

    Плагин Jevents для джумлы

    Itareo, 11 Мая 2014

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

    +71

    1. 1
    2. 2
    config.x = Integer.parseInt(json.get("x").toString());
    config.y = Integer.parseInt(json.get("y").toString());

    Преобразование long в int.

    Strannik1941, 07 Мая 2014

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

    +133

    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
    open System
     
    let inline un激辛カレー<'a> (f:obj) (tuple:obj) =
      match tuple with
      | :? ('a * 'a * 'a) as tuple -> 
        let a , b , c = tuple
        match f with
        | :? ('a -> 'a -> 'a -> 'a) as f -> f a b c
        | _ -> failwith "type did not matched! 3"
      | :? ('a * 'a) as tuple ->
        let a,b = tuple
        match f with
        | :? ('a -> 'a -> 'a) as f -> f a b
        | _ -> failwith "type did not matched! 2"
      | :? 'a as tuple ->
        let a = tuple
        match f with
        | :? ('a -> 'a) as f -> f a
        | _ -> failwith "type did not matched! 1"
      | _ -> failwith "type did not matched! tuple"
     
    printfn"%A"<| un激辛カレー<float> (fun x->x + 1.) 2.
    printfn"%A"<| un激辛カレー<int> (+) (10,10)
    printfn"%A"<| un激辛カレー<string> (fun (x:string) y z->x + y + z) ("How ","are ","you?")

    HaskellGovno, 03 Мая 2014

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

    +132

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    if(fileCounter < 1000){
          subDir =  "SUBDIREC.001";
          //много кода
        }else if (fileCounter < 2000 && fileCounter > 999){
          subDir =  "SUBDIREC.002";
          //много кода, плюс еще 17 таких же веток
        }else if (fileCounter < 20000 && fileCounter > 18999){
          subDir =  "SUBDIREC.020";
          //много кода
        }

    dm-ua, 30 Апреля 2014

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

    +136

    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
    SqlConnection con = new SqlConnection(connectionString);
                string sql = "SELECT idea.Id, idea.Small_text, idea.Full_text, idea.Example_text, ";
                sql = sql + " ul.FullName as Avtor, ref.Name as Status, even.date_act, (select count (*) from events ev where ev.id_action=2 and ev.id_target=idea.Id and ev.type_target=1) as CountComm, (select count (*) from events ev where ev.id_action=57 and ev.id_target=idea.Id and ev.type_target=1) as Voit, (select max(ev.date_act) from events ev where ev.id_action in (1,2,4,5,7,8,9,10,58,60,61,62,63,64,65,66,67,68,69,70,71,72,74) and ev.id_target=idea.Id and ev.type_target=1) as Last_action";
                sql = sql + " FROM Idea idea, UserLists ul, Refbook ref, Events even ";
                sql = sql + " WHERE idea.Avtor=ul.Id and idea.Status_id = ref.Id and even.id_action=1 and even.type_target=1 and even.id_target=idea.id ";
                if (id >= 0)
                    sql = sql + "  and idea.Status_id=" + id;
                if (id_avtor >= 0)
                    sql = sql + "  and idea.Avtor=" + id_avtor;
                sql = sql + " ORDER BY Last_action desc";
    
                SqlCommand cmd = new SqlCommand(sql, con);
                cmd.CommandType = CommandType.Text;
                List<Idea> Ideas = new List<Idea>();
                using (con)
                {
                    con.Open();
                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        Idea idea = GetIdeaInfo(Int32.Parse(reader["Id"].ToString()));
                        Ideas.Add(idea);
                    }
                    reader.Close();
                    return Ideas;
                }

    Принял еще один проект. ASP.NET MVC4. Автор уехал в Новую Зеландию.

    Vince, 28 Апреля 2014

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