Skip to content

Instantly share code, notes, and snippets.

@atomless
atomless / string_literals.js
Last active November 14, 2018 12:43
String To String Literal Template
/** Generate a string literal template with arbitrarily many substitutions.
* Usage: (IMPORTANT, MUST OMIT BRACKETS IN THE INSTANTIATION CALL):
* let template = stringLiteralTemplate`Hello, ${0}. This is a ${1}`;
* let final_string = template.with('world', 'test');
* >> "Hello, world. This is a test"
* Also:
* let template = stringLiteralTemplate`${0}, ${0}, ${1}. ${2}. ${2} 1, 2, 3.`;
* let final_string = template.with('Hello', 'World', 'Testing');
* >> "Hello, Hello, World. Testing. Testing 1, 2, 3"
*/
@atomless
atomless / a_shaggy_dog_tale.js
Last active May 2, 2018 09:16
playing with object and function composition
const series = (...fns) => (...args) => fns.map(f => f(...args));
const tailFactory = (width) => {
let wag_to_width_ratio = Math.random();
let wagspeed = Math.ceil(width * wag_to_width_ratio);
return {
setWagSpeed({ width = 0 } = {}) {
wagspeed = Math.ceil(width * wag_to_width_ratio);
},
wag() { console.log(Array(wagspeed).fill('WAG', 0, wagspeed).join(',')); }
@atomless
atomless / keybase.md
Created March 22, 2017 11:01
Verifying Keybase Identity

Keybase proof

I hereby claim:

  • I am atomless on github.
  • I am atomless (https://keybase.io/atomless) on keybase.
  • I have a public key whose fingerprint is 87F2 9965 5E93 44DB 2DF5 D2A6 951B 9ACF 24AC 19EC

To claim this, I am signing this object:

@atomless
atomless / setDate-vs-setUTCDate.js
Created May 30, 2014 18:47
setDate vs setUTCDate
d = new Date('Fri May 30 2014 00:00:00 GMT+0100 (BST)');
// >> Fri May 30 2014 00:00:00 GMT+0100 (BST)
d.setUTCDate(31);
// >> 1401577200000
d