This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# see http://github.com/intridea/oauth2 | |
require 'rubygems' | |
require 'sinatra' | |
require 'oauth2' | |
require 'json' | |
class ConnectionLogger < Faraday::Middleware | |
def call(env) | |
env[:response].on_complete do |env| | |
puts "RESULT: #{env[:status]}\n#{env[:body]}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias reload='. ~/.bashrc' | |
alias ea="$EDITOR ~/bin/dotfiles/bash/aliases && reload" | |
alias ee="$EDITOR ~/bin/dotfiles/bash/env && reload" | |
alias eh="$EDITOR ~/bin/dotfiles/bash/heroku && reload" | |
# Processes | |
alias tu='top -o cpu' | |
alias tm='top -o vsize' | |
# Projects |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Usage: generate a blank gemspec, for defunkt | |
abort "pass a name" unless name = ARGV[0] | |
date = Time.now.strftime('%Y-%m-%d') | |
puts <<spec | |
Gem::Specification.new do |s| | |
s.name = "#{name}" | |
s.version = "0.1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(function() { | |
$.cookie('tz', (new Date()).getTimezoneOffset()); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rack/openid" | |
require "warden" | |
use Rack::OpenID | |
use Warden::Manager do |manager| | |
Warden::Strategies.add(:openid) do | |
def authenticate! | |
if resp = env["rack.openid.response"] | |
case resp.status | |
when :success |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test/unit/ui/console/testrunner' | |
class Test::Unit::UI::Console::TestRunner | |
def add_fault(fault) | |
hax_output(fault) | |
@faults << fault | |
output_single(fault.single_character_display, 1) | |
@already_outputted = true | |
end | |
def hax_output(fault) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Have to use ActiveRecord so that New Relic shows it on all graphs. | |
# The push scope false stuff makes it so that you can track usage by model and overall. | |
if defined?(NewRelic) | |
module MongoMapperNewRelic | |
def self.included(model) | |
mm_class_methods = [ | |
:find, | |
:find!, | |
:paginate, | |
:first, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Comment | |
include MongoMapper::EmbeddedDocument | |
include Gravatarable | |
key :name, String | |
key :email, String | |
key :url, String | |
key :body, String | |
key :created_at, Time | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pp' | |
require 'rubygems' | |
require 'mongo_mapper' | |
MongoMapper.database = 'testing' | |
class Rating | |
include MongoMapper::EmbeddedDocument | |
key :user_id, ObjectId |