This is a deliberately broken fork of Mike Bostock's "General Update Pattern, II". Please see the original for an explanation of what's supposed to be happening. I've increased the pause between updates and switched to the default key function to illustrate how D3 calculates the enter, update, and exit selections. Open the console to see the data for each update.
This is a demonstration of how to calculate π using Monte Carlo integration.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
''' | |
usage: %s input_file output_file | |
''' | |
import collections | |
import csv | |
import sys |
I hereby claim:
- I am dehowell on github.
- I am dehowell (https://keybase.io/dehowell) on keybase.
- I have a public key whose fingerprint is EE13 6FE8 20BD 6768 1C1F F841 54EF 03F8 51F4 7BF4
To claim this, I am signing this object:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import re | |
import sys | |
import appscript | |
def get_calendar(name): | |
calendar = appscript.app('iCal').calendars[name] | |
try: | |
calendar.get() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import csv | |
import math | |
import random | |
import sys | |
import numpy | |
NUMBER_OF_LEVERS = 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |