Skip to content

Instantly share code, notes, and snippets.

View francisdb's full-sized avatar
💾
undefined

Francis De Brabandere francisdb

💾
undefined
  • Ghent, Belgium
View GitHub Profile
@francisdb
francisdb / AkkaStreams.scala
Last active October 16, 2017 12:19
Akka streams utilities
import akka.NotUsed
import akka.stream.scaladsl.{Flow, Source} `
import akka.stream.{Attributes, FlowShape, Inlet, Outlet}
import akka.stream.Attributes._
import akka.stream.stage.{GraphStage, GraphStageLogic, InHandler, OutHandler}
import scala.collection.immutable.Seq
object AkkaStreams{

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@francisdb
francisdb / gist:fde82f887df3d9f6fc23
Last active September 29, 2015 02:11
loopy loop
while(true){
console.log("ok");
}
@francisdb
francisdb / android.headless.sh
Created January 8, 2014 16:08
Android headless sdk update
./android list sdk --all
./android update sdk --no-ui --all --filter 87,81,1,2,3,82,tool,platform-tool
@francisdb
francisdb / gist:6630625
Created September 19, 2013 22:16
Debug maven test (waits for debugger to connect)
mvn clean test -Dmaven.surefire.debug -Dtest=com.bla.MyTest
@francisdb
francisdb / gist:6471158
Created September 6, 2013 23:02
Anorm + play json
implicit val pkWrites = new Writes[Pk[Long]] {
def writes(pk: Pk[Long]): JsValue = {
pk.toOption match {
case Some(value) => JsNumber(value)
case None => JsNull // TODO check if correct
}
}
}
@francisdb
francisdb / Dependencies.scala
Created August 29, 2013 21:57
JacksonMapper for easy json in scala
val fasterXmlJacksonVersion = "2.2.2"
val appDependencies = Seq(
"com.fasterxml.jackson.core" % "jackson-core" % fasterXmlJacksonVersion,
"com.fasterxml.jackson.core" % "jackson-annotations" % fasterXmlJacksonVersion,
"com.fasterxml.jackson.core" % "jackson-databind" % fasterXmlJacksonVersion,
"com.fasterxml.jackson.module" %% "jackson-module-scala" % fasterXmlJacksonVersion
)
#!/bin/sh
export PATH=/opt/play2:$PATH
cd ~/server
rundir=myproject
repo=git@server:myproject.git
temp=$rundir.buid.temp
rm -rf $temp
@francisdb
francisdb / gist:5031171
Created February 25, 2013 16:45
add more automatic imports in play framework 2 templates
.settings{
routesImport += "se.radley.plugin.salat.Binders._",
templatesImport += "org.bson.types.ObjectId"
}
@francisdb
francisdb / gist:4514950
Last active December 11, 2015 00:09
Logging WS requests in playframework scala
// I'm looking for a better solution for the time logging (preferable in a transparent way)
private def logTime(message: String, promise: Future[Response]) = {
// not 100% ok, request is already running
// might even not be started yet
val now = System.currentTimeMillis
promise.onRedeem { response =>
val time = System.currentTimeMillis - now
logger.info(message + " => " + response.status + " " + time + "ms " + response.body.length + "b")
}