Skip to content

Instantly share code, notes, and snippets.

View dtanner's full-sized avatar

Dan Tanner dtanner

  • Target
  • Minneapolis MN US
View GitHub Profile
@dtanner
dtanner / Bootstrap.groovy
Created December 16, 2012 22:54
Example of a grails project using mybatis migrations in the Bootstrap.groovy, automatically nuking and paving the test databases.
def init = { servletContext ->
if (["test", "ci", "functional"].contains(Environment.current.name)) {
// bring some environments down to bare database. 20120609160926 is the base migration script's ID
// limitation: if we add development to this list and run the app in IDEA, it orphans the java processes
executeCommand ("${getMigrationCommand()} --env=${Environment.current.name} version 20120609160926", new File("./db"))
executeCommand ("${getMigrationCommand()} --env=${Environment.current.name} up", new File("./db"))
}
// other init operations...
}
@dtanner
dtanner / TestGen.groovy
Created October 30, 2012 18:03
Groovy script to generate addition table quizzes for kids.
def getRandomNumber() {
randomInt = new Random().nextInt(11)
}
def buildCell() {
"""${getRandomNumber()} <br>
+ ${getRandomNumber()} <br>
<hr width=40px>
"""
@dtanner
dtanner / Test.groovy
Created August 24, 2012 17:00
Examples of overriding groovy instance and static methods
class Test {
void method1() {
println 'In method1'
}
void method1(String foo) {
println "In method1 with String param of $foo"
}
static method2(String foo) {