Skip to content

Instantly share code, notes, and snippets.

hello world

Clint Ayres jurassix

hello world
View GitHub Profile
tomhicks / plink-plonk.js
Last active Oct 28, 2020
Listen to your web pages
View plink-plonk.js
getify / 1.js
Last active Apr 4, 2019
fun little experiment... a point-free definition for "copySession()" (essentially a shallow object copy)
View 1.js
// function copySession(sess) {
// return { ...sess };
// }
var copySession = compose(

I bundled these up into groups and wrote some thoughts about why I ask them!

If these helped you, I'd love to hear about it!! I'm on twitter @vcarl_ or send me an email

Onboarding and the workplace

  • How long will it take to deploy my first change? To become productive? To understand the codebase?
  • What kind of equipment will I be provided? Will the company pay/reimburse me if I want something specific?
paulirish / eqt.js
Last active Apr 26, 2020
Expected Queueing Time metric
View eqt.js
// Expected Queueing Time
// Initial impl by Nicolás Peña (npm), Tim Dresser (tdresser)
// Usage:
// var eqt = EQT.begin();
// // ...
// const {expectedQueueingTime} = EQT.end();
class EQT {
constructor() {
paulirish / server-timing-demo.js
Last active May 11, 2020
Demo of server timing values. visualized in chrome devtools
View server-timing-demo.js
// see for screenshot:
const http = require('http');
function requestHandler(request, response) {
const headers = {
'Server-Timing': `
sql-1;desc="MySQL lookup Server";dur=100,
sql-2;dur=900;desc="MySQL shard Server #1",
acdlite / app.js
Last active Aug 18, 2020
Quick and dirty code splitting with React Router v4
View app.js
// getComponent is a function that returns a promise for a component
// It will not be called until the first mount
function asyncComponent(getComponent) {
return class AsyncComponent extends React.Component {
static Component = null;
state = { Component: AsyncComponent.Component };
componentWillMount() {
if (!this.state.Component) {
getComponent().then(Component => {
Rich-Harris /
Last active Oct 29, 2020
Top-level `await` is a footgun

Edit — February 2019

This gist had a far larger impact than I imagined it would, and apparently people are still finding it, so a quick update:

  • TC39 is currently moving forward with a slightly different version of TLA, referred to as 'variant B', in which a module with TLA doesn't block sibling execution. This vastly reduces the danger of parallelizable work happening in serial and thereby delaying startup, which was the concern that motivated me to write this gist
  • In the wild, we're seeing (async main(){...}()) as a substitute for TLA. This completely eliminates the blocking problem (yay!) but it's less powerful, and harder to statically analyse (boo). In other words the lack of TLA is causing real problems
  • Therefore, a version of TLA that solves the original issue is a valuable addition to the language, and I'm in full support of the current proposal, which you can read here.

I'll leave the rest of this document unedited, for archaeological

View .gitconfig
feature = "!f() { git checkout -b feature/$1 --no-track origin/master; }; f"
release = "!f() { git checkout -b release/$1 --no-track origin/master; }; f"
hotfix = "!f() { git checkout -b hotfix/$1 --no-track origin/master; }; f"
bugfix = "!f() { git checkout -b bugfix/$1 --no-track origin/master; }; f"
andymatuschak /
Last active Oct 14, 2020
A composable pattern for pure state machines with effects (draft v3)

A composable pattern for pure state machines with effects

State machines are everywhere in interactive systems, but they're rarely defined clearly and explicitly. Given some big blob of code including implicit state machines, which transitions are possible and under what conditions? What effects take place on what transitions?

There are existing design patterns for state machines, but all the patterns I've seen complect side effects with the structure of the state machine itself. Instances of these patterns are difficult to test without mocking, and they end up with more dependencies. Worse, the classic patterns compose poorly: hierarchical state machines are typically not straightforward extensions. The functional programming world has solutions, but they don't transpose neatly enough to be broadly usable in mainstream languages.

Here I present a composable pattern for pure state machiness with effects,

View joinArray.js
export const joinArray = (list = [], separator) =>
list.reduce((joinedList, item, index, {length}) => {
if (index < (length - 1)) {
return joinedList;
}, []);
You can’t perform that action at this time.