Tuesday, June 10, 2008

Elderflower Cordial

Its that time of year again when the Elderflower bushes are all in bloom. Its very easy to make your own cordial.

30 x flower heads from a bush cut in the sunshine
3 x lemons
1 x 60g packet of citric acid
1 kg of sugar

You will also need 2 big pans and a bit of net curtain or a pop-sock or half a pair of tights for straining the flowers through.

  • Put the flower heads and lemons cut into quarters into the pan.
  • Cover with boiling water, bring to the boil and leave over-night.
  • Fish out the bulk of the flowers and lemons with your fingers and put them in the bin.
  • Attach the pop-sock over a jug so that only the poring lip of the jug escapes the sock. In this way you can pour the unfiltered brew into the sock then pour filterd liqued out of the jug into a second pan. 
  • Pour all the Elderflower tea a bit at a time into the filtering jug described above. 
  • Add the sugar and citric acid to the filtered brew and bring to the boil.
  • Allow it to cool and bottle it.
You can now use it diluted like you would any squash.

Mmm a taste of summer. Make up a jug of it chilled with slices of lemon and ice cubes or use fizzy water.

Sunday, June 8, 2008

Trip to Moscow

Bit of a retrospective blog, this one.

Last year I presented at SD Best Practice Moscow.

It was a fantastic experience and I very much enjoyed Moscow.

I deliberately stayed near the centre away from the conference hotel so that I could experience a bit more of the real Moscow.

A weekly Metro ticket was very cheap, and I was very please with myself for learning and reciting enough Russian to buy my pass.

The art and decor of the Metro is amazing, as are the escalators, which go up and up and up and ... amazing feats of engineering, far longer than anything in the London underground.

Not many people in the street spoke English, so its worth having a phrase book and learning to pronounce the place you are looking for. Its also polite.

I found people perfectly friendly and willing to help the stupid foreigner find where he was looking for. 

Wandering about, sometimes even late at night seemed safe. I didn't see anything untoward. But I may just have been lucky. 

I can recommend a visit to the VVTs - see your guide book. Its easily accessible from the Metro and its nice to wander about. 

At the far end of the park from the Metro is a Vostok rocket. Just sitting there, unguarded largely ignored by all all except me who - as a lover of all things spacey was mightily impressed. It was smaller than I expected and top marks for courage to Uri Gagarin for sitting on top of what is basically a prototype ICBM.

The contrast was even more start for me as the week after I was in Florida and visited the Kennedy Space Center. The understated and free nature of the Vostok rocket was really refreshing. The informality and complete lack of commerciality was great. It was a real reminder of the achievements of this remarkable nation. 

It reminded me of the tale about the urban legend of the Americans spending a million dollars developing a pen that would write in zero gravity. The Russians just used a pencil !

The impression I was left with of Russia was one of a people with brains and pragmatism.

A nation with very much to be proud of.

Saturday, June 7, 2008

Debugging a live Ruby on Rails server

This just something useful that occurred to me that is probably blindingly obvious to seasoned rails people out there.

We have a Rails application hosted with Apache and a Mongrel cluster running in production mode. That means if something goes bang, to see what happened you have to go to /log/production.log to see what happened. This system is for internal use to its considered acceptable to reproduce problems quickly on the server and even fix there and copy back to the repository. Mainly because thats much faster. The problem is that you have to restart the cluster every time you change anything.

What occured to me was that to reproduce bugs I could leave the cluster running normally, but just start another instance of the application running on another port in development mode by doing:

script/server -p 4000

I can then hit the controllers running on those pages and see the error messages and trace.

So there you go - a bit trivial, but it saved me some time yesterday.

Tuesday, June 3, 2008

Extending core Classes in Ruby on Rails

While I was tinkering with our agile tracker tool, I had the need of a first_of_month method that would tell me the first day of the month of any particular day. In a less flexible language, you are limited to the choices of:

  1. write a 'utility' class which is just a bucket of useful methods - not very elegant and ugly too use.
  2. extend the built-in Date class and add your own methods - not very convenient because you have to remember too use the class 'MyDate' everywhere
What Ruby lets you do is simply add your own methods to existing classes! This is exactly what's needed.

To do this in rails, simple create a new file in your 'lib' directory called date_extension.rb and put the following code in it.

class Date

  def first_of_month
    return Date.new(self.year, self.month, 1)


To get Rails to load this extra method, you need to add the following line to your 'config/environment.rb' file.

require 'date_extension.rb'

Thats it! You'll need to restart Rails to see the change, but then you can use the new method anywhere in your controllers or templates. For example:

first_of_month = Date.today.first_of_month

You can do the same with String and add your favourite starts_with? or whatever methods.

Old Languages - Lisp

I have a certain nostalgia for old programming languages. So here are a few notes about Lisp.

Lisp is an old old language - it was originally specified in 1958. I spent a happy three years in the 1980's on a small team writing a frame-based constraint-satisfaction system that automated the layout of chemical plant. 

I also implemented an Object-Oriented Database System (CLOSQL) in it as part of my PhD. So, don't think of it as a 'novelty' language, this is an elegant and powerful language.

Its a functional language - that is, everything is expressed as a function using a parenthesis notation. Thus you would add 2 and 2 together by writing:
(+ 2 2)

It uses lists as its data structure, and lists can contain lists to make trees.

Even the programs themselves are lists. The first part of the list (the head) is the name of the function and everything else in the list are its arguments.

(let ((n 0))
(when (> n 10) (return))
(print n)
(incf n)))

See how the 'let' function contains a list of variables (just n in this case) that are then in scope for the rest of the 'let' command.

Lisp has loads of clever stuff, like being able to create anonymous function blocks called lambda blocks that can be passed around as arguments to functions, in much the same way as blocks in Smalltalk and Ruby.

Remember 1958 !!