Twitter Updates

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

Tuesday 9 March 2010

RubyGem version error: activesupport(1.4.4 not = 2.3.2)

I have been getting this error [1] when trying to set up a ORM lesson for ActiveRecord. Specifically trying to use active record inside of a Rake file.

[1]RubyGem version error: activesupport(1.4.4 not = 2.3.2)

$ gem list
*** LOCAL GEMS ***

abstract (1.0.0)
actionmailer (2.3.5)
actionpack (2.3.5)
activerecord (2.3.5)
activeresource (2.3.5)
activesupport (2.3.5)
acts_as_taggable (2.0.2)
compass (0.8.17)
erubis (2.6.5)
feed-normalizer (1.5.1)
haml (2.2.17)
hoe (2.3.3)
maruku (0.6.0)
mbleigh-acts-as-taggable-on (1.0.5)
mysqlplus (0.1.1)
ncurses (0.9.1)
rack (1.0.1)
rails (2.3.5)
rake (0.8.7)
rubyforge (1.0.4)
sequel (3.8.0, 3.7.0)
simple-rss (1.2)
sinatra (0.9.4)
sqlite3-ruby (1.2.5)
syntax (1.0.0)


activesupport 2.3.5 does seem to be present. but it was fixed by running:
$ gem install activesupport