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 http://lizard-spock.co.uk from now on my new posts will be here. Also my sourceforge/opensource projects will be moved here. Update: software projects no longer available

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 username@username.webfaction.com
$ cd ./bin
#//Check out the latest version, currently it is 1.7.0.2
$ wget http://kernel.org/pub/software/scm/git/git-1.7.0.2.tar.gz
$ tar zxf git-1.7.0.2.tar.gz
$ cd git-1.7.0.2
$ ./configure --prefix=$HOME && make && make install

#//Clean up the original stuff leaving the compiled binaries in ~/bin
$ cd ~/bin
$ rm -rf git-1.7.0.2*
#//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 README.md
$ git add README.md
$ git commit -a -m '*Added README.md'
#//Now try to connect to server, will request your ssh password or not if you have key based ssh auth setup
$ git push ssh://user@user.webfactional.com/~/repo/projectname.git


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
# .bash_profile

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

## MOVE THIS TO .bashrc THENthey Will both be the same
# User specific environment and startup programs
#PATH=$PATH:$HOME/bin
#export PATH


.bashrc
# .bashrc

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

# User specific environment and startup programs
PATH=$PATH:$HOME/bin
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 http://devioustree.co.uk/2009/07/23/setting-up-git-on-webfaction/
and http://docs.webfaction.com/software/git.html

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 google.com

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) mail.yourdomain.com. Then under DNS overides set the CNAME to ghs.google.com

Then under domains for yourdomain.com create these MX records
Domain                Priority
ASPMX5.GOOGLEMAIL.COM 30
ASPMX4.GOOGLEMAIL.COM 30
ASPMX3.GOOGLEMAIL.COM 30
ASPMX2.GOOGLEMAIL.COM 30
ALT2.ASPMX.L.GOOGLE.COM 20
ALT1.ASPMX.L.GOOGLE.COM 20
ASPMX.L.GOOGLE.COM 10

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 www.gandi.net. 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 username.webfactional.com

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 devel.username.webfactional.com 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 vimcasts.org 2