Skip to content

Instantly share code, notes, and snippets.

@bryanchug
bryanchug / gist:3871241
Created October 11, 2012 09:30
Grails Console Filter
consoleImports(controller: 'console', action: '*') {
before = {
String importStatements = """
// Groovy Code here
// Implicit variables include:
// ctx: the Spring application context
// grailsApplication: the Grails application
// config: the Grails configuration
// request: the HTTP request
@bryanchug
bryanchug / FooSpec.groovy
Created October 12, 2012 01:41
/src/test/groovy/FooSpec.groovy
import spock.lang.Specification
class FooSpec extends Specification {
def 'Test foo'(){
expect:
"Bryan".bar == "Bryan is foobar."
}
}
apply plugin: 'groovy'
apply plugin: 'idea'
apply plugin: 'eclipse'
repositories{
mavenCentral()
}
dependencies{
@bryanchug
bryanchug / Foo.groovy
Created October 12, 2012 01:27
/src/main/groovy/Foo.groovy
class Foo{
static String getBar( String self ){
"${self} is foobar."
}
}
@bryanchug
bryanchug / org.codehaus.groovy.runtime.ExtensionModule
Created October 12, 2012 01:33
/src/main/resources/META-INF/services
moduleName = FooExtensions
moduleVersion = 0.1
extensionClasses = Foo
@bryanchug
bryanchug / Config.groovy
Created October 15, 2012 09:08
Grails Config.groovy mail config snippet to connect SMTP to Gmail
grails {
mail {
host = "smtp.gmail.com"
port = 465
username = "username@gmail.com"
password = "password"
props = ["mail.smtp.auth":"true",
"mail.smtp.socketFactory.port":"465",
"mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory",
"mail.smtp.socketFactory.fallback":"false"]
@bryanchug
bryanchug / bash.profile
Created October 26, 2012 17:02
Running application.properties-version-specific Grails with GVM
alias grails='~/.gvm/grails/` [ -e application.properties ] && grep app.grails.version application.properties | sed s/app.grails.version=// || echo current `/bin/grails'
@bryanchug
bryanchug / FaviconResources.groovy
Created November 14, 2012 20:04
Grails favicon declaration in Resource modules
modules = {
favicon{
resource id: 'favicon', url: [file: 'favicon.ico'], disposition: 'head'
}
}
import groovy.time.TimeCategory
Date getMaxDate(){
Date maxDate
use( TimeCategory ){
maxDate = new Date() + 18.years
}
@bryanchug
bryanchug / steps.sh
Created July 26, 2013 22:37
A script that I use to go through each commit in the branch since the initial commit. I use this when I present a technical talk with code examples or walkthroughs.
#!/bin/bash
for commit in $(git rev-list origin/master | tail -r)
do
git reset --hard $commit
read -p "Press enter to continue..."
done