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

    +1

    1. 1
    npm install

    очередной npm пакет с трояном

    https://www.bleepingcomputer.com/news/security/popular-coa-npm-library-hijacked-to-steal-user-passwords/

    Her, 05 Ноября 2021

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

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    interface Surface {
    	n: number;
    }
    
    let shiny: Surface = {
    	n: 10.0
    }
    
    function main() {
    	print(shiny.n);
    }

    шах и мат С/C++ девелоперам :) (постов не будет - сайт все блокирует)

    ASD_77, 02 Ноября 2021

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

    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
    interface Something {
        r: number;
        g: number;
        b: number;
        toString: () => string;
    }
    
    function main() {
        const something = {
            r: 11.0, g: 12.0, b: 13.0, toString() {
                return "Hello " + this.b;
            }
        };
    
        const iface = <Something>something;
        print(iface.toString());
    
        print("done.");
    }

    Интерфесы для абстрактых обьектов.. а ваш говно компилятор может так?

    ASD_77, 28 Октября 2021

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    let textarea = document.querySelector('textarea')
    let list = document.querySelector('ol')
    let newTask = document.createElement('li')
    newTask.innerText = textarea.value
    
    function submitTask() {
        list.appendChild(newTask)
    }

    При попытке добавлять новый HTML элемент функция добавления срабатывает только один раз, к тому же для добавления используется не то значение которое я ввожу в текстовое поле, а только дефолтное. Так как я перепробовал уже массу вариантов и с инпутом, и с событием нажатия Enter, какие-то варианты, которые уже забыл, я подозреваю, что проблема, вероятно, в appendChild, но не уверен, и не понимаю её.

    shuric, 22 Октября 2021

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

    −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
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    let glb1 = 0;
    
    class Color {
        static constructor() {
            glb1++;
            print("Static construct");
        }
    
        constructor(public r: number,
            public g: number,
            public b: number) {
        }
    
        static white = 1;
    }
    
    class Color2 {
        static constructor() {
            glb1++;
            print("Static construct 2");
        }
    }
    
    function main() {
        assert(glb1 == 2);
        print("done.");
    }

    добавил статические кострукторы... а то забыл эту хню сделать

    ASD_77, 21 Октября 2021

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

    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
    function main4() {
    
        let i = 0;
    
        try {
            try {
                throw 1.0;
            }
            catch (e: number) {
                i++;
                print("asd1");
                throw 2.0;
            }
            finally {
                print("finally");
            }
        }
        catch (e2: number) {
            i++;
            print("asd3");
        }
    
        assert(i == 2);
    }
    
    function main() {
        main4();
        print("done.");
    }

    Ну вот и все.. шах и мат С/C++ девелоперы... последняя хитровые...аная инструкция finally сделана. (надо еще для линуха сделать .. а то они разные)

    ASD_77, 13 Октября 2021

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

    +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
    function main() {
        let c = 0;
    
        try {
            c++;
            print("try");
            throw "except";
            c--;
            print("after catch");
        } finally {
            c++;
            print("finally");
        }
    
        assert(2 == c);
    }

    ну вот и все... проимплементил последний keyword в языке... (осталось только темплейты - ну и головняк меня ждем)

    ASD_77, 29 Сентября 2021

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

    +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
    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
    alex@ASD-PC:~/TypeScriptCompiler/3rdParty/llvm-wasm/debug/bin$ node mlir-translate.js --help
    OVERVIEW: MLIR Translation Testing Tool
    USAGE: mlir-translate.js [options] <input file>
    
    OPTIONS:
    
    Color Options:
    
      --color                                              - Use colors in output (default=autodetect)
    
    General options:
    
      --dot-cfg-mssa=<file name for generated dot file>    - file name for generated dot file
      --mlir-disable-threading                             - Disabling multi-threading within MLIR
      --mlir-elide-elementsattrs-if-larger=<uint>          - Elide ElementsAttrs with "..." that have more elements than the given upper limit
      --mlir-pretty-debuginfo                              - Print pretty debug info in MLIR output
      --mlir-print-debuginfo                               - Print debug info in MLIR output
      --mlir-print-elementsattrs-with-hex-if-larger=<long> - Print DenseElementsAttrs with a hex string that have more elements than the given upper limit (use -1 to disable)
      --mlir-print-op-on-diagnostic                        - When a diagnostic is emitted on an operation, also print the operation as an attached note
      --mlir-print-stacktrace-on-diagnostic                - When a diagnostic is emitted, also print the stack trace as an attached note
      -o=<filename>                                        - Output filename
      --split-input-file                                   - Split the input file into pieces and process each chunk independently
      Translation to perform
          --deserialize-spirv                                 - deserialize-spirv
          --import-llvm                                       - import-llvm
          --mlir-to-llvmir                                    - mlir-to-llvmir
          --serialize-spirv                                   - serialize-spirv
          --test-spirv-roundtrip                              - test-spirv-roundtrip
          --test-spirv-roundtrip-debug                        - test-spirv-roundtrip-debug
      --verify-diagnostics                                 - Check that emitted diagnostics match expected-* lines on the corresponding line
    
    Generic Options:
    
      --help                                               - Display available options (--help-hidden for more)
      --help-list                                          - Display list of available options (--help-list-hidden for more)
      --version                                            - Display the version of this program
    program exited (with status: 0), but EXIT_RUNTIME is not set, so halting execution but not exiting the runtime or preventing further async execution (build with EXIT_RUNTIME=1, if you want a true shutdown)
    alex@ASD-PC:~/TypeScriptCompiler/3rdParty/llvm-wasm/debug/bin$

    сказ о том как я LLVM на WASM компилял :)

    ASD_77, 28 Сентября 2021

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

    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
    96. 96
    const range = (count) => Array.from(Array(count).keys());
    class Matrix {
    
        static Dot(A, B) {
            // Dot production
            const wA = A[0].length;
            const hA = A.length;
            const wB = B[0].length;
            const hB = B.length;
    
            if (wA != hB)
            {
                throw "A width != B height";
            }
    
            const C = range(hA).map((_, i) => range(wB).map((_, j) => 0));
    
            for (let i = 0; i < hA; ++i)
                for (let j = 0; j < wB; ++j) {
                    let sum = 0;
    
                    for (let k = 0; k < wA; ++k) {
                        const a = A[i][k];
                        const b = B[k][j];
                        sum += a * b;
                    }
    
                    C[i][j] = sum;
                }
    
            return C;                
        }
    
        static Mul(A, B) {
            // Dot production
            const wA = A[0].length;
            const hA = A.length;
            const wB = B[0].length;
            const hB = B.length;
    
            if (wA != wB || hA != hB)
            {
                throw "A width != B width, A height != B height";
            }
    
            const C = range(hA).map((_, i) => range(wA).map((_, j) => A[i][j] * B[i][j]));
            return C;
        }            
    
        static Add(A, B) {
            const wA = A[0].length;
            const hA = A.length;
            const wB = B[0].length;
            const hB = B.length;
    
            if (wA != wB || hA != hB)
            {
                throw "A width != B width, A height != B height";
            }
    
            const C = range(hA).map((_, i) => range(wA).map((_, j) => A[i][j] + B[i][j]));
            return C;
        }
    
        static Sub(A, B) {
            const wA = A[0].length;
            const hA = A.length;
            const wB = B[0].length;
            const hB = B.length;
    
            if (wA != wB || hA != hB)
            {
                throw "A width != B width, A height != B height";
            }
    
            const C = range(hA).map((_, i) => range(wA).map((_, j) => A[i][j] - B[i][j]));
            return C;
        }
    
            static Translate(A, shift) {
            const wA = A[0].length;
            const hA = A.length;
    
            const R = range(hA).map((_, i) => range(wA).map((_, j) => A[i][j] + shift));
            return R;                        
        }         
    
        static Sigmoid(A) {
            const wA = A[0].length;
            const hA = A.length;
    
            const R = range(hA).map((_, i) => range(wA).map((_, j) => 1 / (1 + Math.exp(-A[i][j]))));
            return R;                                        
        }
    //...
    }

    лаба по математике матрици :)

    ASD_77, 26 Сентября 2021

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

    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
    let users = [
      user_1 = {
        user_name: 'Первый',
        user_login: 'l1',
        user_password: 'p1'
      },
      user_2 = {
        user_name: 'Второй',
        user_login: 'l2',
        user_password: 'p2'
      },
      user_3 = {
        user_name: 'Третий',
        user_login: 'l3',
        user_password: 'p3'
      }
    ]
    
    function authorisation(guest_login, guest_password) {
      for (let key in users) {
        if(guest_login == users[key].user_login && guest_password == users[key].user_password) {
          return alert('Хай ' + users[key].user_name);
        } else {
          alert('Чёт не то'); continue;
        }
      }
    }
    
    authorisation(prompt('Введите логин'), prompt('введите пароль'))

    Вот казалось бы, ну чего тут сложного? А чёт сложно. Всего-то и нужно - пробегаться по массиву объектов, сверять логины и пароли и либо здороваться с пользователем, либо выдавать сообщение об ошибке. Находить пользователя у меня получается, проблема в том, что если он не первый по счёту, то сообщение об ошибке выпадает на каждого предыдущего. Ну и если крутить вертеть последовательность, то просто на каждого с кем данные не совпадают. Как бы мне этого избежать?

    shuric, 18 Сентября 2021

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