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

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

    +993

    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
    if(layerHeader.mFlags&AE_ANIM_BEZIER_EFFECT)
    {
    		btlv=(Point*)calloc(layer->frames.size(),sizeof(Point));
    		btlt=(Point*)calloc(layer->frames.size(),sizeof(Point));
    		btrt=(Point*)calloc(layer->frames.size(),sizeof(Point));
    		brtv=(Point*)calloc(layer->frames.size(),sizeof(Point));
    		brtt=(Point*)calloc(layer->frames.size(),sizeof(Point));
    		brbt=(Point*)calloc(layer->frames.size(),sizeof(Point));
    		bbrv=(Point*)calloc(layer->frames.size(),sizeof(Point));
    		bbrt=(Point*)calloc(layer->frames.size(),sizeof(Point));
    		bblt=(Point*)calloc(layer->frames.size(),sizeof(Point));
    		blbv=(Point*)calloc(layer->frames.size(),sizeof(Point));
    		blbt=(Point*)calloc(layer->frames.size(),sizeof(Point));
    		bltt=(Point*)calloc(layer->frames.size(),sizeof(Point));
    }

    lifemaker, 16 Марта 2012

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

    −111

    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
    -(void)handleNotification:(id<INotification>)notification
    {
    	NSLog(@"NOTIFICATION:%@", [notification description]);
    	if ([[notification name] isEqualToString:ShowMetronomeInTab]) 
    	{
    		[self.viewComponent showMetronomeInTab];
    	}
    	else if ([[notification name] isEqualToString:AlertOnScreen]) 
    	{
    		isShowRateAlert = YES;
    	}
    	else if ([[notification name] isEqualToString:NoAlertOnScreen]) 
    	{
    		isShowRateAlert = NO;
    	}
    	else if ([[notification name] isEqualToString: ShowHowToEnter]) 
    	{
    		id body = [notification body];
    		[self.viewComponent showHowToEnter:body];
    	}
    	else if ([[notification name] isEqualToString:ShowResultView]) 
    	{
    		[self.viewComponent showResultView:[notification body] Animated:YES];
    	}
    	else if ([[notification name] isEqualToString:ShowIndicatorView]) 
    	{
            if ([[notification body] isKindOfClass:[NSString class]]) 
            {
                [self.viewComponent showLoadingIndicator:[notification body]];
            }
            else 
            {
                if ([[notification body] isKindOfClass:[NSArray class]]) 
                {
                    [self.viewComponent showLoadingIndicator:[[notification body] objectAtIndex:0] WithSecondString:[[notification body]objectAtIndex:1]];
                }
            }		
    	}
        else if ([[notification name] isEqualToString:ShowBlackIndicatorView]) 
    	{
            [self.viewComponent showBlackLoadingIndicator:[notification body]];	
    	}
    	else if ([[notification name] isEqualToString:RemoveIndicatorView]) 
    	{
    		[self.viewComponent removeLoadingIndicator];
    	}
    	else if ([[notification name] isEqualToString:ShowTimeOutAlert]) 
    	{
    		[self.viewComponent displayAlertOnConnectionTimeOut];
    	}
    	else if ([[notification name] isEqualToString:ShowNetworkUnavailableAlert]) 
    	{
    		[self.viewComponent displayAlertOnNetworkError];
    	}
    	else if ([[notification name] isEqualToString:ShowServiceUnavailableAlert]) 
    	{
    		[self.viewComponent displayAlertOnConnectionError];
    	}
    	else if ([[notification name] isEqualToString:ShowHomeView]) 
    	{
    		[self.viewComponent showHomeView];
    	}
    	else if ([[notification name] isEqualToString:ShowProcessingView]) 
    	{
    		[self.viewComponent showProcessingView:[notification body]];
    	} else if ([[notification name] isEqualToString:ShowResultViewNotAnimated]) 
    	{
    		[self.viewComponent showResultView:[notification body] Animated:NO];
    	} else if ([[notification name] isEqualToString:ShowTimeOutAlertWithParent]) 
    	{
    		[self.viewComponent displayAlertOnConnectionTimeOutWithParent:notification.body];
    	}
    	else if ([[notification name] isEqualToString:ShowNetworkUnavailableAlertWithParent]) 
    	{
    		[self.viewComponent displayAlertOnNetworkErrorWithParent:notification.body];
    	}
    	else if ([[notification name] isEqualToString:ShowServiceUnavailableAlertWithParent]) 
    	{
    		[self.viewComponent displayAlertOnConnectionErrorWithParent:notification.body];
    	} 
        else if ([[notification name] isEqualToString:RotationIndicator]) 
    	{
            [self.viewComponent rotationIndicator];
    	}
    	else if ([[notification name] isEqualToString:StartMusic])
        {
            if (applicationProxy.mediaPlayerWasPlaying)
    		{	
    			applicationProxy.mediaPlayerIsPlaying = YES;
    			[self sendNotification:MediaPlayerChangeState];
    			MPMusicPlayerController *mpPlayer = [MPMusicPlayerController iPodMusicPlayer];
    			[mpPlayer play];
    		}
        }
    	else if ([[notification name] isEqualToString:StopMusic])
        {
            applicationProxy.mediaPlayerIsPlaying  = NO;
    		[self sendNotification:MediaPlayerChangeState];

    И так 50 elseif'ов. И, сцуко, все разные. И в последней трети отформатированы лесенкой.
    Местное видение PureMVC

    krypt, 05 Марта 2012

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

    +146

    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
    <?php
    if(isset($_GET['id']))
    {
    $id=$_GET['id'];
    }
    else
    {
    $id=$_GET['id'];
    }
    
    echo "<b>Введите в строку запроса id=любое слово или число</b>";
    
    	if(isset($id))
    	{
    
    if($id==0 or $_GET['id']==0)
    {
    echo "<br>Ты не че не ввел))";
    }
    
    else
    {
    
    echo "<br> Вы вели в запрос ";
    echo $_GET['id'];
    echo $id;
    }
    
    	}
    
    	else 
    	{echo "NoFound";}
    ?>

    Начал изучать php и столкнулся с проблемой
    хочу чтобы при вводе в $_GET['id'] отображалось на странице переменная $id
    Если $id=0 или она ваще пуста тогда выводит сообщение о предуприждении что типо перемная пуста
    Если $id= какому нибудь тексту или чему нибудь то и выводить этот текст иили что нибудь

    Мне постояно выводит "echo "<br>Ты не че не ввел))";"

    kumaq, 02 Марта 2012

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

    +173

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    /*
          if($_REQUEST["act_id"]==8){
          а нет. маньяки так не пишут...
    */
    define("Э", $_REQUEST["act_id"]);
    if( 8===Э ){ 
    	...
    }

    оператор члена :)

    basename, 17 Января 2012

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

    +1004

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    if (param["LOG"] != NULL) // пришли логи от плагина.
        {
            this->logs = new loger();
            this->logs->write(param["LOG"], param["TYPE"], this->Name, name);
            delete this->logs;
            return;
        }

    Так мы пишем логи

    ir4y, 12 Января 2012

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

    +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
    ................
    		
    
    	$this->vkey = substr(md5($this->id),13,20); 
    			$this->vname = $vname;
    			$descr=$this->vtitle;
    			if ($descr)
    			{
    				$var=$descr;
    				$temp_max=200;
    		$langtranslit = array(
    		'а' => 'a', 'б' => 'b', 'в' => 'v',
    		'г' => 'g', 'д' => 'd', 'е' => 'e',
    		'ё' => 'e', 'ж' => 'zh', 'з' => 'z',
    		'и' => 'i', 'й' => 'y', 'к' => 'k',
    		'л' => 'l', 'м' => 'm', 'н' => 'n',
    		'о' => 'o', 'п' => 'p', 'р' => 'r',
    		'с' => 's', 'т' => 't', 'у' => 'u',
    		'ф' => 'f', 'х' => 'h', 'ц' => 'c',
    		'ч' => 'ch', 'ш' => 'sh', 'щ' => 'sch',
    		'ь' => '', 'ы' => 'y', 'ъ' => '',
    		'э' => 'e', 'ю' => 'yu', 'я' => 'ya',
    		"ї" => "yi", "є" => "ye",
    		
    		'А' => 'A', 'Б' => 'B', 'В' => 'V',
    		'Г' => 'G', 'Д' => 'D', 'Е' => 'E',
    		'Ё' => 'E', 'Ж' => 'Zh', 'З' => 'Z',
    		'И' => 'I', 'Й' => 'Y', 'К' => 'K',
    		'Л' => 'L', 'М' => 'M', 'Н' => 'N',
    		'О' => 'O', 'П' => 'P', 'Р' => 'R',
    		'С' => 'S', 'Т' => 'T', 'У' => 'U',
    		'Ф' => 'F', 'Х' => 'H', 'Ц' => 'C',
    		'Ч' => 'Ch', 'Ш' => 'Sh', 'Щ' => 'Sch',
    		'Ь' => '', 'Ы' => 'Y', 'Ъ' => '',
    		'Э' => 'E', 'Ю' => 'Yu', 'Я' => 'Ya',
    		"Ї" => "yi", "Є" => "ye",
    		);
    
    	
    	$var = trim( strip_tags( $var ) );
    	$var = preg_replace( "/\s+/ms", "-", $var );
    	$var = strtr($var, $langtranslit);
    	
    	$var = preg_replace( "/[^a-z0-9\_\-.]+/mi", "", $var );
    	$var = preg_replace( "/[^a-z0-9\_\-]+/mi", "", $var );
    	$var = preg_replace( '#[\-]+#i', '-', $var );
    	$var = str_ireplace( ".", "", $var ); 
    	$var = str_ireplace( ",", "", $var );
    	$var = str_ireplace( "---", "-", $var ); 
    	$var = str_ireplace( "--", "-", $var );
    
    	$var = strtolower( $var );
    
    	$var = str_ireplace( ".php", "", $var );
    	$var = str_ireplace( ".php", ".ppp", $var );
    	$var = str_ireplace( '"', "&quot;", $var ); 
    	
    	if( strlen( $var ) > 200 ) {
    		$var = substr( $var, 0, 200 );
    		if( ($temp_max = strrpos( $var, '-' )) ) {$var = substr( $var, 0, $temp_max );}
    	
    	}
    	$idd=$this->id;
    	$idq=$idd+136;
    
    ...............................................

    Что за...
    Вырвиглаз.

    Samedi, 09 Января 2012

    Комментарии (21)
  8. Python / Говнокод #8967

    −89

    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
    def getResidueList():
    	resList = []
    	resList.append("366")
    	resList.append("367")
    	resList.append("368")
    	resList.append("369")
    	resList.append("370")
    	resList.append("371")
    	resList.append("372")
    	resList.append("373")
    	resList.append("374")
    	resList.append("375")
    	resList.append("376")
    	resList.append("377")
    	resList.append("378")
    	resList.append("379")
    	resList.append("380")
    	resList.append("381")
    	resList.append("382")
    	resList.append("383")
    	resList.append("384")
    	resList.append("385")
    	resList.append("386")
    
           .... и так далее ... 
    
    	resList.append("405")
    	resList.append("406")
    	resList.append("407")
    	resList.append("408")
    	resList.append("409")
    	resList.append("410")
    	resList.append("411")
    	resList.append("412")
    	resList.append("413")
    	resList.append("414")
    
           ... и так далее ....
    
            resList.append("585")
    	resList.append("586")
    	resList.append("587")
    	resList.append("588")
    	resList.append("589")
    
    	return resList

    Циклы? Не, не слышал

    denis90, 07 Января 2012

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

    +160

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    class Mysql_class {
    
      function get_row($query) {
        $sql_query = mysql_query($query) or exit(mysql_error());
        return mysql_fetch_array($sql_query);
      }
    
      function single_query($query) {
        if (mysql_query($query)) return true;
        else return mysql_error();
      }
    }

    2011-й год, прототип класса для работы с базой данных ( http://www.askdev.ru/q/8552 )

    demotivator, 04 Января 2012

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

    +1000

    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
    if(SpokaneFileList->Strings[i].SubString(1,8).ToInt() < 1000){
          imageFolder="00000\\";
        }else if (SpokaneFileList->Strings[i].SubString(1,8).ToInt() < 2000){
          imageFolder="00001\\";
        }else if (SpokaneFileList->Strings[i].SubString(1,8).ToInt() < 3000){
          imageFolder="00002\\";
        }else if (SpokaneFileList->Strings[i].SubString(1,8).ToInt() < 4000){
    ....
          imageFolder="00034\\";
        }else if (SpokaneFileList->Strings[i].SubString(1,8).ToInt() < 36000){
          imageFolder="00035\\";
        }else if (SpokaneFileList->Strings[i].SubString(1,8).ToInt() < 37000){
          imageFolder="00036\\";
        }

    Сегодня чувствую себя сказочным героем (Гераклом) в весьма не сказочно обкаканном месте (авгиевых конюшнях),
    которому надо это место отмыть до блеска...

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

    int sfFactor = SpokaneFileList->Strings[i].SubString(1,8).ToInt();
    int imageFolder = StringHelper::NormalizeString(IntToStr(s fFactor/1000), 5, "0", true, true) + "\\";

    - FYI функция StringHelper::NormalizeString() занимает 19 строк.

    На добивание:
    такие куски встречаются в программе около 20 раз (!!!)

    Индийский код - не признак национальности, а способ мышления...

    dm-ua, 19 Декабря 2011

    Комментарии (21)
  11. Java / Говнокод #8865

    +89

    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
    /*
         * helper function that will complete the entire compile
         * process, but allow both filestreams and regular input
         * streams to be compiled.
         */
        static boolean doCompile(InputStream in,
            String pathspec,
            String scriptname,
            String filename,
            String encoding,
    		String swf_options,
    		String avmplus_exe,
            ObjectList<IncludeInfo> includes,
        ObjectList<String> import_filespecs,
        ObjectList<String> use_namespaces,
    	String language,
        ObjectList<ConfigVar> configs,
        ObjectList<CompilerPlug> plugs,
        CompilerHandler handler,
            boolean emit_doc_info /*false*/,
    			boolean emit_debug_info /*=false*/,
                    boolean show_instructions /*=false*/,
                        boolean show_machinecode /*=false*/,
                            boolean show_linenums /*=false*/,
                                boolean show_parsetrees /*=false*/,
                                    boolean show_bytes /*=false*/,
                                        boolean show_flow /*=false*/,
                                            boolean lint_mode /*=false*/,
                                                boolean use_static_semantics /*=false*/,
                                                    boolean emit_metadata,
                                                        boolean save_comment_nodes/*=false*/,
                                                            int dialect /*=0*/,
                                                                int target,
                                                                    boolean optimize,
    							 ObjectList<ConfigVar> optimizer_configs,
    							 int api_version)
        { ... }

    От меня что-то ускользает, или это так нормально?
    http://opensource.adobe.com/svn/opensource/flex/sdk/trunk/modules/asc/src/java/macromedia/asc/embedding/Compiler.java

    wvxvw, 18 Декабря 2011

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