Skip to content

Instantly share code, notes, and snippets.

View dpickett's full-sized avatar

Dan Pickett dpickett

View GitHub Profile
class TestOmniAuth
attr_reader :app, :env
def initialize(app)
@app = app
end
def call(env)
@env = env
if request.path =~ /auth\/facebook\/callback/
require 'spec_helper'
describe UserActivation do
subject { UserActivation.notice }
it 'delivers without error' do
PostmasterGeneral.log_deliveries("a_delivery.txt") do
lambda { subject.deliver }.should_not raise_error
end
end
end
begin
require 'aws/s3'
rescue LoadError => e
e.message << " (You may need to install the aws-s3 gem)"
raise e
end
class SitemapS3Publisher
def generate
sitemap.create
//structure content div
var content = $("<div>").
attr("data-role", "content").
addClass("ui-content").
html($("div.buttons", this.$actionPanel).html());
//remove already duplicated buttons
$("a.ui-btn", content).remove();
Around('@stub_facebook') do |scenario, block|
class OmniAuth::Builder
alias_method :orig_call, :call
def call(env)
TestOmniAuth.new(@app).call(env)
end
end
#for some reason this doesn't work
Rails.application.config.middleware.swap OmniAuth::Builder, TestOmniAuth
@dpickett
dpickett / tmux_textaurant.sh
Created December 1, 2010 15:31
scripted way to start your work in a Rails project
export WORKING_DIR=~/work/textaurant
cd $WORKING_DIR; mvim; gitx
tmux start-server
tmux new-session -d -s Textaurant -n work
tmux new-window -tTextaurant:1 -n server
tmux new-window -tTextaurant:2 -n test
tmux send-keys -tTextaurant:0 'cd $WORKING_DIR' C-m
@dpickett
dpickett / yo.rb
Created September 25, 2010 17:11
def following_by_type(followable_type, options={})
#might have to const_get here
followable_type.joins("INNER JOIN follows ON follower_type = #{followable_type.name}").where("follows.follower_id = ?", self.id)
end
def update(message)
client.update(message)
end
def client
authorize
Twitter::Base.new(oauth)
end
private

##Enlight Solutions Seeks a Rubyist That Wants to Learn##

Are you looking for a part time ruby gig (15-20 hours / week)? Come learn and grow with Enlight Solutions. It's a great opportunity to improve your coding skills and create awesome applications. This could eventually turn out to be a full time, salaried position.

If you're interested, please send me your github account, references, hourly rate, and/or code samples (in lieu of a github account). Resumes are great, but practical application and endorsements from your peers or clients will secure the position.

###You will:###

  • Learn design patterns and architectural techniques that will serve you greatly in the future
  • Learn Rails 3
describe "an email" do
it { should validate_presence_of :recipients }
it { should validate_presence_of :sender }
let(:recipient) { Factory.build(:user) }
let(:sender) { Factory.build(:sender) }
subject { Factory.build(:email, :recipients => [recipient], :sender => sender) }
describe "that is sent" do
subject { Factory.build(:sent_email, :recipients => [recipient]) }