Skip to content

Instantly share code, notes, and snippets.

View nicmarti's full-sized avatar

Nicolas Martignole nicmarti

View GitHub Profile
@nicmarti
nicmarti / README.md
Last active March 5, 2024 20:54
Exercice Scala niveau débutant

Lunatech

Scala tutorial.

Audience : cet exercice s'adresse à des développeurs ayant quelques bases en Scala. Il permet de découvrir la mise en place progressive d'un ensemble de fonctions et de types, pour résoudre un problème simple.

L'objectif de cet exercice est de réaliser un générateur d'équipement pour le jeu Minecraft. Minecraft est un jeu d'exploration. L'aventurier doit trouver des ingrédients de base, puis les combiner afin de constuire

@nicmarti
nicmarti / AkkaServerSentClientApp.scala
Created August 1, 2017 21:43
Simple Akka HTTP Server-sent-event client
/*
* Copyright 2017 Lunatech
*
* 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
@nicmarti
nicmarti / ProjectService.java
Created May 9, 2020 17:15
Quarkus RESTEasy and update with Transaction
@ApplicationScoped
public class ProjectService {
@Inject
UserTransaction transaction;
private static Logger logger = LoggerFactory.getLogger(ProjectService.class);
@Inject
@nicmarti
nicmarti / KVotesReplay.kt
Created May 3, 2018 22:01
Devoxx CFP Web client to replay votes from a Gluon log file
import org.apache.http.client.ClientProtocolException
import org.apache.http.client.ResponseHandler
import org.apache.http.client.methods.HttpPost
import org.apache.http.entity.StringEntity
import org.apache.http.impl.client.HttpClients
import org.apache.http.util.EntityUtils
import java.io.File
/**
@nicmarti
nicmarti / java
Created July 21, 2017 15:27
Play 2.5 Java - Download a set of images, described in a JSON file with a list of URLs, using Akka stream.
package services;
import akka.actor.ActorSystem;
import akka.stream.ActorMaterializer;
import akka.stream.Materializer;
import akka.stream.javadsl.FileIO;
import com.fasterxml.jackson.databind.JsonNode;
import play.api.Play;
import play.libs.Json;
import play.libs.ws.StreamedResponse;
[info] [SUCCESSFUL ] org.scala-sbt#serialization_2.10;0.1.1!serialization_2.10.jar (1615ms)
2017-01-12T08:18:10.881+01:00[info] [SUCCESSFUL ] org.scala-lang.modules#scala-pickling_2.10;0.10.0!scala-pickling_2.10.jar (113ms)
2017-01-12T08:18:10.882+01:00[info] downloading https://repo1.maven.org/maven2/org/json4s/json4s-core_2.10/3.2.10/json4s-core_2.10-3.2.10.jar ...
2017-01-12T08:18:10.898+01:00[info] [SUCCESSFUL ] org.json4s#json4s-core_2.10;3.2.10!json4s-core_2.10.jar (81ms)
2017-01-12T08:18:10.899+01:00[info] downloading https://repo1.maven.org/maven2/org/spire-math/jawn-parser_2.10/0.6.0/jawn-parser_2.10-0.6.0.jar ...
2017-01-12T08:18:10.900+01:00[info] [SUCCESSFUL ] org.spire-math#jawn-parser_2.10;0.6.0!jawn-parser_2.10.jar (44ms)
2017-01-12T08:18:10.901+01:00[info] downloading https://repo1.maven.org/maven2/org/spire-math/json4s-support_2.10/0.6.0/json4s-support_2.10-0.6.0.jar ...
2017-01-12T08:18:11.358+01:00[info] downloading https://repo1.maven.org/maven2/org/scalamacros/quasiquotes_2.10/2.0.1/quasi
@nicmarti
nicmarti / FluentdLogbackAppenderBase.java
Last active December 22, 2015 18:18
Simple logback appender for Fluentd, ready to use with Play2 application
package org.zaptravel.logback.fluentd;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.Map;
import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.core.UnsynchronizedAppenderBase;
import org.apache.commons.lang3.StringEscapeUtils;
@nicmarti
nicmarti / DaemonAppender.java
Last active December 22, 2015 17:49
FluentLogbackAppender Java, that is able to track the URI if you used MDC.put("URL","/page/toto") in your code. Used for zaptravel. I adapted one of the fluent logback appender.
package org.zaptravel.logback.fluentd;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import org.slf4j.Logger;
case class TicketRequest(max: String, eventId: Long, start: String, tickets: List[Ticket])
case class Ticket(modifiedOn: Date,
optIn:Boolean,
ticketId: Long,
email:String,
invoiceState:String,
ticketType: String,
modifiedTime: Long,
partnerCode: String,
@nicmarti
nicmarti / tickets.json
Created March 21, 2013 16:52
JSON sample for tickets
{
"max": "10",
"eventId": 5,
"start": "0",
"tickets": [
{
"invoiceState": "PAID",
"modifiedTime": 1354710165000,
"tagId": "unassigned",
"optIn": false,