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
justsml /
Last active Sep 13, 2019
JavaScript Fetch API Examples
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 => {
justsml /
Last active Jul 28, 2019
Docker Setup for Server Host, DB Instances, and NodeJS App

Docker Host Server Setup, w/ Basic Monitoring Tools

# Updates
apt-get update && apt-get install -y vim-nox git-core ufw curl atop htop build-essential libssl-dev linux-image-amd64 linux-headers-amd64

# Updates Profile init scripts
cd ~/
curl -sSL > .bash_aliases_new
cat .bash_aliases_new >> .bash_aliases
View passport-auth-knex.js
const http = require('http')
const express = require('express')
const session = require('express-session')
const FileStore = require('session-file-store')(session)
const bodyParser = require('body-parser')
const morgan = require('morgan')
const cors = require('cors')
const passport = require('passport')
PACKAGES=$(cat "${1:-/dev/stdin}" | \
grep "require([\"'][^'\"]*.)" | \
sed 's/^[^(]*(.//g' | \
sed 's/.[\)]*[a-zA-Z;]*$//' | \
sed "s/.[)].*$//" | \
sort | uniq)
# Remove NodeJS built-ins
justsml /
Last active Jun 19, 2019
Passing the Tech Screen: Big-O & Sorting algorithms

Sorting algorithms are hard to memorize.

So here's a template for tracking the important differences.

Algo. Name Big-O (worst case) Suitable for large sets? Good for partially/mostly sorted data? Totally random data? Notes
Bubble O(n^2) 👎 😞 😐 Simple/not-ideal for large data sets
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 Apr 28, 2019
User Interface I: Airport Starter File
View index.html
Semantic Markup === Meaningful code
Some semantic markup examples:
justsml / AsyncObjectStore.js
Last active Mar 28, 2019
Add auto JSON encoding to `localStorage` & `AsyncStorage` (from React Native)
View AsyncObjectStore.js
Utility for React Native's AsyncStorage module.
Auto encodes/decodes using `JSON`.
Essentially data is saved as key/value to available flash/SD storage.
import { AsyncStorage } from "react-native"
export default {
setItem(key, value) {
return AsyncStorage.setItem(key, JSON.stringify(value))
You can’t perform that action at this time.