Skip to content

Instantly share code, notes, and snippets.

View kusakusakusa's full-sized avatar
💭
Digital nomad | RubyOnRails | AWS

Victor Leong kusakusakusa

💭
Digital nomad | RubyOnRails | AWS
View GitHub Profile
@kusakusakusa
kusakusakusa / puma.rb
Created September 16, 2019 21:49
rails puma config for server
# 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' }
@kusakusakusa
kusakusakusa / nginx-rails
Created September 16, 2019 21:47
nginx for 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 / {
@kusakusakusa
kusakusakusa / s3 AllowPublicRead bucket policy
Created August 10, 2019 15:29
Make all S3 objects in bucket public regardless of objects' acl
{
"Version": "2008-10-17",
"Statement": [
{
"Sid": "AllowPublicRead",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
@kusakusakusa
kusakusakusa / React (no Redux) static site setup
Last active August 20, 2017 07:04
setup for static site on React and React-router only (no Redux)
Typical setup
@kusakusakusa
kusakusakusa / React (Node)
Last active July 19, 2017 17:33
Typical setup for React projects on Node
Typical setup process of a React project on Node
@kusakusakusa
kusakusakusa / _etc_nginx_sites-available_website
Created March 16, 2017 06:39
Nginx for rails + CDN + SSL
server {
listen 443 ssl;
server_name domain.com;
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;
@kusakusakusa
kusakusakusa / code snippet
Created November 24, 2016 10:13
Exec.js error
JS_PATH = 'app/assets/javascripts/**/*.js'
Dir[JS_PATH].each do |file|
begin
Uglifier.compile(File.read(file))
rescue => e
puts e.message
puts file
end
end
@kusakusakusa
kusakusakusa / robots.txt
Created September 4, 2016 13:23
robots.txt with sitemap_generator
# See http://www.robotstxt.org/robotstxt.html 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
@kusakusakusa
kusakusakusa / logrotate
Last active October 15, 2018 08:05
rails server setup
# /etc/logrotate.d/<logrotate_file>
/home/ubuntu/<folder>/shared/log/*.log {
daily
missingok
rotate 1
compress
notifempty
copytruncate
su ubuntu ubuntu
}
@kusakusakusa
kusakusakusa / page_functions.rb
Last active May 9, 2016 13:51
Rspec page objects module
module PageFunctions
include Capybara::DSL
def in_browser(name)
old_session = Capybara.session_name
Capybara.session_name = name
yield
Capybara.session_name = old_session