- 1
npm install
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+1
npm install
очередной npm пакет с трояном
https://www.bleepingcomputer.com/news/security/popular-coa-npm-library-hijacked-to-steal-user-passwords/
0
interface Surface {
n: number;
}
let shiny: Surface = {
n: 10.0
}
function main() {
print(shiny.n);
}
шах и мат С/C++ девелоперам :) (постов не будет - сайт все блокирует)
0
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.");
}
Интерфесы для абстрактых обьектов.. а ваш говно компилятор может так?
+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('введите пароль'))
Вот казалось бы, ну чего тут сложного? А чёт сложно. Всего-то и нужно - пробегаться по массиву объектов, сверять логины и пароли и либо здороваться с пользователем, либо выдавать сообщение об ошибке. Находить пользователя у меня получается, проблема в том, что если он не первый по счёту, то сообщение об ошибке выпадает на каждого предыдущего. Ну и если крутить вертеть последовательность, то просто на каждого с кем данные не совпадают. Как бы мне этого избежать?