`default.xxxx`
: defaultはあくまでGrails標準で提供されるキーのプレフィックスとする
`xxx.label`
: ドメイン名、プロパティ名
`xxx[.yyy].label`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static groovy.test.GroovyAssert.shouldFail | |
Iterable i1 = new Iterable() { | |
@Delegate | |
Iterable l = [1, 2] | |
} | |
Iterable i2 = new Iterable() { | |
@Delegate | |
Iterable l = [2, 3] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{org.grails.orm.hibernate.GrailsHibernateTemplate$7@17518} | |
OK | |
2 | |
org.grails.orm.hibernate.AbstractHibernateGormInstanceApi$_performSave_closure3@27ba4c03 | |
3 | |
org.grails.orm.hibernate.validation.UniqueConstraint$2@40259e2 | |
OK |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
# | |
# NWの制約がある場合に大きいリポジトリをチマチマとpushするスクリプト | |
# | |
# 実行時の注意事項: | |
# 巨大サイズのブランチ操作をするとファイルバッファの出し入れが大きすぎるため、 | |
# git statusするだけで1分ぐらい待たされる場合がある。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def average = { double v, int count -> | |
double sum = 0; | |
for (int i = 0; i < count; i++) { | |
sum += v; | |
} | |
return sum / count; | |
} | |
println average(0.1d, 10) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ `basename $SHELL` = "zsh" ]; then | |
if which gvm >/dev/null 2>&1; then | |
__gvm_switch_grails_griffon() { | |
# for 2.x | |
if [ -s "application.properties" ]; then | |
local array candidate target current | |
array=($(cat application.properties | grep --color=never 'app.\(grails\|griffon\).version' | sed -E "s|app.(.*).version=(.*)|\1 \2|g" | tr -d "\r\n")) | |
candidate=${array[1]} | |
target=${array[2]} | |
current=$((gvm offline enable >/dev/null && gvm current ${candidate} && gvm offline disable > /dev/null) | awk '{ print $4 }') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Application extends GrailsAutoConfiguration { | |
static void main(String[] args) { | |
def app = new GrailsApp(Application) | |
// インラインでロゴ文字列を指定できる | |
// クラスパスにbanner.txtがある場合はそちらが優先して使われる(grails-app/conf/banner.txt)。 | |
app.setBanner { org.springframework.core.env.Environment environment, Class<?> sourceClass, PrintStream out -> | |
out.println ">" * 100 | |
out.println "My Banner!" | |
out.println "Env: ${environment.dump()}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fileContents = { fileName, encoding -> new File(fileName).getText(encoding) } | |
def toLines = { text -> text.split(/\r?\n/).toList() } | |
def sizePair = { lines -> [lines.size(), lines] } | |
def format = { max, lines -> | |
def size = "$max".size() + 1 | |
def zipped = [(1 .. max), lines].transpose() | |
zipped.collect { index, line -> String.format("%${size}d: %s", index, line) } | |
} | |
def toUnlines = { lines -> lines.join(System.getProperty('line.separator'))} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def by8 = { it * 8 } | |
def plus3 = { it + 3 } | |
def devide2 = { it / 2 } | |
// two closures | |
assert (by8 << plus3).call(3) == 48 | |
assert (plus3 >> by8).call(3) == 48 | |
assert (plus3 >> by8)(3) == 48 | |
// three closures |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def cd = { println("cd") } | |
def c0 = { -> println("c0") } | |
def c1 = { a -> println("c1:$a") } | |
def c2 = { a, b -> println("c2:$a:$b") } | |
assert cd.parameterTypes.size() == 1 | |
assert c0.parameterTypes.size() == 0 | |
assert c1.parameterTypes.size() == 1 | |
assert c2.parameterTypes.size() == 2 |