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
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
#!/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
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
# 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
require 'rubygems' | |
require 'mongo' | |
uid, aid = BSON::ObjectID.new, BSON::ObjectID.new | |
db = Mongo::Connection.new.db('testing') | |
db.drop_collection('ratings') | |
db.create_collection('ratings') | |
ratings = db['ratings'] | |
ratings.create_index([[:user_id, Mongo::ASCENDING], [:article_id, Mongo::ASCENDING]], :unique => true) |
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 'rubygems' | |
require 'mongo' | |
require 'pp' | |
db = Mongo::Connection.new.db('testing') | |
db.collections.each { |c| c.remove } | |
articles = db['articles'] | |
ratings = db['ratings'] |
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
# Patch until MM 0.7.6 which fixes this: | |
# http://github.com/jnunemaker/mongomapper/commit/a721b66d9bc9ef78a5ce32dd2eb36d24abd4b953 | |
module SetWithTypecasting | |
def self.included(model) | |
model.plugin SetWithTypecasting | |
end | |
module ClassMethods | |
def set(*args) | |
criteria, updates = criteria_and_keys_from_args(args) |
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
module ValidatesExistenceOfPlugin | |
def self.included(model) | |
model.plugin ValidatesExistenceOfPlugin | |
end | |
module ClassMethods | |
def validates_existence_of(*args) | |
add_validations(args, ValidatesExistenceOfPlugin::ValidatesExistenceOf) | |
end | |
end |
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 Stylesheet | |
include MongoMapper::Document | |
class Processor | |
def self.errors | |
[] | |
end | |
attr_reader :contents |