start new:
tmux
start new with session name:
tmux new -s myname
| # Capistrano configuration | |
| # | |
| # require 'new_relic/recipes' - Newrelic notification about deployment | |
| # require 'capistrano/ext/multistage' - We use 2 deployment environment: staging and production. | |
| # set :deploy_via, :remote_cache - fetch only latest changes during deployment | |
| # set :normalize_asset_timestamps - no need to touch (date modification) every assets | |
| # "deploy:web:disable" - traditional maintenance page (during DB migrations deployment) | |
| # task :restart - Unicorn with preload_app should be reloaded by USR2+QUIT signals, not HUP | 
| # Nginx+Unicorn best-practices congifuration guide. Heartbleed fixed. | |
| # We use latest stable nginx with fresh **openssl**, **zlib** and **pcre** dependencies. | |
| # Some extra handy modules to use: --with-http_stub_status_module --with-http_gzip_static_module | |
| # | |
| # Deployment structure | |
| # | |
| # SERVER: | |
| # /etc/init.d/nginx (1. nginx) | |
| # /home/app/public_html/app_production/current (Capistrano directory) | |
| # | 
| ### Nginx upstart script | |
| ### source: http://serverfault.com/a/391737/70451 | |
| ### /etc/init/nginx.conf | |
| description "nginx http daemon" | |
| start on (filesystem and net-device-up IFACE=lo) | |
| stop on runlevel [!2345] | |
| env DAEMON=/usr/local/sbin/nginx | 
by Jonathan Rochkind, http://bibwild.wordpress.com
Capistrano automates pushing out a new version of your application to a deployment location.
I've been writing and deploying Rails apps for a while, but I avoided using Capistrano until recently. I've got a pretty simple one-host deployment, and even though everyone said Capistrano was great, every time I tried to get started I just got snowed under not being able to figure out exactly what I wanted to do, and figured I wasn't having that much trouble doing it "manually".
  # This example does an AJAX lookup and is in CoffeeScript
  $('.typeahead').typeahead(
    # source can be a function
    source: (typeahead, query) ->
 # this function receives the typeahead object and the query string| /** | |
| * Underscore.js mixin to emulate Ruby's Enumerable#each_slice method. | |
| * http://www.ruby-doc.org/core/classes/Enumerable.html#M001514 | |
| * | |
| */ | |
| _.mixin({ | |
| // _.each_slice(obj, slice_size, [iterator], [context]) | |
| each_slice: function(obj, slice_size, iterator, context) { | |
| var collection = obj.map(function(item) { return item; }), o = [], t = null, it = iterator || function(){}; | 
| 1. Use latest build | |
| gem 'simple_form', :git => 'git://github.com/plataformatec/simple_form.git' | |
| 2. Create an initializer | |
| # /config/initializers/simple_form.rb | |
| # Use this setup block to configure all options available in SimpleForm. | |
| SimpleForm.setup do |config| | |
| # Wrappers are used by the form builder to generate a complete input. | |
| # You can remove any component from the wrapper, change the order or even | 
| namespace :deploy do | |
| namespace :assets do | |
| task :precompile, :roles => :web, :except => { :no_release => true } do | |
| from = source.next_revision(current_revision) | |
| if capture("cd #{latest_release} && #{source.local.log(from)} vendor/assets/ app/assets/ | wc -l").to_i > 0 | |
| run %Q{cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:precompile} | |
| else | |
| logger.info "Skipping asset pre-compilation because there were no asset changes" | |
| end | |
| end | 
| #!/usr/bin/env ruby | |
| require "nokogiri" | |
| # opens every file in the given dir tree and converts any html img tags to rails image_tag calls | |
| # | |
| # example usage: | |
| # ruby convert.rb ~/my_rails_app/app/views | |
| # | |
| # ***be careful and backup before using this*** | |
| # |