Skip to content

Instantly share code, notes, and snippets.

View nicmarti's full-sized avatar

Nicolas Martignole nicmarti

View GitHub Profile
@nicmarti
nicmarti / Redis.scala
Created March 1, 2013 11:29
My simple Redis client wrapper that uses Play2 configuration
package library
import org.sedis.Pool
import redis.clients.jedis.{JedisPoolConfig, JedisPool}
import play.api.Play.current
import org.apache.commons.pool.impl.GenericObjectPool
/**
* Redis connection wrapper.
* You can configure the server details in the application.conf with:
@nicmarti
nicmarti / HaskellVSGroovy.groovy
Last active December 14, 2015 23:59 — forked from renatoathaydes/HaskellVSGroovy.groovy
Working on a very simple haskell vs groovy vs scala
// This is a comparison between Haskell and Groovy based on some simple problems found in the following
// Haskell Introduction:
// http://learnyouahaskell.com/starting-out#ready-set-go
// Ex 1. If we have two lists, [2,5,10] and [8,10,11] and we want to get the products of all the possible
// combinations between numbers in those lists, here's what we'd do.
/* HASKELL */
[ x*y | x <- [2,5,10], y <- [8,10,11]]
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,
@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;
@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;
/*
* The MIT License (MIT)
*
* Copyright (c) 2013 Association du Paris Java User Group.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
@nicmarti
nicmarti / SecureCFP Controller
Created May 10, 2014 12:39
SecureCFPController Play 2.2 Scala secure controller used for Devoxx CFP
/*
* The MIT License (MIT)
*
* Copyright (c) 2013 Association du Paris Java User Group.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
@nicmarti
nicmarti / JournauxRepository.scala
Created May 26, 2014 23:30
Slick 2.x left join
object JournauxRepository {
def allWithOperateurs():Seq[(Journal, Operateur, Option[String])] = {
DB.withSession {
implicit s =>
val result = for {
((journal, operateur), intervenant) <- Journaux leftJoin Operateurs on(_.idOperateur === _.id) leftJoin Intervenants on(_._1.idIntervenant === _.idAgence)
} yield (journal,operateur,intervenant.nom.?)
result.run
}
}
@nicmarti
nicmarti / selection.scala
Last active August 29, 2015 14:07
Sample scala test
package roger
import org.scalatest.{FlatSpec, ShouldMatchers}
import roger.AggregationOperation.AggregationOperation
case class Metric(id: String, aggregationOperation: AggregationOperation)
case class Dimension(id: String)
object AggregationOperation extends Enumeration {