- Authoring Ebooks: http://www.authoringebooks.com/
- Create Your Own Programming Language: http://createyourproglang.com/
- Exceptional Ruby: http://exceptionalruby.com/
- JavaScript Performance Rocks: http://javascriptrocks.com/performance/
- Redmine Tips: http://www.redminetips.com/
- The SPDY Book: http://spdybook.com/
- Rails 3 Upgrade Handbook: http://www.railsupgradehandbook.com/
- Refactoring Redmine: http://www.refactoringredmine.com/book/
- Bootstrapping Design: http://bootstrappingdesign.com/
- Recipes With Backbone:
task :env_checker do | |
unless Rails.env.development? | |
puts "Not in development environment, exiting!" | |
exit 1 | |
end | |
end | |
namespace :app_name do | |
desc 'Anonymize user, company, and location information' | |
task :anonymize => [:environment, :env_checker] do |
if Rails.env.development? | |
MAX_LOG_SIZE = 10.megabytes | |
logs = [ File.join(Rails.root, 'log', 'development.log'), File.join(Rails.root, 'log', 'test.log') ] | |
logs.each do |log| | |
log_size = File.size?(log).to_i | |
if log_size > MAX_LOG_SIZE | |
$stdout.puts "Removing Log: #{log}" | |
`rm #{log}` |
module HashInit | |
#example usage: | |
# instead of this - | |
# | |
# class Message | |
# attr_reader :content, :sender, :subject | |
# attr_accessor :event | |
# def initialize(message) |
// helper to create proper asset paths if an asset host is configured | |
App.assets = { | |
assets : { | |
<% AssetsUtil.images.each do |img| %> | |
"<%= img %>" : "<%= asset_path(img) %>", | |
<% end %> | |
}, | |
Corey Haines gave his Fast Tests talk at the Golden Gate Ruby Conference 2011 (http://confreaks.net/videos/641-gogaruco2011-fast-rails-tests), here's my feedback on it.
So first up, I think it's very interesting to see another take on how to speed up Rails testing. There's been a focus on it for a couple of years now with various solutions coming for it. From running tests in parallel, to tweaking the filesystem for faster access. Corey Haines take on it is that we should isolate ourselves from the framework that Rails provides and do as much as possible in plain Ruby objects and modules. In his talk he shows how he has been able to massively improve the runtime of his tests by implementing this.
I think it is a logical next step to the current that has been in the community for a while where we have been debating how to improve the design of Rails applications.
require "uri" | |
(URI::REGEXP.constants - ["PATTERN"]).each do |rc| | |
puts "#{rc}: #{URI::REGEXP.const_get(rc)}" | |
end | |
URI::REGEXP::PATTERN.constants.each do |pc| | |
puts "#{pc}: #{URI::REGEXP::PATTERN.const_get(pc)}" | |
end |
# https://gist.github.com/1214052 | |
require 'sinatra/base' | |
class ResqueWeb < Sinatra::Base | |
require 'resque/server' | |
use Rack::ShowExceptions | |
if CFG[:user].present? and CFG[:password].present? | |
Resque::Server.use Rack::Auth::Basic do |user, password| | |
user == CFG[:user] && password == CFG[:password] |
When developing in rails I use watchr to run the tests each time a file is saved, but lots of times I find my self adding a whitespace or a newline and saving just to trigger watchr and run the tests.
I wanted to have is a simple keyboard shortcut (like F15
) to tell watchr to run the last spec, and mpartel (thx! : ) gave me an idea on how to do it, so here it is:
Obviously you need watchr, but we're also going to need pgrep
that will help us find out the pid of the watchr process. So go ahead and do
sudo port install proctools
require 'spec_helper' | |
describe FeaturePool do | |
it "creates a new instance given valid attributes" do | |
Fabricate :feature_pool | |
end | |
it "is not valid without a name" do | |
Fabricate.build(:feature_pool, :name => "").should_not be_valid | |
end |