This file contains hidden or 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 MetaLoader | |
def load_all_controllers | |
@controller_files = [] | |
Find.find( File.join( RAILS_ROOT, 'app/controllers' )) do |fn| | |
next unless fn =~ /_controller.rb$/ | |
# begin | |
@controller_files << fn | |
require( fn ) | |
# rescue Exception => e |
This file contains hidden or 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 'stringio' | |
module NoStdout | |
module InstanceMethods | |
def no_stdout ( to = StringIO.new('','r+'), &block ) | |
# supply an IO of your own to capture STDOUT, otherwise it's put in a StringIO | |
orig_stdout = $stdout | |
$stdout = @alt_stdout = to | |
result = yield |
This file contains hidden or 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 | |
run "rm README" | |
run "rm public/index.html" | |
run "rm public/favicon.ico" | |
run "rm public/robots.txt" | |
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore" | |
file '.gitignore', <<-END | |
.swo |
This file contains hidden or 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 donation_uk_giftaid | |
unless request.post? | |
redirect_to :action=>"donate" | |
return | |
end | |
@heroPage = HeroPage.search_url(params[:url], DateTime.now) | |
hero_page_variables("preview", true) | |
if session[:mydonation_id] | |
@donation = Donation.find_by_id(session[:mydonation_id]) | |
@donation.update_attributes(params[:donation]) |
This file contains hidden or 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 PageHelper | |
def hero? | |
!!params[:event_url] | |
end | |
def event? | |
!hero? && !!params[:url] | |
end | |
This file contains hidden or 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 OrderedHash | |
def []( index ) | |
begin | |
super( index ) | |
rescue TypeError | |
x = self.detect do |i| | |
i.first == index | |
end # if index.class ... | |
x && x[1] | |
end |
This file contains hidden or 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 Foo | |
end | |
class Flibby | |
def make_method( _method_name ) | |
puts _method_name | |
Foo.class_eval do | |
puts _method_name | |
class << self | |
define_method _method_name do |
This file contains hidden or 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
equire 'rubygems' | |
require 'eventmachine' | |
module Socky | |
module Policy | |
DEBUG = true | |
HOST = 'localhost' | |
PORT = 843 | |
EOF = "\r\000" | |
REQUEST = "<policy-file-request/>\000" |
This file contains hidden or 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 new | |
x = Builder::XmlMarkup.new | |
x.instruct! | |
x.comment! "User Authentication Successful" | |
x.user { | |
x.id @user.id | |
x.login @user.login | |
x.name @user.name | |
} | |
render :xml => x |
This file contains hidden or 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 | |
run "rm README" | |
run "rm public/index.html" | |
run "rm public/favicon.ico" | |
run "rm public/robots.txt" | |
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore" | |
run "for i in tmp/*; do touch tmp/$i; done" | |
file '.gitignore', <<-END |