1. Куча / Говнокод #28853

    +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
    import std.stdio;
    
    interface A {
        void M();
    }
    
    interface B : A {
        final void M() {
            writeln("BBBB");
        }
    }
    
    class C : B {
    
    }
    
    void main() {
        auto c = new C();
        c.M();
    }

    а багры здесь тихие

    > Error: class `C` interface function `void M()` is not implemented

    Desktop, 20 Сентября 2023

    Комментарии (6)
  2. Assembler / Говнокод #28852

    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
    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
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    format pe console
    include 'win32a.inc'
             sub esp,256
             mov edi,esp
             xor ebx,ebx
         cinvoke puts,.title
    .nxt:cinvoke gets,edi
         cinvoke strlen,eax
            test eax,eax
              jz .ext
             mov ecx,eax
             mov eax,edi
            call hash
            test ebx,ebx
              jz .add
             mov ecx,ebx
             mov edi,esp
           repne scasd
             jnz .add
         cinvoke puts,.yes
         cinvoke sleep,1000
             jmp .nxt
    .add:   push eax
             inc ebx
             mov ecx,eax
             mov eax,edi
            call get_hex
             mov eax,edi
         cinvoke puts,edi
             jmp .nxt
    .ext:cinvoke exit,0
    .title db 'get hash of string',0
    .yes db '!!!hash found!!!',0
    hash:   push ebx esi
             mov esi,eax
             mov eax,ecx
             xor edx,edx
             mov ecx,4
             div ecx
             mov ecx,eax
             xor eax,eax
             mov ebx,$03020100
    .start: test ecx,ecx
              jz .finish
             add eax,[esi]
             add esi,4
             xor eax,ebx
             add ebx,$04040404
            loop .start
    .finish:test edx,edx
              jz .exit
             cmp edx,1
              je .exit1
             add ax,[esi]
             xor ax,bx
             cmp edx,2
              je .exit
             add esi,2
             shr ebx,16
           bswap eax
             add ah,[esi]
             xor ah,bl
           bswap eax
             jmp .exit
    .exit1:  add al,[esi]
             xor al,bl
    .exit:   pop esi ebx
             ret
    get_hex:push ebx edi
             mov edi,eax
             mov ebx,.hex
             mov edx,ecx
             mov ecx,4
           bswap edx
             cld
    .next:   mov al,dl
             shr al,4
           xlatb
           stosb
             mov al,dl
             and al,$0F
           xlatb
           stosb
             shr edx,8
            loop .next
             xor al,al
           stosb
             mov eax,8
             pop edi ebx
             ret
    .hex db '0123456789ABCDEF'
    data import
      library msvcrt,'msvcrt.dll'
      import msvcrt,exit,'exit',puts,'puts',sleep,'_sleep',gets,'gets',strlen,'strlen'
    end data

    Приветствуем любителей накласть.
    Понадобился алгоритм для нахождения хэша строки, наклали.
    Пихает хэши в стэк и проверяет новые на совпадение со старыми.
    У кого есть предложения по его улучшению милости просим!

    chiacorp, 20 Сентября 2023

    Комментарии (11)
  3. Куча / Говнокод #28851

    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
    import std.stdio;
    
    interface Pethu {
        final void Say() {
            writeln("Hrueeee");
        }
    }
    
    void SayTwice(Pethu pethu) {
        pethu.Say();
        pethu.Say();
    }
    
    class PethuImpl : Pethu { }
    
    void main() {
        auto pethu = new PethuImpl();
        pethu.SayTwice();
    }

    Desktop, 19 Сентября 2023

    Комментарии (54)
  4. C# / Говнокод #28850

    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
    20. 20
    21. 21
    public readonly struct Int64 : IComparable<long>, IConvertible, 
    IEquatable<long>, IParsable<long>, ISpanParsable<long>, 
    System.Numerics.IAdditionOperators<long,long,long>, 
    System.Numerics.IAdditiveIdentity<long,long>, 
    System.Numerics.IBinaryInteger<long>, System.Numerics.IBinaryNumber<long>, 
    System.Numerics.IBitwiseOperators<long,long,long>, 
    System.Numerics.IComparisonOperators<long,long,bool>, 
    System.Numerics.IDecrementOperators<long>, 
    System.Numerics.IDivisionOperators<long,long,long>, 
    System.Numerics.IEqualityOperators<long,long,bool>, 
    System.Numerics.IIncrementOperators<long>, 
    System.Numerics.IMinMaxValue<long>, 
    System.Numerics.IModulusOperators<long,long,long>, 
    System.Numerics.IMultiplicativeIdentity<long,long>, 
    System.Numerics.IMultiplyOperators<long,long,long>, 
    System.Numerics.INumber<long>, System.Numerics.INumberBase<long>, 
    System.Numerics.IShiftOperators<long,int,long>, 
    System.Numerics.ISignedNumber<long>, 
    System.Numerics.ISubtractionOperators<long,long,long>, 
    System.Numerics.IUnaryNegationOperators<long,long>, 
    System.Numerics.IUnaryPlusOperators<long,long>

    https://learn.microsoft.com/en-us/dotnet/api/system.int64?view=net-7.0

    ISO, 18 Сентября 2023

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

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    from time import sleep
    from datetime import datetime
    
    
    def _sum(num1, num2):
        start_time = datetime.now()
        sleep(num1)
        end_time = datetime.now()
        total_passed = end_time - start_time
        return num2 + total_passed.seconds

    Функция сложения с хитрым, очень эффективным алгоритмом.

    F_C_TL, 16 Сентября 2023

    Комментарии (25)
  6. Куча / Говнокод #28848

    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
    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
    MEMORY{
            ROM(rx)    : ORIGIN = 0x08020000, LENGTH = 1920K
            SRAM (rwx) : ORIGIN = 0x20020000, LENGTH = 128K
    }
    
    _estack = LENGTH(SRAM) + ORIGIN(SRAM);
    
    SECTIONS{
            .isr_vector : {
            KEEP(*(.isr_vector))
            } >ROM
    
            .text : {
            . = ALIGN(4);
            *(.text)
        } >ROM
    
            _sidata = LOADADDR(.data);
            .data : {
                    . = ALIGN(4);
                    _sdata = .;
                    *(.data)
                    . = ALIGN(4);
                    _edata = .;
            } >SRAM AT>ROM
    
            .bss : {
                    . = ALIGN(4);
                    _sbss = .;
                    *(.bss)
                    . = ALIGN(4);
                    _ebss = .;
            } >SRAM
    }

    попытка написать блинк под STM32F767VIT6 на плате OpenMV 0V7725-M7

    JloJle4Ka, 16 Сентября 2023

    Комментарии (4)
  7. C# / Говнокод #28847

    0

    1. 1
    2. 2
    public ArgumentException (string? message, string? paramName);
    public ArgumentNullException (string? paramName, string? message);

    https://learn.microsoft.com/en-us/dotnet/api/system.argumentexception.-ctor?view=net-7.0#system-argumentexception-ctor(system-string-system-string)
    https://learn.microsoft.com/en-us/dotnet/api/system.argumentnullexception.-ctor?view=net-7.0#system-argumentnullexception-ctor(system-string-system-string)

    ISO, 15 Сентября 2023

    Комментарии (17)
  8. C++ / Говнокод #28846

    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
    char *SomeGlobalPointer {};
    
    void foo()
    {
      SomeGlobalPointer = new char[1024];
    }
    
    int main()
    {
      foo();
    
      if (!SomeGlobalPointer)
      {
        delete[] SomeGlobalPointer;
      }
    
      return 0;
    }

    Отсюдова:

    https://pvs-studio.ru/ru/blog/posts/cpp/1068/

    CEHT9I6PbCKuu_nemyx, 13 Сентября 2023

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

    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
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    bot.onText(/\/now/, (message) => {
        const DayOfTheWeek = new Date().toLocaleString('en-GB', { weekday: 'long' });
        const currentTime = new Date();
        let timeLeft = null;
        let currentLesson = "";
    
        for (let LessonId of Object.keys(lessons.v1[DayOfTheWeek])) {
            const lesson = lessons.v1[DayOfTheWeek][LessonId];
            const date = `${currentTime.getFullYear()}-${(currentTime.getMonth()+1).toString().padStart(2, '0')}-${currentTime.getDate().toString().padStart(2, '0')}`;
            const startLessonTime = new Date(`${date}T${lesson.start}:00.001Z`);
            const endLessonTime = new Date(`${date}T${lesson.end}:00.001Z`);
    
            if (currentTime.toLocaleString('en-GB', {timeZone: 'Europe/Moscow'}) >= startLessonTime.toLocaleString('en-GB', {timeZone: 'Africa/Ouagadougou'}) && currentTime.toLocaleString('en-GB', {timeZone: 'Europe/Moscow'}) <= endLessonTime.toLocaleString('en-GB', {timeZone: 'Africa/Ouagadougou'})) {
                currentLesson = lesson.name;timeLeft = (endLessonTime-currentTime) / 1000;
                timeLeft=timeLeft-10800+2;
                break;
            };
        };
    
        if (currentLesson && timeLeft) {
            const minutes = Math.floor(timeLeft / 60);
            const seconds = Math.floor(timeLeft % 60);
            bot.sendMessage(message.chat.id, `щяс урок: ${currentLesson}\nдо конца осталось ${minutes} минут ${seconds} секунд`);
        } else {
            bot.sendMessage(message.chat.id, 'Сейчас нет уроков');
        };
    });

    это я ночью говнокодил, ВАХхфВАХХВхаххвАХАВхаВХАХАХахвх

    qwkz1, 12 Сентября 2023

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

    0

    1. 1
    Бесконечный оффтоп имени Борманда #19

    #1: https://govnokod.ru/25864 https://govnokod.xyz/_25864
    #2: https://govnokod.ru/25921 https://govnokod.xyz/_25921
    #3: https://govnokod.ru/26544 https://govnokod.xyz/_26544
    #4: https://govnokod.ru/26838 https://govnokod.xyz/_26838
    #5: https://govnokod.ru/27625 https://govnokod.xyz/_27625
    #6: https://govnokod.ru/27736 https://govnokod.xyz/_27736
    #7: https://govnokod.ru/27739 https://govnokod.xyz/_27739
    #8: https://govnokod.ru/27745 https://govnokod.xyz/_27745
    #9: https://govnokod.ru/28307 https://govnokod.xyz/_28307
    #10: https://govnokod.ru/28631 https://govnokod.xyz/_28631
    #11: (vanished) https://govnokod.xyz/_28742
    #12: (vanished) https://govnokod.xyz/_28752
    #13: (vanished) https://govnokod.xyz/_28754
    #14: https://govnokod.ru/28759 https://govnokod.xyz/_28759
    #15: https://govnokod.ru/28765 https://govnokod.xyz/_28765
    #16: (vanished) https://govnokod.xyz/_28818
    #17: (vanished) https://govnokod.xyz/_28819
    #18: https://govnokod.ru/28822 https://govnokod.xyz/_28822

    nepeKamHblu_nemyx, 11 Сентября 2023

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