Skip to content

Instantly share code, notes, and snippets.

View jesstelford's full-sized avatar

Jess Telford jesstelford

View GitHub Profile
@jesstelford
jesstelford / event-loop.md
Last active May 10, 2024 01:23
What is the JS Event Loop and Call Stack?

Regular Event Loop

This shows the execution order given JavaScript's Call Stack, Event Loop, and any asynchronous APIs provided in the JS execution environment (in this example; Web APIs in a Browser environment)


Given the code

@jesstelford
jesstelford / 01-shape-up-to-kindle.md
Last active January 10, 2024 20:08
Read SHAPE UP by basecamp on a Kindle / reMarkable / eReader

Read Shape Up by basecamp on a kindle / reMarkable / eReader

Basecamp's new book Shape Up is now available online (https://basecamp.com/shapeup) to read page-by-page.

There is a .pdf version, but that's not the best format for Kindle / other eReaders. Instead, we can convert the page-by-page into an eReader friendly format.

Part 1: Convert to a single page

NOTE: This has only been tested on Chrome

@jesstelford
jesstelford / README.md
Last active November 14, 2023 12:26
Starving the Event Loop with Microtasks

Starving the Event Loop with microtasks

"What's the Event Loop?"

Sparked from this twitter conversation when talking about doing fast async rendering of declarative UIs in Preact

These examples show how it's possible to starve the main event loop with microtasks (because the microtask queue is emptied at the end of every item in the event loop queue). Note that these are contrived examples, but can be reflective of situations where Promises are incorrectly expected to yield to the event loop "because they're async".

  • setTimeout-only.js is there to form a baseline

Getting started

  • Everything except images in a website is text, so it's a lot of reading and writing. As such, it makes sense to use an editor built for the purpose to make your life easier.
  • Install Visual Studio Code (VSCode): https://code.visualstudio.com/
  • There are 3 main technologies that make up a website: HTML, CSS, JavaScript (JS)
@jesstelford
jesstelford / pr-compare.sh
Last active December 5, 2022 10:46
List the Pull Requests which have been merged into one branch but not another. Execute this from within a git directory that has it's `origin` remote set to github.
#!/bin/sh
if (( $# < 2 )) || (( $# > 3 ))
then
echo "$0 <are-in-this-branch> <are-not-in-this-branch> [<url-of-repo>]"
exit 1
fi
URLPREFIX=
if (( $# == 3 ))
then
URLPREFIX=$(echo "$3/pull/" | sed -e 's/[\/&]/\\&/g')
@jesstelford
jesstelford / Links in markdown.md
Last active June 6, 2022 13:56
Putting links in code blocks on GitHub
@jesstelford
jesstelford / machine.js
Created September 21, 2020 01:44
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
@jesstelford
jesstelford / machine.js
Created September 21, 2020 01:36
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
@jesstelford
jesstelford / README.md
Last active July 9, 2020 12:42
A fork of Capsize used to generate a typographic scale (https://github.com/seek-oss/capsize)

A fork of Capsize used to generate a typographic scale (https://github.com/seek-oss/capsize)

Generate the typographic scale by running generate-typographic-scale.js:

node generate-typographic-scale.js

Add it to your Chakra UI theme under the key typography:

@jesstelford
jesstelford / detect-dangling-relationships.js
Last active April 14, 2020 13:59
Detect relationship inconsistencies in Keystone databases prior to the [Arcade](https://www.keystonejs.com/discussions/new-data-schema) release
/**
* NOTE: We use console.error for log output below so that the output can be
* redirected to a file by the user
*/
const path = require('path');
const entryFile = process.argv[2];
if (!entryFile) {