This file contains hidden or 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
# in order to access ENV you need to include your env recipe | |
include_recipe 'application::env' | |
chef_gem 'aws-sdk' do | |
version '2.7.9' | |
end | |
require 'aws-sdk' | |
owc = Aws::OpsWorks::Client.new( region: 'us-east-1' ) |
This file contains hidden or 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
<% module_namespacing do -%> | |
class <%= class_name %> < <%= parent_class_name.classify %> | |
# Rails style guided+ | |
#-------------------- 1. includes and extend -------------- | |
#-------------------- 2. default scope -------------------- | |
#-------------------- 3. inner classes -------------------- | |
#-------------------- 5. attr related macros -------------- | |
#-------------------- 6. enums ---------------------------- | |
#-------------------- 7. scopes --------------------------- |
This file contains hidden or 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 style guided+ | |
#-------------------- 1. includes and extend -------------- | |
#-------------------- 2. default scope -------------------- | |
#-------------------- 3. inner classes -------------------- | |
#-------------------- 4. constants ------------------------ | |
#-------------------- 5. attr related macros -------------- | |
#-------------------- 6. enums ---------------------------- | |
#-------------------- 7. scopes --------------------------- | |
#-------------------- 8. has and belongs ------------------ | |
#-------------------- 9. accept nested macros ------------ |
This file contains hidden or 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 { | |
set $versioned_location @version_one; | |
if ( $cookie_condition ) { | |
set $versioned_location @version_two; | |
} | |
if ( $cookie_site_version = "version_one" ) { | |
set $versioned_location @version_one; | |
} |
This file contains hidden or 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
def send_devise_notification(notification, *args) | |
# don't forget email not sended without calling deliver | |
message = devise_mailer.send(notification, self, *args) | |
# this is the params you want to anylise when something crashes | |
add_to_airbrake_notice = attributes.slice('email', 'name', 'surname', 'cell', 'id') | |
# run message delivering | |
run_async_with_rescue(add_to_airbrake_notice) { message.deliver } | |
end |
This file contains hidden or 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
def run_async_with_rescue( airbrake_params = {} ) | |
backtrace = Kernel.caller | |
Thread.new do | |
begin | |
yield | |
rescue => e | |
e.set_backtrace( backtrace ) | |
notice = Airbrake.build_notice(e, airbrake_params) | |
Airbrake.notify(notice) if notice | |
end |
This file contains hidden or 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
proxy_cache_pass /path/to/cache levels= keys_zone=rails_cache:10m max_size=10g use_temp_path=off inactive=120m; | |
location / { | |
try_files $uri @rails; | |
} | |
location @rails { | |
# lets skip authorized user. | |
proxy_no_cache $cookie_remember_user_token; | |
proxy_cache_bypass $cookie_remember_user_token; |
This file contains hidden or 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
#in controller: | |
before_action :resourceful_cache_headers | |
before_action :resourceless_cache_headers | |
before_action :skip_session | |
def skip_session | |
# if you need to deliver flash, or authencity token, or you explicitly need session | |
request.session_options[:skip] = true unless you_need_session | |
end |
This file contains hidden or 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
def all_files_in(dir) | |
Dir[ File.join(dir, '**', '*') ].reject { |p| File.directory? p } | |
end | |
new_namespace = Digest::SHA256.hexdigest( all_files_in( 'app/views' ) | |
.map{|fl| Digest::SHA256.file(fl).hexdigest } | |
.join ) |
This file contains hidden or 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
proxy_cache_path /path/to/cache levels=1:2 keys_zone=my_cache:10m max_size=10g | |
inactive=60m use_temp_path=off; | |
server { | |
... | |
location / { | |
proxy_cache my_cache; | |
proxy_cache_revalidate on; | |
proxy_cache_min_uses 1; | |
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 |