Skip to content

Instantly share code, notes, and snippets.

@tednaleid
tednaleid / bootstrap_diff
Created July 22, 2012 03:07
removing redundant `packageApp()` call in bootstrap target shaves ~1sec off many grails commands for me
Not sure if this causes issues elsewhere, but `test-app`, `run-app`, and `package` seem fine. The `packageApp()` method is called again in `loadApp()` so this one seems redundant.
Shaves off about a second for me on a larger app as it removes a redundant call. YMMV, put it back if you see any issues:
diff --git a/scripts/_GrailsBootstrap.groovy b/scripts/_GrailsBootstrap.groovy
index 4c44aa3..218a41a 100644
--- a/scripts/_GrailsBootstrap.groovy
+++ b/scripts/_GrailsBootstrap.groovy
@@ -126,7 +126,7 @@ target(monitorApp:"Monitors an application for changes using the PluginMana
}
@tednaleid
tednaleid / ipadchrome_alias
Created October 25, 2011 18:43
alias to launch google chrome with the iPad user-agent
alias ipadchrome='open /Applications/Google\ Chrome.app --args -user-agent="Mozilla/5.0(iPad; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10"'
def findResult (collection, closure) {
for ( value in collection) {
def result = closure(value)
if (result != null) return result
}
}
assert "5foo" == findResult([1, 2, 3, 4, 5, 6, 7]) {
if (it >= 5) return "${it}foo"
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>TerminalColours</string>
<key>CFBundleIdentifier</key>
<string>sh.ciaranwal.terminal-colours</string>
@tednaleid
tednaleid / gist:118797
Created May 27, 2009 18:18
alternate way to replace GORM save method and add named parms
// do this in the plugins doWithDynamic methods on each domain class:
def domainClass = grailsApplication.getDomainClass("Foo")
def clazz = domainClass.clazz
// prime the pump to get the GORM methods actually decorated and available on the meta class
clazz.count()
def oldSave = clazz.metaClass.getMetaMethod("save", [java.util.Map] as Class[])
clazz.metaClass.save = { java.util.Map args ->
@tednaleid
tednaleid / gist:118407
Created May 27, 2009 01:28
adding arguments to GORM save through metaClass
// do this in the plugins doWithDynamic methods on each domain class:
def domainClass = grailsApplication.getDomainClass("Foo")
def clazz = domainClass.clazz
// prime the pump to get the GORM methods actually decorated and available on the meta class
clazz.count()
clazz.metaClass.invokeMethod = { String name, args ->
if (name == "save" && args[0] instanceof Map) {