Skip to content

Instantly share code, notes, and snippets.

Digital nomad | RubyOnRails | AWS

Victor Leong Vic-L

Digital nomad | RubyOnRails | AWS
View GitHub Profile
Vic-L / puma.rb
Created Sep 16, 2019
rails puma config for server
View puma.rb
# frozen_string_literal: true
max_threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 }
min_threads_count = ENV.fetch('RAILS_MIN_THREADS') { max_threads_count }
threads min_threads_count, max_threads_count
port ENV.fetch('PORT') { 3000 }
environment ENV.fetch('RAILS_ENV') { 'staging' }
Vic-L / nginx-rails
Created Sep 16, 2019
nginx for rails
View nginx-rails
upstream staging_backend {
server unix:///home/ubuntu/<SOMETHING>/shared/tmp/sockets/puma.sock fail_timeout=0;
# no server_name, routes to default this default server directive
server {
listen 80;
client_max_body_size 10m;
location / {
Vic-L / s3 AllowPublicRead bucket policy
Created Aug 10, 2019
Make all S3 objects in bucket public regardless of objects' acl
View s3 AllowPublicRead bucket policy
"Version": "2008-10-17",
"Statement": [
"Sid": "AllowPublicRead",
"Effect": "Allow",
"Principal": {
"AWS": "*"
"Action": "s3:GetObject",
Vic-L / React (no Redux) static site setup
Last active Aug 20, 2017
setup for static site on React and React-router only (no Redux)
Vic-L / React (Node)
Last active Jul 19, 2017
Typical setup for React projects on Node
View React (Node)
Typical setup process of a React project on Node
View _etc_nginx_sites-available_website
server {
listen 443 ssl;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
ssl_certificate /etc/ssl/certs/domain.crt;
ssl_certificate_key /etc/ssl/certs/domain.key;
ssl on;
View code snippet
JS_PATH = 'app/assets/javascripts/**/*.js'
Dir[JS_PATH].each do |file|
rescue => e
puts e.message
puts file
Vic-L / robots.txt
Created Sep 4, 2016
robots.txt with sitemap_generator
View robots.txt
# See for documentation on how to use the robots.txt file
# To ban all spiders from the entire site uncomment the next two lines:
User-agent: libwww-perl
User-agent: Rogerbot
User-agent: Exabot
User-agent: MJ12bot
User-agent: Dotbot
User-agent: Gigabot
User-agent: AhrefsBot
Vic-L / logrotate
Last active Oct 15, 2018
rails server setup
View logrotate
# /etc/logrotate.d/<logrotate_file>
/home/ubuntu/<folder>/shared/log/*.log {
rotate 1
su ubuntu ubuntu
Vic-L / page_functions.rb
Last active May 9, 2016
Rspec page objects module
View page_functions.rb
module PageFunctions
include Capybara::DSL
def in_browser(name)
old_session = Capybara.session_name
Capybara.session_name = name
Capybara.session_name = old_session
You can’t perform that action at this time.