Skip to content

Instantly share code, notes, and snippets.


Arnaud Esteve aesteve

  • Lille
Block or report user

Report or block aesteve

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
aesteve / JSXTransform
Last active Apr 9, 2018
Transforming JSX with nashorn
View JSXTransform
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import javax.script.Invocable;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
public interface RouteDSL {
RouteDSL param(String paramName, Handler<RoutingContext> checker)
default<T> RouteDSL param(String paramName, Function<String, T> checker) {
return param(paramName, ctx -> {
String p = ctx.request().getParam(name);
try {
ctx.put(paramName, checker.apply(p));;
aesteve / HandlerExtension.kt
Created Oct 11, 2016
Extension method in Kotlin to handle a method reference as a Handler
View HandlerExtension.kt
// It's weird it doesn't work ootb since Handler<T> is a functional java interface
// I must have missed something
fun <T> asHandler(handler: (T) -> Unit): Handler<T> =
Handler { event -> handler(event) }
aesteve /
Created Oct 11, 2016
Creating interceptor-like logic just with handlers
public class InterceptorExample extends AbstractVerticle {
public final static String API_PATH = "/api/v1/";
public final static String STATIC_FILES = "/static/";
// ...
private Router router;
public void start(Future<Void> future) {
aesteve / WhatWeCouldDo.groovy
Last active May 24, 2016
AST transform on AsyncResult methods
View WhatWeCouldDo.groovy
// Let's imagin you have such a service
class TodoMongoService {
void fetchById(String todoId, Handler<AsyncResult<Todo>> handler) {
mongo.find(id) { res ->
if(res.succeeded) {
} else {
aesteve / Uh oh
Created May 8, 2016
exception happening on CI only while testing Nubes with 3.3.0-SNAPSHOT
View Uh oh
java.lang.IllegalStateException: Uh oh! Event loop context executing with wrong thread! Expected null got Thread[Test worker,5,main]
at io.vertx.core.impl.ContextImpl.lambda$wrapTask$3(
at io.vertx.core.impl.ContextImpl.executeFromIO(
at io.vertx.core.http.impl.ConnectionManager$ConnQueue.http1xConnected(
at io.vertx.core.http.impl.ConnectionManager$ConnQueue.lambda$internalConnect$159(
at io.vertx.core.http.impl.ConnectionManager$ConnQueue$1.lambda$connect$157(
at io.vertx.core.http.impl.ConnectionManager$ConnQueue$1.connect(
at io.vertx.core.http.impl.ConnectionManager$ConnQueue.internalConnect(
at io.vertx.core.http.impl.ConnectionManager$ConnQueue.createNewConnection(
List<Handler<RoutingContext>> handlers = /* ... */;
handlers.forEach(router.route("/a/b/")::handler); // KO : "You're attaching a handler to a route more than once"
handlers.forEach(handler -> router.route("/a/b").handler(handler)); // works
aesteve / maps.go
Created Jan 20, 2016
Go Map exercise
View maps.go
package main
import (
func WordCount(s string) map[string]int {
count := make(map[string]int)
words := strings.Fields(s)
aesteve / slices.go
Created Jan 20, 2016
Slices (with closure)
View slices.go
package main
import ""
func mult(x, y int) uint8 {
return uint8( x * y )
func mid(x, y int) uint8 {
return uint8( (x + y) / 2 )
aesteve /
Created Jan 19, 2016
Use Future<Void> instead of timers
package com.github.vertx.node.example;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Vertx;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
You can’t perform that action at this time.