Skip to content

Instantly share code, notes, and snippets.

@ubourdon
ubourdon / Build.scala
Created February 4, 2014 18:47
example cross building sbt config file
import sbt._
import sbt.Keys._
object ScalaTestEmbededMongoBuild extends Build {
lazy val root = Project(id = "simplyscala-server", base = file("."),
settings = Project.defaultSettings ++ Seq(
name := "scalatest-embedmongo",
organization := "com.github.simplyscala",
description := "API to use embeded mongoDb database for testing in Scala",
package service
import org.scalatest.FunSuite
import org.scalatest.matchers.ClassicMatchers
import play.api.libs.ws.{Response, WS}
import scala.concurrent.{Await, Future}
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext.Implicits.global
class LoadDevoxxTest extends FunSuite with ClassicMatchers {
@ubourdon
ubourdon / BoatRepository.scala
Created May 4, 2014 21:28
Dependency Injection in Scala object
// The "classic" Repository interface
trait BoatRepository {
def find(uid: String): Future[Boat]
}
from base
run apt-get update
run apt-get install -y curl
run cd /opt && curl -s -L -b oraclelicense=accept-securebackup-cookie http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jdk-7u51-linux-x64.tar.gz | tar xvz
run cd /opt && ln -s jdk1.7.0_51 jdk7
env JAVA_HOME /opt/jdk7
#!/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`
@ubourdon
ubourdon / 1ExampleRepository.scala
Last active August 29, 2015 14:02
abstract the notion of sycn/async result: question ?
/**
* I want to be able to abstract the notion of sycn/async result
*
* I use the example of Repository object
*
* The only difference between sync & async result is async result is encapsulated with scala.concurrent.Future[+T]
* Async vs Sync
* Future vs []
*/
@ubourdon
ubourdon / Repository.scala
Last active August 29, 2015 14:02
abstract the notion of sycn/async result : solution
import scala.concurrent.Future
trait Repository[ResultWrapper[_], AggregateRoot] {
def create(root: AggregateRoot): ResultWrapper[String]
def retrieve(id: String): ResultWrapper[Option[AggregateRoot]]
def retrieveAll(): ResultWrapper[Set[AggregateRoot]]
def update(root: AggregateRoot): ResultWrapper[ServerResponse]
def delete(root: AggregateRoot): ResultWrapper[ServerResponse]
}
@ubourdon
ubourdon / App.scala
Created July 9, 2014 14:24
playframework bug when process GET http request wth json body
// route : GET /api/myRessource controllers.App.prepare
object App extends Controller {
def prepare = Action(parse.json) { request =>
Ok("test")
}
}
/** L'erreur
*
* <h1>Bad request</h1>
/**
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
#!/bin/bash
#
# =========================================================================
# Copyright 2014 Rado Buransky, Dominion Marine Media
#
# 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