Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@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"
@matthewadams
matthewadams / slf4jScriptLogging.groovy
Created May 2, 2013 13:59
Convenient logback/slf4j logging closures for Groovy script authors.
@Grab(group='ch.qos.logback', module='logback-classic', version='[1.0.9,)')
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import ch.qos.logback.classic.Level
logger = LoggerFactory.getLogger("yourScript") // or whatever
logger.level = Level.INFO // or whatever
log = { level, msg, Object... args -> logger."${level.toLowerCase()}"((msg ?: "").toString(), args) }
@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()
}