Skip to content

Instantly share code, notes, and snippets.

Jochen Bedersdorfer beders

Block or report user

Report or block beders

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
beders /
Last active Sep 29, 2015
Hello World! Complete example
import us.monoid.web.Resty;
public class HelloResty {
// Hello World!
public static void main(String... args) throws IOException {
Resty r = new Resty();
// Get the content of the URL as text and print it
String hello = r.text("").toString();
beders /
Created Jan 17, 2012
Getting the Google Developer calendar
// Getting the Google Developer calendar
// getting a link from JSON to an XML description of an entry, parsing the text out with XPath
Resty r = new Resty();
String title =
.xml(path("feed.entry[0].id.$t")).get("entry/title/text()", String.class);
beders /
Created Jan 17, 2012
POST multipart form data (application/multipart-formdata)
// POST multipart form data (application/multipart-formdata)
Resty r = new Resty();
String firstResult = r.xml("",
form(data("appid","YahooDemo"),data("query", "Resty+java"), data("results", "10")))
beders / gist:1cb3b3f8ddba12d697f7
Created Apr 17, 2015
Odd side effects using eval
View gist:1cb3b3f8ddba12d697f7
// run with: curl -d 'console.log("hi");' http://localhost:8063; curl -d 'console.log("hi");' http://localhost:8063
vertx.createHttpServer().requestHandler(function (req) {
req.bodyHandler(function (buffer) {
var code = buffer.toString("UTF-8");
var result = eval('"use strict";' + code) || {};
View gist:7849cce449098d7e2de2
import io.vertx.core.AbstractVerticle;
import io.vertx.core.DeploymentOptions;
import io.vertx.core.Vertx;
import io.vertx.ext.apex.Router;
import io.vertx.ext.apex.handler.sockjs.BridgeOptions;
import io.vertx.ext.apex.handler.sockjs.SockJSHandler;
// curl http://localhost:8888/eventbus/info
beders / jps.js
Created Jun 21, 2015
List of currently running Java processes, color coded using Nashorn
View jps.js
// List running Java Processes
// ansicolors
var a = { reset : "\u001B[0m", black: "\u001B[30m", red: "\u001B[31m", green: "\u001B[32m",
yellow: "\u001B[33m", blue: "\u001B[34m", purple: "\u001B[35m", cyan: "\u001B[36m",
white: "\u001B[37m"
var jps = `jps -vl`.split('\n').slice(0,-1);
var ownPID ='@')[0];
beders /
Created Jun 25, 2015
Simple EventBusBridge
package com.saffrontech.vertx;
import io.vertx.core.AsyncResult;
import io.vertx.core.Handler;
import io.vertx.core.MultiMap;
import io.vertx.core.Vertx;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.eventbus.DeliveryOptions;
import io.vertx.core.eventbus.Message;
import io.vertx.core.http.WebSocket;
beders / gist:a4229baac6464e1c7e51
Created Jul 7, 2015
Optional parameters in lambdas
View gist:a4229baac6464e1c7e51
bus.register(msg -> { System.out.println("I gots a message") });
bus.register((msg,param) -> { System.out.println("I gots a message w/ params"); });
beders /
Last active Dec 8, 2015
Examples for optional lambda parameters and polymorphism with default methods
package example;
import java.util.ArrayList;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
* Created by beders on 7/7/15.
View gist:467a7fccfccb1744607e
var json = JSON.parse(document.getElementsByTagName('pre')[0].innerText);
var result = JSON.parse(json.result);
document.getElementsByTagName('BODY')[0].appendChild(document.createTextNode("Result to convert: " + JSON.stringify(result, null, 2)));
// mock data
result = {
You can’t perform that action at this time.