- 1
 - 2
 - 3
 - 4
 - 5
 - 6
 - 7
 - 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)
}
                                    Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+1
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, но не уверен, и не понимаю её.
−1
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.");
}
                                    добавил статические кострукторы... а то забыл эту хню сделать
0
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 сделана. (надо еще для линуха сделать .. а то они разные)
+1
function main() {
    let c = 0;
    try {
        c++;
        print("try");
        throw "except";
        c--;
        print("after catch");
    } finally {
        c++;
        print("finally");
    }
    assert(2 == c);
}
                                    ну вот и все... проимплементил последний keyword в языке... (осталось только темплейты - ну и головняк меня ждем)
+1
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 компилял :)
0
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;                                        
    }
//...
}
                                    лаба по математике матрици :)
0
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('введите пароль'))
                                    Вот казалось бы, ну чего тут сложного? А чёт сложно. Всего-то и нужно - пробегаться по массиву объектов, сверять логины и пароли и либо здороваться с пользователем, либо выдавать сообщение об ошибке. Находить пользователя у меня получается, проблема в том, что если он не первый по счёту, то сообщение об ошибке выпадает на каждого предыдущего. Ну и если крутить вертеть последовательность, то просто на каждого с кем данные не совпадают. Как бы мне этого избежать?
0
type int = 1;
function main() {
    print("try/catch");
    let t = 1;
    try {
        throw 1;
    } catch (v: int) {
        print("Hello ", v);
        v = t;
    }
    assert(v == t);
    print("done.");
}
                                    Ура ура.. новый говнокод подоспел... это гавно теперь параметры в тело "catch"-а передает
0
let randomNum = Math.floor(Math.random() * 10) + 1;
let inputNum
do {
  inputNum = prompt('Угадай циферку!')
  if (inputNum < randomNum) {
    alert('Недобор');
  } else if (inputNum > randomNum) {
    alert('Перебор');
  } else if (typeof inputNum === "string") {
    alert('ну не, циферку же!');
  } else if (inputNum == null || inputNum == '') {
    alert('Покасики!');
  } else if (inputNum === randomNum) { 
    alert('Угадал!!!'); break;
    }
} while (inputNum != randomNum);
                                    Оно сначала совсем не работало. Потом вдруг заработало. Потом я ему дал полежать, настояться, и оно работать перестало опять О_о моя нипанимать
0
function main()
{
	print("before");		
	try
	{
		throw 1;
	}
	catch (x: any)
	{
		print("catch");		
	}
	print("end");		
}
                                    Самый большей говнокод за всю историю человечества сделан.