Skip to content

Instantly share code, notes, and snippets.

View glaforge's full-sized avatar

Guillaume Laforge glaforge

View GitHub Profile
@glaforge
glaforge / groovy-xmas.txt
Created December 29, 2015 13:38
Some Groovy Xmas poetry
So as we bring closure on twenty-15
@grab your maven by its j-bean
Swing those builders for a laugh
But only on their own classpath
Have you...
Met a class with a trait?
Got your binding way too late?
Seen Elvis looking like ?:
Or lost your way in recursion
@glaforge
glaforge / gist:6692100
Created September 24, 2013 22:17
Safer usage of memcache service in Google App Engine
// when doing the following...
if (ms.containsKey(key)) {
return ms.get(key);
} else {
// ... fetch and cache
}
// you run the risk that between the existence check in the if statement
// and the moment you actually call the get,

This is ** bold **

This is bold

  • abc
    • bcd
  • cde
@glaforge
glaforge / .vimrc
Created June 8, 2012 14:27
My current .vimrc configuration
let mapleader = ","
let g:mapleader=","
set number
set expandtab
set shiftwidth=4
set tabstop=4
set smarttab
@glaforge
glaforge / gist:2351150
Created April 10, 2012 12:51
Ray tracer example using @CompileStatic
// translated from http://www.ffconsultancy.com/languages/ray_tracer/code/1/ray.java
// by Derek Young - Sep 6, 07
import groovy.transform.CompileStatic
@CompileStatic
class Vec {
public double x, y, z;
public Vec(double x2, double y2, double z2) { x = x2; y = y2; z = z2; }
@glaforge
glaforge / closure-trampoline.diff
Created November 16, 2010 13:20
Closure Trampoline Patch
Index: groovy-core/src/main/groovy/lang/Closure.java
===================================================================
--- groovy-core/src/main/groovy/lang/Closure.java (revision 21027)
+++ groovy-core/src/main/groovy/lang/Closure.java (revision )
@@ -610,6 +610,39 @@
return Memoize.buildSoftReferenceMemoizeFunction(protectedCacheSize, new LRUCache(maxCacheSize), this);
}
+ /**
+ * Executes the current closure on a functional trampoline.
@glaforge
glaforge / gist:c44f439974b631a384e9
Created June 4, 2014 07:28
Super lean Grails 3.0 micro-services coming!
@Grab("com.h2database:h2:1.3.173")
import grails.persistence.*
@Entity
@Resource(uri='/books')
class Book {
String title
}
Index: src/test/groovy/lang/GroovyClassLoaderTest.groovy
===================================================================
--- src/test/groovy/lang/GroovyClassLoaderTest.groovy (revision 16526)
+++ src/test/groovy/lang/GroovyClassLoaderTest.groovy Wed Jun 24 12:49:00 CEST 2009
@@ -87,9 +87,14 @@
paths += getPaths(System.getProperty("java.class.path"))
paths = paths.unique()
- def file
+ def file, tempFolder
@glaforge
glaforge / fluentHttp.groovy
Last active August 29, 2015 14:22 — forked from dgageot/fluentHttp.groovy
Fluent HTTP further groovyfied!
@Grab('net.code-story:http:2.98')
import net.codestory.http.WebServer
new WebServer()
.configure { routes -> routes.anyGet { ctx -> "Hello"} }
.start()
@Grab('com.github.groovy-wslite:groovy-wslite:1.1.0')
import wslite.rest.*
import wslite.http.auth.*
def client = new RESTClient("https://api.github.com")
def response = client.get(
path: '/repos/restlet/restlet-framework-java/events',
query: [page: 11]) // <== page 11 and beyond yield 422