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

    Всего: 202

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

    −101

    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
    class ImageAsset(Asset):
     
        def to_xml(self):  
            if self.asset_type == self.VIDEO:
                return self.videoasset.to_xml()
            element = etree.Element("imageAsset")
            if self.mask_key:
                element.set("maskId", self.mask_key)
            if self.image_x:
                element.set("imageX", str(self.image_x))
            if self.image_y:
                element.set("imageY", str(self.image_y))
            if self.image_width:
                element.set("imageWidth", str(self.image_width))
            if self.image_height:
                element.set("imageHeight", str(self.image_height))
            self.set_xml_attrs(element)
            return element
    
    class VideoAsset(ImageAsset):
     
        def to_xml(self):  
            element = etree.Element("videoAsset")
            if self.mask_key:
                element.set("maskId", self.mask_key)
            if self.image_x:
                element.set("imageX", str(self.image_x))
            if self.image_y:
                element.set("imageY", str(self.image_y))
            if self.image_width:
                element.set("imageWidth", str(self.image_width))
            if self.image_height:
                element.set("imageHeight", str(self.image_height))
            self.set_xml_attrs(element)
            return element

    Полиморфизм это вам не шубу в трусы заправлять!

    wvxvw, 26 Августа 2014

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

    −161

    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
    // RangeError: Error #2006: The supplied index is out of bounds.
    //	at flash.display::DisplayObjectContainer/getChildAt()
    //	at com.pt.utils::CustomSWFLoaderUtil$/isCorrectCustomSWF()[/var/lib/jenkins/workspace/<secret>/src/com/pt/utils/CustomSWFLoaderUtil.as:23]
    
    private static function isCorrectCustomSWF(swf:SWFLoader):Boolean
    {
    	if (swf &&
    		swf.content &&
    		swf.content is ContentDisplay &&
    		(swf.content as ContentDisplay).getChildAt(0) &&
    		(swf.content as ContentDisplay).getChildAt(0) is MovieClip &&
    		((swf.content as ContentDisplay).getChildAt(0) as MovieClip).numChildren == 1)
    		return (swf.content.getChildAt(0) is MovieClip);
    	else 
    		return false;
    }

    Ну не фарт!

    wvxvw, 21 Августа 2014

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

    +153

    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
    function parse(input) {
            var options = arguments.length > 1 ? arguments[1] : {},
        
                peg$FAILED = {},
        
                peg$startRuleFunctions = { grammar: peg$parsegrammar },
                peg$startRuleFunction  = peg$parsegrammar,
        
                peg$c0 = peg$FAILED,
                peg$c1 = null,
                peg$c2 = [],
                peg$c3 = function(initializer, rules) {
    . . .
                peg$c142 = { type: "other", description: "whitespace" },
                peg$c143 = /^[ \t\x0B\f\xA0\uFEFF\u1680\u180E\u2000-\u200A\u202F\u205F\u3000]/,
                peg$c144 = { type: "class", value: "[ \\t\\x0B\\f\\xA0\\uFEFF\\u1680\\u180E\\u2000-\\u200A\\u202F\\u205F\\u3000]", description: "[ \\t\\x0B\\f\\xA0\\uFEFF\\u1680\\u180E\\u2000-\\u200A\\u202F\\u205F\\u3000]" },
        
                peg$currPos          = 0,
                peg$reportedPos      = 0,
                peg$cachedPos        = 0,
                peg$cachedPosDetails = { line: 1, column: 1, seenCR: false },
                peg$maxFailPos       = 0,
                peg$maxFailExpected  = [],
                peg$silentFails      = 0,
        
                peg$result;
    . . . // + 3К строк бреда до конца функции

    История моих мытарств и жалких метаний:
    Меня попросило начальство радикально улучшить формат в котором приложение хранит данные. Думал я, думал, и решил, что YAML ка нельзя лучше подходит для задачи (нужно хранить описание слайдов презентации, т.е. много текста и довольно схематичная графика, все это желательно бы иметь возможность комфортно редактировать в текстовом виде, создавать заготовки и т.д.).

    Шаг первый: поиск готового YAML парсера, врезультате обнаружились две штуки для АС3. Один - клон Ява парсера, в котором по класу на токен. Я не шучу. Проект заброшен 5 лет назад. Второй: заброшен 4 года назад, все в одном файле, парсится регулярками и магией, какие-то комментарии имеются, но они только свидетельствуют о несостоятельности писавшего коментарии.

    Подумал: если нет нормального парсера, может есть генератор парсеров?

    Шаг второй: поиск обнаружил одну попытку написать клон ANTLR, но очень ограниченную, и не работающую.

    Думаю: ну бля, если все так херово, может с ж.скрипта портирую чего-нибудь простенькое, PEG как раз должен подойти.

    И тут я нашел это.

    wvxvw, 21 Августа 2014

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

    +70

    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
    *  Calculates the minimum number of bits necessary to represent the given number.  The
         *      number should be given in its unsigned form with the starting bits equal to 1 if it is
         *      signed.  Repeatedly compares number to another unsigned int called x.
         *      x is initialized to 1.  The value of x is shifted left i times until x is greater
         *      than number.  Now i is equal to the number of bits the UNSIGNED value of number needs.
         *      The signed value will need one more bit for the sign so i+1 is returned if the number
         *      is signed, and i is returned if the number is unsigned.
     * @param number the number to compute the size of
     * @param bits 1 if number is signed, 0 if unsigned
     */
        public static int minBits(int number, int bits)
        {
        int val = 1;
        for (int x = 1; val <= number && !(bits > 32); x <<= 1) 
        {
            val = val | x;
            bits++;
        }
    
        if (bits > 32)
                {
                        assert false : ("minBits " + bits + " must not exceed 32");
                }
        return bits;
    }

    Адоб, как обычно, порадовал (условие окончания цикла).
    [color=blue]https://git-wip-us.apache.org/repos/asf/flex-sdk/repo?p=flex-sdk.git;a=blob;f=modules/swfutils/src/java/flash/swf/SwfEncoder.java;h=03a100dda92989d537b00b 96033d614c73c47801;hb=HEAD#l320[/code]

    wvxvw, 17 Августа 2014

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

    −153

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    private function getOldPreviewBySize(width: Number, height: Number): BitmapData
     			{
    -				return oldPreviewsArr[width.toString() + height.toString()];
    +				if (width && height)
    +					return oldPreviewsArr[width.toString() + height.toString()];
    +				else
    +					return null;
     			}

    хорошо исправил (размеры картинки вполне могут быть и двух и трех-значными цифрами)

    wvxvw, 03 Августа 2014

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

    −97

    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
    def load_library():
        requests = []
        class Handler(object):
            pass
        Handler.errors = 0
        def handler(request):
            print "failed to load: %s" % request.url
            Handler.errors += 1
        for node in res:
            for url in filter(lambda x: x, map(node.prop, names)):
                requests.append(grequests.get(url))
        gmap(tuple(requests), exception_handler = handler)
        print "total failures: %s" % Handler.errors

    Ля-ля-ля, замыкания!

    wvxvw, 10 Июля 2014

    Комментарии (211)
  8. JavaScript / Говнокод #16177

    +159

    1. 1
    https://software.intel.com/sites/billboard/article/simd-javascript-faster-html5-apps

    Почему нужно выбрать самый говенный язык, и усиленно добавлять в него фичи, с которыми он все равно не может нормально работать? :( Просто пиздец какой-то.

    wvxvw, 16 Июня 2014

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

    −106

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    case EffectVO.ENTER_FROM_LEFT: 
    	xFrom = - (sprite.boundingRect.width + Math.abs(sprite.boundingRect.x));
    	xFrom *= extraSafetyScaleFactor;
    	objectTween = TweenLite.from(spriteView, 0.5,
            {
                x: String(xFrom),
                immediateRender: true,
                ease: Cubic.easeOut
            });

    Культовый код. Вот, недавно набрел на ссылку:
    http://en.wikipedia.org/wiki/Cargo_cult_programming
    Почему-то во всем проекте анимированые свойства либо конвертируются в строки, либо изначально задаются строками. Писец давно уволился, и выяснить первопричину сейчас не представляется возможным, но существует предположение, что таким образом писец боролся с NaN... вряд ли это конечно могло помочь, но на то он и культ.

    wvxvw, 11 Июня 2014

    Комментарии (1)
  10. Куча / Говнокод #16023

    +126

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    2.2.14   Empty text box                                                Why there is an option to add an empty text box
    3.2.14   Presentation on the left side                                 The paper that the narrow on him (that playing right now), should be enlarge (like magnifying glass).
    3.2.14   Player- time scale                                            Should be an option to move the narrow on the scale and "jump" forward\backwards
    3.2.14   Slide- changing pages                                         Should be an option to move between pages while the presentation is playing\the caption appearing
    3.2.14   Slide's tooltips invisible                                    Slide's tooltips invisible because the arror is hide them
    3.2.14   Delete a slide - Are you sure message                         When a user deleting a slide, should be a message: "Are you sure?"
    5.2.14   Slide- "Play presentation" button, should call "Full screen"  It's not clear enough that this button is Full screen
    5.2.14   Slide- Minimize button- should have tooltip                   It's not clear enough that this button is Minimize button
    5.2.14   Picture Editing                                               Its not clear enough that the small button in corner is the "Edit button", when clicking on the picture to
                                                                           edit, its go back to the library

    English as she is spoke.

    Сегодня получил списог багов обнаруженый нашим КуЭй. Это только малая толика (всего их там около сотни).

    wvxvw, 20 Мая 2014

    Комментарии (2)
  11. JavaScript / Говнокод #15969

    +157

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    function test(x) {
        function undefined(x) { throw "Missing in action"; }
        switch (x) {
        case 1: console.log("X reporting for duty!"); break;
        case undefined(x): break;
        }
    }

    Переделка длинного и скучного кода, но смысл остался.

    wvxvw, 13 Мая 2014

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