Skip to content

Instantly share code, notes, and snippets.

View luigi's full-sized avatar

Luigi Ray-Montañez luigi

View GitHub Profile
# For Mac OS X users who don't want to manually add entries into /etc/hosts
# Stick these functions in your .bash_login or equivalent
#
# From the command line:
# $ add_localhost foo
# will create foo.local
#
# No error checking, so don't mess up...
function add_localhost {
require 'ostruct'
require 'pp'
class NewStruct < OpenStruct
def self.new(hash)
if hash.nil? || hash.empty?
return nil
else
super(hash)
@luigi
luigi / gt.md
Created September 18, 2009 15:39

Local and remote branches

Create and checkout topic branch

gt start my_topic

Create and checkout topic branch with corresponding remote branch

gt start_and_pushup my_topic

National Data Catalog API

The National Data Catalog stores metadata about data sets and APIs published by all leves of government. It helps developers search for, identify, and work with data sources that would otherwise take significant effort to track down.

Currently, the National Data Catalog consists of a web front-end that is powered by an API back-end.

Accessing the API

The API is RESTful and speaks JSON. It will throw appropriate HTTP status codes on errors, along with a helpful error message passed as a JSON object.

module Rack
class ChromeFrame
def initialize(app, options={})
@app = app
end
def call(env)
status, headers, response = @app.call(env)
if env['HTTP_USER_AGENT'] =~ /MSIE/ && response.content_type == 'text/html'
# Adapted from ActiveSupport's parameterize
# http://github.com/rails/rails/blob/ea0e41d8fa5a132a2d2771e9785833b7663203ac/activesupport/lib/active_support/inflector.rb#L259
def slugify(str, sep = '-')
str.gsub!(/[^a-z0-9\-_\+]+/i, sep)
unless sep.nil? || sep == ''
re_sep = Regexp.escape(sep)
str.gsub!(/#{re_sep}{2,}/, sep)
str.gsub!(/^#{re_sep}|#{re_sep}$/i, '')
end
@luigi
luigi / steelify.html
Created October 16, 2009 21:15
steelify any web page!
<style type="text/css">
#mSteele {
width:576px;
height:388px;
position:absolute;
top:100px;
right:0;
background: transparent;
}
</style>

National Data Catalog - Catalog Scraper Specification

The National Data Catalog stores metadata about data sets and APIs published by all levels of government. It helps developers, researchers, and journalists search for, identify, and work with data sources that would otherwise take significant effort to track down.

Here are some resources:

function zipToState(zip) {
var state;
if (zip >= '99501' && zip <= '99950') { state = 'AK'; }
else if (zip >= '35004' && zip <= '36925') { state = 'AL'; }
else if (zip >= '71601' && zip <= '72959') { state = 'AR'; }
else if (zip >= '75502' && zip <= '75502') { state = 'AR'; }
else if (zip >= '85001' && zip <= '86556') { state = 'AZ'; }
else if (zip >= '90001' && zip <= '96162') { state = 'CA'; }
else if (zip >= '80001' && zip <= '81658') { state = 'CO'; }
else if (zip >= '06001' && zip <= '06389') { state = 'CT'; }
h scroll left
j scroll down
k scroll up
l scroll right
gg scroll to top of the page
G scroll to bottom of the page
f activate link hints mode to open in current tab
F activate link hints mode to open in new tab
r reload