Skip to content

Instantly share code, notes, and snippets.

@therealechan
therealechan / Deploy Rails application with unicorn and apache.md
Created March 18, 2015 08:31
Deploy Rails application with unicorn and apache

Gemfile:

# an HTTP server for Rack applications
# http://unicorn.bogomips.org/
gem 'unicorn', '~> 4.8.3'

gem 'capistrano-unicorn', :require => false, group: :development

add new file config/unicorn.rb

@therealechan
therealechan / How Rails application connect to the remote pg database.md
Last active August 29, 2015 14:17
How Rails application connect to the remote pg database

Before this you need to build the server as usual

your database.yml should be edited like this

production:
  adapter: postgresql
  encoding: unicode
  database: foo_production
  pool: 5
@therealechan
therealechan / rails_production_log_empty_debugger.md
Created March 18, 2015 06:37
Rails production log file empty?

1 check nginx.conf

2 check /var/www and log folder permission

3 Remove rails_12factor gem if added in your gem file

# group :production do

# gem 'rails_12factor'
namespace :figaro do
desc "SCP transfer figaro configuration to the shared folder"
task :setup do
transfer :up, "config/application.yml", "#{shared_path}/application.yml", :via => :scp
end
desc "Symlink application.yml to the release path"
task :finalize do
run "ln -sf #{shared_path}/application.yml #{release_path}/config/application.yml"
end
@therealechan
therealechan / incomplete response received from application.md
Last active August 29, 2015 14:17
incomplete response received from application

遇到 incomplete response received from application

可能是 config/secret.yml 没有配置好.

e.g config/secret.ymlproduction secret key 没有配置好

@therealechan
therealechan / set ubuntu time zone.md
Created March 10, 2015 10:05
Set Ubuntu time zone from command line
$ sudo dpkg-reconfigure tzdata
@therealechan
therealechan / rake_task_encoding_problem.md
Created March 10, 2015 05:53
invalid byte sequence in US-ASCII (ArgumentError)
rake aborted!
/home/me/.rvm/gems/ruby-1.9.3-p392/gems/rake-10.0.4/lib/rake/trace_output.rb:16:in `block in trace_on': invalid byte sequence in US-ASCII (ArgumentError)

If you got this error

checkout your your custom initializers, your database.yml, etc

add

/*
HTML5 Shiv v3.7.0 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
*/
(function(l,f){function m(){var a=e.elements;return"string"==typeof a?a.split(" "):a}function i(a){var b=n[a[o]];b||(b={},h++,a[o]=h,n[h]=b);return b}function p(a,b,c){b||(b=f);if(g)return b.createElement(a);c||(c=i(b));b=c.cache[a]?c.cache[a].cloneNode():r.test(a)?(c.cache[a]=c.createElem(a)).cloneNode():c.createElem(a);return b.canHaveChildren&&!s.test(a)?c.frag.appendChild(b):b}function t(a,b){if(!b.cache)b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag();
a.createElement=function(c){return!e.shivMethods?b.createElem(c):p(c,a,b)};a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+m().join().replace(/[\w\-]+/g,function(a){b.createElem(a);b.frag.createElement(a);return'c("'+a+'")'})+");return n}")(e,b.frag)}function q(a){a||(a=f);var b=i(a);if(e.shivCSS&&!j&&!b.hasCSS){var c,d=a;c=d.createElement("p");d=d.getElementsBy
@therealechan
therealechan / install_zsh_to_ubuntu.md
Last active August 29, 2015 14:14
Install and switch zsh on Ubuntu

Perpare:

$ sudo apt-get install git
$ sudo apt-get install curl

Install zsh:

$ sudo apt-get install zsh
@therealechan
therealechan / creating_ssh_shortcut.md
Last active August 29, 2015 14:13
Creating SSH shortcut

touch a file call config in your ~/.ssh folder, edit like below

Host myserver  
HostName 104.216.186.124  
User deployer  
Port 22

Make sure you have the right permissions

$ chmod 600 ~/.ssh/config