Skip to content

Instantly share code, notes, and snippets.

View enterpredator's full-sized avatar

Eugene Smykov enterpredator

  • Moscow
View GitHub Profile
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="https://270927.selcdn.ru/satelead-static/widget/1.0/satelead.widget.lib.js"></script>
<script>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="https://270927.selcdn.ru/inwine-static/widget/1.1/inwine.widget.lib.js"></script>
<script>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="http://270927.selcdn.com/inwine-static/widget/inwine.widget.lib.js"></script>
<script>
@enterpredator
enterpredator / Tuple2Format.scala
Created July 4, 2017 12:39 — forked from alexanderjarvis/Tuple2Format.scala
Allow case classes with Tuple2 types to be represented as a Json Array with 2 elements e.g. (Double, Double)
import play.api.libs.json._
import play.api.libs.functional.syntax._
import play.api.data.validation._
implicit def tuple2Reads[A, B](implicit aReads: Reads[A], bReads: Reads[B]): Reads[Tuple2[A, B]] = Reads[Tuple2[A, B]] {
case JsArray(arr) if arr.size == 2 => for {
a <- aReads.reads(arr(0))
b <- bReads.reads(arr(1))
} yield (a, b)
case _ => JsError(Seq(JsPath() -> Seq(ValidationError("Expected array of two elements"))))
package controllers
import play.api._
import play.api.mvc._
import play.api.data.Form
import play.api.data.Forms._
import play.api.data.format.Formats._
import models.Credential
import views.html.defaultpages.unauthorized
import scala.concurrent.Await