Skip to content

Instantly share code, notes, and snippets.

View mgandin's full-sized avatar

Mathieu Gandin mgandin

View GitHub Profile
@mgandin
mgandin / EmbeddedMongoDb.java
Last active June 7, 2019 15:54
How to embed MongoDb for your Junit Integration test
import java.io.IOException;
import de.flapdoodle.embed.mongo.MongodExecutable;
import de.flapdoodle.embed.mongo.MongodProcess;
import de.flapdoodle.embed.mongo.MongodStarter;
import de.flapdoodle.embed.mongo.config.MongodConfigBuilder;
import de.flapdoodle.embed.mongo.config.Net;
import de.flapdoodle.embed.mongo.distribution.Version;
import de.flapdoodle.embed.process.runtime.Network;
@mgandin
mgandin / ConcurrentFooBarQix.java
Last active December 25, 2015 17:19
Concurrent FooBarQix
package fr.mga.foobarqix;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.*;
public class ConcurrentFooBarQix implements Callable<String> {
private int toFooBar;
@mgandin
mgandin / ConcurrentFooBarQix.java
Last active February 23, 2022 01:03
A small example to monitor Java Thread Pool with JMX
package fr.mga.concurrent;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.*;
public class ConcurrentFooBarQix implements Callable<String> {
@mgandin
mgandin / HelloControllerSpec.js
Last active August 29, 2015 13:57
Hello Angular World
'use strict';
describe("HelloController", function() {
var isTrue;
var helloController;
var scope;
beforeEach(angular.mock.module('helloWorld.app'));
beforeEach(angular.mock.inject(function($rootScope, $controller){
@mgandin
mgandin / ConcurrentFooBar.java
Last active August 29, 2015 14:01
Some small examples in Java 8 with new java.time API, Stream, Lambdas, CompletableFuture, String Joiner, ParallelPrefix & ParallelSetAll in Arrays, File & Path Closeable Stream, List.sort and Map.compute & merge
package fr.mga.spike;
import java.util.concurrent.*;
public class ConcurrentFooBar {
public static String fooBar(int anInteger) {
String result = "";
if (anInteger % 3 == 0)
result += "foo";
@mgandin
mgandin / Vagrantfile
Last active August 29, 2015 14:02
Hello Vagrant world
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define :ubuntu do |ubuntu|
ubuntu.vm.box = "ubuntu"
ubuntu.vm.network "private_network", ip: "10.11.12.13"
@mgandin
mgandin / Hello.java
Last active August 29, 2015 14:07
Hello RXJava World
package fr.mga.mashup;
import rx.Observable;
public class Hello {
public String msg(String ... msg) {
HelloFunction function = new HelloFunction();
HelloReduce reduce = new HelloReduce();
return Observable.from(msg).map(function).reduce(reduce).toBlocking().first();
}
@mgandin
mgandin / MapReduce.java
Last active August 29, 2015 14:07
Map Reduce RXJava
package fr.mga.mashup.mapreduce;
import rx.Observable;
import java.util.List;
public class MapReduce {
private List<Integer> list;
@mgandin
mgandin / Application.java
Created December 18, 2014 10:09
Hello Spring Boot
package fr.mga.hello;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
@ComponentScan
@EnableAutoConfiguration
public class Application {
@mgandin
mgandin / FooBar.java
Last active November 5, 2015 09:38
Functional FooBarQix ...
package fr.mga.functional;
import java.util.HashMap;
import java.util.Map;
import static java.lang.Character.getNumericValue;
import static java.util.stream.Collectors.joining;
public class FooBar {