Skip to content

Instantly share code, notes, and snippets.

@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')
@uhlenbrock
uhlenbrock / deploy.rb
Created December 14, 2011 17:36
Precompile assets locally for Capistrano deploy
load 'deploy/assets'
namespace :deploy do
namespace :assets do
desc 'Run the precompile task locally and rsync with shared'
task :precompile, :roles => :web, :except => { :no_release => true } do
%x{bundle exec rake assets:precompile}
%x{rsync --recursive --times --rsh=ssh --compress --human-readable --progress public/assets #{user}@#{host}:#{shared_path}}
%x{bundle exec rake assets:clean}
end
# Expand print panel by default
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true
# Disable the “Are you sure you want to open this application?” dialog
defaults write com.apple.LaunchServices LSQuarantine -bool false
# Enable subpixel font rendering on non-Apple LCDs
defaults write NSGlobalDomain AppleFontSmoothing -int 2
# Disable press-and-hold for keys in favor of key repeat
@developer88
developer88 / csv_export.rb
Last active January 1, 2016 08:59
Export data to Excel in csv format
# For windows only.
#
csv_string = CSV.generate(col_sep: ";", encoding: 'Windows-1251') do |csv|
csv << "Add some data"
end
send_data(csv_string.encode('Windows-1251'), type: 'text/csv; charset=windows-1251; header=present', disposition: "attachment", filename: "file_to_export.csv")