Skip to content

Instantly share code, notes, and snippets.

View ntamvl's full-sized avatar
🏠
Working from home

Tam Nguyen ntamvl

🏠
Working from home
View GitHub Profile
@ntamvl
ntamvl / gist:8bcf8ab6c700cca6346d
Created December 23, 2015 03:58
nginx + unicorn + performance tweaks: myapp.conf example
# myapp
upstream unicorn_myapp {
server unix:/var/rails/myapp/current/tmp/sockets/unicorn.sock fail_timeout=0;
}
server {
server_name myapp.com www.myapp.com;
root /var/rails/myapp/current/public;
@ntamvl
ntamvl / gist:9860a4fc5d8065427a79
Created December 23, 2015 03:57
nginx + unicorn + performance tweaks: nginx.conf example
# nginx.conf
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
timer_resolution 500ms;
@ntamvl
ntamvl / deploy.rake
Created December 21, 2015 08:25 — forked from shmatov/deploy.rake
rails + mina + unicorn
# lib/tasks/deploy.rake
namespace :deploy do
desc 'Deploy to staging environment'
task :staging do
exec 'mina deploy -f config/deploy/staging.rb'
end
end
@ntamvl
ntamvl / mina_deploy_example.rb
Last active February 21, 2024 11:17 — forked from jbonney/deploy.rb
Mina deployment file to setup new host for Rails applications. Creates the folder structure, fill up the database.yml file, create the associated DB and user and set up new Apache virtual host file.
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rvm'
# Usually mina focuses on deploying to one host and the deploy options are therefore simple.
# In our case, there is a number of possible servers to deploy to, it is therefore necessary to
# specify the host that we are targeting.
server = ENV['server']
# Since the same host can have multiple applications running in parallel, it is necessary to
@ntamvl
ntamvl / digital_ocean_setup.md
Created December 15, 2015 16:45 — forked from ChuckJHardy/digital_ocean_setup.md
DigitalOcean Ubuntu 14.04 x64 + Rails 4 + Nginx + Unicorn + PostgreSQL + Capistrano 3 Setup Instructions

DigitalOcean Ubuntu 14.04 x64 + Rails 4 + Nginx + Unicorn + PostgreSQL + Capistrano 3

SSH into Root

$ ssh root@123.123.123.123

Change Root Password

@ntamvl
ntamvl / Deep_Symbolization
Last active February 21, 2024 11:17 — forked from morhekil/LICENSE
Implementation of deep symbolization of keys for Ruby hashes
The MIT License (MIT)
Copyright (c) 2015 Oleg Ivanov http://github.com/morhekil
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@ntamvl
ntamvl / nginx
Created December 10, 2015 07:27 — forked from hisea/nginx
ubuntu passenger nginx init.d script
sudo cp nginx /etc/init.d/
sudo update-rc.d nginx defaults
sudo chmod +x /etc/init.d/nginx
/etc/init.d/nginx start
@ntamvl
ntamvl / authentication_with_bcrypt_in_rails_4.md
Created November 9, 2015 08:04 — forked from thebucknerlife/authentication_with_bcrypt_in_rails_4.md
Simple Authentication in Rail 4 Using Bcrypt

#Simple Authentication with Bcrypt

This tutorial is for adding authentication to a vanilla Ruby on Rails app using Bcrypt and has_secure_password.

The steps below are based on Ryan Bates's approach from Railscast #250 Authentication from Scratch (revised).

You can see the final source code here: repo. I began with a stock rails app using rails new gif_vault

##Steps

@ntamvl
ntamvl / tmux-cheatsheet.markdown
Created November 4, 2015 17:00 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@ntamvl
ntamvl / mysql2-gem-install.sh
Created November 3, 2015 08:50 — forked from roolo/mysql2-gem-install.sh
Fixing "Incorrect MySQL client library version! This gem was compiled for 5.5.29 but the client library is 5.6.10. (RuntimeError)" on OS X while using Brew
ARCHFLAGS="-arch x86_64" gem install mysql2 -- –with-mysql-config=/usr/local/bin/mysql_config