Skip to content

Instantly share code, notes, and snippets.

Avatar

Guillaume Laforge glaforge

View GitHub Profile
@glaforge
glaforge / fluentHttp.groovy
Last active Aug 29, 2015 — forked from dgageot/fluentHttp.groovy
Fluent HTTP further groovyfied!
View fluentHttp.groovy
@Grab('net.code-story:http:2.98')
import net.codestory.http.WebServer
new WebServer()
.configure { routes -> routes.anyGet { ctx -> "Hello"} }
.start()
@glaforge
glaforge / LongAdderTest.groovy
Last active Aug 29, 2015 — forked from timyates/LongAdderTest.java
Tim's long adder test with streams but groovier :-)
View LongAdderTest.groovy
import java.util.Random
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.atomic.LongAdder
import java.util.stream.IntStream
def frequencyMap = new ConcurrentHashMap<>()
def rnd = new Random()
IntStream.range( 0, 10000 )
.parallel()
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 ) {
@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') << {