Skip to content

Instantly share code, notes, and snippets.

⚱️
gimme elixir!

Darien Maillet Valentine bathos

⚱️
gimme elixir!
Block or report user

Report or block bathos

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@bathos
bathos / function-types-kinda.md
Created Apr 8, 2018
function-types-kinda.md
View function-types-kinda.md
FK Cstr TM: Lexical TM: Global / Strict
normal cstr - function() {}; new Function
normal no () => {} x() {}
classConstructor cstr - class {}
classConstructor no - -
generator cstr - -
generator no - function * () {}; * x() {}
async cstr - -
async no async () => {} async function() {}; async x() {}
@bathos
bathos / strings.md
Last active Mar 22, 2018
strings.md
View strings.md

When Strings Attack

The Enduring Legacy of a Very Naughty Hack from 1995 / A Bit of Intl

This is my first attempt at a tech talk thing. The focus here is strings in ES. First we’ll talk about what a string is in ES, then some of the consequences that fall out of that (a few aren’t super obvious), and finally some of the cool tools available for working with strings safely & effectively. Because of the nature of the subject we’ll also get into some more general information about Unicode, encodings and broad concepts related to strings and language.

@bathos
bathos / find-a-thingie-somewhere-in-the-infinite-expanse-of-domland.js
Last active Jan 15, 2018
find a thingie somewhere in the infinite expanse of domland
View find-a-thingie-somewhere-in-the-infinite-expanse-of-domland.js
search = (() => {
const INDEX = /^(?:0|[1-9]\d+)$/;
let IDENT;
try {
IDENT = /^[\$_\p{ID_Start}][\$_\u200C\u200D\p{ID_Continue}]*$/u;
} catch (err) {
IDENT = /^[\$_a-z][\$_a-z\d]*$/i;
}
@bathos
bathos / debouncing-promises.js
Last active Nov 8, 2017
debouncing-promises.js
View debouncing-promises.js
// Typically "debouncing" means limiting execution frequency by a specific
// interval while still guaranteeing that, after a call, the behavior will still
// execute (just not synchronously; the relationship is many->one for "calls" to
// "executions"). However it is sometimes desireable to not limit by a specific
// time — you may just want to prevent something from recurring concurrently,
// without concern for overall frequency. In these cases, you may instead want
// to debounce "against" promises. This function accepts a method that returns a
// promise and returns a new function that will execute that method immediately
// only when the last execution’s promise remains unresolved, and otherwise will
// queue for re-execution (once) when the current execution is complete. In all
@bathos
bathos / quik-utf8-to-cps-sync.js
Last active Oct 18, 2017
quik-utf8-to-cps-sync.js
View quik-utf8-to-cps-sync.js
// Deliberately permissive (but fast) conversion from utf8 buffer to codepoint
// array. Invalid multibyte codepoint sequences become replacement character and
// orphaned surrogates are expressly permitted.
//
// The speed is almost identical to the built-in TextDecoder; however, it yields
// an array of codepoints, rather than a string. When compared as ways to get
// codepoints (e.g. by following TextDecoder.end with map), this runs fourteen
// times faster (not because TextDecoder is slow, but because x.from(str, map)
// is — not sure what accounts for such a big difference, though it only reaches
// those extremes on large files).
@bathos
bathos / es-identifier-pattern.js
Last active Oct 17, 2017
es identifier regex pattern
View es-identifier-pattern.js
const ID_CONTINUE_RANGE =
'\u{00024}\u{00030}-\u{00039}\u{00041}-\u{0005A}\u{0005F}\u{0005F}\u{00061}' +
'-\u{0007A}\u{000AA}\u{000B5}\u{000B7}\u{000BA}\u{000C0}-\u{000D6}\u{000D8}' +
'-\u{000F6}\u{000F8}-\u{002C1}\u{002C6}-\u{002D1}\u{002E0}-\u{002E4}' +
'\u{002EC}\u{002EE}\u{00300}-\u{00374}\u{00376}\u{00377}\u{0037A}-\u{0037D}' +
'\u{0037F}\u{00386}-\u{0038A}\u{0038C}\u{0038E}-\u{003A1}\u{003A3}-' +
'\u{003F5}\u{003F7}-\u{00481}\u{00483}-\u{00487}\u{0048A}-\u{0052F}' +
'\u{00531}-\u{00556}\u{00559}\u{00561}-\u{00587}\u{00591}-\u{005BD}' +
'\u{005BF}\u{005C1}\u{005C2}\u{005C4}\u{005C5}\u{005C7}\u{005D0}-\u{005EA}' +
'\u{005F0}-\u{005F2}\u{00610}-\u{0061A}\u{00620}-\u{00669}\u{0066E}-' +
View urlchange.js
// This module installs a custom global DOM event, 'urlchange', which is
// dispatched when the URL _semantically_ changes for any reason.
//
// It also alters URL behavior more generally. The URL is kept consistently in a
// canonical form, such that differences in the order of query parameters (other
// than same-key parameters, whose order is potentially meaningful) are
// eliminated. While the event is not fired on load, URL canonicalization may be
// performed.
//
// Like HashChangeEvent, URLChangeEvent has two properties, 'newURL' and
View clippen-majik.js
document.querySelectorAll('canvas')[1].getContext('2d').drawImage = function(canvas) {
const downloadButton = document.getElementById('download');
const anchor = document.createElement('a');
anchor.download = 'poop.png';
anchor.innerText = 'POOP';
anchor.setAttribute('class', downloadButton.getAttribute('class'));
downloadButton.parentElement.replaceChild(anchor, downloadButton);
@bathos
bathos / .eslintrc.yaml
Last active May 18, 2017
personal eslint config 2017 update
View .eslintrc.yaml
%YAML 1.2
---
# This is the client config, but it is also used as the basis of the server
# config, which just switches env and appends node-specific rules.
# Current as of eslint 3.19.0
parserOptions:
ecmaVersion: 2017
sourceType: module
View hid.js
const binary = require('node-pre-gyp');
const binding = require(binary.find(require.resolve('node-hid/package.json')));
const { Duplex } = require('stream');
const SHARED_METHOD_KEYS = [
'getDeviceInfo',
'getFeatureReport',
'sendFeatureReport',
'setNonBlocking'
You can’t perform that action at this time.