var links = ["TkPbJIlEXow", | |
"Z4nAUPw8j5s", | |
"H5MtQA5dvrU", | |
"ouNvc6GRwUg", | |
"0VI4HV0pX-o", | |
"h-x0y3o1UwA", | |
"Z4nAUPw8j5s", | |
"MOzQ4Bs916I", | |
"JByDbPn6A1o", | |
"rf2kMnnNROc", |
/** | |
* css gradient for triangle shaped arrow (SO) | |
* http://stackoverflow.com/questions/12431596/css-gradient-for-triangle-shaped-arrow | |
*/ | |
.rectangle { | |
float: left; | |
position: relative; | |
height: 80px; | |
width: 240px; | |
border: solid 1px #ccc; |
Web Audio API spec is a great way of professional audio playing and mixing in the modern browser. However, it's too complex and versatile for some simple one-off tasks such as "load an audio sample into memory and just play it when necessary". That's why Samples.js has come true. It's a really simple and tiny (less than 1K minified) library that exposes just 5 methods to manipulate your samples from JS code in a really easy and fun way.
The library exposes the following calls:
// This is a tiny radix-2 FFT implementation in JavaScript. | |
// The function takes a complex valued input signal, and performs an in-place | |
// Fast Fourier Transform (i.e. the result is returned in x_re, x_im). The | |
// function arguments can be any Array type (including typed arrays). | |
// Code size: <300 bytes after Closure Compiler. | |
function FFT(x_re, x_im) { | |
var m = x_re.length / 2, k, X_re = [], X_im = [], Y_re = [], Y_im = [], | |
a, b, tw_re, tw_im; | |
for (k = 0; k < m; ++k) { |
vec2 rotate(vec2 v, float a) { | |
float s = sin(a); | |
float c = cos(a); | |
mat2 m = mat2(c, s, -s, c); | |
return m * v; | |
} |
Updated: 20250516
console.hex = (d) => console.log((Object(d).buffer instanceof ArrayBuffer ? new Uint8Array(d.buffer) : | |
typeof d === 'string' ? (new TextEncoder('utf-8')).encode(d) : | |
new Uint8ClampedArray(d)).reduce((p, c, i, a) => p + (i % 16 === 0 ? i.toString(16).padStart(6, 0) + ' ' : ' ') + | |
c.toString(16).padStart(2, 0) + (i === a.length - 1 || i % 16 === 15 ? | |
' '.repeat((15 - i % 16) * 3) + Array.from(a).splice(i - i % 16, 16).reduce((r, v) => | |
r + (v > 31 && v < 127 || v > 159 ? String.fromCharCode(v) : '.'), ' ') + '\n' : ''), '')); |
With the addition of ES modules, there's now no fewer than 24 ways to load your JS code: (inline|not inline) x (defer|no defer) x (async|no async) x (type=text/javascript | type=module | nomodule) -- and each of them is subtly different.
This document is a comparison of various ways the <script>
tags in HTML are processed depending on the attributes set.
If you ever wondered when to use inline <script async type="module">
and when <script nomodule defer src="...">
, you're in the good place!
Note that this article is about <script>
s inserted in the HTML; the behavior of <script>
s inserted at runtime is slightly different - see Deep dive into the murky waters of script loading by Jake Archibald (2013)
This is a half-baked sketch of compiling HTM expressions into a list of instructions that can be interpreted in runtime with a compact function. The instructions hopefully compress well and the evaluation function should be not-slow. Maybe.
-
evaluate.js
contains the evaluation function (evaluate(...)
) as well as an example of a compiled HTM call. -
babel.js
contains a Babel plugin that transforms HTM calls into the stack language. Thebuild.mjs
file it imports is HTM'ssrc/build.mjs
.
This tweet demonstrates that a minified evaluate()
fits in one tweet: https://twitter.com/jviide/status/1257755526722662405 🙂