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

    Всего: 33

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

    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
    @dataclass(slots=True)
    class Govno:
        govno_index: int
        
        def patch(self, indices_dict: Dict[int, int]) -> None:
            new_index = indices_dict[self.govno_index]
            self.govno_index = new_index
    
    
    @dataclass(slots=True)
    class Mocha:
        mocha_index: int
        
        def patch(self, indices_dict: Dict[int, int]) -> None:
            new_index = indices_dict[self.govno_index]
            self.govno_index = new_index

    Метод «patch» был скопипащен из класса «Govno» в класс «Mocha». Тайпчекер никаких ошибок не показывал; все типы были выведены корректно.

    А в рантайме всё упало, что и неудивительно!

    ISO, 13 Июня 2023

    Комментарии (42)
  3. JavaScript / Говнокод #28785

    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
    if (this.$arg0 == 'inc')    this.$ret = this.$math = args[0] + 1;
            if (this.$arg0 == 'dec')    this.$ret = this.$math = args[0] - 1;
            if (this.$arg0 == 'div')    this.$ret = this.$math = args[0] / args[1];
            if (this.$arg0 == 'ceil')   this.$ret = this.$math = Math.ceil(args[0]);
            if (this.$arg0 == 'floor')  this.$ret = this.$math = Math.floor(args[0]);
            if (this.$arg0 == 'sqrt')   this.$ret = this.$math = Math.sqrt(args[0]);
            if (this.$arg0 == 'exp')    this.$ret = this.$math = Math.exp(args[0]);
            if (this.$arg0 == 'log')    this.$ret = this.$math = Math.log(args[0]);
            if (this.$arg0 == 'sin')    this.$ret = this.$math = Math.sign(args[0]);
            if (this.$arg0 == 'log10')  this.$ret = this.$math = Math.log10(args[0]);
            if (this.$arg0 == 'cos')    this.$ret = this.$math = Math.cos(args[0]);
            if (this.$arg0 == 'tan')    this.$ret = this.$math = Math.tan(args[0]);
            if (this.$arg0 == 'acos')   this.$ret = this.$math = Math.acos(args[0]);
            if (this.$arg0 == 'atan')   this.$ret = this.$math = Math.atan(args[0]);
            if (this.$arg0 == 'round')  this.$ret = this.$math = Math.round(args[0]);
            if (this.$arg0 == 'atan2')  this.$ret = this.$math = Math.atan2(args[0]);

    Исходный код интерпретатора компилятора (!) Языка Программирования «AsmX».
    https://github.com/langprogramming-AsmX/AsmX/blob/main/compiler.js#L215

    ISO, 19 Мая 2023

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

    0

    1. 1
    AttributeError: type object 'datetime.datetime' has no attribute 'from_timestamp'. Did you mean: 'fromtimestamp'?

    ISO, 19 Марта 2023

    Комментарии (27)
  5. C++ / Говнокод #28597

    −1

    1. 1
    std::int32_t(v8::Maybe<std::int32_t>::* maybe_from_just)() && = v8::Maybe<std::int32_t>::FromJust;

    ISO, 10 Февраля 2023

    Комментарии (56)
  6. VisualBasic / Говнокод #28567

    −3

    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
    Public Function DescendingSort(ByRef Data As Variant) As Variant
        Dim i As Long
        For i = LBound(Data) To UBound(Data) - 1
            Dim j As Long
            For j = i + 1 To UBound(Data)
                If Data(i) < Data(j) Then
                    Dim Temp As Variant
                    Temp = Data(j)
                    Data(j) = Data(i)
                    Data(i) = Temp
                End If
            Next
        Next
    
        DescendingSort = Data
    End Function

    Вот все спрашивают, зачем на собеседованиях требуют сортировки писать — так вот для этого! Вдруг вам придётся писать на «VBA»?
    > Как в VBA правильно создавать одномерный массив. ArrayList
    https://habr.com/ru/post/712000/

    ISO, 23 Января 2023

    Комментарии (286)
  7. Java / Говнокод #28543

    +1

    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
    static private Double getHashString(String string, Integer foundation){
        Double hash = 0.0 ;
        short [] charsToInteger = getCharArray(string);
        double step = Double.MAX_VALUE / 256 - foundation;
        for (int i = 0; i < charsToInteger.length ; i++ ){
            hash += charsToInteger[i] * step;
            step = step / 2 - 1;
        }
        return hash;
    }
    
    static private short [] getCharArray(String string){
        char [] chars = string.toLowerCase().toCharArray();
        short [] bytes = new short [chars.length];
        for (int i = 0; i < chars.length; i++){
            bytes [i] = (short) (chars[i] & 0x00FF);
            //System.out.println("bytes [" + i + "] = " + bytes[i]);
        }
        return bytes;
    }

    Вычисление сигнатуры строки для её применения в сортировке строк в алфавитном порядке по всем символам
    https://habr.com/ru/post/709406/ / https://itnan.ru/post.php?c=1&p=709406
    https://github.com/Helgi-cell/HashStringAlphabetical

    ISO, 08 Января 2023

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

    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
    table inet filter {
        set open_ports {
            type inet_proto . inet_service
            counter
            elements = { tcp . 123 counter packets 0 bytes 0,
                     udp . 123 counter packets 0 bytes 0,
                     tcp . 456 counter packets 0 bytes 0,
                     tcp . 567 counter packets 0 bytes 0 }
        }
    
        chain input {
            type filter hook input priority filter; policy drop;
            iifname "eth*" ct state established,related accept
            iifname "eth*" ct state invalid drop
            iifname "eth*" ct state new meta l4proto . th dport @open_ports accept
        }
    }

    «nftables» — охуенны.

    ISO, 30 Декабря 2022

    Комментарии (141)
  9. Куча / Говнокод #28519

    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
    YAML:
    - 0:00
    - 01:00
    - 12:34
    
    yaml2json.hs
    ["0:00","01:00","12:34"]
    
    yaml2json.pl
    ["0:00","01:00","12:34"]
    
    yaml2json.py
    ["0:00", "01:00", 754]
    
    yaml2json.rb
    [0,3600,45240]
    
    rq
    ["0:00","01:00","12:34"]

    https://github.com/cblp/yaml-sucks

    ISO, 21 Декабря 2022

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

    0

    1. 1
    const govnoMochi = `$mocha.govno` ?? "Ваше говно не определено";

    ISO, 20 Декабря 2022

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

    0

    1. 1
    const govnoMochi = `$mocha.govno` ?? "Ваше говно не определено";

    ISO, 20 Декабря 2022

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