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
@justsml
justsml / fetch-api-examples.md
Last active Nov 18, 2019
JavaScript Fetch API Examples
View fetch-api-examples.md
@justsml
justsml / AsyncObjectStore.js
Last active Nov 8, 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))
@justsml
justsml / insertAdjacentHTML.js
Last active Oct 15, 2019 — forked from eligrey/insertAdjacentHTML.js
insertAdjacentHTML polyfill
View insertAdjacentHTML.js
/*
* Updated w/ insertAdjacentElement
* @author Dan Levy @justsml
* 2016-06-23
*
* Credit: @lyleunderwood - afterend patch/fix
*
* ```js
* import { insertAdjacentElement } from './libs/insertAdjacentHTML.js';
* Use either:
@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 ovh-mount-nfs-ftp-backup-server.sh
#!/bin/bash
set -e
# REQUIRED ACTION: Configure your backup server vars - see OVH Server Manager's "Backups" tab.
# BACKUP_HOST_PREFIX: use the prefix domain for the listed "Name" value on the "Backups" tab.
# Example: With a 'Name' value `ftpback-bhs1-3.ip-111-222-333.net` you would need to set `BACKUP_HOST_PREFIX=ftpback-bhs1-3`
# Add something likethese to your ~/.bashrc - /etc/profile
#export OVH_SERVER_ID="ns5xxxxx.ip-x-x-x.net"
#export BACKUP_HOST_PREFIX="ftpback-bhs1-x"
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 => {
@justsml
justsml / setup-docker.md
Last active Jul 28, 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 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')
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
You can’t perform that action at this time.