Skip to content

Instantly share code, notes, and snippets.

Avatar

Anton Khlynovskiy subzey

View GitHub Profile
View index.js
#!/usr/bin/env node
const { createServer } = require('http');
function serveStatic(req, res) {
res.writeHead(200, {
'Content-Type': 'text/html;charset=utf-8',
});
res.end(`
<!doctype html>
@subzey
subzey / index.html
Last active Jun 29, 2020
new window right away
View index.html
<!doctype html>
<html>
<head>
<title>New window right away open test</title>
</head>
<body>
<button id="openwnd">Open a new window</button>
<script>
const pageTemplate = '<h1>Loading...</h1>';
View index.html
<!doctype html>
<html>
<head>
<title>New window open test</title>
</head>
<body>
<button id="openwnd">Open a new window</button>
<script>
function openTab(url) {
const a = document.createElement('a');
@subzey
subzey / readme.md
Created Jun 4, 2020
Погода на Марсе
View readme.md

Показать погоду на Марсе. Это не оборот речи, это реально погода на Марсе.

Вот свагер-доки https://maas2.apollorion.com/.

Нужно вывести на консоль браузера температуры за последние 5 солов (марсианских дней). Пример вывода:

Sol #2667: -70..-13 C
Sol #2666: -70..-11 C
Sol #2665: -69..-13 C
@subzey
subzey / pipe.wat
Created Mar 2, 2020
Writes to stdout what it gets from stdin
View pipe.wat
(module
;; Expects a https://wasi.dev/ interface
;; Run this module with https://wasmer.io/ or https://wasmtime.dev/
(func $fd_write (import "wasi_unstable" "fd_write") (param i32 i32 i32 i32) (result i32))
(func $fd_read (import "wasi_unstable" "fd_read") (param i32 i32 i32 i32) (result i32))
(func $proc_exit (import "wasi_unstable" "proc_exit") (param i32))
(memory (export "memory") 1)
(func (export "_start")
@subzey
subzey / test.wat
Last active Mar 2, 2020
WASI iovec
View test.wat
(module
(func $fd_write (import "wasi_unstable" "fd_write") (param i32 i32 i32 i32) (result i32))
(func $proc_exit (import "wasi_unstable" "proc_exit") (param i32))
(memory (export "memory") 1)
(data (offset (i32.const 65532)) "TEST")
(func (export "_start")
(i32.store (i32.const 0) (i32.const 65532)) ;; iov.iov_base
(i32.store (i32.const 4) (i32.const 4)) ;; iov.iov_len
@subzey
subzey / Debug z-index.js
Created Dec 25, 2019
Debug z-index snippet
View Debug z-index.js
console.table(
$x('ancestor-or-self::*', $0).reverse().map(el => {
const computedStyle = el.ownerDocument.defaultView.getComputedStyle(el);
return { element: el, 'z-index': computedStyle.zIndex, position: computedStyle.position };
})
);
@subzey
subzey / xorshift.ts
Last active Dec 11, 2019
PRNG vs RNG
View xorshift.ts
// Run this file with:
// npx ts-node -T xorshift.ts
const { randomFillSync } = require('crypto');
const enum Hardcode {
IdBytesLength = 4,
GeneratorsInParallel = 32,
TestIterations = 1001,
}
@subzey
subzey / index.html
Created Nov 18, 2019
webgl2 shaders example
View index.html
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<canvas id="a"></canvas>
<script>
const gl = a.getContext('webgl2');
const program = gl.createProgram();
@subzey
subzey / index.html
Created Nov 13, 2019
iframe autoplay
View index.html
<!doctype html>
<html>
<head>
<title></title>
</head>
<body>
<script>
function playSound() {
var ifr = document.createElement('iframe');
ifr.allow = 'autoplay';
You can’t perform that action at this time.