Skip to content

Instantly share code, notes, and snippets.

View glaforge's full-sized avatar

Guillaume Laforge glaforge

View GitHub Profile
@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()
@glaforge
glaforge / LongAdderTest.groovy
Last active August 29, 2015 14:00 — forked from timyates/LongAdderTest.java
Tim's long adder test with streams but groovier :-)
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()
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 November 25, 2011 16:04 — forked from Dierk/build.gradle
build.gradle for setting up a new gradle-based project
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') << {