Use these rapid keyboard shortcuts to control the GitHub Atom text editor on Mac OSX.
- ⌘ : Command key
- ⌃ : Control key
- ⌫ : Delete key
- ← : Left arrow key
- → : Right arrow key
- ↑ : Up arrow key
| # config/deploy.rb | |
| namespace :upstart do | |
| desc 'Generate and upload Upstard configs for daemons needed by the app' | |
| task :update_configs, except: {no_release: true} do | |
| upstart_config_files = File.expand_path('../upstart/*.conf.erb', __FILE__) | |
| upstart_root = '/etc/init' | |
| Dir[upstart_config_files].each do |upstart_config_file| | |
| config = ERB.new(IO.read(upstart_config_file)).result(binding) |
| # Dealing with namespaces in Nokogiri. | |
| # | |
| # First thing you must do is abandon what you're used to with Builder, | |
| # namespaces aren't just attributes on an element, they uniquely identify | |
| # what sort of element you are building and, as such, you are better off | |
| # specifying them manually. | |
| # | |
| # The key here is accessing the Nokogiri::XML::Element being built with | |
| # b.parent, then you can set the namespace (distinguished by an element | |
| # with a prefix such as "soap12:Envelope") or add a default namespace |
Use these rapid keyboard shortcuts to control the GitHub Atom text editor on Mac OSX.
| # app/models/user.rb | |
| class User < ActiveRecord::Base | |
| validates :zip_code, presence: true, zip_code: true | |
| end |
| # lib/tasks/db.rake | |
| namespace :db do | |
| desc "Dumps the database to db/APP_NAME.dump" | |
| task :dump => :environment do | |
| cmd = nil | |
| with_config do |app, host, db, user| | |
| cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump" | |
| end | |
| puts cmd |
| # This custom matcher can be used to test state machine | |
| # | |
| # Examples | |
| # | |
| # it { should have_event(:status, :event_name, [:state1, :state2] => [:state3, :state4]) } | |
| # it { should have_event(:status, :event_name, { | |
| # :state1 => :state3, | |
| # :state1 => :state4, | |
| # :state3 => :state3, | |
| # :state2 => :state4 |
http://www.zhlwish.com/2012/07/23/rails-activesupport-concern/
# autoload concerns
module YourApp
class Application < Rails::Application
# config.autoload_paths += %W(
# #{config.root}/app/controllers/concerns/
# #{config.root}/app/models/concerns/
# )| # | |
| # Wide-open CORS config for nginx | |
| # | |
| location / { | |
| if ($request_method = 'OPTIONS') { | |
| add_header 'Access-Control-Allow-Origin' '*'; | |
| # |
An implementation of Conway's Game of Life in 140 characters of Ruby.
Created by Simon Ernst (@sier).