() => {}
is not the same as() => void
.{a?: string | undefined}
is tautology.void | undefined | {} | never | null
is tautology.- Native types
Record
,Partial
etc are a bunch of internal jargon, meaningless from JS view. - Interfaces and types are same thing differently named, only creates confusion.
unknown
vsany
: little who cares about the difference.JSX.Element
,React.ReactNode
,React.ReactFragment
is tautologyconst X = {abc:123} as const
- If there is
//@ts-ignore
on the first line, prettier may split it to multiple lines and break ts this way. - Prettier expands inline constructs into ugly multiline vertical parts (myriads of examples)
- Prettier breaks matrices formatting
- It produces redundant diff logs, making it hard to analyze logic changes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// what if we had simple method on elements, taking in VDOM pieces? | |
// * it makes sure there's no internal content that messes up rendering | |
// * it allows simple function as input - something prohibited by preact | |
// * it enables element existence check | |
element?.render(({props}) => <div></div>); | |
element?.render(<div></div>); | |
element?.render(<Element></Element>); | |
function Element({props}) { ... } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// extension of document fragment, keeps references to children | |
// based on https://github.com/WebReflection/document-persistent-fragment/blob/master/esm/document-persistent-fragment.js | |
class Bug extends DocumentFragment {} | |
const shenanigans = !(new Bug instanceof Bug); | |
export default class HyperFragment extends DocumentFragment { | |
#nodes = [] | |
// DocumentFragment overrides |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; test passing array to and back | |
(module | |
(import "js" "mem" (memory 1)) | |
(import "console" "log" (func $log (param i32 f32))) | |
(global $blockSize (import "js" "blockSize") (mut i32)) | |
(global $len (mut i32) (i32.const 0)) | |
;; len = blockSize * 4 | |
(func (global.set $len (i32.mul (global.get $blockSize) (i32.const 4)))) | |
(start 1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<a href="https://twitter.com/jviide/status/1257755526722662405">ref</a> | |
<script type="module"> | |
import t from './libs/tst.js' | |
// function μ(h,...d){for(var a=[],g=0,f=0,b=-1,c;c=h[g++];)c--?c--?c--?c--?c--?a[++b]=c--?c--?[d[f++],c?{}:null]:1<g||[]:d[f++]:a[b]=this(...a[b]):Object.assign(a[b][1],d[f++]):a[b-1].push(a[b--]):a[b-2][1][a[b--]]=a[b--]:a[b-1]+=""+a[b--];return a[0]} | |
function μ(hash, ...fields){ | |
// [root, tag, props, ...children] | |
var stack=[], i=0, f=0, d=-1, c |
- Adding/removing indentation of large blocks creates huge diff-log, although that's simply spaces.
- Renaming a file doesn't come along with diff-log, it must be a separate commit, otherwise log is huge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
// 0, | |
1/2, | |
1/3,2/3, .33,.333,.3333,.66,.666,.6666, | |
1/4,3/4, | |
1/5,2/5,3/5,4/5, | |
1/6,5/6, | |
1/7, | |
1/8,3/8,5/8,7/8, | |
1/9, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(() => { | |
// play around with initial sequences / operator combinations | |
let seqs = {}, ops = {'+':(a,b)=>a+b,'-':(a,b)=>a-b}//'/':(a,b)=>a/b,'*':(a,b)=>a*b} | |
const results = new Proxy({}, { | |
set(results, prop, value){ | |
if (results[prop]) { | |
if (!results[prop].includes(value)) console.error('set', prop, ':', value, 'exists as', results[prop]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// paste the code below into browser console in any youtube page and call `record(from, to)` | |
// from and to are in seconds | |
async function record(from, to) { | |
var mediaElement=document.querySelector('video') | |
var recordedChunks = []; | |
var mimeType = 'audio/webm;codecs="opus"' | |
var ac = new AudioContext(); | |
var mediaSource = new MediaElementAudioSourceNode(ac, {mediaElement}); |