Skip to content

Instantly share code, notes, and snippets.

@matthewadams
matthewadams / git-scrum.sh
Last active June 6, 2017 20:28
git log for scrum across multiple repos
#!/usr/bin/env bash
SCRUM_TIME=${SCRUM_TIME-"08:45:00"}
BEFORE_DAY=${BEFORE_DAY-$(date +%Y-%m-%d)}
BEFORE_TIME=${BEFORE_TIME-$SCRUM_TIME}
AFTER_DAY=${AFTER_DAY-$(python -c "from datetime import datetime, timedelta; before = datetime.strptime('$BEFORE_DAY','%Y-%m-%d').date(); monday = before.strftime('%u') == '1'; days = -3 if monday else -1; after = before + timedelta(days=days); print after;")}
AFTER_TIME=${AFTER_TIME-$BEFORE_TIME}
TZ_OFFSET=$(date +%z)
AFTER="${AFTER_DAY}T${AFTER_TIME}${TZ_OFFSET}"
BEFORE="${BEFORE_DAY}T${BEFORE_TIME}${TZ_OFFSET}"
DIR="${DIR-$PWD}"
@matthewadams
matthewadams / rmdirs.groovy
Created May 2, 2013 13:48
Closure to remove an entire directory tree.
rmdirs = {
it = (it instanceof File) ? it : new File(it)
if (!it.exists()) return
it.eachDir(delDir)
it.eachFile { it.delete() }
it.delete()
}
@matthewadams
matthewadams / Spark aggregateByKey
Last active March 11, 2016 16:43 — forked from tmcgrath/Spark aggregateByKey
Spark aggregateByKey example
Welcome to
____ __
/ __/__ ___ _____/ /__
_\ \/ _ \/ _ `/ __/ '_/
/___/ .__/\_,_/_/ /_/\_\ version 1.1.0
/_/
Using Scala version 2.10.4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_65)
Type in expressions to have them evaluated.
Type :help for more information.
@matthewadams
matthewadams / gist:6686329
Created September 24, 2013 15:19
compare sha1 on Mac OS X
hash=(`openssl sha1 $1`)
hash=${hash[1]}
if [ "$2" != "$hash" ]; then
echo "Mismatch: given $2, calculated $hash" > /dev/stderr
exit 1
else
echo "ok"
fi
@matthewadams
matthewadams / gist:6686305
Created September 24, 2013 15:17
echo sha1 to stdout on Mac OS X
hash=(`openssl sha1 $1`)
echo "${hash[1]}"
@matthewadams
matthewadams / gist:6516544
Created September 10, 2013 22:16
SOM Property Methods eclipse template
public ${Type} get${UpperName}() {
return ${lowerName};
}
public void set${UpperName}(${Type} ${lowerName}) {
testSet${UpperName}(${lowerName});
doSet${UpperName}(${lowerName});
}
protected void testSet${UpperName}(${Type} ${lowerName}) {
@matthewadams
matthewadams / jdk
Last active December 18, 2015 09:19
Easy JVM switcher script for Mac OS X
#!/bin/bash
if [ ! $1 ]; then
echo "Please include desired jdk version: 1.7 or 7, 1.6 or 6, ..."
exit
fi
j7="/Library/Java/JavaVirtualMachines/jdk1.7.0_17.jdk/Contents/Home"
#j6="/Library/Java/JavaVirtualMachines/1.6.0_45-b06-451.jdk/Contents/Home"
j6="/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home"