Skip to content

Instantly share code, notes, and snippets.

View colaru's full-sized avatar

Cristian Olaru colaru

View GitHub Profile
// Groovy map-reduce example
// declare a closure
def half = { it ->
it / 2
}
// declare another closure
def sum = { result, i ->
result + i
@colaru
colaru / moduleIntegrationTest.js
Created August 21, 2013 10:01
javascript integration test with module start
/*
* Example JavaScript integration test that deploys the module that this project builds.
*
* Quite often in integration tests you want to deploy the same module for all tests and you don't want tests
* to start before the module has been deployed.
*
* This test demonstrates how to do that.
*/
load("util.js");
@colaru
colaru / ModuleIntegrationTest.java
Created July 2, 2013 14:14
Integration test for Vert.x WebSocket server that insteed of responding to a request, register a Event Bus handler that send back to client all events on Event Bus for a given topic.
@Test
public void testWebSocketServer() {
long startTime;
long endTime;
startTime = System.currentTimeMillis();
container.logger().info("Starting web socket test");
HttpClient client = vertx.createHttpClient().setPort(8081).setHost("localhost").setMaxPoolSize(CONNS);
for (int i = 0; i < CONNS; i++) {
@colaru
colaru / WebSocketServer.java
Created July 2, 2013 14:05
Vert.x WebSocket server that insteed of responding to a request, register a Event Bus handler that send back to client all events on Event Bus for a given topic.
package com.openwager.rtp;
import org.vertx.java.core.Handler;
import org.vertx.java.core.buffer.Buffer;
import org.vertx.java.core.eventbus.Message;
import org.vertx.java.core.http.ServerWebSocket;
import org.vertx.java.core.json.JsonObject;
import org.vertx.java.core.streams.Pump;
import org.vertx.java.platform.Verticle;
@colaru
colaru / gist:5309747
Created April 4, 2013 11:48
Scala FunSets
object FunSets {
/**
* We represent a set by its characteristic function, i.e.
* its `contains` predicate.
*/
type Set = Int => Boolean
/**
* Indicates whether a set contains a given element.
*/