Skip to content

Instantly share code, notes, and snippets.

@adzap
adzap / development.rb
Created July 25, 2008 23:50
Restart task for passenger with debug option
# ... bottom of your development.rb
if File.exists?(File.join(RAILS_ROOT,'tmp', 'debug.txt'))
require 'ruby-debug'
Debugger.wait_connection = true
Debugger.start_remote
File.delete(File.join(RAILS_ROOT,'tmp', 'debug.txt'))
end
@adzap
adzap / gist:7229
Created August 26, 2008 07:13 — forked from topfunky/gist:7224
/´¯/)
,/¯ /
/ /´¯/'¯¯'/´¯¯¯`·¸
/ / / / /¨¯\
('( ´ ´ ¯~/' ')
\ ' /
'' \ _ ·´
\ (
\ \
@adzap
adzap / multiruby.rb
Created February 8, 2009 03:15
A copy of the changes to multiruby from a pastie (http://pastie.org/375339)
require 'fileutils'
require 'open-uri'
##
# multiruby_setup is a script to help you manage multiruby.
#
# usage: multiruby_setup [-h|cmd|spec...]
#
# cmds:
#
module ValidatesTimeliness
module ActiveRecord
# Rails 2.1 removed the ability to retrieve the raw value of a time or datetime
# attribute. The raw value is necessary to properly validate a string time or
# datetime value instead of the internal Rails type casting which is very limited
# and does not allow custom formats. These methods restore that ability while
# respecting the automatic timezone handling.
#
# The automatic timezone handling sets the assigned attribute value to the current
require 'action_mailer'
##
# Adds sending email through an ActiveRecord table as a delivery method for
# ActionMailer.
#
class ActionMailer::ARMailer < ActionMailer::Base
def self.inherited(sub)
require 'action_mailer'
##
# Adds sending email through an ActiveRecord table as a delivery method for
# ActionMailer.
#
class ActionMailer::ARMailer < ActionMailer::Base
def self.inherited(sub)
# Any tasks you need class caching turned off for, just include this task as a dependency
#
# task :do_sumthin_tricky => [:disable_class_cache] do
# sumthin_tricky
# end
#
# Stick this file in your lib/tasks dir. You could also put the guts of it in your Rakefile to apply it to all rake tasks for your app.
task :disable_class_cache do
module Rails
# to the tune of Old McDonald
I made a site, it looked quite good
IE IE oh!
And on this site there was a bug
IE IE oh!
With a box hack here
And a margin hack there
Here a hack, there a hack
Everywhere a hack-hack
Then /^I should see "([^\"]*)" value updated to "([^\"]*)"$/ do |dom_id, value|
current_value_of(dom_id).should == value
end
Then /^I should see "([^\"]*)" text updated to "([^\"]*)"$/ do |dom_id, value|
current_text_of(dom_id).should == value
end
def current_value_of(dom_id)
dom_id = "##{dom_id}" unless dom_id.starts_with?('#')
@adzap
adzap / extended_modules.rb
Created July 29, 2009 12:29
Ruby extended_modules method which returns all modules a class or module has been extended with
# Defines a method on modules and classes to output the modules it has been extended with.
# This works because extending class really just includes the module into the classes metaclass.
class Module
def extended_modules
# this exposes the metaclass and for any code inside, self is scoped to the metaclass
class << self
self.included_modules
end
end