Skip to content

Instantly share code, notes, and snippets.

Avatar
🐢
hello world

Clint Ayres jurassix

🐢
hello world
View GitHub Profile
@tomhicks
tomhicks / plink-plonk.js
Last active Oct 28, 2020
Listen to your web pages
View plink-plonk.js
@getify
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(
reduce(
compose(
flip,
binary,
uncurry,
View questions-for-your-interviewer.md

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 carl.vitullo@gmail.com

Onboarding and the workplace

https://blog.vcarl.com/interview-questions-onboarding-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
paulirish / eqt.js
Last active Apr 26, 2020
Expected Queueing Time metric
View eqt.js
// Expected Queueing Time
// https://docs.google.com/document/d/1Vgu7-R84Ym3lbfTRi98vpdspRr1UwORB4UV-p9K1FF0/edit
// Initial impl by Nicolás Peña (npm), Tim Dresser (tdresser)
// Usage:
// var eqt = EQT.begin();
// // ...
// const {expectedQueueingTime} = EQT.end();
class EQT {
constructor() {
@paulirish
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:
// https://twitter.com/paul_irish/status/829090506084749312
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
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
Rich-Harris / footgun.md
Last active Oct 29, 2020
Top-level `await` is a footgun
View footgun.md

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
[alias]
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
andymatuschak / States-v3.md
Last active Oct 14, 2020
A composable pattern for pure state machines with effects (draft v3)
View States-v3.md

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}) => {
joinedList.push(item);
if (index < (length - 1)) {
joinedList.push(separator);
}
return joinedList;
}, []);
You can’t perform that action at this time.