Skip to content

Instantly share code, notes, and snippets.

View samnang's full-sized avatar
🚀

Samnang Chhun samnang

🚀
View GitHub Profile
@samnang
samnang / gist:2601575
Created May 5, 2012 11:03 — forked from ambar/gist:1534274
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@samnang
samnang / ruby_gc.sh
Created May 1, 2012 05:15 — forked from mikhailov/ruby_gc.sh
Ruby’s GC Configuration
- http://www.coffeepowered.net/2009/06/13/fine-tuning-your-garbage-collector/
- http://snaprails.tumblr.com/post/241746095/rubys-gc-configuration
article’s settings: ("spec spec" took 17-23!sec)
export RUBY_HEAP_MIN_SLOTS=1250000
export RUBY_HEAP_SLOTS_INCREMENT=100000
export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1
export RUBY_GC_MALLOC_LIMIT=30000000
export RUBY_HEAP_FREE_MIN=12500
@samnang
samnang / pair.md
Created April 11, 2012 16:35 — forked from wm/pair.md
TMUX Pairing

SSH setup for remote pairing

If Animal and Fozzie wanted to pair on Animals machine and they both have access to shared.muppets.com then they could use the following setup

  • Animal will have the following in ~/.ssh/config
Host tunnel_from_muppets
  Hostname space.muppets.com
 RemoteForward 1235 localhost:22
@samnang
samnang / vimrc
Created April 8, 2012 16:38
My Vim plugins
" Let Vundle manage Vundle
Bundle 'gmarik/vundle'
Bundle 'tpope/vim-rails'
Bundle 'tpope/vim-rake'
Bundle 'tpope/vim-fugitive'
Bundle 'tpope/vim-surround'
Bundle 'tpope/vim-endwise'
Bundle 'scrooloose/nerdtree'
Bundle 'kien/ctrlp.vim'
@samnang
samnang / api_controller.rb
Created April 1, 2012 15:41 — forked from ahawkins/api_controller.rb
Basic API style controller for Rails
# A Basic API Controller for Rails
# Handles authentication via Headers, params, and HTTP Auth
# Automatically makes all requests JSON format
#
# Written for production code
# Made public for: http://broadcastingadam.com/2012/03/state_of_rails_apis
#
# Enjoy!
class ApiController < ApplicationController
@samnang
samnang / osx_rails_env_setup_in_1_step.md
Created April 1, 2012 15:29 — forked from mpapis/osx_rails_env_setup_in_1_step.md
One step to get up'n'running with Rails on OS X or Linux

Use this command and follow the instructions:

bash -s stable --rails < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)

Other options include(any gems imply --ruby):

--ruby=1.9.3
--gems=rails,gist

Optionally on OSX install homebrew, use brew command to install whatever database engine you need, ie brew install sqlite

@samnang
samnang / authlogic_to_devise.rb
Created February 21, 2012 09:17
Migrate Authlogic to Devise
# Change devise encryption strategy to match your existing authentication
# https://github.com/plataformatec/devise/tree/master/lib/devise/encryptors
class MigrateUsers < ActiveRecord::Migration
def self.up
rename_column :users, :crypted_password, :encrypted_password
add_column :users, :confirmation_token, :string, :limit => 255
add_column :users, :confirmed_at, :timestamp
add_column :users, :confirmation_sent_at, :timestamp
@samnang
samnang / requires.rb
Created February 12, 2012 17:42
Automatically require the modules under lib
# config/initializers/requires.rb
Dir[File.join(Rails.root, 'lib', '*.rb')].each do |f|
require f
end
@samnang
samnang / gist:1759336
Created February 7, 2012 11:52
Install Bash version 4 on MacOS X
# Install Bash 4 using homebrew
brew install bash
# Or build it from source...
curl -O http://ftp.gnu.org/gnu/bash/bash-4.2.tar.gz
tar xzf bash-4.2.tar.gz
cd bash-4.2
./configure --prefix=/usr/local/bin && make && sudo make install
# Add the new shell to the list of legit shells
@samnang
samnang / user.rb
Created October 9, 2011 16:38
Consistant with Order in Model
# Pluralize-able Noun
class User < ActiveModel::Base
# Module Inclusions
include User::Feature # app/models/user/feature.rb
# CONSTANTS
MY_CONSTANT = "value"
# Class-Level Method Invocations(,etc.)
acts_as_tree