Skip to content

Instantly share code, notes, and snippets.

Avatar

Guillaume Laforge glaforge

View GitHub Profile
View gist:135197
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 / closure-trampoline.diff
Created Nov 16, 2010
Closure Trampoline Patch
View closure-trampoline.diff
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 / build.gradle
Created Nov 25, 2011 — forked from Dierk/build.gradle
build.gradle for setting up a new gradle-based project
View build.gradle
apply plugin:'groovy'
apply plugin:'idea'
repositories { mavenCentral() }
dependencies {
groovy 'org.codehaus.groovy:groovy-all:1.8.4'
}
task makeDirs(description:'make all dirs for project setup') << {
@glaforge
glaforge / gist:2351150
Created Apr 10, 2012
Ray tracer example using @CompileStatic
View gist:2351150
// 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 / .vimrc
Created Jun 8, 2012
My current .vimrc configuration
View .vimrc
let mapleader = ","
let g:mapleader=","
set number
set expandtab
set shiftwidth=4
set tabstop=4
set smarttab
View bold2.md

This is ** bold **

This is bold

  • abc
    • bcd
  • cde
@glaforge
glaforge / markdownCompare.groovy
Last active Jan 11, 2016
Compare HTML output of Pegdown and XWiki Rendering's upcoming Markdown support
View markdownCompare.groovy
@Grab("org.pegdown:pegdown:1.2.1")
import org.pegdown.*
@Grab("org.xwiki.commons:xwiki-commons-component-default:4.5-SNAPSHOT")
import org.xwiki.component.embed.EmbeddableComponentManager
import org.xwiki.component.annotation.*
@Grab("org.xwiki.rendering:xwiki-rendering-syntax-markdown:4.5-SNAPSHOT")
import org.xwiki.rendering.parser.Parser
import org.xwiki.rendering.converter.Converter
View gist:4563430
@interface Min {
int value() default 0
}
@interface Max {
int value() default 100
}
import org.codehaus.groovy.transform.AnnotationCollectorTransform
import org.codehaus.groovy.ast.*
@glaforge
glaforge / gist:6692100
Created Sep 24, 2013
Safer usage of memcache service in Google App Engine
View gist:6692100
// 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,
View piapprox.groovy
import groovy.transform.*
import groovyx.gpars.actor.*
import groovyx.gpars.group.*
@Immutable class Calculate {}
@Immutable class Work { int start, nrOfElements }
@Immutable class Result { double value }
@Immutable class PiApproximation { double pi ; long duration }
double calculatePiFor( int start, int nrOfElements ) {