Skip to content

Instantly share code, notes, and snippets.

View bathos's full-sized avatar
⚱️
gimme elixir!

Darien Maillet Valentine bathos

⚱️
gimme elixir!
View GitHub Profile
@bathos
bathos / ng-material-color-classes.js
Last active March 17, 2016 05:32
md color classes (.text & .background w/ contrast text)
module.run(($mdColorPalette, $mdTheming) => {
const { THEMES } = $mdTheming;
const rules = [];
for (const themeName in THEMES) {
const { colors } = THEMES[themeName];
const themeCls = themeName == 'default' ? '' : `.md-${ themeName }-theme`;
@bathos
bathos / sailormoon-helper.js
Last active June 27, 2016 02:44
sketchy thing I had in an about:blank tab so I could keep track of where I am in sailor moon -- paste in console
// STATE ///////////////////////////////////////////////////////////////////////
const state = {
down: false,
index: 0
};
// DATA ////////////////////////////////////////////////////////////////////////
const scouts = [
@bathos
bathos / angular-ui-router.js
Created December 25, 2016 15:43
1.0.0-beta.3 built bundle
/*!
* State-based routing for AngularJS
* @version v1.0.0-beta.3
* @link https://ui-router.github.io
* @license MIT License, http://www.opensource.org/licenses/MIT
*/
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("angular"));
else if(typeof define === 'function' && define.amd)
@bathos
bathos / hid.js
Created February 23, 2017 15:40
replacement entry for node-hid?
const assert = require('assert');
const binary = require('node-pre-gyp');
const { Duplex } = require('stream');
const SHARED_METHOD_KEYS = [
'getDeviceInfo',
'getFeatureReport',
'sendFeatureReport',
'setNonBlocking'
];
@bathos
bathos / hid.js
Created March 1, 2017 15:37
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'
@bathos
bathos / .eslintrc.yaml
Last active May 18, 2017 22:15
personal eslint config 2017 update
%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
@bathos
bathos / quik-utf8-to-cps-sync.js
Last active October 18, 2017 03:00
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 / clippen-majik.js
Created May 24, 2017 02:46
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 / debouncing-promises.js
Last active November 8, 2017 18:59
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 / strings.md
Last active March 22, 2018 02:32
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.