Skip to content

Instantly share code, notes, and snippets.

View ianstarz's full-sized avatar

Ian Storz ianstarz

View GitHub Profile
@ianstarz
ianstarz / docker-cheat-sheet.sh
Last active August 29, 2017 23:41
Docker cheat sheet
# https://docs.docker.com/get-started/part2/#conclusion-of-part-two
docker build -t friendlyname . # Create image using this directory's Dockerfile
docker run -p 4000:80 friendlyname # Run "friendlyname" mapping port 4000 to 80
docker run -d -p 4000:80 friendlyname # Same thing, but in detached mode
docker container ls # List all running containers
docker container ls -a # List all containers, even those not running
docker container stop <hash> # Gracefully stop the specified container
docker container kill <hash> # Force shutdown of the specified container
docker container rm <hash> # Remove specified container from this machine
docker container rm $(docker container ls -a -q) # Remove all containers
@ianstarz
ianstarz / immutable-deep-filter.js
Last active March 23, 2017 17:39
Deep filter for nested Immutable Maps and Lists
import Immutable from 'immutable';
const { isIterable } = Immutable.Iterable;
const { isMap } = Immutable.Map;
const { isList } = Immutable.List;
const isLeafNode = (node) => {
if (!isIterable(node)) {
return true;
}
[0, ['a', 'b', 'c'], 2, 'd', 4, 5, 'f', 7, ['g', 'h'], 9].reduce(function rec (prev, curr) {
if (/array/i.test(curr.constructor)) {
return curr.reduce(rec, prev);
} else if (/string/i.test(curr.constructor)) {
prev.push(curr);
}
return prev;
}, []);
@ianstarz
ianstarz / get-home-directory.js
Created June 17, 2016 00:25
Node function to get the user's home directory on mac and windows
module.exports = function() {
return process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'];
}
@ianstarz
ianstarz / guid.js
Created March 15, 2016 17:27 — forked from shawndumas/guid.js
GUID
var guid = function fn (n) {
return n ?
(n ^ Math.random() * 16 >> n/4).toString(16) :
('10000000-1000-4000-8000-100000000000'.replace(/[018]/g, fn));
};
@ianstarz
ianstarz / logic-gates.js
Last active April 17, 2022 03:34 — forked from shawndumas/taggedTemplate.js
Build up all the logic gates from nand in js
const logicGates = {
nand (a, b) { return !(a && b); },
not (a) { return this.nand (a, a); },
and (a, b) { return this.not (this.nand (a, b)); },
or (a, b) { return this.nand (this.not (a), this.not(b)); },
nor (a, b) { return this.not (this.or (a, b)); },
xor (a, b) { return this.and (this.nand (a, b), this.or(a, b)); },
xnor (a, b) { return this.not (this.xor (a, b)); }
};
@ianstarz
ianstarz / longest-common-prefix.js
Created March 15, 2016 17:24
Find the longest common prefix in a list of strings using only a regex
['aaawhu', 'aaaajkssh', 'aaahwv', 'aaa'].join().match(/^(\w*)\w*(?:,\1\w*)*$/).pop();
# Turn on git state in command prompt
GIT_PS1_SHOWDIRTYSTATE=true
# Command prompt with "username path (git state) | "
export PS1='\[\033[1;37m\]\u \[\033[0m\]\w$(__git_ps1)\[\033[1;37m\] | \[\033[0m\]'
[core]
editor = subl -n -w
excludesfile = ~/.gitignore_global
[color]
branch = auto
diff = auto
status = auto
[color "branch"]
current = yellow reverse
local = yellow