Skip to content

Instantly share code, notes, and snippets.

View matterche's full-sized avatar

Matthias Erche matterche

View GitHub Profile
@matterche
matterche / postgres-json-cheatsheet.md
Last active July 4, 2017 14:45 — forked from rmtsrc/postgres-json-cheatsheet.md
Using JSON in Postgres by example

PostgreSQL JSON Cheatsheet

Using JSON in Postgres by example.

Quick setup via Docker

  1. Download and install: Docker Toolbox
  2. Open Docker Quickstart Terminal
  3. Start a new postgres container:
    docker run --name my-postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres
@matterche
matterche / ScalaZ Monad Transformers.scala
Last active October 3, 2015 13:20 — forked from eamelink/transformers.scala
Working with Eithers in Futures
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?
@matterche
matterche / git-log2json.sh
Last active August 29, 2015 14:27 — forked from textarcana/git-log2json.sh
Convert Git logs to JSON. The first script (git-log2json.sh) is all you need, the other two files contain only optional bonus features :)
#!/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/},]/}]/'
@matterche
matterche / zsh.md
Last active August 29, 2015 14:24 — forked from tsabat/zsh.md
@matterche
matterche / EnumUtils.scala
Last active August 29, 2015 14:24 — forked from mikesname/gist:5237809
Play Json enumeration read/write
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._
@matterche
matterche / junit4-templates.xml
Created March 22, 2012 12:16 — forked from hstaudacher/junit4-templates.xml
JUnit4 Templates for Eclipse
<?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