Using JSON in Postgres by example.
- Download and install: Docker Toolbox
- Open Docker Quickstart Terminal
- Start a new postgres container:
docker run --name my-postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres
Using JSON in Postgres by example.
docker run --name my-postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres| import scala.concurrent.Future | |
| object either { | |
| // Scala standard library Either is sometimes used to distinguish between 'failure' and 'success' state. Like these two methods: | |
| def getUser(id: String): Either[String, User] = ??? | |
| def getPreferences(user: User): Either[String, Preferences] = ??? | |
| // The Right side contains the success value by convention, because right is right, right? |
| #!/usr/bin/env bash | |
| # Use this one-liner to produce a JSON literal from the Git log: | |
| git log \ | |
| --pretty=format:'{%n "commit": "%H",%n "author": "%an <%ae>",%n "date": "%ad",%n "message": "%f"%n},' \ | |
| $@ | \ | |
| perl -pe 'BEGIN{print "["}; END{print "]\n"}' | \ | |
| perl -pe 's/},]/}]/' |
Prereq:
apt-get install zsh
apt-get install git-coreGetting zsh to work in ubuntu is weird, since sh does not understand the source command. So, you do this to install zsh
wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh
| package enumtest | |
| import play.api.libs.json._ | |
| object EnumUtils { | |
| def enumReads[E <: Enumeration](enum: E): Reads[E#Value] = new Reads[E#Value] { | |
| def reads(json: JsValue): JsResult[E#Value] = json match { | |
| case JsString(s) => { | |
| try { | |
| JsSuccess(enum.withName(s)) |
| #!/usr/bin/env scalas | |
| /*** | |
| scalaVersion := "2.11.7" | |
| libraryDependencies += "com.typesafe.play" %% "play-netty-server" % "2.4.1" | |
| */ | |
| import play.core.server._ | |
| import play.api.routing.sird._ | |
| import play.api.mvc._ |
| <?xml version="1.0" encoding="UTF-8" standalone="no"?><templates><template autoinsert="true" context="java" deleted="false" description="" enabled="true" name="setup">${:import(org.junit.Before)} | |
| @Before | |
| public void setUp() { | |
| ${cursor} | |
| }</template><template autoinsert="true" context="java" deleted="false" description="" enabled="true" name="teardown">${:import(org.junit.After)} | |
| @After | |
| public void tearDown() { | |
| ${cursor} | |
| }</template><template autoinsert="false" context="java-members" deleted="false" description="test method" enabled="true" id="org.eclipse.jdt.ui.templates.test" name="test">${:import(org.junit.Test)} | |
| @Test |