Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Dan Levy justsml

🎯
Focusing
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 passport-auth-knex.js
require('dotenv').config()
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')
@justsml
justsml / setup-docker.md
Last active Jun 19, 2019
Docker Setup for Server Host, DB Instances, and NodeJS App
View setup-docker.md

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 https://gist.githubusercontent.com/justsml/b667f158731fd054cd38/raw/5778dbb5d3d138ccf99ae1bf973457ce89661362/.bash_aliases > .bash_aliases_new
cat .bash_aliases_new >> .bash_aliases
View detect-and-install-npm-packages.sh
#!/bin/bash
PACKAGES=$(cat "${1:-/dev/stdin}" | \
grep "require([\"'][^'\"]*.)" | \
sed 's/^[^(]*(.//g' | \
sed 's/.[\)]*[a-zA-Z;]*$//' | \
sed "s/.[)].*$//" | \
sort | uniq)
# Remove NodeJS built-ins
@justsml
justsml / sorting-algos.md
Last active Jun 19, 2019
Passing the Tech Screen: Big-O & Sorting algorithms
View sorting-algos.md

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
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:
<nav></nav>
<section></section>
<main></main>
<header></header>
@justsml
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))
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"
You can’t perform that action at this time.