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 / extreme-chrome-reset.css
Created December 27, 2016 02:19
extreme chrome css reset
/* Slash and burn / shock and awe / total war CSS reset for Chrome specifically */
:-webkit-any(article,aside,nav,section) :-webkit-any(article,aside,nav,section) :-webkit-any(article,aside,nav,section) :-webkit-any(article,aside,nav,section) :-webkit-any(article,aside,nav,section) h1,
:-webkit-any(article,aside,nav,section) :-webkit-any(article,aside,nav,section) :-webkit-any(article,aside,nav,section) :-webkit-any(article,aside,nav,section) h1,
:-webkit-any(article,aside,nav,section) :-webkit-any(article,aside,nav,section) :-webkit-any(article,aside,nav,section) h1,
:-webkit-any(article,aside,nav,section) :-webkit-any(article,aside,nav,section) h1,
:-webkit-any(article,aside,nav,section) h1,
::-webkit-input-placeholder,
:focus,
a:-webkit-any-link,
@bathos
bathos / decor8.js
Last active September 21, 2022 18:03
decorators
// CLASS DECORATORS ////////////////////////////////////////////////////////////
/*
These can be thrown on to augment the class with the static properties method
and $arguments, which makes it possible to generically attach them to an
angular module without the angular module "directory" file needing to know any
particulars about the individual providers:
import hnAuth from './services/hn-auth';
@bathos
bathos / moplogger.js
Created July 6, 2021 15:43
moplogger.js
// This is useful for a few things:
//
// 1. Checking what dictionary options are supported by some platform API.
// 2. Debugging mysterious cases where an object you pass as input to another
// API doesn’t seem to get treated the way you’re expecting.
// 3. When designing another Proxy’s handler implementation, verifying that you
// are accounting for everything correctly and that the intended abstraction
// isn’t leaking in quirky ways.
//
// ex:
@bathos
bathos / consequence-of-constructor-kind-derived.js
Created April 16, 2021 18:18
demonstration of the consequence of whether [[ConstructorKind]] is "base" or "derived"
// CLASS SYNTAX ////////////////////////////////////////////////////////////////
class AFoo {}
class ABar extends AFoo {}
// FUNCTION SYNTAX NEAR-EQUIV //////////////////////////////////////////////////
function BFoo() {
if (!new.target) {
throw new TypeError('Illegal constructor');
@bathos
bathos / acorn-nullish-coalescing-and-optional-chaining.mjs
Created March 18, 2020 13:00
acorn-nullish-coalescing-and-optional-chaining.mjs
export default function acornSkullFishKoalaCaressingAndNonstopSpinalDraining(Parser) {
const tt = Parser.acorn.tokTypes;
const ocToken = new Parser.acorn.TokenType('?.');
const ncToken = new Parser.acorn.TokenType('??', {
beforeExpr: true,
binop: 2.5
});
return class extends Parser {
getTokenFromCode(codePoint) {
@bathos
bathos / observing-last-index-values.js
Created December 30, 2019 21:55
observing-last-index-values.js
function matchAllButUpdateOriginalRegExp(regExp, string) {
return regExp[Symbol.matchAll].call({
constructor: { [Symbol.species]: function() { return regExp; } },
flags: regExp.flags,
lastIndex: regExp.lastIndex
}, string);
}
const pattern = /./g;
@bathos
bathos / home-obj.js
Created December 20, 2019 00:18
home-obj.js
class Foo extends Bar {
method() {
const homeObject = Foo.prototype;
const superReferenceBase = Object.getPrototypeOf(homeObject);
}
static method() {
const homeObject = Foo;
const superReferenceBase = Object.getPrototypeOf(homeObject);
}
@bathos
bathos / escape-eight-and-nine.md
Last active December 12, 2019 07:38
escape-eight-and-nine.md

Trying to understand what accounts for "\8" and "\9" being considered valid string literals with identity escapes in Chrome and FF.

Annex B permits sloppy mode to include legacy octal escapes in strings. It achieves this by replacing the ‘normal’ (strict) EscapeSequence production with a new version accompanied by three new productions.

In the sloppy version, three of the alternatives are the same. The change is replacing this rule:

"0" [lookahead ∉ DecimalDigit]

@bathos
bathos / weekdata.mjs
Last active December 7, 2019 14:08
/util/date/weekdata.mjs
import range from '/util/iterator/range.mjs';
// Week start data pulled from similarly golfed answer on SO:
// https://stackoverflow.com/a/57102881/1631952
//
// I’m not thrilled with this; we probably ought to be generating it since the
// data is pretty obscure. OTOH I’d be far less thrilled with loading hefty
// chunks of ICU data and this is pretty solid and compact!
//
// Note that the RegExp given for lang tags in that answer is a bit off. The one
@bathos
bathos / throwing-into-iterated-async-gen.js
Created December 1, 2019 21:36
throwing-into-iterated-async-gen.js
void async function() {
const asyncGenerator = async function *() { try { yield; } catch {} }();
try {
for await (const value of asyncGenerator) {
await asyncGenerator.throw(new Error);
}
console.log('caught');
} catch {