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
namespace :static do | |
desc 'Create a static html version of the site' | |
task :build do | |
# Make static directory | |
Dir.mkdir "#{RAILS_ROOT}/static" unless File.exists? "#{RAILS_ROOT}/static" | |
# wget our local rails site. | |
%x{ wget --recursive --convert-links --html-extension --no-host-directories --directory-prefix=static http://localhost:3000/ } | |
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
require 'rubygems' | |
require 'mp4info' | |
require 'fileutils' | |
def padded_track_num(num) | |
num <= 9 ? "0#{num}" : "#{num}" | |
end | |
print "Enter directory: " | |
dir = gets.chomp |
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
namespace :test do | |
Rake::TestTask.new(:gems => :environment) do |t| | |
t.libs << "test" | |
if ENV['GEM'] | |
t.pattern = "vendor/gems/#{ENV['GEM']}/test/**/*_test.rb" | |
else | |
t.pattern = 'vendor/gems/*/**/test/**/*_test.rb' | |
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
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
# Version 2, December 2004 | |
# | |
# Copyright (C) 2004 Sam Hocevar | |
# 14 rue de Plaisance, 75014 Paris, France | |
# Everyone is permitted to copy and distribute verbatim or modified | |
# copies of this license document, and changing it is allowed as long | |
# as the name is changed. | |
# | |
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
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
[08:48 AM:gist-99771(master)] $ irb -rubygems -r myapp.rb -r rack/test | |
>> app = Rack::Test::Session.new(Sinatra::Application) | |
=> #<Rack::Test::Session:0x17e8820 @headers={}, @app=Sinatra::Application> | |
>> app.get '/' | |
=> #<Rack::Response:0x17ad4dc @block=nil, @writer=#<Proc:0x0189f7b4@/opt/local/lib/ruby/gems/1.8/gems/rack-0.9.1/lib/rack/response.rb:24>, header{"Content-Type"=>"text/html", "Content-Length"=>"7"}, body["testing"], length7, status200 | |
>> app.body | |
NoMethodError: undefined method `body' for #<Rack::Test::Session:0x17e8820> | |
from (irb):3 |
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
module Subclasses | |
# return a list of the subclasses of a class | |
def subclasses(direct = false) | |
classes = [] | |
if direct | |
ObjectSpace.each_object(Class) do |c| | |
next unless c.superclass == self | |
classes << c | |
end | |
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
# Slight modifications to code posted by Gregory Brown at http://pastie.org/515450 | |
require 'delegate' | |
module Decoration | |
def decorator_for(*types, &block) | |
types.each do |type| | |
decorators[type] = Module.new(&block) | |
end | |
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
# mongo_template.rb | |
# remove unneeded defaults | |
run "rm public/index.html" | |
run "rm public/images/rails.png" | |
run "rm public/javascripts/controls.js" | |
run "rm public/javascripts/dragdrop.js" | |
run "rm public/javascripts/effects.js" | |
run "rm public/javascripts/prototype.js" |
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
require 'active_support/ordered_hash' | |
require 'active_support/core_ext/enumerable' | |
module Enumerable | |
def group_by_attribute(attr, options={:nils_first => true}) | |
raise "attr parameter must by a symbol" unless attr.is_a?(Symbol) | |
h = group_by(&attr) | |
returning h2 = ActiveSupport::OrderedHash.new do | |
h2[nil] = h.delete(nil) if options[:nils_first] && h.has_key?(nil) | |
h2.merge!(h) |
OlderNewer