Skip to content

Instantly share code, notes, and snippets.

View nathanborgo's full-sized avatar

Nathan Borgo nathanborgo

View GitHub Profile
@nathanborgo
nathanborgo / element.rb
Created September 17, 2012 19:24
Stream
class Element < ActiveRecord::Base
attr_accessible :target_type, :target_id, :reason
def target
target_type.constantize.find target_id
rescue
nil
end
#!/usr/bin/env ruby
# resolve bin path, ignoring symlinks
require "pathname"
bin_file = Pathname.new(__FILE__).realpath
# add self to libpath
path = File.expand_path("../../lib", bin_file)
$LOAD_PATH.unshift path
@nathanborgo
nathanborgo / console.js
Created August 15, 2012 21:33
What I'm using in the console
url = "http://api.education.com/service/service.php?f=schoolSearch&key=mykey&sn=sf&v=4&latitude=41.6054224116913&longitude=-87.8814947605133&distance=5&resf=json&callback=";
$.getJSON(url, function(data) { console.log(data); })
.success(function() { alert("second success"); })
.error(function() { alert("error"); })
.complete(function(data) { console.log(data); });
@nathanborgo
nathanborgo / application.rb
Created May 17, 2012 18:03
How I load subtractiv.com with Sinatra.
class Application < Sinatra::Base
use CoffeeHandler
get '/' do
slim :page
end
get '/works' do
slim :page