Skip to content

Instantly share code, notes, and snippets.

#another paste
#this time public
# Is there a way to combine the should_redirect_to and
# should_set_the_flash_to tests since they are repeated
# in multiple contexts?
context "when valid email addresses passed" do
setup do
Group.any_instance.expects(:notify_new_memberships).once
end
context "when separated by commas" do
# Is there a way to run mocha expectations against demeter violators?
# This is possible with Flexmock, but I grew tired of it.
@group.expects('users.from_subdomain').with(subdomain).once
This was nuts. On CSPAN-2 last night they were playing the Idaho senate debate from two nights ago. There were four candidates in the race to replace Larry Craig. I thought Minnesota politics was nuts. Highlights:
o The Republican, Jim Risch, is ahead by 20 points.
o Independent Rex Rammell is the "true conservative" running.
o Rammell was asked the "Palin question" (where does he get his news). He proudly said: FOX News, Hannity, and Limbaugh.
o Rammell accussed Risch of (a) stealing his land and (b) killing a large part of his elk herd that was running loose.
o The other independent's politics I'd loosely qualify as Christian fundamentalist + extreme libertarian
o Rammell would charge any woman who has an abortion at any time with murder.
o Since the Republican is ahead by 20 points, the independents didn't even address the Democrat, Larry LaRocco. Basically the entire debate was railing against Risch.
o Did I mention that the other independent candidate legally renamed himself Pro-Life? He w
# When I want to get beginning of day in the time zone set for
# the request, not the local machine's time zone.
class ::Date
def beginning_of_day_in_zone
Time.zone.parse(self.to_s)
end
alias_method :at_beginning_of_day_in_zone, :beginning_of_day_in_zone
alias_method :midnight_in_zone, :beginning_of_day_in_zone
alias_method :at_midnight_in_zone, :beginning_of_day_in_zone
ActiveRecord::Base.send(:attr_accessible, nil)
def zone
Thread.current[:time_zone] || zone_default
end
require 'lib/caching'
get '/' do
cache(erb(:index, :layout => :main))
end
<FilesMatch "\.(ico|pdf|flv|jpe?g|png|gif|js|css|swf)$">
ExpiresActive On
ExpiresDefault "access plus 1 year"
</FilesMatch>
@bjhess
bjhess / adjust_twitter_id_to_unsigned_bigint.rb
Created May 13, 2009 18:54
Adjust your Twitter ID's as they're breaking MySQL's signed INT allocation space
# If you really want safety from Twitter blowing up, this will get you
# to 18,446,744,073,709,551,615 tweets. (Remember, mediumint is smaller
# than int.) (http://dev.mysql.com/doc/refman/4.1/en/numeric-types.html)
class AdjustTwitterIdToUnsignedBigint < ActiveRecord::Migration
def self.up
change_column :twitter_messages, :twitter_id, "bigint unsigned"
end
def self.down
change_column :twitter_messages, :twitter_id, :integer