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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Card Flip Editor</title> | |
<style> | |
body, html { | |
height: 100%; | |
margin: 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>CSS Tabs Example</title> | |
<script> | |
/* | |
This script enables direct-linking to a tab. |
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
pathEndOrSingleSlash { | |
(post & parameter("rev")) { rev => | |
// This is very important, so we can provide a more specific | |
// implicit to overcome the Json4sSupport default unmarshaller | |
// that will require an `application/json` ContentType! | |
import Unmarshaller._ | |
entity(as[Multipart.General]) { body => | |
import scala.concurrent.duration._ |
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
// fold | |
client ! Projects(rows.headOption.fold(Nil)(_ \ "value" extract)) | |
// map.getOrElse | |
client ! Projects(rows.headOption | |
.map(_ \ "value" extract) | |
.getOrElse(Nil)) | |
// Option.toList | |
client ! Projects(rows.headOption.toList.map(_ \ "value" extract)) |
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
// Don't include private.conf in main package. | |
mappings in (Compile, packageBin) ~= { | |
_ filter { | |
case (_, "private.conf") => false | |
case _ => true | |
} | |
} | |
// Don't include private.conf in main sources package. | |
mappings in (Compile, packageSrc) ~= { |
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.json4s._ | |
case object IdSerializer extends CustomSerializer[Id](formats => ( { | |
case JObject(JField("prefix", JString(prefix)) :: JField("id", JString(id)) :: JField("rev", JString(rev)) :: Nil) => IdWithRev(prefix, id, rev) | |
case JObject(JField("prefix", JString(prefix)) :: JField("id", JString(id)) :: Nil) => NewId(prefix, id) | |
}, { | |
case NewId(prefix, id) => JObject(JField("prefix", JString(prefix)) :: JField("id", JString(id)) :: Nil) | |
case IdWithRev(prefix, id, rev) => JObject(JField("prefix", JString(prefix)) :: JField("id", JString(id)) :: JField("rev", JString(rev)) :: Nil) | |
} | |
)) |
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 just a basic sealed trait implementing a couple cases. | |
sealed trait Password { | |
val value: String | |
def hashed: HashedPassword | |
def check(plainTextCandidate: String): Boolean | |
} | |
case class PlainTextPassword(value: String) extends Password { | |
def hashed = HashedPassword.Scrypt(value) | |
def check(plainTextCandidate: String) = plainTextCandidate == 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
type FixtureFunction[T] = T => Any | |
implicit class FixtureFunctionZipper[A](f1: FixtureFunction[A] => Any) { | |
def zip[B](f2: FixtureFunction[B] => Any): ((A, B) => Any) => Any = { test => | |
f1(a => f2(b => test(a, b))) | |
} | |
def zip(f2: (Unit => Any) => Any): (A => Any) => Any = { test => | |
f1(a => f2(_ => test(a))) | |
} |
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
// Just inlining the revelant bits of https://github.com/hseeberger/akka-http-json/blob/master/akka-http-json4s/src/main/scala/de/heikoseeberger/akkahttpjson4s/Json4sSupport.scala#L44 | |
// for the gist. | |
trait Json4sSupport { | |
implicit def json4sUnmarshallerConverter[A: Manifest](serialization: Serialization, formats: Formats): FromEntityUnmarshaller[A] = | |
json4sUnmarshaller(manifest, serialization, formats) | |
/** | |
* HTTP entity => `A` | |
* | |
* @tparam A type to decode |
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
// Example actor: | |
class EchoActor extends Actor { | |
def receive = { | |
case message => context.sender ! message | |
} | |
} | |
// I want to be able to write: | |
object EchoActor extends ActorGenerator0 |
NewerOlder