This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ... | |
deb http://nginx.org/packages/mainline/ubuntu/ trusty nginx | |
deb-src http://nginx.org/packages/mainline/ubuntu/ trusty nginx | |
# Where 'trusty' is the Ubuntu release codename (see `cat /etc/lsb-release`) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Be sure to restart your server when you modify this file. | |
# Version of your assets, change this if you want to expire all your assets. | |
Rails.application.config.assets.version = '1.0' | |
# Add additional assets to the asset load path | |
# Rails.application.config.assets.paths << Emoji.images_path | |
# Precompile additional assets. | |
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
# ... | |
# Feed | |
location ~* \.(?:rss|atom)$ { | |
expires 1h; | |
add_header Cache-Control "public"; | |
} | |
# Media: images, icons, video, audio, HTC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ... | |
http { | |
# ... | |
## | |
# Gzip Settings | |
## |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rails.application.configure do | |
# ... | |
# Compress JavaScripts and CSS. | |
config.assets.css_compressor = :sass | |
config.assets.js_compressor = :uglifier | |
# ... | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use rsync during your deployment process to sync | |
rake assets:precompile | |
rsync -avzhe ssh /home/rails/my_app/public/* user@assets.example.com:/public_html/ | |
# Now your Rails app will fetch assets from the assets server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
server_name www.example.com; | |
return 301 https://example.com$request_uri; | |
} | |
upstream rails_app { | |
server unix:/var/run/rails/my_app/unicorn.sock fail_timeout=0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Sample verbose configuration file for Unicorn (not Rack) | |
# | |
# This configuration file documents many features of Unicorn | |
# that may not be needed for some applications. See | |
# http://unicorn.bogomips.org/examples/unicorn.conf.minimal.rb | |
# for a much simpler configuration file. | |
# | |
# See http://unicorn.bogomips.org/Unicorn/Configurator.html for complete | |
# documentation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a handy pattern for handling slow computations like API calls | |
def slow_results | |
Rails.cache.fetch("slow_api_results", expires_in: 10.minutes) do | |
slow_api_call | |
end | |
end | |
slow_results # Takes a few seconds to load first time | |
# => "Lorem ipsum..." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Thread ID: 21277412 | |
%self cumulative total self children calls self/call total/call name | |
46.34 4.06 8.72 4.06 4.66 501 0.01 0.02 Integer#upto | |
23.89 6.16 2.09 2.09 0.00 61 0.03 0.03 Kernel.sleep | |
15.12 7.48 1.33 1.33 0.00 250862 0.00 0.00 Fixnum#% | |
14.13 8.72 1.24 1.24 0.00 250862 0.00 0.00 Fixnum#== | |
0.18 8.74 0.02 0.02 0.00 1 0.02 0.02 Array#each_index | |
0.17 8.75 6.64 0.01 6.63 500 0.00 0.01 Object#is_prime | |
0.17 8.77 6.66 0.01 6.64 1 0.01 6.66 Array#select | |
0.00 8.77 0.00 0.00 0.00 501 0.00 0.00 Fixnum#- |