Skip to content

Instantly share code, notes, and snippets.

View jeffreyiacono's full-sized avatar

Jeff Iacono jeffreyiacono

  • Eight Sleep
  • San Francisco
  • X @jfi
View GitHub Profile
@jeffreyiacono
jeffreyiacono / remove_merged_branches.rb
Created August 19, 2013 03:29
remove all the merged branches
for b in `git branch --merged | grep -v \*`; do git branch -D $b; done
@jeffreyiacono
jeffreyiacono / start-all.sh
Last active December 21, 2015 06:19
starts / stops hadoop dfs + mapr
#! /bin/bash
# Starts up Hadoop dfs + mapred
# can specify config by passing in an optional parameter:
#
# $ ./start-all.sh
# $ ./start-all.sh path-to-config
#
# If optional parameter is not supplied, it will default to
# $HADOOP_INSTALL/conf
@jeffreyiacono
jeffreyiacono / queue.js
Last active December 18, 2015 20:59
generic queue that applies the passed operation to each element, separating each call out by the specified throttle
function Queue(config) {
this.throttle = (typeof config['throttle'] !== "undefined") ? config['throttle'] : 2000;
this.elements = config['elements'];
this.operation = config['operation'];
this.interval_id = null;
return this;
}
Queue.prototype.process = function() {
@jeffreyiacono
jeffreyiacono / extended_csv.rb
Last active December 18, 2015 13:29
fun with CSVs
require 'csv'
class ExtendedCSV
attr_accessor :filepaths
def initialize filepaths
@filepaths = [*filepaths]
end
def + other_extended_csv
{
"USD": {
"symbol": "$",
"name": "US Dollar",
"symbol_native": "$",
"decimal_digits": 2,
"rounding": 0,
"code": "USD",
"name_plural": "US dollars"
},
@jeffreyiacono
jeffreyiacono / cut_plot.md
Created April 28, 2013 00:03
fun with cut in R
We couldn’t find that file to show.
import cairo
from contextlib import contextmanager
@contextmanager
def saved(cr):
cr.save()
try:
yield cr
finally:
cr.restore()
<html>
<head>
<script type="text/javascript" src="curry.js" />
<title>currying in javascript</title>
</head>
<body>
<div id="item">default</div>
</body>
</html>
@jeffreyiacono
jeffreyiacono / bak.sh
Created March 29, 2013 18:22
bak - CLI to easily backup files and directories
# quick and easy backuping
# put int ~/src/bak
cp -r "$1" "$1.bak"
@jeffreyiacono
jeffreyiacono / foreman.rb
Last active December 14, 2015 21:09
Foreman divides up units of work evenly amongst workers
class Foreman
attr_accessor :units_of_work, :workers_count
def initialize attrs = {}
@units_of_work = attrs[:units_of_work]
@workers_count = attrs[:workers_count]
end
def fair_shares
even_shares = Array.new(@workers_count) { @units_of_work / @workers_count }