Archive for June, 2007

Everyday Scripting with Ruby – Book Review

June 24th, 2007 by pyrat

I recently finished Everyday Scripting with Ruby written by Brian Marick

Apart from using the pickaxe as a reference this is the first book on pure ruby that I have read. One big advantage that this book has is it uses ruby in a different context instead of the “rails way� that I am used to.

Over the last year I have been writing more and more scripts; mostly in Ruby and Bash. I have written everything from basic copy scripts to a more complicated website crawler called the harvester. I wont speak any more about the harvester as I am not proud of its application! It was great to read a book about the black art of scripting and get a strong grasp of how Ruby can be utilised in this context.

I thoroughly recommend getting this book and reading it cover to cover. The book starts easy then progresses in difficulty so is more of a cover to cover read than a reference. Apart from the chapter on regular expressions which is the most detailed description of ruby regular expressions I have seen to date.

TDD


Brian also mentions TDD very early on and manages to do well to enforce it throughout the book. I definitely go for the TDD approach when developing rails applications and plugins (wrote my first last week!) but have yet to use it for script development.

I am of the mind that TDD is great if you go as far as to start extracting methods to a class. If however, you are just writing a simple single stream script as I mostly do, it is not worthwhile writing tests for something simple and throw-away.

Driving the Browser


(http://www.openqa.org/selenium/)
There is an interesting section in browser control which I did not know about. There is Watir and Selenium which can be used to control browsers from within ruby.

There is also the mechanize ruby gem which can be used to build simple crawlers. This is interesting when you think about what is possible. I remember back in the day Alistair Burns and I wrote a bot for planetarion which would login every few hours and then send an email to your phone if you were under attack. We wrote it in PHP4 and it was a fairly dirty script. Nowadays you could do the same in ruby in an embarrassingly little amount of lines.

Modules, Classes and Monkey Patching


There is a great description of the above and when you should do each. Shoud what you are writing be a module or a class. Do you just monkey patch to solve the problem? All is explained here.

Top marks for this book. Buy it if you can.

Grey Nomads

June 22nd, 2007 by pyrat

From super highways in the cities to dirt tracks, Grey Nomads are chasing their dreams and discovering a whole new world. David Mason is leaving home at 62 years of age. Although he has never driven more than a few kilometres from home before he is leaving his life as a father and grandfather for a nomadic existence, travelling the vast expanses of the Australia continent. David is a Grey Nomad.

Defn: Monkey Patch

June 19th, 2007 by pyrat

monkey patch

Railsconf Europe Here I Come

June 19th, 2007 by pyrat

Robert Taylor at iformis is kindly sending me to Railsconf Europe in Berlin.

I’ll be keeping my ear to the ground and checking out all sorts of things on the bleeding edge.

The tutorials / sessions I am planning on going to as of now are as follows:

Monday

  • BDD Tutorial

  • Scaling Rails in Europe Tutorial

Tuesday

  • Deployment and Continuous Integration from the Trenches

  • Meta-Magic in Rails: Become a Master Magician

  • Utilizing Amazon S3 and EC2 in Rails

  • Xen and the Art of Rails Deployment

Wednesday

  • Building Rich Internet Applications with Flex and Ruby on Rails

  • Ruby on Rails Security

  • Browser-based Testing of Massive Ajax-using Rails Applications with Selenium

  • Outsourcing to Open Source

  • Obscure Data Formats, Workflow, and Remote Synchronization

I might change my mind! And hopefully the brain will be able to handle the influx!

Spamtrap

June 11th, 2007 by pyrat

Spamtrap

“Spamtrap”–watch the video

Spamtrap: a creation by the artist bill shackelford. It would be ace to work on a project like this.

Database Administration on a VPS

June 10th, 2007 by pyrat

Lets say you are setting up a lightweight VPS for hosting a rails stack. You install Nginx a high-performance HTTP server and reverse proxy with a small memory footprint and doesnt leak memory like my scirocco leaked petrol.

You also install mysql and tweak it like a mofo to decrease the memory usage and increase speed. You also install mongrel and mongrel_cluster to make scaling a reality for when your app hits the big time. It hasnt quite yet; so one mongrel process in the cluster will do for now :-)
You also configure a firewall, update ubuntu to the latest version, change ssh ports and make the server pretty lightweight and secure.

Usefuljaja has a pretty good guide on VPS setup.

Also, props to the amazing nginxconfiggenerator which makes setting up this beast from the motherland a sinch.

Now database admin. I like using phpmyadmin for simple database tasks. I have command line skillz but there is something about the visual representation in the browser that appeals to me. Does this mean I need to install php, fastcgi and lighttpd; or the industry heavyweight and Macdonald’s fan Apache2? Nope! Just setup a tasty ssh tunnel to port 3306 on the VPS and use a local install of phpmyadmin! It is pretty fast and works really well for simple tasks.

Also something like wamp or instant rails will give you a phpmyadmin install in a couple of minutes.

There is something about a VPS which gives you a new sense of power and the feeling that your hosting is truly in your hands. Out with the shared, in with the VPS!

ruby mongrel pound server polling script

June 7th, 2007 by pyrat

A simple polling script I wrote in 5 minutes to check that racentries is still up. When it falls over; which it does sometimes the script ssh’s into the server and call a pound / mongrel restart script.

Hopefully moving everything over to slicehost soon and can use something a little more powerful such as monit to keep my processes in order.

Pidgin to increase productivity

June 5th, 2007 by pyrat

I use GTalk a lot over at Iformis We use it for text talk and voice chat all the time. The only problem with it is that it is pretty tightly coupled with Gmail.

Now a lot of people are saying that you should stop checking your email as much and only look at it twice per day.

Something about endorphins released when you send an email causing problems with the completions of your other tasks. As you are already forfilled from the email postage.

Also, interruptions are bad etc etc there are loads of other benefits just read the links above.

Anyway, as google talk keeps telling me how many emails I have waiting (you can turn off the notifications but not the number unread) this is a problem for me keeping checking email.

Enter pidgin the program formerly known as Gaim. It has jabber integration functionality which means that it works on the google talk network! Hurray no more email notifications, we can now all live a more productive, less interrupted life.

Buachaille Etive Mor and Mountain Navigation

June 4th, 2007 by pyrat

Buachaille Etive Mor (The big herdsman of the glen) is an iconic scottish hill / ridge line in glencoe.

It makes a great point to point hill run as I found out yesterday with Robert Munro.

As you can see by the route it is a point to point run starting at Lagangarbh and finishing at Dalness. We achievied this using 2 cars but you could quite as easily drive to dalness with one car then hitch a lift to the start.

In terms of the details of the route, there is a fairly good path the whole way to keep you right.

However, the mist was down yesterday and a word of warning, a map and compass is required for this route and it was very handy yesterday in the thick mist.

You can see by the route that we made a couple of errors on the tops. After we arrived at the summits we did not check our direction the first few times and this caused us to run down the wrong ridge / corrie.

  • Always check your compass when you are about to descend.

The run took 3 hours 5 minutes; a good jaunt for a Sunday.

We stopped at the Real Food Cafe on the way back for some tasty food. I had a top class Lamb Burger.

I was thinking about getting a soup but then saw that it was £3.25!! so I went hungry and ate smart price bourbons in the car instead.

Mod a cheap torch into a super duper torch.

June 1st, 2007 by pyrat

Lifehacker directed me to this great video. (Its embedded for all you rss kids.)




$10 Police Flashlight Hack!–video powered by Metacafe

Im going to try this myself and will let you know how it goes, battery life etc.