Skip to content

Instantly share code, notes, and snippets.

View fteychene's full-sized avatar

Francois Teychene fteychene

View GitHub Profile
@fteychene
fteychene / ProtobufMain.java
Created December 18, 2015 14:12
Test protobuf and Chronicle for events
package fte.tests.chronicle;
import com.cognitect.transit.Reader;
import com.cognitect.transit.TransitFactory;
import com.cognitect.transit.Writer;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.guava.GuavaModule;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import net.openhft.chronicle.Chronicle;
import net.openhft.chronicle.ChronicleQueueBuilder;
@fteychene
fteychene / Batcher.java
Created December 18, 2015 15:16
Sample of structure for Batcher
public class Batcher {
static class Flusher implements Runnable {
private ConcurrentLinkedQueue<Events.Event> queu = new ConcurrentLinkedQueue<>();
@Override
public void run() {
// Flush with defined interval or with special rules
}
@fteychene
fteychene / TennisGame1.java
Created March 29, 2016 14:00
Tennis refactor proposal
public class TennisGame1 implements TennisGame {
private int scoreP1 = 0;
private int scoreP2 = 0;
private String player1Name = "player1";
private String player2Name = "player2";
public TennisGame1(String player1Name, String player2Name) {
this.player1Name = player1Name;
this.player2Name = player2Name;
@fteychene
fteychene / delete_agent.sh
Created August 10, 2016 18:24
Delete rancher agent
docker rm -fv rancher-agent rancher-agent-state
rm -Rf /var/lib/rancher/state
@fteychene
fteychene / Requests.java
Created March 14, 2017 21:41
Solution Cours 1 ORM EPSI B3
package fr.ccavalier.hibernate.course.requests;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* Created by charlotte on 20/02/17.
@fteychene
fteychene / script.sh
Created May 16, 2017 15:33
Docker commands
docker network create petclinic-db
docker run -d --net=petclinic-db --network-alias=mysql -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=test mysql:5.5
docker build -t spring-petclinic:latest
docker run -p 8080:8080 --net=petclinic-db spring-petclinic:latest
for i in {1..5}; do; docker run --net=petclinic-db --network-alias=petclinic -d spring-petclinic:latest; done;
@fteychene
fteychene / curry.kt
Created April 2, 2019 08:30
Kotlin currified
fun <P1, P2, R> ((P1, P2) -> R).curried(): (P1) -> (P2) -> R = { p1: P1 -> { p2: P2 -> this(p1, p2) } }
fun <P1, P2, P3, R> ((P1, P2, P3) -> R).curried(): (P1) -> (P2) -> (P3) -> R = { p1: P1 -> { p2: P2 -> { p3: P3 -> this(p1, p2, p3) } } }
fun <P1, P2, P3, P4, R> ((P1, P2, P3, P4) -> R).curried(): (P1) -> (P2) -> (P3) -> (P4) -> R = { p1: P1 -> { p2: P2 -> { p3: P3 -> { p4: P4 -> this(p1, p2, p3, p4) } } } }
fun <P1, P2, P3, P4, P5, R> ((P1, P2, P3, P4, P5) -> R).curried(): (P1) -> (P2) -> (P3) -> (P4) -> (P5) -> R = { p1: P1 -> { p2: P2 -> { p3: P3 -> { p4: P4 -> { p5: P5 -> this(p1, p2, p3, p4, p5) } } } } }
fun test(val1: Int, val2: String, val3: Float, val4: Double): String = "$val1, $val2, $val3, $val4"
@fteychene
fteychene / build.gradle.kts
Last active April 2, 2019 15:45
Polymorphic monad stack test with Arrow
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm") version "1.3.21"
kotlin("kapt") version "1.3.21"
}
repositories {
mavenCentral()
}

Keybase proof

I hereby claim:

  • I am fteychene on github.
  • I am fteychene (https://keybase.io/fteychene) on keybase.
  • I have a public key ASBN34zfHMRt8MGbJiGbgEgnsvgys9UFVaJRi89tf9YYmgo

To claim this, I am signing this object:

@fteychene
fteychene / StreamInputStream.kt
Last active May 16, 2019 10:04
InputStream to combine a Stream of other InputStream in a lazy way in Kotlin
class StreamInputStream(private val source: Stream<out InputStream>) : InputStream() {
private val iterator by lazy {
source
.flatMap {
generateSequence {
val result = it.read(); if (result == -1) {
it.close(); null
} else result
}.asStream()