View gist:a0c3f86aa70deaea694e
$ git status -s
warning: skipping rename detection, detected duplicate destination 'src/main/java/com/a/r/s2s/eventbus/'
D src/main
D src/main/java/com/a/r/s2s/
A src/main/java/com/a/r/s2s/
A src/main/java/com/a/r/s2s/
D src/main/java/com/a/r/s2s/
D src/main/java/com/a/r/s2s/
D src/main/java/com/a/r/s2s/
A src/main/java/com/a/r/s2s/
View TemplatedParquetScheme.scala
package com.a.r.ingest.scalding
import scala.collection.JavaConversions._
import _root_.parquet.cascading.ParquetTupleScheme
import cascading.scheme.Scheme
import cascading.tap.SinkMode
import cascading.tuple.Fields
import com.twitter.scalding.FixedPathSource
import com.twitter.scalding.HadoopSchemeInstance
View Typeclassopedia: Functors
Exploring the Typeclassopedia. First up: Functors.
A Functor is a type which satisfies the following laws:
fmap id = id
fmap (f . g) = fmap f . fmap g
Its declaration is:
class Functor f where
View HiveSources.scala
import scala.collection.JavaConversions._
import cascading.scheme.Scheme
import cascading.tap.SinkMode
import cascading.tuple.Fields
import com.twitter.scalding.{FixedPathSource, HadoopSchemeInstance, SchemedSource}
import org.apache.hadoop.mapred.{JobConf, OutputCollector, RecordReader}
trait HiveScheme extends SchemedSource {
// cascading-hive Schemes take two arrays as arguments
View mux.hs
mux :: [a] -> [a] -> [a]
mux = muxl
muxl :: [a] -> [a] -> [a]
muxl [] [] = []
muxl xs [] = xs
muxl [] ys = ys
muxl (x:xs) ys = x : muxr xs ys
muxr :: [a] -> [a] -> [a]
View angles.hs
newtype Degree = Degree Float
newtype Radian = Radian Float
toRadian :: Degree -> Radian
toRadian deg = Radian $ (fromDegree deg) * (pi / 180)
fromRadian :: Radian -> Float
fromRadian (Radian x) = x
toDegree :: Radian -> Degree

A startup Marketing Plan “Moltke-style” starts with defining 6 terms that are too often conflated by young marketers:

  • goal – what we hope to achieve.
  • objective – how we will measure success in reaching our goal.
  • strategy – an approach we think will meet our objective.
  • tactic – execution to convert our strategy into action.
  • program – a collection of related tactics.
  • plan – what needs to be done when, given the above.
import itertools
def ngrams(xs, f = None, n = 3):
ts = itertools.tee(xs, n)
for i, t in enumerate(ts[1:]):
for _ in xrange(i + 1):
next(t, None)
return map(f, itertools.izip(*ts))
[/* Standardize on a byte-swap function naming */
#if defined(__linux__)
# include <endian.h>
#elif defined(__FreeBSD__) || defined(__NetBSD__)
# include <sys/endian.h>
#elif defined(__OpenBSD__)
# include <sys/types.h>
# define be16toh(x) betoh16(x)
# define be32toh(x) betoh32(x)
# Needed to rename a directory chock full o' files (don't ask).
# First thought?
find . -type f -exec rename 's/(\d+).(foo|bar|baz).(\d+).txt/$1.$3.$2.txt/' +
# Result? Horrible!
# Not sure what was going on, but between find batching the arguments to rename,
# and rename pausing after each batch, run-time was approaching 4 hours+!