October 16, 2008

Using staging servers in Capistrano and Rails

I was looking for a way to deploy our website to different servers and this snippet did it very well.

The idea is very simple: in config/deploy.rb create a couple of new tasks to set the deployment variables:

task :production do
  role :web, "production.server.com"
  role :app, "production.server.com"
  role :db,  "production.server.com", :primary=>true
end

task :staging do
  role :web, "staging.server.com"
  role :app, "staging.server.com"
  role :db,  "staging.server.com", :primary=>true
end

After these tasks were added you can deploy using cap staging deploy or cap production deploy.

August 28, 2008

Converting Subversion repositories to Git

Today I converted our last subversion repository to git.

I do not want to repeat all the praise given to git and tell how smaller, faster and more powerful it is, you can google it yourself.

Linux Torvalds gives a great video introduction and Peepcode screencast will get you up and running on git in no time.

Here is a few simple repository conversion steps:

1. clone the svn repository

git-svn clone svn+ssh://username@servername.com/var/svn/Project

2. make it bare

git clone --bare Project Project.git

3. setup Git user on server

useradd git --create-home --shell /usr/bin/git-shell

su -s /bin/bash git

cd; mkdir .ssh; chmod og-rwx .ssh

vi .ssh/authorized_keys

Paste developer public keys and save...

chmod og-rwx .ssh/authorized_keys; exit

Add developer public keys to /home/git/.ssh/authorized_keys

4. upload the repository to server

upload to /home/git/Project.git

5. start using the new repository

git clone git@servername.com:Project.git

Goodbye, subversion and thanks.

July 13, 2008

Code Cuts

Code Cuts — this is what Thsrs came up with when I tried to shorten Software Trenches.

Thsrs is special kind of thesaurus that suggests shorter words. Might be very useful when you try to cram your full message into a Twitter post.

Via Daring Fireball.

localhost.com annoyance

If you are developing with Ruby on Rails then I am sure you had this happened more than once — type http://localhost:3000 in your browser and after a short delay it goes to http://www.localhost.com because your local server didn't start successfully.

To get rid of this annoyance, change /etc/hosts file and add

127.0.0.1 localhost.com

June 05, 2008

Cocoa: Converting from nib to xib

Apple introduced new resource file format in Xcode 3.0: **.xib**. Xib files are used during development time only and are will be converted to deployment format (compressed .nib) at build time. The main benefit of .xib is that it is text-based. Text makes it easier to work with .xib files stored in a source control system. Here is quick way to convert all old .nib files to .xib format: `ls | grep nib | xargs -L1 ibtool --upgrade`

March 29, 2008

ack - a better grep

I was searching through with [WebKit](http://webkit.org/) sources today and was struggling with [grep](http://www.gnu.org/software/grep/). The main problem was that, as any other [SVN](http://subversion.tigris.org/) checkout, WebKit directory had a bunch of hidden .svn subfolders and grep included them in the search results making the output completely unreadable and full of junk:
grep_vs_ack I started playing with grep and [find](http://en.wikipedia.org/wiki/Find) options to try to filter out the unwanted .svn results. The much better solution however is to simply switch to [**ack**](http://petdance.com/ack/). Not only ack ignores .svn directories, it also produces a much more readable output:
ack_vs_grep Kudos to [Andy Lester](http://petdance.livejournal.com/) for creating this great utility!

February 01, 2008

Quote of the Life

> Your time is limited, so don't waste it living someone else's life. Don't be trapped by dogma — which is living with the results of other people's thinking. Don't let the noise of others' opinions drown out your own inner voice. And most important, have the courage to follow your heart and intuition. They somehow already know what you truly want to become. Everything else is secondary. – Steve Jobs ### Steve Jobs Stanford Commencement Speech Commencement Speech Text

December 17, 2007

Quicksilver and Customer Support

Providing customer support for your products can be a lot of fun and a great source of motivation for every developer. Unfortunately it can also be a lot of pain and it appears that pain is killing one of my favourite Mac applications - [QuickSilver](http://www.blacktree.com/). In his [recent interview with Lifehacker](http://www.tuaw.com/2007/12/06/lifehacker-interview-on-the-future-of-quicksilver/), Nicholas Jitkoff mentions that >**Jitkoff**: I'm inclined to encourage users to move over to the more stable and well supported alternatives like [LaunchBar](http://www.obdev.at/products/launchbar/). Right now QS 54 (ed: the current build) accomplishes everything that I really need, the problem is stability, which for some reason most people seem to be ignoring. The conversation continues... >**Lifehacker**: Right. I guess from my standpoint, the fact that Quicksilver is free (as well as open source, now) is a major part of why it's so beloved. >**Jitkoff**: But also why it is so poorly supported. I have to do any work in off-time. It is very sad that with so many loyal users willing to pay for support and future development this project is going to slowly die. I am not sure if [making it open source](http://code.google.com/p/blacktree-alchemy/) will help.

November 10, 2007

Compiling libIDL on Leopard

It appears that libIDL is packaged with old config.guess file and when you try to build it on Mac OS X 10.5 (Leopard) you will end up with this error:

configure: error: can not guess host type; you must specify one

An easy fix is to replace the config.guess and config.sub files before running ./configure:

cp /usr/share/automake-1.10/config.* ./

November 07, 2007

Bitstream Vera Sans Mono

James Duncan Davidson recently wrote [an article about monospaced fonts on Mac OS X](http://duncandavidson.com/archives/654). He mentioned Bitstream Vera Sans Mono as a great replacement for Monaco — the standard monospaced font packaged with OS X. The blog readers quickly added more fonts: [Inconsolata](http://www.levien.com/type/myfonts/inconsolata.html) (my favourite now), DejaVu, Panic Sans, [Envy Code R](http://damieng.com/blog/2007/08/19/envy-code-r-preview-6-released-with-visual-studio-italics) and more.