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

    −122

    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
    public static function hide (target:MovieClip, time:Number = .1, finshCallBack:Function = null, time2:Number = 0):void
    {
    	if (!target) return;
    
    	cansel(target);
    
    	var fun:Function = function (event:Event = null):void
    	{
    		var tw:Tween = new Tween(target, 'alpha', null, target.alpha, 0, time, true);
    		tw.addEventListener(TweenEvent.MOTION_FINISH, hideEnd);
    		if (finshCallBack != null) tw.addEventListener(TweenEvent.MOTION_FINISH, finshCallBack);
    		if (target['tw']) target['tw'].stop();
    		target['tw'] = tw;
    		target['is_hide'] = true;
    		if (target.hasOwnProperty('is_over')) target['is_over'] = false;
    	}
    	if (time2 == 0)
    	{
    		fun();
    	}
    	else
    	{
    		var timer:MyTimer = new MyTimer(time2 * 1000, 1);
    		target['timer'] = timer;
    		timer.addEventListener(TimerEvent.TIMER_COMPLETE, fun);
    		timer.start();
    	}
    }

    Вот такой недотвин)

    kyzi007, 18 Ноября 2011

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

    +1009

    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
    void SendIntMessages(int* array, int len, bool sendFromstart)
    {
    	int i = sendFromstart ? 0 : (len - 1);
    
    	for (;;)
    	{
    		if ((sendFromstart) && (i >= len)) break;
    		else if ((!sendFromstart) && (i < 0)) break;
    
    		SentIntMessage(array[i]);
    
    		if (sendFromstart) i++;
    		else i--;	
    	}
    }

    Гибкий цикл.

    southerton, 18 Ноября 2011

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

    +161

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    function to_int_convert($num)
    {
        $arr_num = str_split($num);
        $new_num = "";
        foreach($arr_num as $key => $value)
                if($value == intval($value))
                $new_num = $new_num.$value;
        return $new_num;
    }

    korchasa, 18 Ноября 2011

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

    +158

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    foreach ($aa as $key => $value) {
                $aa[$key][2] = str_replace(',', '.', $aa[$key][2]);
                $aa[$key][3] = str_replace(',', '.', $aa[$key][3]);
                $aa[$key][4] = str_replace(',', '.', $aa[$key][4]);
            }

    jf4ever, 18 Ноября 2011

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

    +155

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    function some_function ($aa, $bb) {
            $col_names = _cfg::get('ccc');
            foreach ($bb as $key => $value) {
                $bb[$key][0] = array_search($bb[$key][0], $aa);
                $bb[$key][1] = array_search($bb[$key][1], $aa);
                
                foreach ($this->currency_names as $currency_key => $currency_value) {
                    if ($oil_array[$key][5] == $this->currency_names[$currency_key]['name']) $oil_array[$key][5] = $this->currency_names[$currency_key]['id'];
                }
                $bb[$key] = array_combine($col_names, $bb[$key]);
            }
            return $bb;

    продолжение с Говнокод #8566

    jf4ever, 18 Ноября 2011

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

    +162

    1. 1
    2. 2
    $id = $this->db->fetchCol('SELECT id FROM data;');
    $names = $this->db->fetchCol('SELECT name FROM points INNER JOIN data ON points.id = data.point_id_from;');

    Zend Db usage

    jf4ever, 18 Ноября 2011

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

    +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
    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
    function &GetObject($cls, $p=null, $flags=0)
    {	//HIDE($objects,$i,$ext,$n,$v)
    	static $objects;
    	if (is_array($cls)) {
    		$i = null;
    		foreach($cls as $n=>$v) $i->$n = $v;
    		$result = &$i;
    		return $result;
    	}
    	if (!($flags&O_NEW) && isset($objects[$cls])) return $objects[$cls];
    
    	$ext = new WExtern($cls, 'c');
    	if (!($flags&O_NEW) && isset($objects[$i=$ext->Id()])) return $objects[$i];
        if ($flags&O_INSTANCE) {$x = null; $result = &$x; return $result;}
    
    	if (!$ext->Exists()) $ext->Prepare();
    	if (($flags&O_NOERROR) && !class_exists($ext->c)) {
    		$co = $ext->c;
    		$cc = $co{0}.'B'.substr($co,1);
    		if (($flags&O_NOERROR) && !class_exists($cc)) {
    			$i = false;
    			return $i;
    		} else {
    			$ext->c = $cc;
    		}
    	}
    	
    	if (!class_exists($ext->c)) {
    		$co = $ext->c;
    		$cc = $co{0}.'B'.substr($co,1);
    		if (!class_exists($cc)) {
    			$i = false;
    			return $i;
    		} else {
    			$ext->c = $cc;
    		}
    	}
    	$c = $ext->c;
    	$i = new $c;
    
    	if (isset($ext->I) && $ext->I) $i->_I = reset($ext->I);	// Instance ID
    	if (isset($ext->A) && $ext->A) $i->_A = $ext->A;		// Alias ID
    
    	if (!($flags&O_NEW)) {
    		$objects[$ext->Id()] = &$i;
    		if ($ext->Id()!=$cls) $objects[$cls] = &$i;
    	}
    	$options = &WConfig::Get('OPTIONS');
    	if (/*is_a($i, 'wobject')*/ $i instanceof wobject && $options) {
    		$o = $options;
    		$c = get_class($i);
    		do{
    			$c = strtolower($c);
    			if (isset($o[$c])) {
        			$i->o = array_merge($o[$c], isset($i->o) ?$i->o :array());
    			}
    		}while($c=get_parent_class($c));
    		if (isset($ext->A) && isset($o[$ext->A])) 	$i->o = array_merge(isset($i->o) ?$i->o :array(), $o[$ext->A]);
    		if ($ext->I && isset($o[$ext->Id()])) 		$i->o = array_merge(isset($i->o) ?$i->o :array(), $o[$o[$ext->Id()]]);
    	}
    
    	if (is_object($p)) {
    		if (isset($p->o)) $i->o = array_merge(isset($i->o) ?$i->o :array(), $p->o);
    		$p = isset($p->c) ? $p->c : null;
    	}
    	if (method_exists($i,'Create')  && $p!==false) {
    		call_user_func_array(array(&$i,'Create'), is_array($p) ?$p : (isset($p) ? array($p) : array()));
    	}
    
    	return $i;
    }

    Одна из базовых функций фремворка.

    Orion189, 18 Ноября 2011

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

    +124

    1. 1
    _videoNum = (byte) (videoNum==0?videoNum:0);

    попалось сегодня в исходниках рабочего проекта

    _vinka, 18 Ноября 2011

    Комментарии (6)
  9. Java / Говнокод #8563

    +80

    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
    m_scrabblerProperties = Utils.loadPropertiesFile(m_args[1]);
    if (null != m_scrabblerProperties)
    {
    	System.out.println("Executing DBScrubber with properties file " + m_args[1] + " loaded from the classpath");
    }
    else
    {
    	try
    	{
    		m_scrabblerProperties.load(new FileInputStream(m_args[1]));
    		System.out.println("Executing DBScrubber with properties file " + m_args[1] + " loaded from the file system");
    	}
    	catch (IOException e)
    	{
    		System.err.println("Failed to load " + m_args[1] + " from the classpath or the file system");
    	}
    }

    Utils.loadPropertiesFile - какая то хитрая поделуха которая ищет файл в кэше. Если он не найден в кэше, то автор видимо хотел попробовать считать файл с диска, но судя по всему оказался оказался дебилом.

    askell, 18 Ноября 2011

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

    +166

    1. 1
    foreach ($_GET as $xxx => $rvar) { $$xxx = $rvar; }

    может боян конешн

    pusinsky, 18 Ноября 2011

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