Skip to content

Instantly share code, notes, and snippets.

// My stupid algorithm on Groovy's list reshape:
def reshape = { x, size ->
int j = 0
def result = []
def sublist = []
x.each {
j++
sublist.add(it)
if(j == size) {
0xb3e3bc5f: call 0xb3e0d060 ; OopMap{[16]=Oop [36]=Oop off=3012}
;*invokedynamic
; - g7.tests.classgen.Fib::fib@43
; - g7.tests.classgen.Fib::fib@33
; {optimized virtual_call}
0xb3e3bc64: mov esp, ebp ;*invokedynamic
; - g7.tests.classgen.Fib::fib@43
; - g7.tests.classgen.Fib::fib@33
0xb3e3bc66: mov [esp+0x1C], eax
0xb3e3bc6a: jmp 0xb3e3bcb4
import groovy.util.*
import java.net.*
class HomeController {
def index = {
//
// read input via NekoHTML
//
def p = new XmlParser( new org.cyberneko.html.parsers.SAXParser() )
apply plugin: 'groovy'
apply plugin: 'eclipse'
repositories {
mavenCentral()
mavenRepo urls: "http://groovypp.artifactoryonline.com/groovypp/libs-releases-local/"
}
dependencies {
def gppVersion = '0.2.4'
@chanwit
chanwit / switch.sh
Created June 27, 2010 10:09
Grails Switcher
pushd $PWD
cd $GRAILS_HOME/..
unlink current
ln -s grails-$1 current
popd
title "S5: An Introduction"
theme "default"
// header
footer
h1 "S5 Testbed"
h2 "Location / Date"
slide "Abcde"
h1 "S5 Testbed"
class Simple {
String name
def propertyMissing(String p) {
return new Simple(name: p)
}
def call(c) {
c.delegate = new FieldCaller()
c.resolveStrategy = Closure.DELEGATE_FIRST
c.call()
}
@chanwit
chanwit / gist:629748
Created October 16, 2010 12:47
A proper command to run a single selenium test
grails -Dserver.port=8081 test-app :selenium Issue131
class SQLite {
private JavaScriptObject con;
private String name;
public SQLite(Strig name) {
this.name = name;
init();
}
// from: http://adammonsen.com/post/548
detectMobile (controller:'*', action:'*') {
before = {
if (request.getHeader('user-agent') =~ /(?i)iphone/) {
request['isMobile'] = true
} else {
request['isMobile'] = false
}
return true // keep processing other filters and the action