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

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

    −139

    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
    #!/usr/bin/perl -w
    
    use strict;
    use warnings;
    use diagnostics;
    use LWP::Simple;
    
    binmode(STDOUT, ":utf8");
    
    my $url = 'http://govnokod.ru/comments';
    my $document = get $url;  die "Couldn't get $url" unless defined $document;
    $document =~ s/\n/ /g;
    $document =~ s/\h+/ /g;
    my @arr = ( $document =~ m/(?<=\<strong class="entry-author">)(.*?)(?<=\<a class="answer")/gi );
    my $str;
    my @sink;
    
    foreach my $val (@arr) {
    	$val =~ m/(?<=\>)(.*?)(?=\<\/a\>)/i;
    	$str = "Author:    ".$1;
    	$val =~ m/(?<=published" title\=")(.*?)(?=")/i;
    	( my $dt, my $tm ) = split('T', $1);
    	$str = $str . "\nDate:      " . $dt;
    	$str = $str . "\nTime:      " . $tm;
    	$val =~ m/(?<=\<\/abbr\> \<a href\=")(.*?)(?=" name\=)/i;
    	$str = $str."\nLink:      ". $1;
    	$val =~ m/(?<=\<div class\="entry-comment">)(.*?)(?=\<\/div\>)/i;
    	$str = $str . "\nComment:   " . str_formater($1);
    	push(@sink, $str);
    }
    
    @sink = reverse (@sink);
    foreach my $v (@sink) {
    	print ("\n".("+" x 81)."\n"."$v\n");
    }
    print ("\n".("+" x 81)."\n\n");
    
    sub str_formater {
    	my $str = $_[0];
    	my $res="";
    	my $cmt_len = 69;
    	my $cmt_indent = 11;
    	while (1) {
    		if (length($str)<=$cmt_len) {
    			return $res . $str;
    		}
    		$res = $res . substr($str,0, $cmt_len) . "\n" . (" " x $cmt_indent);
    		$str = substr($str, $cmt_len);
    	}
    	return $res;
    }
    exit 0;

    Давненько перловку не заваривал...

    sayidandrtfm, 06 Августа 2012

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

    +62

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    public synchronized void changePassword(String password, int id){
    		try {
    			Connection conn = Db.getInstance().createConnection();
    			Statement stmt = conn.createStatement();
    			String sql = "UPDATE "+tableName+"SET `password` ='"+password+"' WHERE `userId` ="+id+"";
    			stmt.executeUpdate(sql);
    		}
    		catch(Exception ex){
    			Logger.writeToFile("Exception occured " + ex.toString());
    		}
    	}

    Типичная лаба

    qsort, 30 Июля 2012

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

    −108

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    - (void)setValue:(NSString *)value
    {
        if(value != _value)
        {
            [_value release];
            
            if (value)
                 _value = [value retain];
        }
    
    //Тут всякие действия еще
    }

    Седьмая строка просто убила, делаем setValue:nil и в _value у нас указатель на мусор

    notxcain, 23 Июля 2012

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

    +155

    1. 1
    element.data('selected') ? element.show() : $.noop();

    Либо человек из ассемблера пришел, либо "IF" сильно ему по жизни насолил.

    InnerJoin, 11 Июля 2012

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

    −16

    1. 1
    2. 2
    3. 3
    void setOn(const bool &on) {
        // ...
    }

    А вот чего только не встретишь в коде...

    glook, 29 Июня 2012

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

    +75

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    protected Condition parseLogicNot(Element n)
    {
       for(Object element : n.elements())
          return new ConditionLogicNot(parseCond((Element) element));
    
       log.error("Empty <not> condition in " + getCurrentFileName());
       return null;
    }

    Закинем ка для каждого по Exception'у :)

    EvSpirit, 07 Июня 2012

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

    −102

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    "ВЫБРАТЬ
     |	Вопросы.Ссылка,
     |	Вопросы.Вопрос,
     |	Вопросы1.Код
     |ИЗ
     |	Справочник.Вопросы КАК Вопросы
     |		ЛЕВОЕ СОЕДИНЕНИЕ Справочник.Вопросы КАК Вопросы1
     |		ПО Вопросы.Ссылка = Вопросы1.Ссылка"

    Запросец из обработки, которую толкают (и её даже покупают) за 2к

    ilyailya, 06 Июня 2012

    Комментарии (18)
  9. Си / Говнокод #10595

    +127

    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
    if(!menu_font||!oboima_text||!info||!infoR||!infoD||!infoBR||
          !oblaka1_tex||!fon1_tex||!fon2_tex||!fon3_tex||
          !galka_tex||!galka_menu_tex||!strelka_menu_tex||!strelka_menu_D_tex||
          !znak_myasnik_tex||!znak_strelok_tex||!znak_razrushitel_tex||!znak_tehnik_tex||
          !status_opit_tex||!status_udar_tex||!status_status_tex||!opit_okno_vibora_tex||
          !okno_lvl_progress_tex||!okno_lvl_progress_red_tex||!okno_lvl_progress_green_tex||!okno_lvl_polzunok_tex||
          !snd||!ak_reload1||!ak_reload2||!pm_fire||!pm_reload1||!pm_reload2||
          !pp19_fire||!pp19_reload1||!pp19_reload2||!fn_f2000_fire||!tt_fire||
          !mac_fire||!mac_reload1||!mac_reload2||!webley_fire||!webley_reload1||!webley_reload2||!milkor_fire||
          !fn_five_seven_fire||!winch_fire||!drob_reload1||!drob_pompa||!vzriv_grena1||
          !rocket_fire||!rocket2_fire||!rocket_polet||!rocket2_polet||
          !myaso_upalo1||!myaso_upalo2||!myaso_upalo3||!myaso_upalo4||!myaso_upalo5||!myaso_upalo6||!myaso_upalo7||
          !myaso_upalo8||
          !myaso_razriv_user1||!myaso_razriv_user2||
          !menu_sound||!menu_choose||
          !shot1||!headshot1||!headshot2||!headshot3||!headshot4||!headshot5||!headshot6||!headshot7||!headshot8||
          !ssik1||!ssik2||!ssik3|!ssik4||
          !ptenec_death1||
          !ak||!ak2||!ak_upgraded||!ak2_upgraded||!w_pm_tex||!w_pp19_vityaz_tex||!w_fn_f2000_tex||!w_fn_f2000_upgraded_tex||
          !w_tt_tex||!w_rpk_tex||!w_mac_tex||
          !w_winchester_tex||!w_winchester_anime_tex||!w_rpk47_tex||!w_glok_tex||!w_glok2_tex||!w_rgd5_tex||!w_milkor_tex||
          !w_panzer_tex||!w_panzer_out_tex||!w_webley_tex||!w_fn_five_seven_tex||!w_granata_podstvol_tex||!w_granata_panzer_tex||
          !w_qlz87_pushka_tex||!w_qlz87_trenoga_tex||!katana_udar_sleva_tex||
          !blood1_tex||!blood2_tex||!blood3_tex||!blood_shot1_tex||
          !blood_plyam1_tex||!blood_plyam2_tex||!blood_plyam3_tex||!blood_luzha1_tex||
          !blood_myaso1_tex||!blood_myaso2_tex||!blood_myaso3_tex||!blood_myaso4_tex||!blood_myaso5_tex||
          !blood_zayac_noga1_tex||!blood_zayac_noga2_tex||!blood_zayac_noga3_tex||!blood_zayac_noga4_tex||
          !blood_zayac_rebra1_tex||!blood_zayac_rebra2_tex||
          !blood_vzriv1_a_tex||!blood_vzriv1_b_tex||!blood_vzriv1_c_tex||!blood_vzriv1_d_tex||!blood_vzriv1_e_tex||
          !blood_vzriv1_e2_tex||
          !player1_myasnik_gogranata_ruka1_tex||!player1_myasnik_gogranata_ruka2_tex||
          !player1_strelok_gogranata_ruka1_tex||!player1_strelok_gogranata_ruka2_tex||
          !player1_razrushitel_gogranata_ruka1_tex||!player1_razrushitel_gogranata_ruka2_tex||    
          !player1_tehnik_gogranata_ruka1_tex||!player1_tehnik_gogranata_ruka2_tex||
          !player1_myasnik_tex||!player1_strelok_tex||!player1_razrushitel_tex||!player1_tehnik_tex||
          !player1_myasnik_ruka1_udar_sleva_tex||!player1_strelok_ruka1_udar_sleva_tex||
          !player1_razrushitel_ruka1_udar_sleva_tex||!player1_tehnik_ruka1_udar_sleva_tex||
          !player1_myasnik_ruka1_pistol_tex||!player1_strelok_ruka1_pistol_tex||
          !player1_razrushitel_ruka1_pistol_tex||!player1_tehnik_ruka1_pistol_tex||
          !player1_myasnik_ruka1_vintovka_tex||!player1_strelok_ruka1_vintovka_tex||
          !player1_razrushitel_ruka1_vintovka_tex||!player1_tehnik_ruka1_vintovka_tex||
          !player1_myasnik_ruka1_winch_tex||!player1_strelok_ruka1_winch_tex||
          !player1_razrushitel_ruka1_winch_tex||!player1_tehnik_ruka1_winch_tex||
          !player2_strelok_tex||!player2_gogranata_ruka1_tex||!player2_gogranata_ruka2_tex||
          !player2_strelok_ruka1_udar_sleva_tex||!player2_strelok_ruka1_vintovka_tex||!player2_strelok_ruka1_pistol_tex||
          !zayac_go_tex||!zayac_uhi_k_tex||!zayac_uhi_s_tex||!zayac_uhi_tex||
          !zayac_boshka_tex||!zayac_boshka_bezuh_tex||
          !volk_go_tex||!volk_trup1_a_tex||!volk_trup1_b_tex||!volk_trup1_c_tex||
          !medved_go_tex||!medved_boshka1_tex||
          !medved_trup1_a_tex||!medved_trup1_b_tex||!medved_trup1_c_tex||!medved_trup1_d_tex||!medved_trup1_e_tex||!medved_trup1_f_tex||
          !medved_trup1_a_bezboshki_tex||!medved_trup1_b_bezboshki_tex||!medved_trup1_c_bezboshki_tex||
          !medved_trup1_d_bezboshki_tex||!medved_trup1_e_bezboshki_tex||!medved_trup1_f_bezboshki_tex||
          !ptenec_go_tex||!ptenec_wait_tex||!ptenec_vpolete_tex||!ptenec_vpolete_reverse_tex||!ptenec_trup1_tex||
          !ptenec_boshka_vzriv1_a_tex||!ptenec_boshka_vzriv1_b_tex||!ptenec_boshka_vzriv1_c_tex||
          !ptenec_boshka_vzriv1_d_tex||!ptenec_boshka_vzriv1_e_tex||
          !RPG_healer_tex||!RPG_illusionist_tex||!RPG_teleporter_tex||
          !bonus_shilo_tex||!bonus_this_tex||
          !bonus_shilo_text_tex||!bonus_this_text_tex||!bonus_daun_text_tex||!bonus_ulitka_text_tex||!bonus_umnik_text_tex||
          !bonus_shilo_status_tex||!bonus_daun_status_tex||!bonus_ulitka_status_tex||!bonus_umnik_status_tex||
          !zayac_trup1_a_tex||!zayac_trup1_b_tex||!zayac_trup1_c_tex||!zayac_trup1_d_tex||
          !zayac_trup1_a_bezuh_tex||!zayac_trup1_b_bezuh_tex||!zayac_trup1_c_bezuh_tex||!zayac_trup1_d_bezuh_tex||
          !zayac_trup1_a_bezboshki_tex||!zayac_trup1_b_bezboshki_tex||!zayac_trup1_c_bezboshki_tex||
          !zayac_trup1_d_bezboshki_tex||
          !zayac_go_bezuh_tex||!ogon1||
          !blood_ssit_tex||!RPG_healing_tex||!vzriv_grena_tex||!vzriv_ogon_grena_tex||
          !alkash1_tex||!derevo1_tex||!penek1_tex||
          !znak_polputi_tex||!polosa_finish_tex)

    Название проекта: ЩИ!!!Симулятор жестокости
    http://www.gamedev.ru/projects/forum/?id=160897

    Уверен, название выбиралось не только исходя из геймплея, но и из кода игры.

    greevex, 06 Июня 2012

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

    −30

    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
    #include <iostream>
    #include <conio.h>
    
    
    using namespace std;
    
    
    char* find(char* str)
    {
    	int i = 0, mlen=0;
    	char* minword = new char[100];
    	char* curword = new char[100];
    	while(str[i]==' ') i++;
    	mlen = i;
    	while((str[mlen]!=' ')&&(str[mlen])) mlen++;
    	mlen -= i;
    	strncpy(minword, str+i, mlen);
    	minword[mlen] = '\0';
    	i += mlen;
    	while(str[i])
    	{		
    		while(str[i]==' ') i++;
    		mlen = i;
    		while((str[mlen]!=' ')&&(str[mlen])) mlen++;
    		mlen -= i;
    		strncpy(curword, str+i, mlen);
    		curword[mlen] = '\0';
    		i += mlen;
    		
    		if(strcmp(minword, curword) > 0)
    		{
    			strcpy(minword, curword);
    		}
    	}
    	return minword;
    }
    
    void del(char*& str, char* str2)
    {
    	int i = 0, j =0, st=0;
    	char* nstr = new char[200];
    	
    	while(str[i])
    	{
    			j = 0;
    			while(str[i]==str2[j])
    			{
    				i++; j++;
    			}
    			if(j==strlen(str2))
    			{
    				strncpy(nstr, str+st, i-j);
    				nstr[i-j] = '\0';
    				st = i;
    				break;
    			}
    			i++;
    	}
    	strcat(nstr, str+st);
    	str = nstr;
    }
    
    
    void sort(char*& str)
    {
    	int len = strlen(str);
    	char* nstr = new char[200];
    	char* buf = new char[200];
    	buf = find(str);
    	strcpy(nstr, buf);
    	del(str, buf);
    	while(strlen(nstr) != len)
    	{
    		buf = find(str);
    		strcat(nstr, " ");
    		strcat(nstr, buf);
    		del(str, buf);
    	}
    	nstr[len] = '\0';
    	str = nstr;
    }
    
    
    
    void main()
    {
    	char* str = new char[200];
    	str = "my little pony";
    	sort(str);
    	cout<<str;
    }

    Из вузовского компьютера.

    dos_, 03 Июня 2012

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

    −24

    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
    template <bool ValueToLock>
    	class TBoolLocker
    	{
    	private:
    		bool _lockedValue;
    	public:
    		TBoolLocker(void) : _lockedValue(!ValueToLock) {}
    		TBoolLocker(const TBoolLocker & Copy) : _lockedValue(Copy._lockedValue) {}
    		const TBoolLocker & operator=(const TBoolLocker & Copy)
    		{
    			_lockedValue = Copy._lockedValue;
    			return *this;
    		}
    		bool update(const bool NewValue)
    		{
    			if (_lockedValue != ValueToLock)
    				_lockedValue = NewValue;
    			return _lockedValue;
    		}
    	};

    Говногость, 16 Мая 2012

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