1. ActionScript / Говнокод #5756

    −102

    1. 1
    import com.adobe.protocols.dict.events.ErrorEvent;

    Ну хоть бы циферку добавили...

    wvxvw, 21 Февраля 2011

    Комментарии (4)
  2. Java / Говнокод #5755

    +84

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    transDate = ( ExtBaApiStaging.class.equals( extExcep.getClass() ) )?((ExtBaApiStaging)extExcep).getBeginDate():
    		( ExtRsApiCancel.class.equals( extExcep.getClass() ) )?((ExtRsApiCancel)extExcep).getTransDate():
    		( ExtRsApiWriteCustContact.class.equals( extExcep.getClass() ) )?((ExtRsApiWriteCustContact)extExcep).getTransDate():
    		( ExtRsApiPayAdjust.class.equals( extExcep.getClass() ) )?((ExtRsApiPayAdjust)extExcep).getTransDate():
    		( ExtRsApiChgCustomer.class.equals( extExcep.getClass() ) )?((ExtRsApiChgCustomer)extExcep).getTransDate():
    		( ExtRsApiChgService.class.equals( extExcep.getClass() ) )?((ExtRsApiChgService)extExcep).getTransDate():
    		( ExtRsApiChgBoxData.class.equals( extExcep.getClass() ) )?((ExtRsApiChgBoxData)extExcep).getTransDate():
    		( ExtCLApiIsfMnp.class.equals( extExcep.getClass() ) )?((ExtCLApiIsfMnp)extExcep).getLoadDate():
    		( ExtCLApiNoTruckSro.class.equals( extExcep.getClass() ) )?((ExtCLApiNoTruckSro)extExcep).getLoadDate():
    		( ExtCLApiNsfHoldEcOsa.class.equals( extExcep.getClass() ) )?((ExtCLApiNsfHoldEcOsa)extExcep).getLoadDate():
    		( ExtRsApiSendAHit.class.equals( extExcep.getClass() ) )?((ExtRsApiSendAHit)extExcep).getTransDate() : null;

    Это писала одна тимлид

    tr00_gr1m_doomster, 21 Февраля 2011

    Комментарии (17)
  3. Perl / Говнокод #5754

    −123

    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
    sub check_interface
    {
    	my $int_input = shift;
    	my $all_intr_local = [];
    	$_ = qx[ip a];
    	s[\d{1,}:[ ]{1,}([^ ]{1,}):.*]<unshift(@$all_intr_local, $1)>ge;
    	if ( ! grep( { /^$config_params{$int_input}$/ } @$all_intr_local ))
    	{
    		$warning->debug("Error: interface $int_input can't found local!!!");
    		exit 1;         
    	}
    	else
    	{
    		$info->debug("Load param $int_input = $config_params{$int_input}.");   
    	}
    }

    А вот так мы сканируем сетевые интерфейсы...

    SadKo, 21 Февраля 2011

    Комментарии (10)
  4. Perl / Говнокод #5753

    −124

    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
    sub check_dir
    {
    	my ($param, $mode) = @_;
    	$mode ||= 'sr';
    
    	unless ( $mode eq 'sc')
    	{
    		my $full_path = $config_params{$param};
    		$full_path =~ /^(.+)\/(.+)$/;
    		my $put = $1;
    
    		while(1)
    		{
    			if (-l $full_path)
    			{
    				$info->debug("Load param $param = $full_path it is symlink. Readlink...");
    				$full_path = readlink $full_path;
    			}
    			elsif (-d $full_path or -d "$put/$full_path")
    			{
    				$info->debug("Load param $param = $full_path. It is directory and it is exists");
    				last;
    			}
    			else
    			{
    				$warning->debug("Not valid config. Error parsing param: $param");
    				exit 1;
    			}
    		}
    	}
    	else
    	{
    		my $full_path = $config_params_sc{$param};
    		$full_path =~ /^(.+)\/(.+)$/;
    		my $put = $1;
    
    		while(1)
    		{
    			if (-l $full_path)
    			{
    				$info_sc->debug("Load param $param = $full_path it is symlink. Readlink...");
    				$full_path = readlink $full_path;
    			}
    			elsif (-d $full_path or -d "$put/$full_path")
    			{
    				$info_sc->debug("Load param $param = $full_path. It is directory and it is exists");
    				last;
    			}
    			else
    			{
    				$warning_sc->debug("Not valid config. Error parsing param: $param");
    				exit 1;
    			}
    		}
    	}
    }

    По крайней мере, этот код можно сократить вдвое... И подобное по всей утилите...

    SadKo, 21 Февраля 2011

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

    +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
    const StringId sidPathName = [=]() -> const char* const
    {
    	switch (path)
    	{
    		case PATH_TOWN_HERO:
    			return "game/careers/town_hero";
    		case PATH_MAD_SCIENTIST:
    			return "game/careers/mad_scientist";
    		case PATH_SPECIAL_AGENT:
    			return "game/careers/special_agent";
    		case PATH_PSYCHIC_PAINTER:
    			return "game/careers/psychic_painter";
    		default:
    			RZT_ASSERT(false);
    			return "";
    	}
    }();

    Не удержался: давно мечтал о возможности ставить const на такие переменные, не отказываясь при этом от свитчей!

    Kirinyale, 21 Февраля 2011

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

    +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
    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
    public static class EventExtensions
        {
            public static void Fire(this EventHandler eventHandler, object sender)
            {
                eventHandler.Fire(sender, EventArgs.Empty);
            }
    
            public static void Fire(this EventHandler eventHandler, object sender, EventArgs args)
            {
                eventHandler.FireDelegate(sender, args);
            }
    
            public static void Fire<TEA>(this EventHandler<TEA> eventHandler, object sender, TEA args)
                where TEA : EventArgs
            {
                eventHandler .FireDelegate(sender, args);
            }
    
            public static void FireDelegate(this Delegate eventHandler, params object[] parameters)
            {
                if (eventHandler != null)
                {
                    Delegate[] delegates = eventHandler.GetInvocationList();
                    foreach (var del in delegates)
                    {
                        try
                        {
                            del.Method.Invoke(del.Target, parameters);
                        }
                        catch (Exception e)
                        {
                            // use logger here
                            throw;
                        }
                    }
                }
            }
        }

    Надоело писать инвокаторы для ивентов? Как тебе это?

    walash, 21 Февраля 2011

    Комментарии (4)
  7. Python / Говнокод #5750

    −179

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    def ispalindrome(string):
    	decide=1
    	i=0
    	while i<=int(len(string)/2) and decide==1:
    		if string[i]!=string[-(i+1)]:
    			decide=0
    		i+=1
    	return decide

    Функция определяет, является ли число паниндромом =)

    SSPkrolik, 21 Февраля 2011

    Комментарии (6)
  8. PHP / Говнокод #5749

    +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
    <?php 
    echo '
    <form method="POST" action="">
    <input type="submit" name="sub" value="Отправить">
    </form>
    ';
    $sub=$_POST['sub'];
    if ($sub==true){
    function rand_foto($patch = "images") 
    { 
    if(!$dir = opendir($patch)) return "images"; 
    while(($t = readdir($dir)) !== false) 
    { 
    $ext = substr(strrchr($t,'.'), 1); 
    if(is_file($t) && ($ext == "gif") || ($ext == "jpg") || ($ext == "png")) 
    { 
    $filename[] = $patch."/".$t; 
    } 
    } 
    closedir($dir); 
    $index = rand(0, count($filename) - 1); 
    $foto = "<img src=".$filename[$index].">"; 
    return $foto; 
    } 
    echo rand_foto(); }

    qbasic, 21 Февраля 2011

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

    +178

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    if($active_days > 4)
    {
    	$active_days = 1;
    }
    else
    {
    	if($active_days > 5)
    	{
    		$active_days = 1;
    	}
    }

    В цикле

    vizio, 21 Февраля 2011

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

    −241

    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
    while (i < 6) 
    {
        scene.scene["pirat" + i].shot = false;
        scene.scene["pirat" + i].num = i;
        scene.scene["pirat" + i].gotoAndStop(1);
        scene.scene["pirat" + i]._visible = false;
        scene.scene["pirat" + i].swapDepths(10 + i);
        scene.scene["pirat" + i].thisDepth = scene.scene["pirat" + i].getDepth();
        scene.scene["pirat" + i].pirat.piratFall.gotoAndStop(1);
        scene.scene["pirat" + i].pirat.piratFall._visible = false;
        scene.scene["splash" + i].splash1.gotoAndStop(1);
        scene.scene["splash" + i].splash2.gotoAndStop(1);
        scene.scene["splash" + i]._visible = false;
        ++i;
    }

    Данный кусок был найден в недрах флеш-рекламы.

    Govnocoder#0xFF, 21 Февраля 2011

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