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
#ifdef GL_ES | |
precision highp float; | |
#endif | |
uniform sampler2D from, to; | |
uniform float progress; | |
uniform vec2 resolution; | |
float Rand(vec2 v) { | |
return fract(sin(dot(v.xy ,vec2(12.9898,78.233))) * 43758.5453); | |
} |
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
#ifdef GL_ES | |
precision highp float; | |
#endif | |
uniform sampler2D from, to; | |
uniform float progress; | |
uniform vec2 resolution; | |
// default amplitude = 1.0 | |
uniform float amplitude; | |
// default waves = 30. | |
uniform float waves; |
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
#ifdef GL_ES | |
precision highp float; | |
#endif | |
uniform sampler2D from, to; | |
uniform float progress; | |
uniform vec2 resolution; | |
// default amplitude = 1.0 | |
uniform float amplitude; | |
// default waves = 30. |
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
#ifdef GL_ES | |
precision highp float; | |
#endif | |
uniform sampler2D from, to; | |
uniform float progress; | |
uniform vec2 resolution; | |
// default amplitude = 1.0 | |
uniform float amplitude; | |
// default waves = 30. |
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
#ifdef GL_ES | |
precision highp float; | |
#endif | |
uniform sampler2D from, to; | |
uniform float progress; | |
uniform vec2 resolution; | |
// default a = 4 | |
uniform float a; | |
// default b = 1 |
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.functional.syntax._ | |
val r = ( | |
(__ \ "field1").readNullable[String] and | |
(__ \ "field2").readNullable[Int] | |
).tupled.filter(ValidationError("unexpected result")){ | |
case( Some(x), None ) => true; | |
case ( None, Some(x) ) => true; | |
case _ => false |
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
// Reads a JsArray and then map on its elements applying Reads (cumulating errors) | |
def readJsArrayMap[A <: JsValue](transformEach: Reads[A]): Reads[JsArray] = Reads { js => js match { | |
case arr: JsArray => | |
arr.value.foldLeft(JsSuccess(Seq[JsValue]()): JsResult[Seq[JsValue]]) { (acc, e) => | |
acc.flatMap{ seq => | |
e.transform(transformEach).map( v => seq :+ v ) | |
} | |
}.map(JsArray(_)) | |
case _ => JsError("expected JsArray") |
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.data.validation._ | |
import play.api.libs.functional.syntax._ | |
val json = Json.obj( | |
"name" -> "John", | |
"email" -> "[email protected]", | |
"password" -> "password", | |
"confirmPassword" -> "password" | |
) |
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.functional.syntax._ | |
sealed trait Shape | |
case class Circle(c: (Float, Float), r: Float) extends Shape | |
object Circle { | |
// reader is covariant and can be implicit in inheriting caseclasses | |
implicit val reader = Json.reads[Circle] | |
// writer is contravariant and can't be implicit in inheriting caseclasses |
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 scala.reflect.macros.Context | |
import language.experimental.macros | |
trait MyTypeClass[A] { | |
def doit(a: A): A | |
} | |
object Macros { | |
def inferImplicitsImpl[A: c.WeakTypeTag](c: Context): c.Expr[MyTypeClass[A]] = { | |
import c.universe._ |
NewerOlder