Skip to content

Instantly share code, notes, and snippets.

View hellertime's full-sized avatar
🏠
Working from home

Chris Heller hellertime

🏠
Working from home
View GitHub Profile
@hellertime
hellertime / gist:a0c3f86aa70deaea694e
Last active August 29, 2015 14:24
#git index corruption?
$ 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
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
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
@hellertime
hellertime / HiveSources.scala
Last active August 29, 2015 13:58
Using cascading-hive in Scalding
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
@hellertime
hellertime / mux.hs
Created August 23, 2012 04:24
list multiplexer
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]
@hellertime
hellertime / angles.hs
Created August 12, 2012 00:17
Basic angle types
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
@hellertime
hellertime / moltke.md
Created August 7, 2012 15:40
"Moltke"-style planning

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.
@hellertime
hellertime / ngrams.py
Created July 6, 2012 14:50
Python n-gram generator using itertools
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))
@hellertime
hellertime / byteswap.ac
Created June 10, 2012 19:49
Autoconf fragment for normalizing byte-swap functions.
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)
@hellertime
hellertime / specific_rename.sh
Created December 23, 2011 20:38
Outpacing 'rename'
#!/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+!
#