Oauth presentation

December 2nd, 2009

He is a copy of my Oauth presentation [806 kB] from tonight’s WellRailed group. I discussed Oauth from both a client and a server perspective. Plenty of examples from Sharesight, where we are building an API.

Here is the example test.rb

I also discussed LoadStorm.com, which has a free plan that allows up to 50 simultaneous users. I recommend you check them out.

Korimako (Bellbird) iPhone ringtone

November 27th, 2009

bellbird
I’ve been enjoying listening to New Zealand native birds as ringtones on my iPhone. Here is one of my favourites – the Korimako, or Bellbird [164 kB].

You are welcome to share this with your friends and redistribute – as long as you retain the copyright information contained within the file.

To add it to your iPhone, just download the file and then double click it. It should open iTunes and import itself. It will be copied to your iPhone next time to connect it to your computer.

Let me know in the comments if you like it, and I’ll create some more. Any requests?

Recession Busting Free Offer

October 1st, 2009

special-offer
There’s a recession on at the moment, and we’re doing our bit to help ease the pain.

Able Technology is offering a free half-day session with one of our technical consultants. You can use us for any of our usual services during this time.

We have up to four slots available – one for each week in October. The weeks are:

  • 5 October – taken
  • 12 October – taken
  • 19 October
  • 26 October

To apply, speak to Nigel on 0800 14-ABLE (0800 142-253).

Small print

  • First-come, first-served
  • No strings attached
  • For new customers only
  • Not available to our competitors

Macbook Pro Speed Test

September 11th, 2009

With the Sharesight test suite (ruby/rails/mysql && rake test), i tested the performance of my the new MBP on Snow Leopard.

I save 16 seconds per run – its going to take a while to pay for itself…. But about 22% faster, which is not too bad.

Macbook Pro (March 06) 1.83GHz 2G Ram
real 1m29.464s
user 0m50.348s
sys 0m5.812s

Macbook Pro (Sep 09) 2.53 GHz 4G Ram
real 1m13.450s
user 0m43.662s
sys 0m3.280s

Installing Centos on VMWare Fusion

August 5th, 2009

I recently created a couple of Centos virtual machines, and took notes of all the steps. You can use these notes for both installing another VM, or for building a production server.

We used these VMs for running staging and production instances of a Ruby on Rails deployment.

Install Centos 5.3 64 bit

VM configuration settings

- Redhat Linux Enterprise 5 64 bit
- 30 GB drive
- 2 CPU
- 1 GB memory
- Network: bridged

Server install settings:

- use default settings for drive partitions
- set network address to: IP_ADDRESS_GOES_HERE IP version 4
- hostname: HOSTNAME
- gateway: GATEWAY
- primary dns: DNS1
- disable IP version 6
- net mask: 255.255.255.0
- timezone: Pacific/Auckland
- System clock uses UTC: tick
- set root password to PASSWORD_YEAH_RIGHT
- Additional tasks: none

SETUP TASKS

- yum update
- yum install sudo
- adduser nigeluser
- passwd nigeluser
- adduser marcususer
- passwd marcususer

visudo

- add lines at bottom of file:
nigeluser ALL=(ALL) ALL
marcususer ALL=(ALL) ALL

PACKAGES

- sudo yum install ruby
- wget http://rubyforge.org/frs/download.php/58677/ruby-enterprise-1.8.6-20090610.tar.gz
- tar xvfz ruby-enterprise-1.8.6-20090610.tar.gz
- sudo yum install httpd
- sudo yum install gcc-c++
- sudo yum install zlib-devel
- sudo yum install openssl-devel
- sudo yum install readline-devel
- sudo ./installer (ruby tar directory)
- sudo ln -s /opt/ruby-enterprise/bin/cap /usr/bin/cap
- sudo ln -s /opt/ruby-enterprise/bin/capify /usr/bin/capify
- sudo ln -s /opt/ruby-enterprise/bin/erb /usr/bin/erb
- sudo ln -s /opt/ruby-enterprise/bin/gem /usr/bin/gem
- sudo ln -s /opt/ruby-enterprise/bin/integrity /usr/bin/integrity
- sudo ln -s /opt/ruby-enterprise/bin/irb /usr/bin/irb
- sudo ln -s /opt/ruby-enterprise/bin/rails /usr/bin/rails
- sudo ln -s /opt/ruby-enterprise/bin/rake /usr/bin/rake
- sudo ln -s /opt/ruby-enterprise/bin/rdoc /usr/bin/rdoc
- sudo ln -s /opt/ruby-enterprise/bin/ruby /usr/bin/ruby
- sudo yum remove ruby
- sudo yum install httpd-devel apr-devel
- sudo yum install mysql-devel
- sudo /opt/ruby-enterprise/bin/passenger-install-apache2-module
- sudo yum install mysql-server
- sudo /sbin/chkconfig httpd on
- sudo /sbin/chkconfig mysqld on
- sudo yum install ncurses-devel
- wget http://downloads.sourceforge.net/sourceforge/htop/htop-0.8.3.tar.gz?use_mirror=transact
- tar xcfz htop-0.8.3.tar.gz
- cd htop-0.8.3
- ./configure
- make
- sudo make install
- wget http://kernel.org/pub/software/scm/git/git-1.6.3.3.tar.bz2
- bunzip2 files/git-1.6.3.3.tar.bz2
- tar xvf files/git-1.6.3.3.tar
- ./configure
- make
- sudo make install
- sudo gem install mysql –no-rdoc –no-ri — –with-mysql-config=/usr/bin/mysql_config

