colored git

29 Nov 2009
Tags: git, config, colors

Want to make your git experience literally colorful? :D Add the following to your global options

>> git config --global color.interactive always
>> git config --global color.diff always
>> git config --global color.status always
>> git config --global color.branch always

To explore other global options,

>> git config --help

To explore your current global options

>> git config --global --list

specify gem groups to install in heroku

24 Jan 2011
Tags: gem, config, heroku

While I was migrating my wife's site to Rails 3 on Heroku, I encountered the following error

Installing linecache19 (0.5.11) with native extensions /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/installer.rb:483:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

To solve the problem above, add a config variable in heroku specifying that gems listed under a specific group should not be installed.

heroku config:add BUNDLE_WITHOUT="development test"

So adding the code above will skip gems under the development and test groups.

301 redirect with more than 1 alias in nginx

11 Jul 2011
Tags: nginx, config

Usually, companies acquire multiple domains and point them to one application. In these cases, the company would want to use a 301 redirect to change the url to the one they want indexed by search engines.

In nginx, you can do a 301 redirect by following my other post. It would've been easy if "if" blocks in nginx support conditional operators like || or && (in most programming languages).

To get around this, we use the set command to set a value to a variable, and set that variable's value if the host matches one of the alias. To better illustrate, suppose we're given 4 domains:


If the domain we want indexed by search engines is, then our config file should look like

server {
  listen 80; 

  set $my_var 0;
  if ($host = '') {set $my_var 1;} 
  if ($host = '') {set $my_var 1;}
  if ($host = '') {set $my_var 1;} 

  if ($my_var = 1) {
    rewrite ^/(.*)$$1 permanent;