Skip to content

Instantly share code, notes, and snippets.

@JoeGermuska
JoeGermuska / ranker.py
Created April 18, 2012 15:20
Example of how to convert a csv file to a table of ranked headers for each row
#!/usr/bin/env python
import csv, json
from collections import defaultdict
r = csv.reader(open("data.csv"))
headers = r.next()
countries = headers[1:]
out_rows = []
for row in r:
area = row[0]
out_row = [area]
@csessig86
csessig86 / crime_scraper.py
Created June 29, 2012 21:00
This Python scraper pulls information off a PDF after its been converted to HTML. The PDF is a weekly arrest log provided by the Waterloo Police Department. The information is then put into a CSV file.
# We will be using the Python library Beautiful Soup
# To scrape the information
import urllib2
from bs4 import BeautifulSoup
import re
# Note: This arrest log is available at:
# http://chrisessig.com/arrestlog.PDF
# It was taken from the Waterloo Police Department's website:
# http://www.waterloopolice.com/images/arrestlog.PDF
@csessig86
csessig86 / geojson.js
Created July 8, 2012 08:18 — forked from mourner/geojson.js
Leaflet GeoJSON API proposal
var geojson = L.geoJson(data, {
// style for all vector layers (color, opacity, etc.) (optional)
getStyle: function (feature) {
return feature.properties && feature.properties.style;
},
// function for creating layers for GeoJSON point features (optional)
pointToLayer: function (feature, latlng) {
return L.marker(latlng, {
@brandonb927
brandonb927 / osx-for-hackers.sh
Last active May 2, 2025 16:33
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx
@jsvine
jsvine / draft.md
Created August 8, 2012 14:56
Why I love Tabletop.js but don't use it in production

Tabletop.js is a fantastic, open-source JavaScript library that lets developers easily integrate data from Google Spreadsheets into their online projects. I've used it, even contributed a minor feature, and love it for prototyping. Non-programmers love being able to update a project via Google Spreadsheets' hyper-intuitive interface.

That said, I'm extraordinarily wary of using Tabletop in production. Instead, at the Wall Street Journal, we use a bit of middleware to "prune" our Google Spreadsheets-based data and then cache it on our own servers. A few brief reasons:

@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@kyleondata
kyleondata / gist:3440492
Last active February 1, 2023 19:23
Backbone.js and Handlebars.js example
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=utf-8" />
<script src="jquery-1.7.2.min.js" ></script>
<script src="handlebars-1.0.0.beta.6.js" ></script>
<script src="underscore-min.js" ></script>
<script src="backbone-min.js" ></script>
@criccomini
criccomini / gist:3805436
Created September 29, 2012 23:50
Schedules & Scores API for Streaming Live Sports Stats - MSNBC
import pytz
import datetime
import time
import urllib2
import json
import os
import elementtree.ElementTree as ET
# e.g. http://scores.nbcsports.msnbc.com/ticker/data/gamesMSNBC.js.asp?jsonp=true&sport=MLB&period=20120929
url = 'http://scores.nbcsports.msnbc.com/ticker/data/gamesMSNBC.js.asp?jsonp=true&sport=%s&period=%d'
@desandro
desandro / require-js-discussion.md
Created January 31, 2013 20:26
Can you help me understand the benefit of require.js?

I'm having trouble understanding the benefit of require.js. Can you help me out? I imagine other developers have a similar interest.

From Require.js - Why AMD:

The AMD format comes from wanting a module format that was better than today's "write a bunch of script tags with implicit dependencies that you have to manually order"

I don't quite understand why this methodology is so bad. The difficult part is that you have to manually order dependencies. But the benefit is that you don't have an additional layer of abstraction.


@schwanksta
schwanksta / parse_scotus.py
Created March 27, 2013 20:41
Quick and dirty script to parse a Supreme Court transcript and output a JSON file of [speaker, words]
import re
import json
ws_re = re.compile("\s+")
line_num_re = re.compile("\s\d+\s{2,}", re.M)
# first, pdftotext -layout <pdf> <text>
with open("12-307_jnt1.txt", "r") as f:
data = f.read()