Skip to content

Instantly share code, notes, and snippets.

View andypetrella's full-sized avatar

Andy Petrella andypetrella

View GitHub Profile
@andypetrella
andypetrella / Build.scala
Created February 20, 2012 22:47
Neo4J using Play and Dispatch
import sbt._
import Keys._
import PlayProject._
object ApplicationBuild extends Build {
val appName = "Play20WithNeo4J"
val appVersion = "1.0"
val sbtIdeaRepo = "sbt-idea-repo" at "http://mpeltonen.github.com/maven/"
url(urlString)
>\ "ISO-8859-1" //set the charset
<:< (Map("Accept-Language" -> "fr-BE" )) //set some headers
gzip //encode the response in archived gzip is accepted
@andypetrella
andypetrella / Format.scala
Created February 19, 2012 21:16
Play Json
trait Format[T] extends Writes[T] with Reads[T]
/**
* Default Json formatters.
*/
object Format extends DefaultFormat
@andypetrella
andypetrella / json
Created February 19, 2012 21:06
Test Play REPL
scala> val o:JsObject = JsObject(Seq("a" -> JsNumber(1), "2" -> JsString("two")))
o: play.api.libs.json.JsObject = {"a":1.0,"2":"two"}
scala> o \ "a" //return the value as a JsValue
res26: play.api.libs.json.JsValue = 1.0
scala> val o2:JsObject = JsObject(Seq("a" -> JsNumber(1), "2" -> JsObject(Seq("deep" -> JsBoolean(true)))))
o2: play.api.libs.json.JsObject = {"a":1.0,"2":{"deep":true}}
scala> o \\ "a" // find at first level and return in a list
@andypetrella
andypetrella / Build.scala
Created February 6, 2012 23:40
Play20 RC1 : sbt-idea
import sbt._
import Keys._
import PlayProject._
object ApplicationBuild extends Build {
val appName = "playbasket"
val appVersion = "1.0"
val sbtIdeaRepo = "sbt-idea-repo" at "http://mpeltonen.github.com/maven/"