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
| val json = Json.obj("users" -> Json.arr(Json.obj("name" -> "martin"), Json.obj("name" -> "dupont"))) | |
| val path = ((__ \ "users")(1) \ "name") | |
| __.json.update(path.json.put(JsString("toto"))).reads(json) |
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
| { | |
| "license": "All Rights Reserved", | |
| "version": "5541036", | |
| "results": [ | |
| { | |
| "data": { | |
| "all": { | |
| "Group": { | |
| "value": [ | |
| { |
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
| { | |
| "tags": ["toto"], | |
| "type": "all", | |
| "Group": [ | |
| { | |
| "color": "#d85cb8" | |
| }, | |
| { | |
| "color": "#39ede7" | |
| } |
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
| function propMap<T>(values: Array<[string, T]>): (key: string, value?: T) => T { | |
| var _prop = (map?: Map<string, T>) => { | |
| var prop = (key: string, value?: T) => { | |
| if (value !== undefined) map.set(key, value); | |
| return map.get(key); | |
| } | |
| return prop; | |
| } | |
| var map = values.reduce((acc, pair) => { |
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
| gulp.task('watch', ['compile'], function() { | |
| var assets = Assets.ts.src.files.concat(Assets.styl.src.files); | |
| gulp.src(assets) | |
| .pipe(watch(assets)) | |
| .pipe(plumber()) | |
| .pipe(exec('tarifa build web', { | |
| pipeStdout: true | |
| })) | |
| .pipe(exec.reporter({ | |
| err: true, |
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
| object Utils { | |
| import scala.concurrent.duration._ | |
| import play.api.libs.concurrent.Promise | |
| import play.api.libs.iteratee.{ Enumerator, Iteratee } | |
| def sequence[A, B](seq: Seq[A])(f: A => Future[B]): Future[Seq[B]] = { | |
| val enumerator = Enumerator[A](seq: _*) | |
| val consummer = Iteratee.foldM[A, Seq[B]](Seq.empty[B]) { | |
| case (acc, i) => f(i).map(t => t +: acc) |
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
| sealed trait Literal extends Term { | |
| def asOpt[A <: Literal](): Option[A] = { | |
| this match { | |
| case x: A => Some(x) | |
| case _ => None | |
| } | |
| } | |
| } |
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
| def flattenObject(obj: JsObject, prefix: Option[String] = None) :Seq[(String, JsValue)] = { | |
| obj.fields.toList match { | |
| case ("$date",_) :: Nil if prefix.isDefined => Seq(prefix.get -> obj) | |
| case ("$date",_) :: Nil => throw new Exception("Can't save $date at the first level.") | |
| case fs => fs.flatMap { t => | |
| val name = prefix.map(_ + ".").getOrElse("") + t._1 | |
| t._2 match { | |
| case obj: JsObject => flattenObject(obj, Some(name)) | |
| case value => Seq(name -> value) | |
| } |
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
| def flattenObject(obj: JsObject, prefix: Option[String] = None) :Seq[(String, JsValue)] = { | |
| obj.fields.toList match { | |
| case ("$date",_) :: Nil if prefix.isDefined => Seq(prefix.get -> obj) | |
| case ("$date",_) :: Nil => throw new Exception("Can't save $date at the first level.") | |
| case fs => fs.flatMap { t => | |
| val name = prefix.map(_ + ".").getOrElse("") + t._1 | |
| t._2 match { | |
| case obj: JsObject => flattenObject(obj, Some(name)) | |
| case value => Seq(name -> value) | |
| } |
NewerOlder