Skip to content

Instantly share code, notes, and snippets.

View jmduke's full-sized avatar
🏠

Justin Duke jmduke

🏠
View GitHub Profile
# -*- coding: utf-8 -*-
import re
from scrapy.item import Item, Field
from scrapy.contrib.spiders import CrawlSpider, Rule
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor
from scrapy.selector import HtmlXPathSelector
from lxml.cssselect import css_to_xpath
@jmduke
jmduke / README.md
Last active August 29, 2015 13:57 — forked from mbostock/.block
@jmduke
jmduke / Makefile
Last active August 29, 2015 13:57 — forked from mbostock/.block
GENERATED_FILES = \
unemployment.tsv
.PHONY: all clean
all: $(GENERATED_FILES)
clean:
rm -rf -- $(GENERATED_FILES)
from Queue import Queue
from threading import Thread, active_count
import pytumblr
import sys
import time
import logging
client = pytumblr.TumblrRestClient(
'FILLINYOUROWNDAMNVALUES',
'FILLINYOUROWNDAMNVALUES',
@jmduke
jmduke / gist:5660594
Created May 28, 2013 04:54
Error when running pagoda
$ pagoda .
/Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:45:in `gem_original_require': /Library/Ruby/Gems/1.8/gems/pagoda-jekyll-0.0.9/bin/../lib/pagoda/app.rb:39: syntax error, unexpected tIDENTIFIER, expecting tAMPER (SyntaxError)
...source, *%w[_posts], post_file)
^
/Library/Ruby/Gems/1.8/gems/pagoda-jekyll-0.0.9/bin/../lib/pagoda/app.rb:146: syntax error, unexpected tIDENTIFIER, expecting tAMPER
repo.add File.join(jekyll_site.source, *%w[_posts], filename)
^
from /Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:45:in `require'
from /Library/Ruby/Gems/1.8/gems/pagoda-jekyll-0.0.9/bin/pagoda:20
from /usr/bin/pagoda:23:in `load'
@jmduke
jmduke / gist:7427030
Created November 12, 2013 07:37
Plotting retweets over time.
import matplotlib.pyplot as plt
from datetime import datetime, timedelta
import numpy as np
from math import log
import tweepy
import collections
import bisect
DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
INTERVAL = timedelta(hours = 1)
@jmduke
jmduke / gist:7654733
Created November 26, 2013 07:45
Analyze daily GitHub Explore emails
import requests
import operator
companies = ["hubspot"]
api_url = "https://api.github.com/orgs/{}/repos"
data = {}
for company in companies:
data[company] = {'forks': 0, 'stars': 0, 'repos': 0, 'languages': {}}
r = requests.get(api_url.format(company))
@jmduke
jmduke / index.html
Last active January 1, 2016 15:39
Visualizing Seattle's 911 calls.
<!DOCTYPE html>
<head>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7/leaflet.css" />
<link rel="stylesheet" href="http://leaflet.github.io/Leaflet.markercluster/dist/MarkerCluster.Default.css" />
<script src="http://cdn.leafletjs.com/leaflet-0.7/leaflet.js"></script>
<script src="http://leaflet.github.io/Leaflet.markercluster/dist/leaflet.markercluster-src.js" type='text/javascript'></script>
<script src="http://briangonzalez.github.io/jquery.adaptive-backgrounds.js/js/jquery.js"></script>
<style>
@jmduke
jmduke / gist:8382405
Created January 12, 2014 08:51
Fun with NFL scores.
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import vincent
# source: http://www.pro-football-reference.com/boxscores/game_scores.cgi
SOURCE_FILE = "./nflscores.csv"
data = pd.read_csv(SOURCE_FILE, header=0)
import nltk
import vincent
from curses.ascii import isdigit
from nltk.corpus import cmudict
import nltk.data
import sys
authors = ['kerouac', 'joyce', 'hemingway', 'milton', 'dickens', 'fitzgerald', 'nabokov', 'vonnegut']
d = cmudict.dict()