Skip to content

Instantly share code, notes, and snippets.

View fbiville's full-sized avatar

Florent Biville fbiville

View GitHub Profile
@fbiville
fbiville / registry-source.yaml
Created August 12, 2020 16:21
https://github.com/fbiville/eventing-contrib/ | registry-source branch | 91efb2b1da5db214e9c839bc23752ffad2543d8c
# Copyright 2019 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@fbiville
fbiville / wait_for_up_status.sh
Last active December 19, 2019 16:55
Wait for Spring Boot's health status to be up
#!/bin/bash
set -Eeuo pipefail
get_health_status() {
curl --request GET http://localhost:8080/actuator/health 2> /dev/null | jq --raw-output '.status'
}
main() {
while [ "$(get_health_status)" != "UP" ]; do
@fbiville
fbiville / summary.md
Last active September 25, 2019 14:30
HTTP/2 vulnerabilities and Node / Java libs
@fbiville
fbiville / ResultExtensionTest.kt
Last active March 1, 2019 16:40
kotlin.Result - flatMap extension
import net.jqwik.api.ForAll
import net.jqwik.api.Property
// requires compiler option '-Xallow-result-return-type'
fun <T, U> Result<T>.flatMap(function: (T) -> Result<U>): Result<U> {
return if (isSuccess) {
function(getOrNull()!!)
} else {
Result.failure(this.exceptionOrNull()!!)
}
@fbiville
fbiville / gist:3041a07f8e83f3925815c74a68184143
Created November 27, 2018 11:01
Hands on Neo4j - Devoxx Morocco 2018 - solutions
[
{
"instructions": "Find the number of movies",
"solution": "MATCH (m: Movie) RETURN COUNT(m);"
},
{
"instructions": "Find the number of action movies",
"solution": "MATCH (m: Movie {genre: 'Action'}) RETURN COUNT(m);"
},
{
@fbiville
fbiville / prepend_test.go
Last active October 5, 2018 10:51
Golang property-based testing example
package main
import (
"testing"
"testing/quick"
)
func TestSlicePrepend(t *testing.T) {
f := func(head string, tail []string) bool {
result := prepend(head, tail)
@fbiville
fbiville / configuration-zsh.sh
Created September 4, 2018 07:38
Zsh custom config in workstation-setup
echo
echo "Configuring zsh"
brew install grc
brew install coreutils
brew install watch
brew install z
touch ~/.z
brew install zsh zsh-completions
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
cp files/dircolors.ansi-dark ~/.dircolors
@fbiville
fbiville / CustomContextInitializer.java
Last active October 5, 2019 11:22
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> {
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 / 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;