START APPS

- copy /system/mysql/my.cnf to /etc/my.cnf
- sudo /sbin/service mysqld start
- /usr/bin/mysqladmin -u root password ‘PASSWORD_GOES_HERE’
- sudo /sbin/service httpd start

CAPISTRANO

- cap staging deploy:setup
- cap staging deploy:cold
- cap staging deploy

CONFIGURE

- sudo /usr/sbin/adduser deploy
- sudo passwd deploy

VMWARE TOOLS

- Login as root
- Select from VMware Workstation: go to VM> Install VMware Tools
- mkdir /root/mn
- From the VM: mount the virtual cd drive , this should be done with the guest OS (CentOS ) command line:
mount /dev/cdrom /root/mn
- From the CDROM extract VMware Tools into /tmp/ directory
tar -C /tmp -zxvf /root/mn/VMwareTools-5.5.3-34685.tar.gz
- Running VMware Tools installation/setup script
cd /tmp/vmware-tools-distrib
./vmware-install.pl
- This is VMware Tools installation/setup script, it will ask for confirmation to begin the installation
answer the defaults for each question
- when done, restart the VM (shutdown -r now)

using git submodules for plugins

July 15th, 2009

# first remove your copy and paste plugin….

git rm -r vendor/plugins/xxxxxx
git commit

now you are ready to add the submodule

git submodule add git://your_git_repo/xxxxx.git vendor/plugins/xxxxx
git commit

To load the submodule, you need to

git submodule init
git submodule update

To deploy submodules using capistrano, capistrano needs to also do the submodule init and update.

# in deploy.rb
set :git_enable_submodules,1

if you want to update the version of the submodule – or the branch
cd into the plugin, git pull or git checkout branch
then cd back to the containing project and git commit

serving php from a rails app with passenger

June 21st, 2009

We have a situation where we want one domain which serves a rails app at root and also has a wordpress blog served within the main site.

yours.com/  --> served by rails
yours.com/blog --> served by php

To configure this in apache,

The key is the PassengerEnabled – else passenger will try and serve the php content.

Installing Ruby Enterprise Edition on Mac OSX

June 18th, 2009

This is quite trivial and very easy. I wanted to use the same version of ruby on my mac as is running on our production servers (Ruby Enterprise Edition).

Firstly, do a

gem list

and keep this information. You will need to reinstall all your gems once you have successfully installed REE.

Download REE from http://www.rubyenterpriseedition.com/

tar xvfz ruby-enterprise-X.X.X
sudo ./ruby-enterprise-X.X.X/installer

I suggest changing the default location to just /opt/ruby-enterprise – as you are unlikely to need to roll back the symbolic links in your development environment.

Once it is installed, then you need to make sure that you use it for all your gems, ruby, rake tasks. To do this we will sym link in all the executables into /usr/bin

Find any previous versions of ruby

whereis ruby

and

which ruby

Cleanup – backup and remove any old versions and the associated ruby, gems, rake, irb, cap, capify, erb so they are not on your path.

Then sym link from /usr/bin to opt/ruby-enterprise/bin with all the executables that you may require….

sudo ln -s -f /opt/ruby-enterprise/bin/ruby /usr/bin/ruby
sudo ln -s -f /opt/ruby-enterprise/bin/cap    /usr/bin/cap
sudo ln -s -f /opt/ruby-enterprise/bin/capify /usr/bin/capify
sudo ln -s -f /opt/ruby-enterprise/bin/erb    /usr/bin/erb
sudo ln -s -f /opt/ruby-enterprise/bin/gem    /usr/bin/gem
sudo ln -s -f /opt/ruby-enterprise/bin/irb    /usr/bin/irb
sudo ln -s -f /opt/ruby-enterprise/bin/rails  /usr/bin/rails
sudo ln -s -f /opt/ruby-enterprise/bin/rake   /usr/bin/rake
sudo ln -s -f /opt/ruby-enterprise/bin/rdoc   /usr/bin/rdoc

Do a gem list to see what ruby-enterprise came bundled with.

Now you will need to install all your gems again – that you noted earlier.

rails legacy database migration

June 4th, 2009

Just migrated a legacy database into a rails compliant database – and wrote this nifty DSL script to help out….

The rake task generates the Hash data for the table creation, data insert and rollback scripts.

Once you run the rake task, paste the output into the migration modify the update table and column names – then run the migration.

Performance issues with sub-queries in MYSQL 5

May 7th, 2009

I just recently spent some time with a client investigating some performance issues with mysql subqueries.

The obviously contrived example below

Depending on data size the query can run very slow. When running two queries and pasting in the actual IDs the query runs extremely fast.

The good news it is looks like it is fixed in version 6.0 – looking forward to it becoming a production release….