Skip to content

Instantly share code, notes, and snippets.

View kentfrazier's full-sized avatar

Kent Frazier kentfrazier

View GitHub Profile
@kentfrazier
kentfrazier / clean-merged-git-local-branches
Last active July 29, 2020 17:10
Scripts to delete all remote/local git branches which have been merged back to master
#!/bin/bash
IGNORE_REGEX="${IGNORE_REGEX:-^(master$|develop$|release/)}"
COMPARE_BASE="${COMPARE_BASE:-master}"
git branch --merged "$COMPARE_BASE" | \
sed 's/^\*\{0,1\} *//' | \
grep -E -v "$IGNORE_REGEX" | \
while read -r branch; do
merge_base="$(git merge-base "$COMPARE_BASE" "$branch")"
@kentfrazier
kentfrazier / .bashrc
Created June 4, 2020 17:03
Improved Multiprocess Bash History Management
# --- History File Management --- #
HISTDIR="$HOME/.history"
if [[ ! -d "$HISTDIR" ]]; then
mkdir "$HISTDIR"
chmod 0700 "$HISTDIR"
fi
HISTTIMEFORMAT='%F %T '
HISTFILE="$HISTDIR/$(date -j +'%Y-%m-%dT%H:%M:%S')" # Make process-specific history file
HISTFILESIZE=0 # close any old history files
HISTFILESIZE=4096 # and set a large new size
@kentfrazier
kentfrazier / gist:9d4f5cad30372d22ac9a
Created June 3, 2014 22:44
thalamus/core/__init__.py
from datetime import (
datetime,
timedelta,
)
import functools
from itertools import (
chain,
takewhile,
)
import json
@kentfrazier
kentfrazier / badresponse.py
Created April 3, 2013 19:51
A simple piece of middleware to detect and log bad responses. Drop badresponse.py into your extra folder and add a reference to your MIDDLEWARE_CLASSES in settings.py right after the MessageMiddleware.
import logging
from django.http import HttpResponse
# I am not sure if the default PyPE logging handler will automatically pick
# this up. You might need to get some assistance from Matt to make sure it will
# get logged.
logger = logging.getLogger('pype.badresponse')