Skip to content

Instantly share code, notes, and snippets.

View kpmeen's full-sized avatar
👾

Knut Petter Meen kpmeen

👾
View GitHub Profile
@kpmeen
kpmeen / converter.scala
Created May 22, 2016 09:02
Converting case classes in an HList to reactivemongo based BSONDocuments using Shapeless
import reactivemongo.bson.Macros
import shapeless._
object ToBson extends Poly1 {
import reactivemongo.bson._
implicit def caseClass[E](
implicit
ev: E <:< Product,
@kpmeen
kpmeen / typeclass-coproduct.scala
Created May 18, 2016 13:57 — forked from aaronlevin/typeclass-coproduct.scala
Writing a typeclass in Scala that crawls a shapelss Coproduct and returns a new Coproduct
/**
* Let's write a typeclass for a coproduct. The idea is we're given the name of a string, and we need to:
*
* 1. check that the string matches a value
* 2. if the string matches a value, convert that string into some type and return it
* 3. If the string doesn't match that value, try another alternative.
* 4. If no alternatives match the value, return an error.
*
* The usecase is based on something I encountered in real life: we have to parse different kind of events in
* my work's data pipeline, and the type of event (and subsequent parsing) depends on an "event type" string. I
@kpmeen
kpmeen / global.sbt
Last active April 10, 2017 19:53
My custom SBT Shell prompt
// Requires that sbt-git plugin is enabled. Make sure you have this plugin
// added to your ~/.sbt/0.13/plugins/plugins.sbt file:
// addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.8.5")
shellPrompt := { state =>
object NoOpSbtLogger extends Logger {
def trace(t: => Throwable): Unit = {}
def success(message: => String): Unit = {}
def log(level: Level.Value, message: => String): Unit = {}
}
@kpmeen
kpmeen / GitHubAuthController.scala
Created March 13, 2016 16:30
Getting emails for GitHub users after OAuth2 authentication.
class LoginController @Inject() (
// ...
socialProviderRegistry: SocialProviderRegistry,
configuration: Configuration,
// ...
) extends Silhouette[User, JWTAuthenticator] {
private val log = Logger(this.getClass)
// Fetch the email from the GitHub REST API
@kpmeen
kpmeen / JodaTimeSerializer.scala
Last active October 7, 2015 21:15 — forked from ctcarrier/gist:9918087
Joda DateTime Serializer for ReactiveMongo
package foo
import reactivemongo.bson.{BSONHandler, BSONDateTime, Macros}
import org.joda.time.format.ISODateTimeFormat
import org.joda.time.{DateTime, DateTimeZone}
package object bar {
DateTimeZone.setDefault(DateTimeZone.UTC)
implicit object BSONDateTimeHandler extends BSONHandler[BSONDateTime, DateTime] {

Stash Shortcomings (relative to GitHub)

Doesn't work on mobile ANYTHING!!! This item should be on a giant, 2 meter poster in the Atlassian office. It should be in all caps, red text, with images of blood droplets dripping from the lettering. There should be a pager alert sent to a random project manager every night at 2am containing this text until such time as the issue is resolved. There are no words for how much of a problem this is.

General

  • Did I mention that it doesn't work on mobile?
  • Performance. Across the board. In everything. Rendering reflow. Server-side latency due to reading out repository data. Everything. It's all very very slow compared to the same operations in GitHub.
  • Doesn't support syntax highlighting in Markdown. GitHub flavored Markdown is the standard for this sort of thing.
  • Why does the "Overview" tab exist at all? It shows nothing that the "Source" view doesn't show, and what it does show is of tremendously limited usefulness.

Git DMZ Flow

I've been asked a few times over the last few months to put together a full write-up of the Git workflow we use at RichRelevance (and at Precog before), since I have referenced it in passing quite a few times in tweets and in person. The workflow is appreciably different from GitFlow and its derivatives, and thus it brings with it a different set of tradeoffs and optimizations. To that end, it would probably be helpful to go over exactly what workflow benefits I find to be beneficial or even necessary.

  • Two developers working on independent features must never be blocked by each other
    • No code freeze! Ever! For any reason!
  • A developer must be able to base derivative work on another developer's work, without waiting for any third party
  • Two developers working on inter-dependent features (or even the same feature) must be able to do so without interference from (or interfering with) any other parties
  • Developers must be able to work on multiple features simultaneously, or at lea
@kpmeen
kpmeen / echelon.zsh
Last active May 5, 2017 21:00
My custom ZSH themes...
# echelon
function virtualenv_info {
[ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') '
}
function box_name {
hostname -s
}
@kpmeen
kpmeen / nxfetch.sh
Created January 28, 2014 07:36 — forked from adutra/nxfetch.sh
#!/bin/bash
# Argument = -h -v -i groupId:artifactId:version -c classifier -p packaging -r repository
#shopt -o -s xtrace
# Define Nexus Configuration
NEXUS_BASE=http://repository.example.com:8081/nexus
REST_PATH=/service/local
ART_REDIR=/artifact/maven/redirect