Skip to content

Instantly share code, notes, and snippets.

View KylePDavis's full-sized avatar

Kyle P Davis KylePDavis

View GitHub Profile
@KylePDavis
KylePDavis / ln-pkg.sh
Last active June 9, 2020 18:04
A simple way to symlink local npm packages into your node_modules for testing
#!/bin/bash -e
################################################################################
# Links a local Node.js package directory into the current node_modules/ folder.
# This is simpler and more isolated than `npm link` so it's better for quick one-off testing.
#
# USAGE:
# ~/bin/ln-pkg.sh LOCAL_PKG_DIR [LOCAL_PKG_DIR_2]
#
################################################################################
[ -d "node_modules" ] || { echo "missing node_modules/"; exit 1; }
@KylePDavis
KylePDavis / js_class_template.js
Created October 16, 2012 19:42
JavaScript Classes Template (with proper inheritance)
//NOTE: if not in Node.js then you'll need to remove references to module.exports and require()
var MyClassName = (function(){
// CONSTRUCTOR
var klass = module.exports = MyClassName = function MyClassName(){
//[CONSTRUCTOR]; e.g., if(arguments.length > 0) throw new Error("Unexpected args!");
//[INSTANCE MEMBERS]; e.g., this.value = 123;
base.call(this);
}, base = require("./BaseClass"), proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
// PRIVATE STATIC MEMBERS
@KylePDavis
KylePDavis / sh_env_var_opts.sh
Last active September 14, 2023 01:26
Simple bash shell script templates. There are two versions: 1) simple env var based options, and 2) with added command line argument parsing and error handling.
#!/bin/bash -e
# A SHORT DESCRIPTION OF YOUR SCRIPT GOES HERE
# USAGE:
# DESCRIPTION OF ENV VARS HERE
###############################################################################
set -e # exit on command errors (so you MUST handle exit codes properly!)
set -o pipefail # capture fail exit codes in piped commands
#set -x # execution tracing debug messages
# Get command info