Skip to content

Instantly share code, notes, and snippets.

@prawin
prawin / Ruby2 on Dreamhost
Last active March 7, 2016 05:56
RoR with Ruby 2.0.0 on Dreamhost
BUILD AND INSTALL RUBY FROM SOURCE
cd ~
mkdir build
cd build
wget http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz
tar xzf ruby-2.0.0-p247.tar.gz
cd ruby-2.0.0-p247
./configure --prefix /home/adamish/ruby # <=== make sure you install to your own home directory
make install
# Usage: rake name:task app_name
task PROD = "appname" # "task" here stubs to prevent rake errors with commandline
task STAGING = "appname-staging"
APP = ARGV[1] || PROD # default app
puts "=== APP #{APP} ==="
namespace :deploy do
@prawin
prawin / deploy.rake
Created February 12, 2014 10:46 — forked from RSpace/deploy.rake
task :deploy => ['deploy:push', 'deploy:restart', 'deploy:tag']
namespace :deploy do
task :migrations => [:push, :off, :migrate, :restart, :on, :tag]
task :rollback => [:off, :push_previous, :restart, :on]
task :push do
puts 'Deploying site to Heroku ...'
puts `git push heroku`
end
@prawin
prawin / gist:8488791
Created January 18, 2014 10:43
MySQL Privileges
GRANT ALL PRIVILEGES ON test_database.* TO 'user_name'@'%' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON test_database.* TO 'user_name'@'ip' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON test_database.* TO 'user_name'@'domain' WITH GRANT OPTION;
FLUSH PRIVILEGES;
@prawin
prawin / deploy.rb
Created December 11, 2013 07:07 — forked from reu/deploy.rb
# Bundler Integration
require "bundler/capistrano"
# Application Settings
set :application, "yourapplicationname"
set :user, "serveruser"
set :deploy_to, "/home/#{user}/rails-applications/#{application}"
set :rails_env, "production"
set :use_sudo, false
set :keep_releases, 3
@prawin
prawin / gist:7687559
Last active December 29, 2015 14:59
Create csr
openssl req -nodes -newkey rsa:2048 -keyout domain.key -out domain.csr
@prawin
prawin / README.md
Created September 19, 2013 05:49 — forked from fnichol/README.md

A Common .ruby-version File For Ruby Projects

Background

I've been using this technique in most of my Ruby projects lately where Ruby versions are required:

  • Create .rbenv-version containing the target Ruby using a definition name defined in ruby-build (example below). These strings are a proper subset of RVM Ruby string names so far...
  • Create .rvmrc (with rvm --create --rvmrc "1.9.3@myapp") and edit the environment_id= line to fetch the Ruby version from .rbenv-version (example below).

Today I learned about another Ruby manager, rbfu, where the author is using a similar technique with .rbfu-version.

@prawin
prawin / gist:6607985
Created September 18, 2013 11:43
nginx compression settings
location ~ ^/(assets)/ {
root /path/to/assets/folder/;
gzip on;
gzip_static on;
gzip_http_version 1.1;
@prawin
prawin / Apache DEPLATE compression
Last active December 23, 2015 08:29
GZIP Compression
####################
# GZIP COMPRESSION #
####################
SetOutputFilter DEFLATE
Addtype font/opentype .otf
Addtype font/truetype .ttf
AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml application/x-javascript application/x-httpd-php font/opentype font/truetype
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
@prawin
prawin / es.sh
Created September 17, 2012 10:42
Install ElasticSearch on Ubuntu 12.04
cd ~
sudo apt-get update
sudo apt-get install openjdk-7-jre -y
wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.19.0.tar.gz -O elasticsearch.tar.gz
tar -xf elasticsearch.tar.gz
rm elasticsearch.tar.gz
sudo mv elasticsearch-* elasticsearch
sudo mv elasticsearch /usr/local/share