Skip to content

Instantly share code, notes, and snippets.

View wookietreiber's full-sized avatar
🎸

♫ Christian Krause ♫ wookietreiber

🎸
View GitHub Profile
@wookietreiber
wookietreiber / imap-check.scala
Last active August 29, 2015 13:57
Checks your IMAP folders for new and unread messages.
#!/bin/bash
cd "$(dirname "$0")"
[[ ! -d lib ]] &&
mkdir lib
[[ ! -e lib/java-mail.jar ]] &&
wget -q -O lib/java-mail.jar http://search.maven.org/remotecontent?filepath=com/sun/mail/javax.mail/1.5.1/javax.mail-1.5.1.jar
@wookietreiber
wookietreiber / ffmpeg-convert-animation.sh
Last active August 29, 2015 13:57
ffmpeg-based animation converter, converts from * to high quality x264 and good libvorbis, is quite slow, however
#!/bin/bash
[[ -z $2 ]] && {
echo "usage $0 /path/to/movie/in /path/to/movie/out" > /dev/stderr
exit 1
}
PRESET=veryslow
TUNE=animation
CRF=18
@wookietreiber
wookietreiber / ZipInvert.scala
Created April 5, 2014 13:45
Scala inverted zip extension method
import language.higherKinds
import collection.GenIterable
import collection.generic.CanBuildFrom
implicit class ZipInvert[A,CC[X] <: GenIterable[X]](coll: CC[A]) {
def zipInvert[A1 >: A, B, That](that: GenIterable[B])(implicit bf: CanBuildFrom[CC[A], (B, A1), That]): That = {
val b = bf(coll)
val these = coll.iterator
val those = that.iterator
@wookietreiber
wookietreiber / optLast.scala
Created October 19, 2014 10:28
last option for scala scripts
import annotation.tailrec
def optLast[A](opts: String*)(convert: String => Option[A])(implicit args: List[String]): Option[A] = {
val longOpts = opts filter { _ startsWith "--" }
val longOptsRE = longOpts.mkString("^(","|",")=(.+)").r
@tailrec def optLastInternal(current: Option[A], args: List[String]): Option[A] = args match {
case Nil =>
current
@wookietreiber
wookietreiber / StringOutputStream.scala
Last active August 29, 2015 14:17
Scala StringOutputStream: feed an OutputStream and retrieve the data as a String
import java.io.OutputStream
class StringOutputStream extends OutputStream {
private val bytes = collection.mutable.ArrayBuffer[Byte]()
override def write(b: Int): Unit = {
bytes += b.toByte
}
def s: String = new String(bytes.toArray)
@wookietreiber
wookietreiber / StringInputStream.scala
Created March 13, 2015 07:28
Scala StringInputStream: have a String and read from it with an InputStream
import java.io.InputStream
class StringInputStream(s: String) extends InputStream {
private val bytes = s.getBytes
private var pos = 0
override def read(): Int = if (pos >= bytes.length) {
-1
} else {

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
@wookietreiber
wookietreiber / app.scala
Last active August 29, 2015 14:22
sbt itext jfreechart dependency blow up
package org.example
import scalax.chart.api._
object Main extends App {
val data = for {
i <- 1 to 5
category = i.toString
date = new org.jfree.data.time.Day(i, 2, 1998)
value = i * 2
@wookietreiber
wookietreiber / sigpipe.scala
Created September 3, 2015 11:45
handle SIGPIPE in Scala
import sun.misc.Signal
import sun.misc.SignalHandler
object Foo extends App {
val signal = new Signal("PIPE")
val handler = new SignalHandler {
def handle(signal: Signal): Unit = {
Console.err.println(s"""caught signal: $signal""")
sys.exit(128 + signal.getNumber)
# Maintainer: Christian Krause ("wookietreiber") <kizkizzbangbang@googlemail.com>
pkgname=jellyfish
pkgver=2.2.3
pkgrel=1
pkgdesc="fast, memory-efficient counting of k-mers in DNA"
arch=('i686' 'x86_64')
url="http://www.genome.umd.edu/jellyfish.html"
license=('GPL3')
depends=('gcc-libs')