Skip to content

Instantly share code, notes, and snippets.

View tovbinm's full-sized avatar
⌨️
<typing sounds>

Matthew Tovbin tovbinm

⌨️
<typing sounds>
View GitHub Profile
#!/usr/bin/env python
#
# Python code for http://www.cloudera.com/blog/2009/06/17/analyzing-apache-logs-with-piganalyzing-apache-logs-with-pig/
import sys
import math
def rescale(values, low=0, high=4095):
"""Linearly rescales values to be strictly between low and high."""
maxval = max(values)
@tovbinm
tovbinm / instantHTTP
Created April 20, 2011 06:59 — forked from softprops/instantHTTP
One line Python Web server
python -m SimpleHTTPServer
@nukemberg
nukemberg / knife.sh
Created June 28, 2011 07:51 — forked from ches/knife
bash completion for Chef's knife command (updated for 0.10)
# vim: ft=sh:ts=4:sw=4:autoindent:expandtab:
# Author: Avishai Ish-Shalom <avishai@fewbytes.com>
# We need to specify GNU sed for OS X, BSDs, etc.
if [[ "$(uname -s)" == "Darwin" ]]; then
SED=gsed
else
SED=sed
fi
@tlrobinson
tlrobinson / gist:1073865
Created July 9, 2011 19:34
Autocomplete Makefile targets. Add this to your shell config file.
complete -W "\`grep -oE '^[a-zA-Z0-9_-]+:([^=]|$)' Makefile | sed 's/[^a-zA-Z0-9_-]*$//'\`" make
@aloiscochard
aloiscochard / Stream.scala
Created November 2, 2011 16:06
Scala [In]finite Stream Constructor
import Stream._
/** A possibly finite stream that repeatedly applies a given function to a start value.
*
* @param start the start value of the stream
* @param f the function that's repeatedly applied
* @return the stream returning the possibly finite sequence of values `start, f(start), f(f(start)), ...`
*/
def iterate[A](f: A => A, a: A): Stream[A] = unfold((x: A) => Some((x, f(x))), a)
@pchiusano
pchiusano / microbenchmark.markdown
Created December 2, 2011 13:49
Simple microbenchmarks comparing Scala vs Java mutable map performance

I was curious about the results reported here, which reports that Scala's mutable maps are slower than Java's: http://www.infoq.com/news/2011/11/yammer-scala

In my tests, Scala's OpenHashMap equals or beats java's HashMap:

Insertion 100k elements (String keys) time in ms:

  • scala HashMap: 92.75
  • scala OpenHashMap: 14.03125
  • java HashMap: 15.78125
@ambar
ambar / gist:1534274
Created December 29, 2011 14:15 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@milligramme
milligramme / bash_completion
Created January 20, 2012 08:13
brew install bash-completion
$ brew install bash-completion
==> Downloading http://bash-completion.alioth.debian.org/files/bash-completion-1.3.tar.bz2
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/bash-completion/1.3
==> make install
==> Caveats
Add the following lines to your ~/.bash_profile file:
if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
fi
@alavrik
alavrik / diff -u riakclient.proto.piqi riakclient.proto.piqi.edited
Created February 9, 2012 03:04
Compiling riakclient.proto for OCaml using Piqi
$ diff -u riakclient.proto.piqi riakclient.proto.piqi.edited
--- riakclient.proto.piqi 2012-02-08 20:55:35.000000000 -0600
+++ riakclient.proto.piqi.edited 2012-02-08 20:55:25.000000000 -0600
@@ -299,6 +299,7 @@
]
.field [
.name done
+ .ocaml-name "ocaml_done"
.type bool
.optional
$ diff -u riakclient.proto.piqi riakclient.proto.piqi.edited
--- riakclient.proto.piqi 2012-02-08 20:55:35.000000000 -0600
+++ riakclient.proto.piqi.edited 2012-02-08 20:55:25.000000000 -0600
@@ -299,6 +299,7 @@
]
.field [
.name done
+ .ocaml-name "ocaml_done"
.type bool
.optional