Skip to content

Instantly share code, notes, and snippets.

package example
object FPStyle {
trait Show[T] {
def show(t: T): String
}
object Show {

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@ import scala.concurrent.{ Future, ExecutionContext }
import scala.concurrent.{ Future, ExecutionContext }
@ import scala.concurrent.ExecutionContext.Implicits._
import scala.concurrent.ExecutionContext.Implicits._
@ {
def testF[A](x: => Future[A]): Future[A] = {
println("here")
val future = x
future
}
package queue
import akka.actor.{Actor, Props}
import queue.ActorWithQueue._
class ActorWithQueue(init: Queue[String] = Queue.empty ) extends Actor {
def handleMessage(queue: Queue[String]): Receive = {
case Push(str) =>
handleMessage(queue.enqueue(str))
package spray.routing
package directives
import spray.can.Http
import akka.io.IO
import akka.actor.ActorSystem
import spray.http.{ HttpRequest, Uri }
trait ProxyDirectives {
val json = """{"key1": "value1", "key2":"value2", "key3":"value3"}"""
case class Test(key1:String, rest: Map[String, String])
val test = Test("value1", Map("key2" -> "value2", "key3" -> "value3"))
@bthuillier
bthuillier / parList.scala
Created February 6, 2013 15:37
parallelization
val words = List[String]("scala", "php", "java", "ruby")
//récupère une version parallelisé de la liste
words.par.filter(word => word.length > 3).foreach(println(_))
def test = Action {
// Solution la plus générique
Async {
val futureA = WS.url("xx").get
val futureB = WS.url("yy").get
val resultAB = for {
resA <- futureA
resB <- futureB
} yield (resA, resB)
// searches for nodes by filtering on key value
def filter(jsv: JsValue, filterFn: String => Boolean): Seq[JsValue] = {
jsv match {
case JsObject(fields) => fields.toMap.foldLeft(Seq[JsValue]())((o, pair) => pair match {
case (key, value) if filterFn(key) => o ++ (value +: (filter(value, filterFn)))
case (_, value) => o ++ (filter(value, filterFn))
})
case _ => Seq[JsValue]()
}
}
@bthuillier
bthuillier / gitpull.sh
Created April 11, 2012 15:19
git toolbox
# pour éviter d'avoir à faire
git pull --rebase
# faite la commande ci-dessous pour que la commande git pull fasse par défaut rebase au lieu de merge
git config --global branch.autosetuprebase always
# Et si vous voulez malgrès tout ne pas faire de rebase lors d'un pull
git pull --no-rebase