Skip to content

Instantly share code, notes, and snippets.

View srathbun's full-sized avatar

Spencer Rathbun srathbun

View GitHub Profile
@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 !
@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):
#!/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()
{
@srathbun
srathbun / .ctags
Created April 18, 2013 20:27
This is a working ctags config for use with vim and javascript. Note that if there is any busted options in this config, ctags will not use *any* of the other options! This means you cannot use comments or blank lines in this file!
--recurse=yes
--tag-relative=yes
--exclude=.git
--regex-Javascript=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*\{/\5/o,object/
--regex-Javascript=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*function[ \t]*\(/\5/f,function/
--regex-Javascript=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*\[/\5/a,array/
--regex-Javascript=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*[^"]'[^']*/\5/s,string/
--regex-Javascript=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*(true|false)/\5/b,boolean/
--regex-Javascript=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*[0-9]+/\5/n,number/
--regex-Javascript=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*.+([,;=]|$)/\5/v,variable/
@srathbun
srathbun / gist:4708226
Created February 4, 2013 17:39
continuous tailing of a log file
#!/bin/bash
crash[1]="disconnected"
crash[2]="38290209"
tail --follow=name log.log | while read line; do
for c in "${#crash[@]}"
do
#echo "Crash Word:" $c
if [[ "$item" == *"$c"* ]]; then
echo "RiotShield has crashed."
echo "Killing RiotShield."
@srathbun
srathbun / my.ini
Created July 13, 2012 19:28
Current MySql test settings
# MySQL Server Instance Configuration File
# ----------------------------------------------------------------------
# Generated by the MySQL Server Instance Configuration Wizard
#
#
# Installation Instructions
# ----------------------------------------------------------------------
#
# On Linux you can copy this file to /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options
@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