Skip to content

Instantly share code, notes, and snippets.

View alvinkatojr's full-sized avatar

Alvin Kato J.R. alvinkatojr

View GitHub Profile
@alvinkatojr
alvinkatojr / Traps.markdown
Created November 5, 2012 10:50
Deploy Rails on Ubuntu server 12.04 with Nginx, Unicorn, Mysql
  1. the default index.html does not work well in prodution mode, so do not borther to config that, just delete it and go on.

  2. To put things in production mode, do

     rails g scaffold items name:string
     rake db:migrate RAILS_ENV=production
     rm public/index.html
     #change route.rb point root to items#index
     rake assets:precompile
     sudo service nginx restart
    

./config/unicorn_init.sh stop

### Week 01 ###
0.upto(10) { |i|
print " " * (10 - i)
puts "*" * (2 * i + 1)
}
9.downto(0) { |i|
print " " * (10 - i)
puts "*" * (2 * i + 1)
#!/usr/bin/env ruby
n = 2..1000
o = []
p = []
for i in n
next if o.include? i
ii = i * 2
while ii <= n.last do

Ruby on Rails development setup on Ubuntu 12.04

System update

# change mirror to ubuntu.osuosl.org first
sudo apt-get update

Install common libraries

sudo apt-get install build-essential libreadline-dev libssl-dev zlib1g-dev libxml2-dev libxslt-dev

# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@alvinkatojr
alvinkatojr / install.md
Last active August 29, 2015 14:19 — forked from galulex/install.md

Developer libs

mysql, rmagic, curl, git, vim, sqlite, nodejs nokogiri...

sudo apt-get install libxslt1-dev libxml2-dev libmagickwand-dev imagemagick libsqlite3-dev libcurl4-openssl-dev curl git git-gui vim-gtk mysql-server mysql-client ruby-mysql libmysqlclient-dev mysql-workbench exuberant-ctags icedtea-plugin nodejs rar wmctrl

Ruby

sudo apt-get install python-software-properties

sudo apt-add-repository ppa:brightbox/ruby-ng

Fixing npm On Mac OS X for Homebrew Users

If you just want to fix the issue quickly, scroll down to the "solution" section below.

Explanation of the issue

If you're a Homebrew user and you installed node via Homebrew, there is a major philosophical issue with the way Homebrew and NPM work together. If you install node with Homebrew and then try to do npm update npm -g, you may see an error like this:

$ npm update npm -g
class Meal
def initialize(meal_cost, tax_rate, tip_rate)
@meal_cost = meal_cost
@tax_rate = tax_rate
@tip_rate = tip_rate
end
def calculate_percentage_rate(amount, rate)
return amount.to_f * rate/100