Skip to content

Instantly share code, notes, and snippets.

<html>
<head><title>Counter</title></head>
<body>
<h2>Counter</h2>
<h1>{{hook.output}}</h1>
</body>
</html>
// TRYING TO FIGURE OUT WHAT I'M DOING WRONG
/*
DOMAINS:
class Type {
String code
}
class Parent {
String name
@krsmes
krsmes / XyzController.groovy
Last active December 28, 2015 01:09
Simple grails controller action to evaluate groovy script for debugging
def eval = {
def binding = new Binding(app:grailsApplication,request:request,session:session,controller:this)
def result
try { result = params.script ? new GroovyShell(binding).evaluate(params.script) : '(no script)' }
catch (e) { result = e.message }
result = result instanceof Map ? result.collect{"$it.key: $it.value"}.join('\n') :
result instanceof Iterable ? result.join('\n') : result
render """${g.form(action:'eval',method:'POST') {
"${g.textArea(name:'script',value:params.script,cols:80,rows:10)}${g.submitButton(name:'Submit')}"}}
<hr/><pre>${result}</pre>"""
@krsmes
krsmes / grails.bat
Last active December 27, 2015 12:19 — forked from George1/grails.bat
@ECHO OFF
REM
REM Automatic Grails Version Selector v1.0
REM
REM Description:
REM Automatically selects version of Grails to run based either
REM on context, environment variable, or command line argument.
REM
REM Copyright © 2010, Componentix (http://www.componentix.com/)
@krsmes
krsmes / gist:1029712
Created June 16, 2011 17:11
lazy evaluation of blocks in a groovy string
def lazy = { {w->w<<it()}.asWritable() }
def x = "it is now ${System.currentTimeMillis()}"
def y = "it is now ${{it->it<<System.currentTimeMillis()}.asWritable()}"
def z = "it is now ${lazy{System.currentTimeMillis()}}"
// change to x,y,z - x prints the same number all 5 times
(1..5).each { println z; sleep 250 }
@krsmes
krsmes / gist:1029184
Created June 16, 2011 12:56
dynamically create a java classpath with all jars in current and lib/ directory
-cp `echo *.jar lib/*.jar | sed 's/ /:/g'`
def block
def player
def map = [door1: [x: 1, y: 2, z: 3, owner:'krsbuilt'], door2: [x: 4, y: 5, z: 6]]
def found = map.find{ k,v -> v.x == block.x && v.y == block.y && v.z == block.z }
if (found) {
if (found.value.owner != player.name) {
// cancel action
}
@krsmes
krsmes / test.sh
Created January 21, 2011 21:41
shell script for running grails tests
#!/bin/sh
proj=""
port=8091
function testUnit {
echo "Starting $1 unit tests for $proj"
grails test-app -unit $1
return $?
}