Skip to content

Instantly share code, notes, and snippets.

@jeantil
jeantil / Application.scala
Last active July 29, 2018 12:01
Playframework 2.2 configurable cors filter
/**
The MIT License (MIT)
Copyright (c) 2013 Jean Helou
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
@ubourdon
ubourdon / json.scala
Created April 4, 2013 14:57
Comment lire un array json hétérogène avec l'api json de Play! 2.1
implicit val venueReader: Reads[Venue] = (
(__ \ "address").readNullable[String] and
(__ \ "address_2").readNullable[String] and
(__ \ "city").readNullable[String] and
(__ \ "region").readNullable[String] and
(__ \ "country").readNullable[String] and
(__ \ "postal_code").readNullable[String]
)(Venue)
implicit val eventbriteEventReader: Reads[EventbriteEvent] =
@fsarradin
fsarradin / WebMain.java
Last active December 12, 2015 03:48
Two ways to create a basic Web application from scratch with route management (in Scala and in Java 8)
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpServer;
import java.io.IOException;
import java.net.InetSocketAddress;
public class WebMain {
public static void main(String[] args) throws IOException {
WebServer.serve(8080, "/").withRoute(
object MyApp extends App {
case class Bag[+A](value: A) { // covariance
//override def toString = "toto"
//def copy
//equals
//hashcode
// + elem de Product
// functor dans la théorie des catégories
def map[B](f: A => B): Bag[B] = Bag(f(value))
@wadouk
wadouk / db.events.save.js
Created July 21, 2012 21:41
Generate a sample data for OneCalendar
use OneCalendar
db.events.save({
"title" : "my great record",
"begin" : NumberLong(new String(new Date(new Date().getTime()+1000*60*60*24).getTime())),
"end" : NumberLong(new String(new Date(new Date().getTime()+3000*60*60*24).getTime())),
"location" : "anywhere i want",
"description" : "",
"tags" : [
"TAG1"
]
@wadouk
wadouk / bashrc.sh
Created March 29, 2012 08:26
Maven console in color
PURPLE=$(echo -en "\033[35m")
GREEN=$(echo -en "\033[32m")
RED=$(echo -en "\033[31m")
YELLOW=$(echo -e "\033[33m")
BLUE=$(echo -e "\033[1;34m")
NORMAL=$(echo -e "\033[0m")
mvn2() {
mvn $* | sed \
-e "s/^\(.ERROR. .*\)$/$RED\1$NORMAL/ ; #contain ERROR start 2nd char
@katta
katta / mvncolor.sh
Created June 15, 2011 18:50
Script to add colors to maven output
#!/usr/bin/env bash
# Formatting constants
export BOLD=`tput bold`
export UNDERLINE_ON=`tput smul`
export UNDERLINE_OFF=`tput rmul`
export TEXT_BLACK=`tput setaf 0`
export TEXT_RED=`tput setaf 1`
export TEXT_GREEN=`tput setaf 2`
export TEXT_YELLOW=`tput setaf 3`