Skip to content

Instantly share code, notes, and snippets.

🚀
Looking for new opportunities

Dan Levy justsml

🚀
Looking for new opportunities
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
@justsml
justsml / the-dumpster-fire-of-project-configuration-noise.md
Last active Feb 1, 2020
PSA: Modern project configuration files needlessly pollute root folders by default!
@justsml
justsml / mongodb-export-fixtures.sh
Created Jan 29, 2020
Export all collections in a mongo database to JSON files!
View mongodb-export-fixtures.sh
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
PARAMS=""
DB_HOST="localhost"
DB_PORT=27017
DB_DATABASE="local"
# DB_COLLECTION=""
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
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:
<nav></nav>
<section></section>
<main></main>
<header></header>
View better-privacy-dns-servers.sh
#!/bin/bash
set -e
echo "> CURRENT DNS SERVERS:"
networksetup -getdnsservers Wi-Fi
networksetup -setdnsservers Wi-Fi \
9.9.9.9 1.1.1.1 8.8.8.8
# Quad 9 Cloudflare Google
echo "> DNS SERVERS UPDATED"
@justsml
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'))
fetch('https://api.github.com/orgs/nodejs')
.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])
}
}
promiseTimeout(5000)(fetch('https://api.github.com/orgs/nodejs'))
.then(response => response.json())
.then(data => {
View postgres cheatsheet.md

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.

Setup

installation, Ubuntu

http://www.postgresql.org/download/linux/ubuntu/ https://help.ubuntu.com/community/PostgreSQL

You can’t perform that action at this time.