1. JavaScript / Говнокод #26973

    0

    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
    class HelloRooster implements EditorPlugin {
        getName() {
            return 'HelloRooster';
        }
    
        initialize(editor: Editor) {}
    
        dispose() {}
    
        onPluginEvent(e: PluginEvent) {
            if (e.eventType == PluginEventType.KeyPress && e.rawEvent.which == 65) {
                alert('Hello Rooster');
            }
        }
    }

    https://github.com/microsoft/roosterjs

    3_dar, 24 Сентября 2020

    Комментарии (0)
  2. Си / Говнокод #26972

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    #include <stdlib.h>
    
    void main()
    {
        a: ; malloc(1); goto a;
    }

    GDMaster, 23 Сентября 2020

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

    +2

    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
    REM I'm trying to do some simple webscraping in OpenOffice (I usually work in Excel but I'm trying to port 
    REM something over for a coworker that doesn't have Excel). 
    REM However, when I try to run something very similar to this, it keeps giving me this BASIC runtime error 1.
    
    Sub Macro1
        Dim explorer As Object
        Set explorer = CreateObject("InternetExplorer.Application")
        explorer.Visible = True
        explorer.navigate("www.yahoo.com")
        
        Const READYSTATE_COMPLETE As Long = 4
        Do While explorer.Busy Or explorer.readyState <> READYSTATE_COMPLETE
        Loop
    
        dim page as object
        set page = explorer.Document
        
        dim mailButton as object
        set mailButton = page.GetElementByID("ybar-navigation-item-mail") 'this is the line the error occurs on
        mailButton.Click
    End Sub

    а чего бы нам не краулить сайты, запуская IE через BASIC в экселе

    https://stackoverflow.com/questions/64010764/is-webscraping-with-openoffice-basic-even-possible

    Fike, 22 Сентября 2020

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

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    public void startLoginService(User paramUser) {
        if (paramUser != null) {
            Intent intent = new Intent((Context)this, LoginService.class);
            intent.putExtra("LOGIN_KEY", paramUser.getLogin());
            intent.putExtra("PASSWORD_KEY", String.valueOf(paramUser.getId()));
            startService(intent);
        }
    }

    GDMaster, 22 Сентября 2020

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

    0

    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
    public static UUID fromString(String name) {
            String[] components = name.split("-");
            if (components.length != 5)
                throw new IllegalArgumentException("Invalid UUID string: "+name);
            for (int i=0; i<5; i++)
                components[i] = "0x"+components[i];
    
            long mostSigBits = Long.decode(components[0]).longValue();
            mostSigBits <<= 16;
            mostSigBits |= Long.decode(components[1]).longValue();
            mostSigBits <<= 16;
            mostSigBits |= Long.decode(components[2]).longValue();
    
            long leastSigBits = Long.decode(components[3]).longValue();
            leastSigBits <<= 48;
            leastSigBits |= Long.decode(components[4]).longValue();
    
            return new UUID(mostSigBits, leastSigBits);
        }

    без префикса "0x" написать рабочий код было невозможно, очевидно
    это хоть починили

    https://github.com/openjdk/jdk/blob/jdk8-b120/jdk/src/share/classes/java/util/UUID.java#L191-L209

    Fike, 22 Сентября 2020

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

    0

    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
    /**
         * Compares {@link Comparable} objects in natural order.
         *
         * @see Comparable
         */
        enum NaturalOrderComparator implements Comparator<Comparable<Object>> {
            INSTANCE;
    
            @Override
            public int compare(Comparable<Object> c1, Comparable<Object> c2) {
                return c1.compareTo(c2);
            }
    
            @Override
            public Comparator<Comparable<Object>> reversed() {
                return Comparator.reverseOrder();
            }
        }

    У нас будет компаратор, который сравнивает дженерики, но не совсем дженерики, потому что Object, а еще мы сделаем его enum, потому что можем

    https://github.com/openjdk/jdk/blob/jdk-14-ga/src/java.base/share/classes/java/util/Comparators.java#L47-L59

    Fike, 22 Сентября 2020

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

    0

    1. 1
    <img alt="[object Object]" title="[object Object]" loading="lazy">

    https://beru.ru/catalog/avtotovary/76688?hid=90402 , когда смог в жс на бэкэнде

    phpBidlokoder2, 21 Сентября 2020

    Комментарии (5)
  8. Куча / Говнокод #26966

    0

    1. 1
    Питушня #8

    #1: https://govnokod.ru/26692 https://govnokod.xyz/_26692
    #2: https://govnokod.ru/26891 https://govnokod.xyz/_26891
    #3: https://govnokod.ru/26893 https://govnokod.xyz/_26893
    #4: https://govnokod.ru/26935 https://govnokod.xyz/_26935
    #5: (vanished) https://govnokod.xyz/_26954
    #6: (vanished) https://govnokod.xyz/_26956
    #7: https://govnokod.ru/26964 https://govnokod.xyz/_26964

    nepeKamHblu_nemyx, 21 Сентября 2020

    Комментарии (2317)
  9. JavaScript / Говнокод #26965

    +1

    1. 1
    Чем пакеты "npm" лучше старых добрых плагинов "jQuery"?

    Плагины зависели только от самого "jQuery", а пакеты волокут за собою десятки и сотни левых говен.

    rotoeb, 20 Сентября 2020

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

    +1

    1. 1
    Питушня #7

    #1: https://govnokod.ru/26692 https://govnokod.xyz/_26692
    #2: https://govnokod.ru/26891 https://govnokod.xyz/_26891
    #3: https://govnokod.ru/26893 https://govnokod.xyz/_26893
    #4: https://govnokod.ru/26935 https://govnokod.xyz/_26935
    #5: (vanished) https://govnokod.xyz/_26954
    #6: (vanished) https://govnokod.xyz/_26956

    nepeKamHblu_nemyx, 20 Сентября 2020

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