This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.specs2.mutable._ | |
import play.api.test._ | |
import play.api.test.Helpers._ | |
import play.api.data._ | |
import play.api.data.Forms._ | |
import play.api.libs.json.Json | |
class JsonBindingSpec extends Specification { | |
val missingProperty = Json parse """{}""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override def onRouteRequest(request: RequestHeader): Option[Handler] = { | |
super.onRouteRequest(request).map { | |
case action: Action[body] => Action[body](action.parser) { (request: Request[body]) => | |
println("Before!") | |
val result = action.apply(request) | |
result match { | |
case AsyncResult(resultPromise) => resultPromise.onRedeem { _ => | |
println("After!") | |
} | |
case otherResult => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is in my cookbook: | |
cookbook_file "/tmp/cleanup.sh" do | |
mode "0744" | |
end | |
And this is what Chef logs: | |
[2012-10-24T17:58:28+02:00] INFO: Processing cookbook_file[/tmp/cleanup.sh] action create (basebox::basebox-cleanup line 1) | |
[2012-10-24T17:58:28+02:00] INFO: cookbook_file[/tmp/cleanup.sh] owner changed to 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait ErrorReps { | |
// Copied and adapted from Scala 2.10.0 | |
def repErr[T](p: => Parser[T]): Parser[List[T]] = rep1Err(p) | success(List()) | |
def rep1Err[T](p: => Parser[T]): Parser[List[T]] = rep1Err(p, p) | |
def rep1Err[T](first: => Parser[T], p0: => Parser[T]): Parser[List[T]] = Parser { in => | |
lazy val p = p0 // lazy argument | |
val elems = new ListBuffer[T] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* bar is not a real field: after the lazy val bork is initialized, | |
* 'bar' is set to null. | |
* | |
* It's a normal field when we make bork a def, add 'val' or 'var' to bar or make it a case class. | |
* It's not a field at all when we make bork a val. | |
*/ | |
class MyClass(param: String) { | |
lazy val field = param |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import play.api.libs.iteratee._ | |
import scala.concurrent.ExecutionContext.Implicits.global | |
import scala.concurrent._ | |
import scala.concurrent.duration._ | |
import play.api.libs.concurrent.Promise | |
object iteratees { | |
// Implicit conversion to add 'await' to a Future | |
implicit class WFuture[A](val inner: Future[A]) extends AnyVal { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package controllers | |
import play.api.libs.concurrent.Execution.Implicits.defaultContext | |
import play.api.libs.iteratee.{ Concurrent, Iteratee } | |
import play.api.libs.ws.{ ResponseHeaders, WS } | |
import play.api.mvc.{ Action, Controller, SimpleResult } | |
import scala.concurrent.Promise | |
object Application extends Controller { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait ElasticSearchComponent { | |
val esClient: EsClient | |
} | |
trait ElasticSearchIndex { self: ElasticSearchComponent => | |
def findAll() = esClient.doAQueryForAll() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sbt._ | |
import Keys._ | |
import play.Project._ | |
object ApplicationBuild extends Build { | |
val appName = "fake-templates" | |
val appVersion = "1.0-SNAPSHOT" | |
val appDependencies = Seq( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module HelloWorld where | |
import Data.Either | |
import Prelude | |
import Data.Foreign | |
import Control.Monad.Eff | |
import qualified Control.Monad.JQuery as J | |
import Debug.Trace | |
main = J.ready $ do |
OlderNewer