This file contains 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
'use strict'; | |
angular.module('yourApp') | |
.directive 'file', [ () -> | |
restrict: "E" | |
template: "<input type=\"file\" />" | |
replace: true | |
require: "ngModel" | |
link: (scope, element, attr, ctrl) -> | |
listener = -> |
This file contains 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
val foo = "foo" | |
foo = "Bar" | |
var bar = "Bar" | |
foo + bar |
This file contains 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.json._ | |
import play.api.libs.json.Reads._ | |
// construct a json | |
val user = Json.obj("email" -> "[email protected]", "firstName" -> "Foo", "lastName" -> "Bar") | |
// > user: play.api.libs.json.JsObject = {"email":"[email protected]","firstName":"Foo","lastName":"Bar"} | |
println(s"user -> $user") | |
// > user -> {"email":"[email protected]","firstName":"Foo","lastName":"Bar"} |
This file contains 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
// Create the Global class in your /app folder root package: | |
import play.api.{GlobalSettings, Play} | |
import play.api.Play.current | |
import play.api.mvc._ | |
import scala.concurrent.Future | |
import scala.concurrent.ExecutionContext.Implicits.global | |
/** |
This file contains 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 lists out the initial steps you need to take in your fresh Play project to install the ReactiveMongo plugin | |
// add play.plugins | |
400:play.modules.reactivemongo.ReactiveMongoPlugin | |
// update build.sbt | |
resolvers += "Sonatype Snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/" | |
// Below is optional if you wish to build custom modules and include them into your project | |
//resolvers += Resolver.file("Local repo", file("/Users/<user>/.ivy2/local"))(Resolver.ivyStylePatterns) |
This file contains 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
// step one - build your ActionBuilder | |
/** | |
* Created by terry on 10/1/13. | |
*/ | |
object BasicAuthSecured extends ActionBuilder[AuthorizedRequest] with HeaderNames with Results { | |
protected def invokeBlock[A](request: Request[A], block: (AuthorizedRequest[A]) => Future[SimpleResult]): Future[SimpleResult] = { | |
BasicAuthService.authorize(request.headers.get(AUTHORIZATION)).map { | |
identity => | |
block(AuthorizedRequest(identity, request)) | |
} getOrElse (Future.successful(onUnauthorized)) |
This file contains 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
private def buildUsageUpsert(usage : Usage) = { | |
Json.obj( | |
"$setOnInsert" -> | |
Json.obj( | |
"cpCode" -> usage.customer.cpCode, | |
"zuora.id" -> usage.customer.zuoraId, | |
"zuora.subscriptionId" -> usage.customer.subscriptionId, | |
"month" -> usage.month, | |
"year" -> usage.year, | |
"uom" -> "GB" |
This file contains 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
val filterClientIp : Directive1[InetAddress] = { | |
extractClientIP { | |
ip => | |
ip.getAddress().fold(reject){ | |
address => | |
if (address.isAnyLocalAddress) { | |
provide(address) | |
} else { | |
reject(SuspectIpRejection(address, "IP is suspect!")) | |
} |