Skip to content

Instantly share code, notes, and snippets.


Dan Levy justsml

Block or report user

Report or block justsml

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View lost-in-callbacks.js
The number of stack frames that can
(reasonably) be tracked is small (~dozens).
When you run code like below, the inner async `writeFile`
can 'lose' its prior frame(s) 2 main ways:
1. When the outer `forEach` completes (w/ asyncs still running)
the stack pops off the completed synchronous frames into
the ether. Any later failure may only have a bit of async
justsml / index.html
Last active Oct 7, 2019
User Interface I: Airport Starter File
View index.html
Semantic Markup === Meaningful code
Some semantic markup examples:
set -e
networksetup -getdnsservers Wi-Fi
networksetup -setdnsservers Wi-Fi \
# Quad 9 Cloudflare Google
justsml / promise-timeout.js
Last active Jan 1, 2019
adds tracking of the promise timeout via `__timeout` flag
View promise-timeout.js
function promiseTimeout(msec) {
return (promise) => {
let isDone = false
promise.then(() => isDone = true)
const timeout = new Promise((yea, nah) => setTimeout(() => {
if (!isDone) {
promise.__timeout = true
nah(new Error('Timeout expired'))
}, msec))
View fetch-custom-error.js
const isOk = response => response.ok ? response.json() : Promise.reject(new Error('Failed to load data from server'))
.then(isOk) // <= Use `isOk` function here
.then(data => {
console.log(data) // Prints result from `response.json()`
.catch(error => console.error(error))
View promised-timeout.js
function promiseTimeout(msec) {
return promise => {
const timeout = new Promise((yea, nah) => setTimeout(() => nah(new Error('Timeout expired')), msec))
return Promise.race([promise, timeout])
.then(response => response.json())
.then(data => {
View postgres

Postgres Cheatsheet

This is a collection of the most common commands I run while administering Postgres databases. The variables shown between the open and closed tags, "<" and ">", should be replaced with a name you choose. Postgres has multiple shortcut functions, starting with a forward slash, "". Any SQL command that is not a shortcut, must end with a semicolon, ";". You can use the keyboard UP and DOWN keys to scroll the history of previous commands you've run.


installation, Ubuntu

View file-upload-field.html
<input type='file' multiple class='files' name='files' />
View progressHelper-usage.js
// OPTION #1: no temp streamProcessor var
// fetch(...)
// ⚠️ OR️ ️⚠️
// OPTION #2: define a `streamProcessor` to hold our console logger
const streamProcessor = progressHelper(console.log)
// fetch(...)
You can’t perform that action at this time.