Skip to content

Instantly share code, notes, and snippets.

// tree to find the short tag name for each
// of a list of tag names
// ['a','a','b','button','button'] => ['a1','a2','b','bu1','bu2']
function StringNode(str, parent) {
this.string = str || '';
this.parent = parent;
this.children = {};
this.childCount = 0;
this.pointerCount = 0;
}
@etuttle
etuttle / gist:bc1cd3814b984ec694d6
Last active July 9, 2020 12:36
Assigning a MAC to docker0 in /etc/sysconfig/docker. Hacky, fix for ancient docker ~1.6 issue
# /etc/sysconfig/docker
#
# Other arguments to pass to the docker daemon process
# These will be parsed by the sysv initscript and appended
# to the arguments list passed to docker -d
other_args="--bridge=docker0"
DOCKER_CERT_PATH=/etc/docker
# Resolves: rhbz#1176302 (docker issue #407)
@etuttle
etuttle / docker-registry-caching-proxy.conf
Created February 14, 2017 23:54
NGINX config for a caching proxy that sits in front of a docker registry
upstream docker-mirror-upstream {
server upstream.example.com;
}
proxy_cache_path /var/lib/docker-mirror/cache levels=1:2 max_size=10g inactive=48h keys_zone=cache:10m;
server {
listen 80 default_server;
listen 443 ssl default_server;
@etuttle
etuttle / osx-build-shell.sh
Last active June 28, 2020 20:49
osx-build-shell.sh
#!/bin/bash
# The compiler toolchain is specified by `xcode-select`. You can use
# `/Library/Developer/CommandLineTools` selected as the Developer
# directory. That should make the build independent of Xcode.app.
#
# eg: sudo xcode-select -s /Library/Developer/CommandLineTools
#
# If you are on 10.14+, make sure your CLI tools are installed:
#
@etuttle
etuttle / gitmess
Last active June 29, 2020 00:48
shell script to find un-committed / un-pushed work in local git repos
#!/bin/bash
if [[ $# -eq 0 || $1 == '-h' || $1 == '--help' ]]; then
echo >&2 "Usage: $0 <dirs>"
echo >&2 "Use the IGNORE_REMOTES environment variable to ignore"
echo >&2 "remotes whose hosts match the ignore value."
exit 1
fi
res=0
@etuttle
etuttle / Clone to VSCode.png
Last active July 4, 2020 05:40
Automator service for easy git clonin'
 Clone to VSCode.png
@etuttle
etuttle / enable_touchbar_sudo.sh
Last active July 6, 2020 08:58
.bash_profile function to keep touchbar sudo setup (especially after an OS upgrade has undone it)
(psudo=/etc/pam.d/sudo;
if test -e "$psudo" \
&& ! grep --silent pam_tid.so "$psudo" \
&& test -t 0; then
false
fi) || function sudo() {
set -e
sudo_=$(which sudo)
if ! test -t 0; then
# no tty, just pass the sudo call through