Skip to content

Instantly share code, notes, and snippets.


Jeremiah Roth rothwerx

View GitHub Profile
View gist:7bdc7946402f6746468f412e678a72a7
IMAGE_NAME := whatever/whatever
.PHONY: docker-build version-increment bc-check
docker-build: version-increment
DOCKER_BUILDKIT=1 docker buildx build -t $(IMAGE_NAME):v$(shell cat version.txt) .
version-increment: bc-check
bc <<< "1 + $(shell cat version.txt)" > version.txt
View gist:f04db7daddc8d831bc49f37ad82dc90c
co = checkout
st = status
ls = log --stat
cp = cherry-pick
lsshort = log --stat --abbrev-commit
lsnm = log --stat --no-merges
lslast = "!f() { \
git ls-tree --name-only HEAD $1 | while read filename; do echo \"$(git log -1 --date=iso --pretty=format:'%ad' -- $filename) $filename\"; done \
}; f"

Keybase proof

I hereby claim:

  • I am rothwerx on github.
  • I am rothwerx ( on keybase.
  • I have a public key ASBy7WRKEIU2UJRhUTIcRrHbXliZjB8p5pDriDHcUa6mywo

To claim this, I am signing this object:

View gist:5c626130fcbe4dea2cb0df6c90dcde86
# set -g default-terminal "screen-256color"
# fix pbpaste and pbcopy commands on OSX
# set-option -g default-command "reattach-to-user-namespace -l $SHELL"
# Report support for 256 colors
set -g default-terminal "screen-256color"
# remap prefix to C-a
set -g prefix C-a
rothwerx / gist:ebef10660b42ae4e3235f47b0236b518
Created Dec 4, 2017
Shell: Installing iPython in Python 2.7
View gist:ebef10660b42ae4e3235f47b0236b518
# iPython 6 dropped support for Python 2.7
sudo pip install "pathlib2==2.1.0"
sudo pip install "ipython<6.0"
rothwerx / gist:96d71d9abedab96f7033c674b1b8e876
Last active Jul 14, 2016
Python: Get time delta from log with YYYY-MM-DD hh:mm:ss format
View gist:96d71d9abedab96f7033c674b1b8e876
#!/usr/bin/env python
import sys
from datetime import datetime
from argparse import ArgumentParser
parser = ArgumentParser()
parser.add_argument('logfile', help='Log file')
parser.add_argument('-s', '--seconds', default=1, type=int,
help='Only log entries that took over n seconds')
rothwerx / gist:f1843fe5e295f0c18d21
Created Dec 5, 2015
Python: YAML to JSON preprocessor
View gist:f1843fe5e295f0c18d21
#!/usr/bin/env python
import yaml
import json
import sys
with open(sys.argv[2], "w") as outf, open(sys.argv[1]) as inf:
o = yaml.safe_load(inf)
json.dump(o, outf)
rothwerx / gist:7aa31f5437a4fc2b9416
Created Oct 21, 2015
Bash: Logging helper function
View gist:7aa31f5437a4fc2b9416
function pecho {
if [[ $LOGGING ]]; then
printf "$@" | tee -a some.log
printf "$@"
pecho "%-10s %10s\n" "Logging:" "On"
rothwerx / gist:e1308d61512d7c278268
Created Aug 10, 2015
Bash: Collect HBA/HCA information for facter
View gist:e1308d61512d7c278268
# Produce custom facts about HBA/HCA cards for facter
# This file should be executable in /etc/facter/facts.d/
# Look for Mellanox, Emulex, and QLogic cards
varq=$(lspci | awk '/[Mm]ellanox/ {
printf "mellanox=%s\n", $1 }
/[Ee]mulex/ {
printf "emulex=%s\n", $1 }
/[Qq][Ll]ogic/ {
rothwerx / gist:b60f1fa7b543e8761b3c
Created Jul 13, 2015
Bash: Ensure processes run on allowed CPUs
View gist:b60f1fa7b543e8761b3c
# function to expand the range of allowed CPUs
range_expand () (
set -- $1
for element; do
if [[ $element =~ ^(-?[0-9]+)-(-?[0-9]+)$ ]]; then
set -- "$@" $(eval echo "{${BASH_REMATCH[1]}..${BASH_REMATCH[2]}}")