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

    −165

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    /**
         * This is a really fast way to check for NaN; see the spec of NaN
         * on why this works; this check can yield false only for a Number
         * since it's the only one capable of having NaN as a value.
         */
        if (d != d) {
         throw new Error("value can't be NaN!");
        }

    kyzi007, 15 Мая 2012

    Комментарии (39)
  2. ActionScript / Говнокод #10222

    −168

    1. 1
    staticDataTemp = com.adobe.serialization.json.JSON.encode(com.adobe.serialization.json.JSON.decode(e.target.data));

    kyzi007, 08 Мая 2012

    Комментарии (9)
  3. ActionScript / Говнокод #10215

    −159

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    appendExclamation("one")("two")("three")("four")("five");
    function appendExclamation(str:String):Function{
      trace(str + "! ");
      return appendExclamation;
    }
    /* outputs:
    one!
    two!
    three!
    four!
    five!
    */

    как-то натолкнулся на одном из блогов

    lammar, 08 Мая 2012

    Комментарии (9)
  4. ActionScript / Говнокод #10214

    −155

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    public function initCounter():void
    {
    	_timeDisplayer.text = (_type == COUNT) ? "00:00" : ((_timeLimit < 10) ? "0" + _timeLimit.toString() + ":00" : _timeLimit.toString() + ":00");
    	_seconds = (_type == COUNT) ? 0 : 60;
    	_minutes = (_type == COUNT) ? 0 : _timeLimit;
    	_counterCompleted = false;
    }

    еще одно тернарное извращение:)

    lammar, 08 Мая 2012

    Комментарии (0)
  5. ActionScript / Говнокод #10188

    −207

    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
    public function Square() 
    		{
    			_image = new Image();
    			_image.smoothBitmapContent = true;
    			_mask = new Image();
    			Level.instance.addEventListener("squaresCreated", squareCreatedHandler);
    		}
    		
    		/*
    		 * Добавляет монстров на field по событию "squaresCreated".
    		 * Почему эта логика не в field не ебу.
    		 */
    		private function squaresCreatedHandler(evt:Event):void
    		{
    			if (isMonster)
    			{
    				Level.instance.field.addChild(_fieldMonster);
    				_fieldMonster.x = this.x;
    				_fieldMonster.y = this.y;
    			}
    		}

    Мимими, всегда бы такие комменты в коде встречать

    KirAmp, 04 Мая 2012

    Комментарии (1)
  6. ActionScript / Говнокод #10165

    −204

    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
    // avm+ specific utility method
     public static function throwError(type:Class, index:uint, ... rest)
     {
         // This implements the same error string formatting as the native
         // method PrintWriter::formatP(...) any changes to this method should
         // also be made there to keep the two in sync.
         var i=0;
         var f=function(match, pos, string)
         {
             var arg_num = -1;
             switch(match.charAt(1))
             {
                 case '1':
                     arg_num = 0;
                     break;
                 case '2':
                     arg_num = 1;
                     break;
                 case '3':
                     arg_num = 2;
                     break;
                 case '4':
                     arg_num = 3;
                     break;
                 case '5':
                     arg_num = 4;
                     break;
                 case '6':
                     arg_num = 5;
                     break;
             }
             if( arg_num > -1 && rest.length > arg_num )
                 return rest[arg_num];
             else
                 return "";
         }
         throw new type(Error.getErrorMessage(index).replace(/%[0-9]/g, f), index);
     }

    http://hg.mozilla.org/tamarin-redux/file/fdf1416a3536/core/Error.as
    Проблемы с устным счетом, да и не только...

    wvxvw, 02 Мая 2012

    Комментарии (9)
  7. ActionScript / Говнокод #9987

    −124

    1. 1
    var allInteractiveItems : Array = ItemSearchHelper.join(ItemSearchHelper.join(ItemSearchHelper.sortById(_worldInfo.itemsInteractive), ItemSearchHelper.sortById(GameInfo.instance.items)), ItemSearchHelper.sortById(GameInfo.instance.itemsInteractive)).concat(ItemSearchHelper.sortById(_worldInfo.items));

    Оптимизнула к концу рабочего дня...

    kyzi007, 19 Апреля 2012

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

    −116

    1. 1
    var rowIndex:Boolean = Number(isNaN(parseInt(nextCharacter)));

    Проверка строки на наличие чисел.
    Пикантность ситуации еще придает что parseInt ('буква') всегда равно нулю.

    kyzi007, 06 Апреля 2012

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

    −121

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    override public function removeChildAt(index:int):DisplayObject
    {
    var child:DisplayObject = getChildAt(index);
    
    removingChild(child);
    
    $removeChild(child);
    
    childRemoved(child);
    
    return child;
    }

    kyzi007, 05 Апреля 2012

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

    −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
    if (param.visible == 'cache')
    {
    	while (parseCacheResult.indexOf('$data') != -1) parseCacheResult = parseCacheResult.replace('$data', '_dataCache');
    	while (parseCacheResult.indexOf('$name') != -1) parseCacheResult = parseCacheResult.replace('$name', param.nameParam);
    	while (parseCacheResult.indexOf('$type') != -1) parseCacheResult = parseCacheResult.replace('$type', param.type);
    } else if (param.visible == 'static')
    {
    	while (parseStaticResult.indexOf('$data') != -1) parseStaticResult = parseStaticResult.replace('$data', '_dataStatic');
    	while (parseStaticResult.indexOf('$name') != -1) parseStaticResult = parseStaticResult.replace('$name', param.nameParam);
    	while (parseStaticResult.indexOf('$type') != -1) parseStaticResult = parseStaticResult.replace('$type', param.type);
    }
    else
    {
    	while (parseDynamicResult.indexOf('$data') != -1) parseDynamicResult = parseDynamicResult.replace('$data', '_dataDynamic');
    	while (parseDynamicResult.indexOf('$name') != -1) parseDynamicResult = parseDynamicResult.replace('$name', param.nameParam);
    	while (parseDynamicResult.indexOf('$type') != -1) parseDynamicResult = parseDynamicResult.replace('$type', param.type);
    }
    
    while (setResult.indexOf('$name') != -1) setResult = setResult.replace('$name', param.nameParam);
    while (setResult.indexOf('$type') != -1) setResult = setResult.replace('$type', param.type);
    while (setResult.indexOf('$className') != -1) setResult = setResult.replace('$className', className);
    
    while (getResult.indexOf('$name') != -1) getResult = getResult.replace('$name', param.nameParam);
    while (getResult.indexOf('$type') != -1) getResult = getResult.replace('$type', param.type);
    
    while (varResult.indexOf('$name') != -1) varResult = varResult.replace('$name', param.nameParam);
    while (varResult.indexOf('$type') != -1) varResult = varResult.replace('$type', param.type);
    while (varResult.indexOf('$comment') != -1) varResult = varResult.replace('$comment', param.comment);
    while (varResult.indexOf('$default') != -1) varResult = varResult.replace('$default', param.defaultValue);
    
    }
    
    var result : String = baseTemplate;
    while (result.indexOf('$className') != -1) result = result.replace('$className', className);
    while (result.indexOf('$comment') != -1) result = result.replace('$comment', comment);
    while (result.indexOf('$baseClass') != -1) result = result.replace('$baseClass', baseClass);
    while (result.indexOf('$singleton_1') != -1) result = result.replace('$singleton_1', singl_1);
    while (result.indexOf('$singleton_2') != -1) result = result.replace('$singleton_2', singl_2);
    
    result = result.replace('$var', varResult);
    result = result.replace('$set', setResult);
    result = result.replace('$get', getResult);
    result = result.replace('$parseDynamic', parseDynamicResult);
    result = result.replace('$parseStatic', parseStaticResult);
    result = result.replace('$parseCache', parseCacheResult);
    result = result.replace('$values', valuesList);
    result = result.replace('$dynamic', data.dynamicClass == 1 ? 'dynamic' : '');

    Как то родилось в процессе допилок кодогена )

    kyzi007, 23 Марта 2012

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