Skip to content

Instantly share code, notes, and snippets.

View bendoerr's full-sized avatar

Ben Doerr bendoerr

View GitHub Profile
@bendoerr
bendoerr / WebFlowUnitTestCase.groovy
Created March 22, 2011 20:01
Unit test harness for Grails Web Flows
import grails.test.ControllerUnitTestCase
import org.apache.commons.lang.StringUtils
/**
* Provide support for unit testing Grails web flows inside of controllers.
* Extending ControllerUnitTestCase which will provide us with much
* of the needed mocking around properties and methods that Grails
* provides. Just as ControllerUnitTestCase does it will determine the
* controller based on the test name as well as the web flow to test.
*
class MealController {
def mealService
final breakfastFlow = {
init {
action {
conversation.meal = mealService.prepareForBreakfast()
}
on('success').to('chooseMainDish')
@bendoerr
bendoerr / CountryTimeZones.groovy
Created October 5, 2011 16:57
List all of the Java TimeZone ids for a country
String country = "Australia"
println TimeZone.getAvailableIDs().findAll { it.matches /^(${country}).*/ }.join('\n')
@bendoerr
bendoerr / gist:1761644
Created February 7, 2012 20:06
Some quick and dirty code to scrape two different wiki's about skyrim books compile them into one list
import groovy.json.JsonBuilder
import groovy.json.JsonSlurper
def knownNonBooks = [ // Not listed on any wiki's
"adonato's book",
"alchemist's note",
"bandit's journal",
"decree of monument",
"imperial missive (battle-born)",
"love poem",
@bendoerr
bendoerr / Events.groovy
Created March 19, 2012 20:53
Growl Notifier Script for Grails.
notifications = [
'Final status',
'Status update',
'Status error',
'Plugin installed',
'Created file',
'Created artefact',
'Compile start',
'Compile done',
'Clean done',
@bendoerr
bendoerr / emailServer.groovy
Created June 1, 2012 15:29
Quick and dirty email server for development.
@Grab('org.subethamail:subethasmtp-wiser:1.2') import org.subethamail.wiser.Wiser
Wiser wiser = new Wiser()
wiser.start()
addShutdownHook {
if (wiser.server.isRunning()) {
println "\nStopping..."
wiser.stop()
}
#!/bin/bash
#
# This file echoes a bunch of color codes to the
# terminal to demonstrate what's available. Each
# line is the color code of one forground color,
# out of 17 (default + 16 escapes), followed by a
# test use of that color on all nine background
# colors (default + 8 escapes).
#
@bendoerr
bendoerr / netflixAnimeRatings.groovy
Created October 25, 2012 15:36
Messy script to pull personal ratings for a particular genre from Netflix.
// Repository for Java Netflix Client.
@GrabResolver(name='BLC', root='http://nexus.blueleftistconstructor.com/content/repositories/releases')
// Java Netflix Client to abstract the raw http calls for us.
@Grab(group='com.lysergicjava.nfclient', module='netflix-java-client', version='2.1.2')
// The netflix-java-client uses SLF4J and complains if we don't have a facade around.
@Grab(group='org.slf4j', module='slf4j-simple', version='1.7.2')
// HttpClient since we want the stream for downloading the index file, and

The Gardenet of Things Project

Abstract

To bring technology to my garden using cheap electronics like the Arduino and Rasberry Pi in a connected independent way.

Garden Monitors

@bendoerr
bendoerr / photoMasterRename.groovy
Created January 23, 2013 19:51
Little dodad to rename my master photos.
#! /usr/local/bin/groovy
@Grab('commons-io:commons-io:2.4')
@Grab('com.drewnoakes:metadata-extractor:2.6.2')
@GrabExclude('xerces:xercesImpl')
import java.text.SimpleDateFormat
import org.apache.commons.io.monitor.*
import com.drew.imaging.ImageMetadataReader
import com.drew.metadata.exif.*