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
# Setup the following in your heroku config vars: | |
# See http://blog.leshill.org/blog/2010/11/02/heroku-environment-variables.html for an idea on how to do it | |
HEROKU_APP: poh-dev | |
HEROKU_USER: [email protected] | |
HEROKU_PASSWORD: replace_me | |
# Gemfile | |
gem 'heroku', '>= 1.19.1' | |
gem 'resque' | |
# Use our fork until our fix is merged. |
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
git_completion=`brew --prefix git`/etc/bash_completion.d/git-completion.bash | |
if [ -f $git_completion ] ; then source $git_completion; fi |
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
# Add this to more_web_steps.rb | |
# Selenium docs: http://code.google.com/p/selenium/wiki/RubyBindings#Javascript_Alert/Confirm today! | |
When /^I (accept|dismiss) the "([^"]*)" alert$/ do |action, text| | |
alert = page.driver.browser.switch_to.alert | |
alert.text.should eq(text) | |
alert.send(action) | |
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
git log --all -M -C --name-only | grep -E '^(app|lib)/' | sort | uniq -c | sort |
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
def access_token | |
@access_token ||= begin | |
twitter_request = session['twitter_request'] | |
oauth.authorize_from_request(twitter_request.token, twitter_request.secret, params['oauth_verifier']) | |
oauth.access_token | |
end | |
end | |
def oauth(opts = {}) | |
@oauth ||= ::Twitter::OAuth.new(config.twitter_api_keys['token'], config.twitter_api_keys['secret'], opts) |
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
RSpec.configure do |config| | |
config.before(:all) do | |
clear_database | |
end | |
end | |
def clear_database | |
Mongoid.master.collections.select {|c| c.name !~ /system/ }.each(&:drop) | |
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
# place in features/support | |
require 'ephemeral_response' | |
EphemeralResponse.configure do |config| | |
config.expiration = lambda { one_day * 30 } | |
config.white_list = ['localhost', '127.0.0.1'] | |
config.register('api.twitter.com') do |request| | |
if oauth_token_match = request['authorization'].match(/oauth_token=\"\d+-\w+"/) | |
"#{request.uri.to_s}#{request.method}#{oauth_token_match[0]}" | |
else |
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 Array | |
def method_missing(method, *args, &block) | |
if key_value = dynamic_mapper?(method) | |
map_dynamically(key_value[1], key_value[2]) | |
else | |
super | |
end | |
end | |
def dynamic_mapper?(method) |
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
def javascript_confirm(answer) | |
page.evaluate_script 'window._confirm = window.confirm' | |
page.evaluate_script "window.confirm = function(x) { return #{answer} }" | |
yield | |
page.evaluate_script 'window._confirm && (window.confirm = window._confirm)' | |
page.evaluate_script 'window._confirm = null' | |
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
# Ryan, the hits in the db approach is flawed (not currently atomic, and | |
# probably not really performant for high rates) -- but you knew that. | |
# So in the spirit of gets it done, I have followed along. | |
# | |
# API Example | |
## User Model | |
require 'digest/md5' | |
class User < ActiveRecord::Base | |
API_RATE_LIMIT_WINDOW = 2.minutes |