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
# Preloads models in a subdirectory of RAILS_ROOT/app/models so STI can find | |
# them properly. | |
Dir.glob(File.join(RAILS_ROOT, 'app', 'models', '**/*.rb')) do |file| | |
require file | |
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
before "deploy:symlink", "deploy:check_app_dependencies" | |
namespace :deploy do | |
desc "Checks for required dependencies by starting the application" | |
task :check_app_dependencies, :roles => :app do | |
app_env = fetch(:rails_env, "production") | |
run "cd #{release_path}; RAILS_ENV=#{app_env} ./script/runner ''" | |
# TODO: anything required for rollback? | |
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
Benchmark = function(description, timed_function) { | |
var start = new Date() | |
timed_function(); | |
console.debug(description + ': ' + (new Date() - start) + 'ms'); | |
} |
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
# An array of String subclasses does not sort using <=> on the subclass, WTF? | |
class StringSubclass < String | |
def <=>(other) | |
puts "using <=> in #{self.class}: #{caller.first}" | |
super | |
end | |
end | |
StringSubclass.new <=> StringSubclass.new |
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
def render_optional_error_file(status) | |
begin | |
code = ActionController::StatusCodes::SYMBOL_TO_STATUS_CODE[status] | |
render :template => "/statics/#{code}" | |
rescue | |
super | |
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
# Given I have the following projects: | |
# | short_description | | |
# | Feed Dante | | |
# | Walk my dogs | | |
Given /^I have the following projects:$/ do |table| | |
table.hashes.each do |project_hash| | |
@current_user.projects.create!(project_hash) | |
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
irb(main):001:0> thing | |
NameError: undefined local variable or method `thing' for main:Object | |
from (irb):1 | |
irb(main):002:0> defined? thing | |
=> nil | |
irb(main):003:0> thing = thing | |
=> nil | |
irb(main):004:0> thing | |
=> nil | |
irb(main):005:0> defined? thing |
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 :heroku do | |
desc "Generate the Heroku gems manifest from gem dependencies" | |
task :gems do | |
RAILS_ENV='production' | |
Rake::Task[:environment].invoke | |
list = Rails.configuration.gems.collect do |g| | |
command, *options = g.send(:install_command) | |
options.join(" ") + "\n" | |
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
<script type="text/python"> | |
def pyFunc(): | |
window.alert("hi, i'm python") | |
</script> | |
<script type="text/ruby"> | |
def rubyFunc | |
pyFunc | |
end | |
</script> | |
<script> |
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
class A | |
def initialize | |
puts "A initialized" | |
end | |
end | |
class B < A | |
alias :original_initialize :initialize | |
def initialize |