Twitter Updates

Friday, 14 May 2010

So long and thanks for all the fish

I have not made many posts for a while on this blog. Out of frustration with posting code samples and interest of writing sinatra web applications I have setup on webfaction please view from now on my new posts will be here.

Also my sourceforge/opensource projects will be moved here.

Tuesday, 23 March 2010

Wednesday, 17 March 2010

GIT setup on webfaction

git is a popular revision control system which allow users to make local commits to capture their work in progress before it is pushed to the central repository. Most webfaction servers do not currently have git installed so you will have to compile it your self fairly trivial if you follow the instructions.

The intended work-flow is to keep committing local changes while you work on you r website and when you are happy with it you push to a secure git repo. Then make your webapp pull from the central secure repo.

$ shh
$ cd ./bin
#//Check out the latest version, currently it is
$ wget
$ tar zxf git-
$ cd git-
$ ./configure --prefix=$HOME && make && make install

#//Clean up the original stuff leaving the compiled binaries in ~/bin
$ cd ~/bin
$ rm -rf git-*
#//This bring the total from 80MBs down to 14MBs

$ mkdir ~/repo/projectname.git
$ cd ~/repo/projectname.git
$ git --bare init

Now local stuff to connect it
$ cd /path/to/your/local/repository/
$ git init #Assumes it is not already a git repo
$ touch
$ git add
$ git commit -a -m '*Added'
#//Now try to connect to server, will request your ssh password or not if you have key based ssh auth setup
$ git push ssh://

You will see this error
$ bash: git-receive-pack: command not found
$ fatal: The remote end hung up unexpectedly

This is because of an oddity in the way the .bash_profile and .bashrc are setup.
ssh only loads the .bash_profile.

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc

## MOVE THIS TO .bashrc THENthey Will both be the same
# User specific environment and startup programs
#export PATH

# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc

# User specific environment and startup programs
export PATH
# User specific aliases and functions

NB: The following may be added so you can use the 'git push' shortcut (it actually runs git push origin master).
$ git remote add origin ssh://user@server-ip-or-address/~/repo/projectname.git

$ git push origin master
$ git push

Based on

Webfaction and google apps

First register (for free) with standrad google apps

Create the random subdomain (under domains) that google gives you.
Then under DNS overides choose the new subdomain and complete the CNAME record to be

Check that this has taken affect. when you press the I have done this button google then checks. If you hae not done this it will assume that you do not own the domain and not allow you to continue.

For easy access to your mailbox, create a new subdomain (under domains) Then under DNS overides set the CNAME to

Then under domains for create these MX records
Domain                Priority

Sunday, 14 March 2010

Setting Up on WebFaction

WebFaction is quite popular among the Python and Django community, recently it has simplified Rails and other Ruby web frameworks.

Unlike other Web hosts they do not bundle a domain name, but these can be bought quite cheaply from I would then forward the MX records to google and get a gmail handler for your mail. You do not have to get a domain straight away by default you can use

First I had to install Passenger (I think this is also called Rack), I set the name to passenger.

This means that if you ssh/sftp/ftp into your account you will see ~/webapps/passenger/

Then I entered the Websites section then created a new subdomain and set this to be type:passenger location:/

I had to wait sometime before these setting became active.
There article can then be followed for setting up a basic Sinatra over passenger (Rack).

NB: for a sinatra app you only need to install Passenger (not rails) and gem install sinatra (plus sequel / activerecord etc).

Saturday, 13 March 2010

Sinatra set_cookie started failing

I recently started getting this error [1] in my Sinatra web application (after upgrading from 0.9.4 to 0.9.6)
[1] undefined method `set_cookie' for 

Basically instead of
set_cookie("foo", "bar")
We now have to use:
response.set_cookie("foo", "bar")

Source gitr

Thursday, 11 March 2010

VIM and whitespace

To view white space characters (except spaces)
:set list

To stop tab insertion and uses spaces
set expandtab

To set all types of tabs to 3 spaces
set tabstop=3
set softtabstop=3
set shiftwidth=3

Further Info 2