Skip to content

Instantly share code, notes, and snippets.

View dehowell's full-sized avatar

David Howell dehowell

View GitHub Profile
# fix_networking.sh
#
# This script automates the steps outlined at:
#
# http://weblog.jamisbuck.org/2008/8/15/cloning-ubuntu-hardy-image-in-vmware-fusion
#
# for fixing the networking on a copied Ubuntu VMWare image.
usage() {
cat <<EOF
#!/usr/bin/env python
"""Synchronizes bookmarks from http://pinboard.in/
"""
import base64
import datetime
import sys
import urllib2
from appscript import *
public class RepartitionMapper extends MapReduceBase
implements Mapper<LongWritable, Text, ApacheKeyWritable, Text> {
private static final Log LOG = LogFactory.getLog(RepartitionMapper.class);
private static ApacheKeyWritable outputKey = new ApacheKeyWritable();
public MatchResult parseInputFilename(String filename)
throws IllegalArgumentException {
Pattern p = Pattern.compile(
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.junit.*;
import static org.junit.Assert.*;
public class HBaseTest {
private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
@BeforeClass
public static void setUpBeforeClass() throws Exception {
TEST_UTIL.startMiniCluster(1);
[junit] Failed construction of Master: class org.apache.hadoop.hbase.MiniHBaseCluster$MiniHBaseClusterMastercom.google.common.collect.ImmutableList.copyOf(Ljava/util/Collection;)Lcom/google/common/collect/ImmutableList;
[junit] java.lang.RuntimeException: Failed construction of Master: class org.apache.hadoop.hbase.MiniHBaseCluster$MiniHBaseClusterMastercom.google.common.collect.ImmutableList.copyOf(Ljava/util/Collection;)Lcom/google/common/collect/ImmutableList;
[junit] at org.apache.hadoop.hbase.master.HMaster.constructMaster(HMaster.java:1166)
[junit] at org.apache.hadoop.hbase.LocalHBaseCluster.<init>(LocalHBaseCluster.java:112)
[junit] at org.apache.hadoop.hbase.MiniHBaseCluster.init(MiniHBaseCluster.java:232)
[junit] at org.apache.hadoop.hbase.MiniHBaseCluster.<init>(MiniHBaseCluster.java:71)
[junit] at org.apache.hadoop.hbase.HBaseTestingUtility.startMiniCluster(HBaseTestingUtility.java:293)
[junit] at com.wolfram.ca.jobs.sessions.SessionsHBaseTest.setUpBeforeClass
@dehowell
dehowell / gist:884204
Created March 23, 2011 22:49
Python function to test if a file at a URL exists.
import urllib2
def file_exists(location):
request = urllib2.Request(location)
request.get_method = lambda : 'HEAD'
try:
response = urllib2.urlopen(request)
return True
except urllib2.HTTPError:
return False
@dehowell
dehowell / hadoop-tmux.sh
Created August 14, 2011 00:11
Script to initiate a single node Hadoop cluster in a tmux session
#!/bin/bash
#
# Script to initiate (or connect to) a single node Hadoop cluster in a
# tmux session. Requires that tmux and hadoop are on your path.
SESSION=hadoop
tmux has-session -t $SESSION
if [ $? -eq 0 ]; then
echo "Session $SESSION already exists. Attaching."
@dehowell
dehowell / count_nef_files.py
Created May 5, 2012 11:16
Python script for searching a large binary file for .NEF file headers.
#!/usr/bin/env python
import sys
# .NEF (Nikon Electronic Format) headers
SIGNATURE = '\x4d\x4d\x00\x2a\x00\x00\x00\x08\x00'
def read_chunks(stream, overlap = len(SIGNATURE), size = 100 * 2 ** 20):
'''Read chunks from the stream with a small overlap.'''
data = stream.read(size)
while True:
@dehowell
dehowell / gist:4188413
Created December 2, 2012 12:24
Plotting a bar graph
# Install the awesome ggplot graphics library
install.packages("ggplot2")
# Read in the data file, assuming a CSV and a header line
running <- read.table("running.csv", sep=",", header=TRUE)
# Plot!
ggplot(running, aes(x = as.Date(date), ymin = 0, ymax = ounces)) + geom_linerange()
@dehowell
dehowell / bandit.py
Created December 28, 2012 16:18
Multi-armed bandit simulation.
#!/usr/bin/env python
import csv
import math
import random
import sys
import numpy
NUMBER_OF_LEVERS = 10