Skip to content

Instantly share code, notes, and snippets.

View nobeans's full-sized avatar

Yasuharu Nakano nobeans

  • Yokohama, Japan
View GitHub Profile
diff --git a/grails/src/grails/grails-app/conf/Config.groovy b/grails/src/grails/grails-app/conf/Config.groovy
index 63ef42d..0981d5f 100644
--- a/grails/src/grails/grails-app/conf/Config.groovy
+++ b/grails/src/grails/grails-app/conf/Config.groovy
@@ -35,6 +35,9 @@ grails.enable.native2ascii = true
// enable GSP preprocessing: replace head -> g:captureHead, title -> g:captureTitle, meta -> g:captureMeta, body -> g:captureBody
grails.views.gsp.sitemesh.preprocess = true
+// templates configuration
+grails.templates.domainSuffix = 'Instance'
diff --git a/grails/src/java/org/codehaus/groovy/grails/scaffolding/DefaultGrailsTemplateGenerator.groovy b/grails/src/java/org/codehaus/groovy/grails/scaffolding/DefaultGrailsTemplateGenerator.groovy
index 02e0335..518d059 100644
--- a/grails/src/java/org/codehaus/groovy/grails/scaffolding/DefaultGrailsTemplateGenerator.groovy
+++ b/grails/src/java/org/codehaus/groovy/grails/scaffolding/DefaultGrailsTemplateGenerator.groovy
@@ -57,11 +57,10 @@ class DefaultGrailsTemplateGenerator implements GrailsTemplateGenerator, Resourc
*/
DefaultGrailsTemplateGenerator(ClassLoader classLoader) {
engine = new SimpleTemplateEngine(classLoader)
- def suffix = ConfigurationHolder.config?.grails?.templates?.domainSuffix
- if (suffix == [:]) { // default for compatibility
// Japanese only
// http://imihu.blog30.fc2.com/blog-entry-3151.html
def dict = [
A:"あん!",
B:"んあっ…!",
C:"んあんあ!",
D:"んああ!",
E:"あ!",
F:"ああんあ!",
G:"んっあ!",
fact = { n ->
isEnd = n <= 1
work = isEnd ? 1 : fact(n - 1)
result = n * work as long
}
max = args[0] as long
range = 1..max
range.each { num ->
fact num
println "$num! => $result"
// g100pon *9 Jakarta POI のGroovyサンプル
//
// usage: groovy sampleOfPOI.groovy <入力Excelファイル> <出力Excelファイル名>
// 入力用に適当なExcelファイルを用意してください
// ----------------------------
// Grapeによるライブラリ取得
@Grab(group='org.apache.poi', module='poi', version='3.5-beta3')
import org.apache.poi.hssf.usermodel.*
import org.apache.poi.poifs.filesystem.*
// g100pon *9 Jakarta POI のGroovyサンプル
//
// usage: groovy sampleOfGExcelAPI.groovy <入力Excelファイル>
// 入力用に適当なExcelファイルを用意してください
// ----------------------------
// Grapeによるライブラリ取得
@GrabResolver(name="kobo-repo", root="http://github.com/kobo/maven-repo/raw/master/snapshot")
@GrabConfig(systemClassLoader=true) // for workaround a permgen problem with GroovyServ
@Grab("org.jggug.kobo:gexcelapi:0.2-SNAPSHOT")
@nobeans
nobeans / gist:619334
Last active September 23, 2015 21:37
// g100pon #57 GStringが遅延評価ぽくなるケース
String s1 = "こんにちは"
String s2 = "g100pon"
def gstrFixed = "${s1}、${s2}です" // 文字列としてGStringに埋め込むのでこの時点で確定している
def gstrLazy = "${->s1}、${->s2}です" // Closureでくるむことで評価を遅延させる
assert gstrFixed.toString() == "こんにちは、g100ponです"
assert gstrLazy.toString() == "こんにちは、g100ponです"
import java.io.*;
class Hoge {
public static void main(String[] args) throws Exception {
try (BufferedInputStream is = new BufferedInputStream( new FileInputStream(new File("/tmp/hoge")));
BufferedOutputStream os = new BufferedOutputStream(new FileOutputStream(new File("/tmp/foo")))) {
int length = 0;
byte[] buffer = new byte[1024];
while ((length = is.read(buffer)) >= 0) {
System.out.write(buffer, 0, length);
#!/bin/sh
if [ "$1" == "" ];then
echo "Usage: `basename $0` <GIST_ID>" >&2
exit
fi
GIST_ID=$1
wget https://gist.github.com/gists/$GIST_ID/download -O - 2>/dev/null | tar zxvf - -O - 2>/dev/null
import java.util.*;
class Diamond6 {
public static void main(String[] args) {
List<String> grandchild1 = Arrays.asList("A-1", "A-2", "A-3");
List<String> grandchild2 = Arrays.asList("B-1", "B-2", "B-3");
List<String> grandchild3 = Arrays.asList("C-1", "C-2", "C-3");
Map<Integer, List<String>> child1 = new HashMap<Integer, List<String>>();
child1.put(1, grandchild1);