Skip to content

Instantly share code, notes, and snippets.

import org.codehaus.groovy.tools.groovydoc.GroovyDocTool
import org.codehaus.groovy.groovydoc.GroovyRootDoc
import static groovy.io.FileType.*
import org.codehaus.groovy.tools.groovydoc.*
includeTargets << grailsScript("Init")
/**
* Generate i18n messages.properties from the domain class comments.
* support version: grails-1.3.0 or above
@uehaj
uehaj / test.groovy
Created May 8, 2014 21:37
multi method and Static groovy(TypeChecked, CompileStatic)
class Sample {
def test(String strParam) {
println "String = $strParam"
}
def test(Integer intParam) {
println "int = $intParam"
}
}
import Mouse
import Window
data Event = MouseUp | MouseDown | MouseMove Int Int
type Status = { mouseDown:Bool, points:[(Int, Int)] }
initialState : Status
initialState = Status False []
nextState : Event -> Status -> Status
import Window
thickLine = { defaultLine | width <- 20 }
roundLine = { thickLine | cap <- Round }
smoothLine = { thickLine | join <- Clipped, cap <-Round }
main = let
disp w h = collage w h
[ move (-100,250) <| outlined thickLine <| ngon 5 100
, move (-100,250) <| outlined thickLine <| polygon [(200, 0),(250,100),(150,100)]
@uehaj
uehaj / gist:046956f36f0fe29ee75f
Created October 27, 2014 06:50
Higher kind type parameter sample for groovy
import java.util.function.*;
interface Functor<T,R> {
public R fmap(Function<T,R> func, T t);
}
interface Applicative<A,T,R> extends Functor<T,R> {
public A<T> pure(T t);
public A<T> ap(A<Function<T,R>> func, A<R> a); // <*> :: f (a -> b) -> f a -> f b
}
@uehaj
uehaj / TypeClassTest.groovy
Last active August 29, 2015 14:08
TypeClass for groovy
import java.util.function.*
import groovy.transform.TypeChecked
import static Util.*
/* Type Classes */
@TypeChecked
interface Semigroup<T> {
def T mappend(T t1, T t2);
}
@TypeChecked
FROM onesysadmin/gvm
# [Build]
# cd /path/to/grails/project
# docker build -t you/product .
# [Run]
# docker run -it -v /path/to/grails/project:/app --link pg:db you/project:latest
# docker run -d -v /path/to/grails/project:/app --link pg:db you/project:latest run-app
ENV PROXY_HOST 1.2.3.4 # proxy address/hostname
ENV PROXY_PORT 18080 # proxy port
import groovy.transform.SourceURI
class UriTest {
static main(String[] args) {
@SourceURI String src
println src
}
}
import Graphics.Input (..)
import Signal
import Signal(Channel)
import Graphics.Element (..)
import Text(..)
import List(..)
type Keys = Number Int | Add | Sub | Mul | Div | Clear | Enter
keys : Channel Keys
@uehaj
uehaj / ShowTestTarget.groovy
Last active August 29, 2015 14:14
直近の10個のログから、修正量の多い順にファイル名を表示する
class ShowTestTarget {
static void main(args) {
"git log -10 --numstat --pretty=<@>%s".execute().text.split(/<@>/).drop(1).collect{it.split(/\n/).drop(2)}.flatten().collectMany { def m= (it=~ /(\d+)\W+(\d+)\W+(.*)/); m.matches()?[(m.collect{it}[0][1..-1])]:[] }.sort{-(Integer.parseInt(it[0])+Integer.parseInt(it[1]))}.each {
println it[2]
}
}
}