Skip to content

Instantly share code, notes, and snippets.

View cesidio's full-sized avatar

Cesidio Di Landa cesidio

View GitHub Profile
@indirect
indirect / source.rake
Created June 13, 2012 06:56
rake tasks to remove trailing whitespace and tabs from your codebase
namespace :source do
def find_and_replace_in_source_files(find, replace)
puts "Search and replace #{find.inspect} => #{replace.inspect}"
files = %w[ .autotest .rspec .rvmrc Gemfile Procfile config.ru ].select{|f| File.exist?(f) }
directories = %w[app config lib public script spec test] # exclude bin, db, doc, log, and tmp
directories.each do |d|
files += Dir[File.join(d, "**/*.{rb,rake,haml,erb,builder,js,coffee,css,scss}")]
end
@aliang
aliang / reserved_name_validator.rb
Created December 30, 2010 23:49
validate reserved names in Rails 3
# app/validators/reserved_name_validator.rb
class ReservedNameValidator < ActiveModel::EachValidator
RESERVED_NAMES = %w{
about account add admin api
app apps archive archives auth
blog
config connect contact create
delete direct_messages downloads
edit email
faq favorites feed feeds follow followers following
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')