Skip to content

Instantly share code, notes, and snippets.

View fbiville's full-sized avatar

Florent Biville fbiville

View GitHub Profile
@fbiville
fbiville / ServiceRepository.java
Created June 15, 2015 16:19
Fun with JOOQ (sadly without codegen)
@Override
public Collection<Service> findAllByEnvironmentWithinDuration(Environment environment, Duration duration) {
return DSL.using(dataSource, dialect)
.select(field("s.name", field("s.pattern"), field("a.name"), field("e.name")))
.from(table("service").as("s"))
.leftOuterJoin(table("application").as("a"))
.on(field("s.application_id").equal(field("a.id")))
.leftOuterJoin(table("environment").as("e"))
.on(field("a.environment_id").equal(field("e.id")))
.where(field("s.creation_time_millis").minus(duration.get(MILLIS)).greaterThan(0))
@fbiville
fbiville / Crawler.java
Last active August 29, 2015 14:27
A little fun with Reactor [Reactor Environment has been initialized beforehand]
package fr.vidal.oss.crawler;
import fr.vidal.oss.crawler.cache.UrlCache;
import fr.vidal.oss.crawler.model.LinkedFeed;
import fr.vidal.oss.crawler.parsing.Either;
import fr.vidal.oss.crawler.parsing.FetchError;
import fr.vidal.oss.jaxb.atom.core.Link;
import reactor.Environment;
import reactor.core.Dispatcher;
import reactor.fn.Predicate;

Main title

What is it about?

My super graph is super

@fbiville
fbiville / exercise_2.01.scala
Last active December 18, 2015 17:13
FP in Scala - exercises
def fib(n:Int):Int = {
@annotation.tailrec
def _fib(count:Int, x1:Int, x2:Int):Int = {
val current = x1+x2
if (count == n) current
else _fib(count+1, x2, current)
}
if (n == 1) 0
else if (n == 2) 1
@fbiville
fbiville / Record.java
Last active September 18, 2016 05:24
Neo4j (3.0.4) stored procedure records cannot contain record types
public class Record {
public Record record;
}
@fbiville
fbiville / 1_pom.xml
Last active October 23, 2016 17:04
Liquigraph 2.0.0 with Neo4j 3.x in embedded and file mode (spoiler alert: it won't work)
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.biville.florent</groupId>
<artifactId>test-liquigraph-neo4j3-liquigraph2</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>test-liquigraph-neo4j3-liquigraph2</name>
@fbiville
fbiville / DESCRIPTION.md
Last active November 26, 2016 18:48
Dr Who dataset for Neo4j 3.x

Initial Doctor Who dataset

This is based on the data published by Neo Technology.

The main difference lies in the introduction of labels and the export in Cypher rather than the raw Neo4j files. This offers a greater interoperability (the raw files do not work on Neo4j 3.x instances).

The dataset is in dr-who.cypher.

Import with neo4j-shell

@fbiville
fbiville / EmbeddedGraphDatabaseRule.java
Created August 27, 2017 17:28
Neo4J embedded database JUnit rule that works consistenly against all Neo4j 3.x stable versions
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Transaction;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.function.BiFunction;
2018-01-02 13:29:13
Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.151-b12 mixed mode):
"Attach Listener" #151 daemon prio=9 os_prio=0 tid=0x00007f6b89288800 nid=0x219a waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
"BuilderThread 3" #76 prio=5 os_prio=0 tid=0x00007f6b89285800 nid=0x1bac waiting on condition [0x00007f6b6eb34000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000000807ff168> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
@fbiville
fbiville / CustomContextInitializer.java
Last active October 17, 2025 13:39
Dynamic WireMock port in Spring Boot test
import org.assertj.core.util.Maps;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.MapPropertySource;
import java.util.Map;
import static org.springframework.util.SocketUtils.findAvailableTcpPort;
public class CustomContextInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {