Skip to content

Instantly share code, notes, and snippets.

View matterche's full-sized avatar

Matthias Erche matterche

View GitHub Profile
@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 / 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 / StdOutErrLogger.scala
Last active January 15, 2016 16:24
Redirect System.out and System.err to Play Framework logger
package globals
import java.io.PrintStream
import play.api.Logger
object StdOutErrLogger {
val logger = Logger(this.getClass)
def redirectSystemOutAndErrToLog() = {
@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