Skip to content

Instantly share code, notes, and snippets.

View wookietreiber's full-sized avatar
🎸

♫ Christian Krause ♫ wookietreiber

🎸
View GitHub Profile
@viktorklang
viktorklang / swingfutures.scala
Created April 19, 2012 17:58
Akka Futures in the Swing Event Dispatch Thread
// © 2012 Viktor Klang
import akka.dispatch.ExecutionContext
import javax.swing.SwingUtilities
import java.util.concurrent.Executor
//
object SwingExecutionContext {
implicit val swingExecutionContext: ExecutionContext = ExecutionContext.fromExecutor(new Executor {
def execute(command: Runnable): Unit = SwingUtilities invokeLater command
// Define the following traits and companion object
// It's in Rapture Core (https://github.com/propensive/rapture-core) if you don't want to
trait LowPriorityDefaultsTo { implicit def fallback[T, S]: DefaultsTo[T, S] = null }
object DefaultsTo extends LowPriorityDefaultsTo { implicit def defaultDefaultsTo[T]: DefaultsTo[T, T] = null }
trait DefaultsTo[T, S]
// Then, assuming we want to specify a default for a type class like `Namer`,
case class Namer[T](name: String)

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 / meansd.c
Last active July 23, 2018 05:29
calculate mean and standard deviation from numbers in stdin
// this gist has been superseded by
// https://github.com/wookietreiber/scala-cli-tools
@paulp
paulp / valign.txt
Last active May 9, 2016 20:55
Realizing the benefits of vertical alignment.
To realize the benefits of vertical alignment:
- code must be *self-formatting*
- deltas must be *semantic*
Each is within reach today, with moderate effort:
- edit *virtual* files which continuously adapt
- store semantic actions in a parallel VCS
@guyru
guyru / tarsum
Created April 23, 2016 17:38
A small utility to compute checksums on every file inside a tar archive.
#! /usr/bin/env python
# Copyright (C) 2008-2009 by Guy Rutenberg
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
#!/usr/bin/env r
# create input file with:
# $ find /path/to/dir -type f -printf '%s\n' | gzip > dir.file.sizes.gz
# start with:
# $ zcat dir.file.size.gz | fshist.r
# edit breaks to your needed sizes
# leave the breaks "0" and "2^50" for the edges
suppressMessages(library(stats))
@wookietreiber
wookietreiber / README.md
Last active December 20, 2022 14:00
R - Command Line Interface (CLI) and RStudio - template

R - Interactive Sessions and Command Line Interface

This is a template for R projects that should work both on the command line as well as in an interactive session.

Template Files

The template is made up of three files:

  1. foo.r
@wookietreiber
wookietreiber / git-hook-delegate.sh
Last active July 31, 2017 16:22
git hook delegate
#!/bin/bash
GIT_HOOK_DIR="$0.d"
if [[ -d $GIT_HOOK_DIR ]] ; then
while IFS= read -r -d $'\0' hook ; do
"./$hook" || error="yes"
done < <(find "$GIT_HOOK_DIR" -mindepth 1 -print0)
[[ -n $error ]] && exit 1