Skip to content

Instantly share code, notes, and snippets.

View seamusabshere's full-sized avatar

Seamus Abshere seamusabshere

View GitHub Profile
$ ruby bar.rb
0 ELIZABETH WATERS, MADISON, WI 53706
geocoder latitude +/- longitude +/- quality
AVERAGE 43.07671/43.07689 -89.40950/-89.40921
mapquest 43.07620 +11 -89.40950 +0 zip
google 43.07671 +0 -89.40696 +28 point_of_interest/university/establishment/approximate
yahoo 43.07477 +45 -89.41118 -18 59
geocoda 43.07776 -24 -89.41333 -42 zip
datasciencetoolkit 43.08856 -275 -89.37360 +401 street_address/rooftop
@seamusabshere
seamusabshere / gist:4154610
Created November 27, 2012 14:49 — forked from jatorre/gist:4154502
Combine multiple Census files into single shpefile using PostGIS
mkdir tmpfolder;
cd tmpfolder;
wget "http://www2.census.gov/geo/tiger/TIGER2012/TRACT/tl_2012_01_tract.zip";
unzip tl_2012_01_tract.zip;
shp2pgsql -s4326 -p tl_2012_01_tract.shp census | psql -hlocalhost -Upostgres -dcensus;
rm -rf tl_2012_01_tract.*;
for i in {1..9} :;
do
wget "http://www2.census.gov/geo/tiger/TIGER2012/TRACT/tl_2012_0${i}_tract.zip";
unzip tl_2012_0${i}_tract.zip
@seamusabshere
seamusabshere / maponics.rb
Created October 25, 2012 16:46
get neighborhood name and polygon using maponics spatial api
# encoding: utf-8
require 'multi_json'
require 'httpclient'
require 'cache_method'
require 'active_support/core_ext'
module Maponics
USERNAME = 'oaisjdoaisjdoaisjd'
PASSWORD = 'aosidjoasidjoaisjdoasid'
ENDPOINT = 'http://api.maponics.com/interface/'
@seamusabshere
seamusabshere / postgresql.conf
Created October 12, 2012 23:08
postgresql90 config
# /opt/local/var/db/postgresql90/postgresql.conf
shared_buffers = 768MB # min 128kB
temp_buffers = 256MB # min 800kB
work_mem = 1GB # min 64kB
maintenance_work_mem = 256MB # min 1MB
max_stack_depth = 6MB # min 100kB
synchronous_commit = off # immediate fsync at commit
wal_buffers = 16MB # min 32kB
checkpoint_segments = 64 # in logfile segments, min 1, 16MB each
checkpoint_completion_target = 0.9 # checkpoint target duration, 0.0 - 1.0
@seamusabshere
seamusabshere / hamledit
Created October 9, 2012 15:14
hamledit PATH_TO_XML_FILE: Converts XML to haml, loads it with `subl -w`, and then converts it back to xml in-place.
#!/usr/bin/env ruby
# Usage: hamledit [-v] PATH_TO_XML_FILE
# -v means "view only"
#
# Converts XML to haml, loads it with `subl -w`, and then converts it back to xml in-place.
require 'fileutils'
require 'posix-spawn'
orig = ARGV.last
@seamusabshere
seamusabshere / excelwebservice.vb
Created September 28, 2012 15:44
Excel VB for accessing http://carbon.brighterplanet.com/flights.txt as a web service (early 2011)
Option Explicit
Function GetBrighterPlanetApiKey()
GetBrighterPlanetApiKey = ActiveWorkbook.Worksheets("Setup").Range("C2").Value
End Function
Function IsEmissionEstimateServiceOnline()
If LCase(ActiveWorkbook.Worksheets("Setup").Range("C3").Value) = "online" And ThisWorkbook.HasFinishedWorkbookOpen() = True Then
IsEmissionEstimateServiceOnline = True
Else
package java112.labs1;
import java.io.*;
public class LabSix {
public static void main(String[] arguments) {
if (arguments.length != 2) {
System.out.println("Please enter two arguments on the command line, an input file name and an output file name");
} else {
LabSix lab = new LabSix();
@seamusabshere
seamusabshere / gist:3211989
Created July 30, 2012 23:42 — forked from danparsons/gist:3195652
How to stream the London 2012 Olympics

How to stream the London 2012 Olympics

There have been several HOWTOs posted regarding streaming the 2012 Olympics using HTTP / SOCKS proxies via SSH and other similar methods. None of these actually work using the latest Flash on Mountain Lion (with Firefox, Chrome or Safari). Additionally, the third-party streaming sites don't provide BBC's amazing interface, which lets you quickly skip to individual competitors and events. However, setting up an OpenVPN server does work, with some tweaks. You'll get the exact same UX that people in England receive.

@seamusabshere
seamusabshere / test_ordered_with_indifferent_access.rb
Created April 18, 2012 21:17
random look at ActiveSupport::OrderedHash versus HashWithIndifferentAccess
require 'rubygems'
require 'minitest/spec'
require 'minitest/autorun'
require 'minitest/reporters'
MiniTest::Unit.runner = MiniTest::SuiteRunner.new
MiniTest::Unit.runner.reporters << MiniTest::Reporters::SpecReporter.new
require 'securerandom'
require 'active_support/core_ext'
seen = []
@seamusabshere
seamusabshere / test_helper.rb
Created March 7, 2012 00:08
non-annoying way of requiring ruby-debug
if ::Bundler.definition.specs['ruby-debug19'].first or ::Bundler.definition.specs['ruby-debug'].first
require 'ruby-debug'
end