Skip to content

Instantly share code, notes, and snippets.

@tednaleid
tednaleid / BuildConfig.groovy
Last active Aug 29, 2015
Grails forked mode debug without suspending for remote debugger to connect first
View BuildConfig.groovy
...
// the jvmArgs flag allows us to override the default suspend=y that grails uses when you do --debug-fork
// the grails docs mention jvmArgs, but lie about it wanting a String, it actually wants a List of Strings
grails.project.fork = [
test: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, daemon:true, jvmArgs: ['-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005']],
run: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false, jvmArgs: ['-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005']],
war: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false, jvmArgs: ['-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005']],
console: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, jvmArgs: ['-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005']]
]
...
@tednaleid
tednaleid / test_all_parallel.sh
Last active Aug 29, 2015
run grails tests in parallel
View test_all_parallel.sh
#! /usr/bin/env bash
command -v parallel >/dev/null 2>&1 || { echo >&2 "Please install parallel via brew: brew install parallel"; exit 1; }
BASE_DIR=$(cd "$(dirname "$0")"; pwd -P)/..
PARALLEL_WORKERS=2
export GRAILS_OPTS="-Xmx2G -Xms2g -XX:MaxPermSize=500m"
OPEN_TESTLOG_AND_FAIL="( open target/test-reports/html/index.html && exit 1 )"
TEST_APP="( grails test-app --non-interactive || $OPEN_TESTLOG_AND_FAIL )"
View Equity.md

This is a post by Joel Spolsky. The original post is linked at the bottom.

This is such a common question here and elsewhere that I will attempt to write the world's most canonical answer to this question. Hopefully in the future when someone on answers.onstartups asks how to split up the ownership of their new company, you can simply point to this answer.

The most important principle: Fairness, and the perception of fairness, is much more valuable than owning a large stake. Almost everything that can go wrong in a startup will go wrong, and one of the biggest things that can go wrong is huge, angry, shouting matches between the founders as to who worked harder, who owns more, whose idea was it anyway, etc. That is why I would always rather split a new company 50-50 with a friend than insist on owning 60% because "it was my idea," or because "I was more experienced" or anything else. Why? Because if I split the company 60-40, the company is going to fail when we argue ourselves to death. And if you ju

@tednaleid
tednaleid / gist:118407
Created May 27, 2009
adding arguments to GORM save through metaClass
View gist:118407
// 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) {
@tednaleid
tednaleid / gist:118797
Created May 27, 2009
alternate way to replace GORM save method and add named parms
View gist:118797
// 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 ->
View Info.plist for terminalcolours
<?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>
View gist:442580
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"
}
@tednaleid
tednaleid / ipadchrome_alias
Created Oct 25, 2011
alias to launch google chrome with the iPad user-agent
View ipadchrome_alias
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"'
@tednaleid
tednaleid / bootstrap_diff
Created Jul 22, 2012
removing redundant `packageApp()` call in bootstrap target shaves ~1sec off many grails commands for me
View bootstrap_diff
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
}
View gist:3474341
# execute with `mvimvproject <projname>`
function mvimproject() {
SCRIPT='mvimhere.command'
if [ -n "$1" ]
then
SCRIPT=$1.command
fi
cat <<EOF>$SCRIPT
#! /usr/bin/env sh
BASEDIR=\$(dirname \$0)
You can’t perform that action at this time.