Skip to content

Instantly share code, notes, and snippets.

View srathbun's full-sized avatar

Spencer Rathbun srathbun

View GitHub Profile
@srathbun
srathbun / flatten.py
Created March 1, 2017 20:20
A python flatten function for arbitrarily nested arrays
def flatten(listOfLists):
"""
Flatten arbitrary levels of nesting for an array of integers.
Any non list, non int value throws an exception.
"""
results = []
for item in listOfLists:
if isinstance(item, int):
@srathbun
srathbun / storedProc
Created January 23, 2015 18:33
Example of ambiguous bug
use strict;
use warnings FATAL => 'all';
use MarpaX::Languages::SQL2003::AST;
use Data::Dump qw(pp);
my $input = "";
while (<>) {
$input = $input . $_;
}
@srathbun
srathbun / .gitconfig
Last active August 29, 2015 14:08
.gitconfig
[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
@srathbun
srathbun / tmux.conf
Created July 16, 2014 20:36
My tmux config
set-option -g default-command "reattach-to-user-namespace -l zsh"
# fix colors
set -g default-terminal "screen-256color"
# Arrow movement: nice
bind -n S-down new-window
bind -n S-left prev
bind -n S-right next
bind -n C-S-left swap-pane -D
bind -n C-S-right swap-pane -U
*.json merge=json_merge
@srathbun
srathbun / bisector.sh
Created June 30, 2014 12:48
This file assists git bisects by breaking a commit up on a separate branch
#!/bin/bash -e
# Helps you run a bisect script against your repo and determine which hunk caused a failure
###############################################################################
set -e # exit on command errors (so you MUST handle exit codes properly!)
set -E # pass trap handlers down to subshells
set -o pipefail # capture fail exit codes in piped commands
#set -x # execution tracing debug messages
# Error handler
on_err() {
@srathbun
srathbun / fizzBuzz.m
Created October 30, 2013 18:18
Mumps GT.M fizzBuzz program
F F=1:1:100 W:F#3=0 "Fizz" W:F#5=0 "Buzz" W:(F#3>0)&(F#5>0) F W !
#!/bin/bash -
#===============================================================================
#
# FILE: tmp.sh
#
# USAGE: ./tmp.sh
#
# DESCRIPTION:
#
# OPTIONS: ---
@srathbun
srathbun / posix compliant word splitting read loop
Created May 9, 2013 15:08
how to split a single line with read in a posix manner ( no arrays )
#!/bin/dash
echo "a,b,c" | while read line; do
IFS=','
set -- $line
for word in "$@"; do echo "$word"; done
done
@srathbun
srathbun / refs.sh
Created May 1, 2013 20:45
Magic portable indirect references for shell.
setref()
{
if [ -n "$1" ]; then
eval $1=$2
else
echo "Null parameter passed to this function"
fi
}
deref()
{