1. Список говнокодов пользователя kyzi007

    Всего: 128

  2. Python / Говнокод #16203

    −100

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    #Было
    def extract_brand(x):
                    x = x[0].lower()
                    for brand in brands:
                        if x.count(brand):
                            return brand
    il.brand_out = extract_brand
    
    #Стало после кодревью
    il.brand_in = lambda x: [brand for brand in brands if brand.lower() in x[0].lower()]

    Кто то смог прочитать второй вариант?

    kyzi007, 22 Июня 2014

    Комментарии (90)
  3. Python / Говнокод #16069

    −94

    1. 1
    l.category_out = lambda x: filter(lambda y: y != u'»', x)

    kyzi007, 28 Мая 2014

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

    −102

    1. 1
    l.add_xpath('price', '//table[3]/tr/td[2]/table[1]/tr[1]/td[3]/table/tr[3]/td/table/tr[2]/td/text()', lambda x: '.'.join(x))

    kyzi007, 05 Мая 2014

    Комментарии (42)
  5. Python / Говнокод #15385

    −103

    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
    li = item_parser.select('//li')
    for i in li:
        try:
            i.extract().index(u'Цены')
            item.price = i.select('span/text()').extract()[0]
        except ValueError:
            pass
        try:
            i.extract().index(u'Модификации')
            item.modification = i.select('span/text()').extract()[0]
        except ValueError:
            pass
        try:
            i.extract().index(u'Отзывы')
            item.reviews = i.select('span/text()').extract()[0]
        except ValueError:
            pass

    Ниосилила utf...

    kyzi007, 07 Марта 2014

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

    −118

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    public static function cancel (tween : T) : void {
        delete _dict[tween];
    }
    
    public function cancel () : void {
        delete _dict[this];
    }

    Пыщ пыщ, я развлекаюсь

    kyzi007, 23 Декабря 2013

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

    −119

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    if (repeatCount > 1 && repeatCount > mediator.data.repeat_count && sequence.completeAction == "END") {
        mediator.data.repeat_count = mediator.data.repeat_count + 1;
        mediator.currentSequenceStep = mediator.currentSequenceStep;
    }
    else if (repeatCount > 1 && repeatCount > mediator.data.repeat_count) {
        mediator.data.repeat_count = mediator.data.repeat_count + 1;
        mediator.currentSequenceStep = mediator.currentSequenceStep;
    }

    Я плакать. Я убивать.

    kyzi007, 19 Сентября 2013

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

    −91

    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
    private function checkResourcesForIcon():void {
        if (!(this is TotemMediator)) {
            if ((!Player.instance.friendMode && buildable && step && step.bubbleIco) || _ico) {
                sendNotification(GameNotifications.ADD_RESOURCE_CHECKER, {
                    'caller_id': id, 'res_v': step.requirement,
                    'action_0': { 'notification': ObjectNotifications.UPDATE_ICON, 'body': {'id': id, 'check': false } },
                    'action_1': { 'notification': ObjectNotifications.UPDATE_ICON, 'body': {'id': id, 'check': true } }
                });
            }
        }
    }
    // команда на GameNotifications.ADD_RESOURCE_CHECKER
    override public function execute(notification:INotification):void {
        super.execute(notification);
        var body:Object = notification.getBody();
        var resChecker:ResourceChecker = this.facade.retrieveProxy(ResourceChecker.NAME) as ResourceChecker;
        resChecker.addChecker(body.caller_id, body.res_v, body.action_0, body.action_1);
    }
    // ResourceChecker
    public function addChecker(callerId:String, resV:Vector.<ResourceData>, action0:Object, action1:Object):void {
        if (!callersToCheck) {
            callersToCheck = { };
        }
        //overwrite
        callersToCheck[callerId] = { 'res':resV, 'action0':action0, 'action1':action1, 'enough':false };
        //recheck
        checkCaller(callerId);
    }
    private function checkCaller(callerId:String):void {
        if (callersToCheck[callerId]) {
            var checkV:Vector.<ResourceData> = callersToCheck[callerId]['res'];
            var allEnough:Boolean = true;
            for each(var checkR:ResourceData in checkV) {
                if (checkR.resourcetype != 'WORKER') { //TODO: wtf with worker?
                    //if no such res or res not enough OR this is not completed quest
                    if ((!storedResources[checkR.resourcetype] || storedResources[checkR.resourcetype].quantity < checkR.quantity) && storedQuests.indexOf(checkR.resourcetype) == -1) {
                        allEnough = false;
                        break;
                    }
                }
            }
            if (allEnough && !callersToCheck[callerId]['enough']) {
                callersToCheck[callerId]['enough'] = true;
                executeAction(callersToCheck[callerId]['action1']);
            }else if (!allEnough && callersToCheck[callerId]['enough']) {
                callersToCheck[callerId]['enough'] = false;
                executeAction(callersToCheck[callerId]['action0']);
            }
        }
    }
    // и наконец
    private function executeAction(action:Object):void {
        if (action) {
            if (action['directive']) {
                Facade.getInstance().sendNotification(GameNotifications.RUN_DIRECTIVE, {name: action['directive'], args: action['args'] });
            } else if (action['notification']) {
                Facade.getInstance().sendNotification(action['notification'], action['body']);
            }
        }
    }

    kyzi007, 01 Августа 2013

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

    −120

    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
    manageAsset: {
        var clip : MovieClip = content as MovieClip;
        if (clip && clip.hasOwnProperty(LIB_PROP)) {
            var lib : Object = clip[LIB_PROP];
            ObjectUtils.update(this._library, lib);
            this._assets[url] = lib;
            for each (var name : String in lib) {
                this._fileByAsset[name] = url;
            }
            break manageAsset;
        } else if (clip) {
            this._loadingTargets[url] = e.target;
        }
    
        var bitmap : Bitmap = content as Bitmap;
        if (bitmap) {
            this._libraryBitmap[url] = bitmap.bitmapData;
            break manageAsset;
        }
    
        var sound : Sound = content as Sound;
        if (sound) {
            this._sounds[url] = sound;
            break manageAsset;
        }
    }

    Вот такой вариант инлайновго ретурна (это юзаются метки цикла на пустом эээ выражении если что). Когда первый раз увидела вывесило в ступор минут на пять - не знала что вообще так можно.

    kyzi007, 05 Июля 2013

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

    −124

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    private function checkClickCondition():Boolean {
        if ((isBildable(_focus) && GameObjectMediator(_focus).step && GameObjectMediator(_focus).step.isLock && isEditObjectMode(objectEditorMode))|| isTile(_focus)|| isHelper(_focus)) {
            return true;
        }
        return false;
    }
    private function isEditObjectMode(objectEditorMode:String):Boolean {
        return (objectEditorMode == LevelMediator.MOVE_OBJECTS|| objectEditorMode == LevelMediator.ROTATE_OBJECTS|| objectEditorMode == LevelMediator.CREATE_OBJECTS|| objectEditorMode == LevelMediator.PLACE_OBJECT|| objectEditorMode == LevelMediator.STORE_OBJECTS|| objectEditorMode == LevelMediator.SELL_OBJECTS)
    }
    private function isHelper(val:ISortable):Boolean {return (val && val is HelperMediator);}
    private function isTile(val:ISortable):Boolean {return (val && !(val is GameObjectMediator));}
    private function isBildable(val:ISortable):Boolean {return (val && val is GameObjectMediator);}
    
    protected function onClick(e:MouseEvent = null):void {
        var focusTile:TileMediator = _focus as TileMediator;
        if (_mouseClickLockedFromTutor && _focus != _tutorMagicObject)  return;
        if (_mouseClickLockedlockAllExceptFowFromTutor) {
            if (!_focus) {
                this.sendNotification(CellNotifications.CLICK, this._currentCell);
                return;
            }
            if (!(_focus is FowObject)) return;
        }
        if (focusTile || this._newObjectPreview) {
            if (checkClickCondition()) {
                switch (this.objectEditorMode) {
                    case LevelMediator.MOVE_OBJECTS:
                        if (this._newObjectPreview) {
                            if (this.greenPlace) {
                                this.moveObject();
                            }
                        }
                        else if (focusTile.isMovable && !focusTile.data.worker) {
                            _movedObject = focusTile;
                            focusTile.removeHighlight();
                            _hittest.removeObject(_focus);
                            _focus = null;
                            focusTile.data.clearCells();
                            _movedObject.onStartDragging();
                            this.trackMode = TRACKING_DISABLED;
                            setNewObjectAsset(focusTile.buildable.id, AnimationsList.IDLE, _movedObject.currentAnimationStep);
                            if (_movedObject is GameObjectMediator && GameObjectMediator(_movedObject).flip) {
                                this._newObjectPreview.view.flip = GameObjectMediator(_movedObject).flip;
                            }
                        }
                        break;
                    case LevelMediator.ROTATE_OBJECTS:
                        if (focusTile.isRotateble && !focusTile.data.worker) {
                            this.rotateObject(this._focus as GameObjectMediator);
                        }
                        break;
                    case LevelMediator.CREATE_OBJECTS:
                        if (this._newObjectPreview && greenPlace) {
                            this.createBuyObject();
                        }
                        break;
                    case LevelMediator.PLACE_OBJECT:
                        if (this._newObjectPreview && greenPlace) {
                            this.placeInventoryObject();
                        }
                        break;
                    case LevelMediator.STORE_OBJECTS:
                        if (focusTile.isStorable && !focusTile.data.worker) {
                            sendNotification(SoundNotifications.SOUND_PLAY, Sounds.SND_ITEM_STORE);
                            sendNotification(GameNotifications.RUN_DIRECTIVE, {
                                        name: DStorageItem.NAME,
                                        args: {id: _focus.id}}
                            );
                        }
                        break;
                    case LevelMediator.SELL_OBJECTS:
                        if (focusTile.isSellable && !focusTile.data.worker) {
                            sendNotification(GameNotifications.RUN_DIRECTIVE, {
                                        name: DSellBuildable.NAME,
                                        args: {
                                            id: _focus.id,
                                            buildableId: focusTile.buildable.id,
                                            value: 1,
                                            confirmation: true}
                                    });}
                        break;
                    default:
                        if (this._focus is HelperMediator) {
                            (this._focus as HelperMediator).onClick();
                            sendNotification(GameObjectNotifications.ON_CLICK, {id: _focus.id});}
                        else {
                            var gom:GameObjectMediator = _focus as GameObjectMediator;
                            if (gom && (gom.complete || gom.step != null && !focusTile.data.worker)) {
                                if (!gom.wait) {
                                    Debug.log('LevelMediator.onClick: ObjectNotifications.CLICK ' + focusTile.data);
                                    this.sendNotification(ObjectNotifications.CLICK, focusTile.data);
                                }
                                else if (Settings.ingamelog) {
                                    this.sendNotification(UINotifications.SHOW_CONFIRMATION_WINDOW, {
                                        title: 'speedup',
                                        description: 'for testing purposes',
                                        res: focusTile.buildable,
                                        action: {
                                            notification: UINotifications.TEST_SPEED_UP,
                                            body: this._focus}

    Сижу, меняю условия так чтобы за квестовыми объектами можно было проставлять декор...

    kyzi007, 03 Июля 2013

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

    −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
    protected function updateTimer():void {
        if (this._waitAction) {
            EnterFrame.removeScheduledAction(this._waitAction);
            this._waitAction = null;
        }
        if (this._wait > 0) {
            this._waitAction = EnterFrame.scheduleAction(this._wait - getTime(), this.onWaitComplete);
            this._waitAction.name = 'GameObjectMediator:updateTimer';
        }
        else {
            this._waitAction = null;
        }
        this.playDefaultAnimation();
        if (this._filters) {
            this.highlight(this._filters);
        }
    
        if (!(this is TotemMediator)) {
            if (!Player.instance.friendMode && this.buildable && this.buildable.tags.find(Buildable.TAG_INDICATOR) &&
                (this._complete || (this._wait == 0 && !this._actionProgress && this.data.step))){
                if (!this._ico) {
                    if (!this._complete) {
                        if (this.data.step.waitTimeMs > 0) {
                            switch(this.buildable.id) {
                                case 'building_smithy':
                                    this._ico = new GameObjectIco(GameObjectIco.TYPE_COLLECT_AXES, this);
                                    break;
                                case 'building_alchemist':
                                case 'quest_building_well_magicwell':
                                    this._ico = new GameObjectIco(GameObjectIco.TYPE_COLLECT_MANA, this);
                                    break;
                                default:
                                    this._ico = new GameObjectIco(GameObjectIco.TYPE_COLLECT_RESOURCES, this);
                                    break;
                            }
                        }else {
                            this._ico = new GameObjectIco(GameObjectIco.TYPE_BUILD, this); // case for ruins
                        }
                    }else {
                        this._ico = new GameObjectIco(GameObjectIco.TYPE_COLLECT_RESOURCES, this);
                    }
                    if (this._filters) {
                        this._ico.view.filters = this._filters;
                    }
                    this.alignIco();
                }
            }
            else {
                this.removeIco();
            }
        }
    }

    4 дня до релиза...

    kyzi007, 27 Июня 2013

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