Skip to content

Instantly share code, notes, and snippets.

View dy's full-sized avatar
🙌
you're doing good

Dmitry Iv. dy

🙌
you're doing good
View GitHub Profile
@jviide
jviide / README.md
Last active November 7, 2020 22:39

A Small HTM VM FTW OMG BBQ

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. The build.mjs file it imports is HTM's src/build.mjs.

This tweet demonstrates that a minified evaluate() fits in one tweet: https://twitter.com/jviide/status/1257755526722662405 🙂

@pyrocto
pyrocto / overload.js
Last active January 25, 2024 19:13
A modest proposal for operator overloading in JavaScript
/*
It is a melancholy object-oriented language to those who walk through
this great town or travel in the country, when they see the JavaScript
programs crowded with method calls begging for more succinct syntax.
I think it is agreed by all parties, that whoever could find out a
fair, cheap and easy method of making these operators sound and useful
members of the language, would deserve so well of the publick, as
to have his statue set up for a preserver of the nation. I do therefore
humbly offer to publick consideration a pure JS library I've written
for overloading operators, which permits computations like these:
@jakub-g
jakub-g / async-defer-module.md
Last active April 12, 2024 07:32
async scripts, defer scripts, module scripts: explainer, comparison, and gotchas

<script> async, defer, async defer, module, nomodule, src, inline - the cheat sheet

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)

@NielsLeenheer
NielsLeenheer / console.hex.js
Created November 26, 2017 20:22
console.hex
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' : ''), ''));
@jcamp
jcamp / video-editors-opensource.md
Last active April 2, 2024 21:20
OpenSource Video Editors
vec2 rotate(vec2 v, float a) {
float s = sin(a);
float c = cos(a);
mat2 m = mat2(c, s, -s, c);
return m * v;
}
@mbitsnbites
mbitsnbites / fft.js
Created May 5, 2016 20:34
Tiny FFT implementation in JavaScript
// 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) {
@plugnburn
plugnburn / README.md
Last active August 19, 2023 14:01
Samples.js: a tiny and simple Web Audio API based sample playback library

Samples.js: a tiny and simple Web Audio API based sample playback library

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.

API reference

The library exposes the following calls:

@rwaldron
rwaldron / barbie-hs-3.md
Created November 21, 2014 03:27
Barbie: The High School Days, pt. 3
We couldn’t find that file to show.
@danielkoch
danielkoch / triangle.css
Last active June 3, 2019 11:50
css gradient for triangle shaped arrow (SO)
/**
* 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;