Instantly share code, notes, and snippets.

View gist:a0c3f86aa70deaea694e
$ git status -s
warning: skipping rename detection, detected duplicate destination 'src/main/java/com/a/r/s2s/eventbus/EventBus.java'
D src/main
D src/main/java/com/a/r/s2s/Flags.java
A src/main/java/com/a/r/s2s/Main.java
A src/main/java/com/a/r/s2s/Stream2StoreConfig.java
D src/main/java/com/a/r/s2s/Stream2StoreCycler.java
D src/main/java/com/a/r/s2s/Stream2StoreEvent.java
D src/main/java/com/a/r/s2s/Stream2StoreExecutor.java
A src/main/java/com/a/r/s2s/Stream2StoreScheduler.java
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
View moltke.md

http://bostinno.com/channels/how-to-write-a-startup-marketing-plan/:

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.
View ngrams.py
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))
View byteswap.ac
AH_VERBATIM([PORTABLE_BYTE_SWAP_FUNCTIONS],
[/* 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)
View specific_rename.sh
#!/bin/sh
# 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+!
#