Monday, April 19, 2010

Books and films

My last post left me feeling like Will Freeman, a character in Nick Hornby's novel, "About a boy". As Will doesn't work, he has to find things to do, and so divides his day into half hour units (breakfast - one unit; taking a bath - two units, etc). I was going to quote his calculations from the book, but when I looked there, it turns out that there is no such monologue. Instead there is a calculation about how cool Will is. So where did the time units come from? Obviously from the film, starring Hugh Grant. *

The film adaptation of "About a boy" was fairly accurate until about two thirds of the way through the book. The two diverge when (in the book) Marcus takes a train journey to Cambridge in order to see his father; he is accompanied by Ellie. On the way, things take a wrong turn.... None of this is in the film, probably because it hinges upon Kurt Cobain, and maybe the film producers couldn't get clearance to use the late Cobain in the film - or maybe they reckoned that the film's audience wouldn't know who KC was. So instead, film viewers got Marcus rapping in the corridors along with the school concert.

"The time traveler's wife" has been made into a film, and I was able to watch it today, courtesy of the Internet. Whilst this adaptation is more faithful that "About a boy" in that it doesn't introduce new material (except for the final scene), it leaves much more out. That's hardly unavoidable, as a quick glance at the book shows: the book is written in the first person (although alternates between Claire and Henry) and has very rich prose, whereas the film naturally is third person, and the special tone of the writing is absent.

It's not a bad film by any means, but it wasn't particularly special. Some of the photography was very good, making it a visual treasure, but some parts seemed to be very obviously filmed against a blue screen. As always, it would be interesting to hear the thoughts of someone who had seen the film without having read the book.

* Edit from 13/10/16: I reread "About a boy" yesterday and came across the time units in chapter 12. "Reading the paper, having a bath, tidying the flat" are all activities requiring one unit.

Saturday, April 17, 2010

A typical Saturday

I've noticed over the past few months that I have been planning on a hourly basis how to spend my Saturdays, nominally my day of rest. There always seems to be so much to do and so little time in which to do it that one needs to prepare in advance in order to get the maximum utility (a little economics creeping in there).

Normally, the day consists of two episodes, each two hours in duration, of programming; one two hour session reviewing the material taught in the MBA class the day previously; one two-three hour session of cooking and spending time with my father (today we're having chicken ratatouille, with a slight variation of last time's recipe); one two hour session transferring to dvd a film recorded earlier in the week which I didn't have time to watch. There is also the dog who has to be walked.

Today's schedule was upset by devoting what would normally be the morning programming session to creating a new mix cd for my wife. As usual an eclectic mix, moving from the well known (Jackson Browne, Joni Mitchell, CS&N, The Band) to my folk rock roots (R&L Thompson, Sandy Denny, Nick Drake), interspersed with a few left field contributions (Heron, Colin Blunstone, King Crimson, Robin Frederick, Dar Williams). The response hasn't been too positive yet, but I am hoping that the disk will be played frequently in the car and will become more familiar.

Friday, April 16, 2010

Travelling by train/Outliers/Memories of school

Instead of working in my office this week, 5 km from my home, I've been travelling almost every day to different branches of my company. On Monday I was in Tel Aviv, Tuesday Haifa bay, Wednesday Carmiel and Thursday Tel Aviv again. Some of my fellow workers wondered whether I was healthy, as they haven't seen me for several days.

Every day I travelled by train; I've been getting to recognise many of my fellow travellers. Of course, I don't know their names, but I often assign them nicknames, not necessarily complimentary. I wonder if they notice me and whether they have assigned me a nickname too (that sour looking bloke who's started travelling every day instead of once a week).

The reading material for the past week has been the Hebrew translation of "Outliers" by Malcolm Gladwell. Normally I wouldn't read a book in Hebrew which was originally written in English; I was given the book at Pesach by my occupational psychologist and it was too complicated to arrange to swap the book for the original version. Probably I lost some of the wit and inferences present in the original, but I'm fairly sure that I got the gist of the book. It was a bit repetitive, and some of the material is downright wrong (the Beatles could not have racked up 10,000 playing hours before they became famous), but the pros outweigh the cons. The basic thrust of the book is that no one succeeds on their own; everybody needs a bit of luck and opportunity. Sometimes one has to be born in the correct month of the year.

The book starts with an analysis of junior Canadian ice hockey players; Gladwell points out that one stands a much better chance of being picked for a junior hockey team and then be trained if one is born in the first three months of the year (Jan-Mar). When comparing eight year old children, there is a big physical difference between an eight years and eleven months old child as opposed to an eight years and one month old child. 

I was such a child who theoretically suffered from being born in the wrong month. My birthday is in August, and the British school year started (maybe still does) in September, so I was always one of the youngest children in my class. I certainly don't remember any problems about this whilst in junior school (upto age 11), but then we didn't have competitive sports there. The problem was recognised at my grammar school: during the winter and spring terms, when we played rugby, everyone was classified as under-12 (this was the first year). But when the summer term arrived and we played cricket, suddenly most of the children were in the under-13 age group whereas I was still in the under-12s. There wasn't an under-12s cricket team (as there were so few of us), but I did take part in an swimming competition as an under-12 with few competitors. The following year, we were all under-13s, but when the cricket season arrived, again most children were now under-14s whereas I was still under-13 and played with children in their first year. Thus theoretically I was compensated for having been born in August.

Academically, all of the above was irrelevant. As it happened, 40% of the students skipped a year between what would have been their second and fifth years (ie we took our 0-levels after four years whereas 60% of the students took their 0-levels after five years). As a result, when I was in the 6th form, I was with students who were nearly two years older than me; I remember that in my final year, one of the boys in my class used to drive a car to school, whereas I had barely cleared my sixteenth birthday.

I also left school at sixteen, albeit at sixteen and ten or eleven months. The uncertainty arises because it's not clear exactly when I finished school; during the final term we had A-level exams, which meant that we had no lessons and were at home revising. To complicate matters, my parents moved from Bristol to Cardiff before I finished the exams, so once I had to catch the train from Cardiff to Bristol in order to "sit" an exam (if I remember correctly, it was a practical exam in Chemistry, so no one sat). I know that I came to the 'final assembly', which would have been in July 1973, but again I came on the train and I did not come in school uniform.

Sunday, April 11, 2010

Surprised and pleased

I heard some whispering at college on Friday about exam results but thought that it was too early: the results take two months to arrive and only one month has passed. Over the weekend, I completely forgot about this, but managed to remember this afternoon. I logged into the website that lists results and ...

Punch the sky! Bring out the champagne! Not only did I pass my exam in Organisational Behaviour, but I also achieved the reasonable mark of 66%, much better than I had expected. So I am both surprised and pleased!

Driving lessons

I spent one of the afternoons when I ill with the flu watching a rather quirky British film called "Driving Lessons". I thought the film a bit odd when I had an elevated temperature, and watching it a second time when feeling more normal only confirmed my original suspicions. Maybe the best thing about the film is that includes a Richard Thompson song in the soundtrack ("One door opens") and an obligatory (these days) Nick Drake song (part of "Pink Moon"). 

Thinking about the film later, many questions popped into my mind, mainly about the characters' motivations:
  • How could Ben (Rupert Grint) be so gauche at the age of 17?
  • Why was Laura Linney - an American - cast in such a quintessential British film? How could her character - a vicar's wife - have no qualms about committing adultery with the parish's junior priest? And even worse, how could she do it whilst leaving her son in the car outside, whilst ostensibly giving him an eponymous driving lesson?
  • When was Evie (Julie Walters giving a fantastic performance) lying and when was she telling the truth? Was she really a Dame? Was she really suffering from cancer (presumably not, as she denied that one herself)? How did she manage for money? When she and Ben went camping, Ben had to pay for the campsite. The next minute, they have driven from somewhere (presumably near London) to Edinburgh, showing no signs of tiredness. Who paid for the petrol on the way? If presumably they had money, so why did Evie pawn a ring in order to give Ben money "to buy a clean shirt". How did she pay the hotel bill for her drinks and Ben's room?
  • What was Bryony's motivation in seducing Ben? Did she sleep with every boy that she met? The entire Bryony episode seems in retrospect designed solely to give Ben a reason not to accompany Evie to the poetry reading.
  • How could Sarah be so stupid to say what she did to Ben at the end of the film? Every son wants to hear about his mother's infidelity...... I thought that maybe she would empathise with him, but she appeared to be still under his mother's spell.
I find my reaction to this film interesting because I was able to find so many things unexplicable within the film, and yet I enjoyed it. I later watched a film called 'Smother' (with Diane Keaton) which coincidentally has a similar theme, about a son trying to build his own life apart from a domineering mother. No doubt this film had a budget much bigger than that of 'Driving lessons', and in my opinion it was much worse, by about the same factor. But why? Because it's an American film? Because it got on my nerves? 

British films tend to be much more realistic, featuring people who could easily have lived next door to me when I lived in Britain (at this moment, I will note that Dr David Owen, at the time Britain's Foreign Secretary, lived about three houses away from me when I lived in London). American films tend to populate some kind of fantasy world, and one could never imagine Diane Keaton living next door (as much I would like to) or even her son, Noah.

Saturday, April 10, 2010

Speaking the statements

My last blog, from a few days ago, hinted that the next entry (ie this one) would be about programming. Shortly after writing those lines, I went to bed and woke up the next morning feeling extremely weird. It turns out that I had a temperature of 38.5 degrees, which is why my head felt like it was full of cotton wool. Fortunately, it was only a mild case of flu, but it had the effect of taking me out of the loop for a few days. Wonderdog was giving me strange looks all this time, implying that I could take her for a ramble in the fields instead of lying around and doing nothing, but I think I'm back on the case now.

As I have written before, my occupational psychologist's flagship exam consists of 400 statements: each person has to mark whether they agree or not with the statements (eg "I usually feel nervous and ill at ease at a formal dance or party", "I have at one time or another in my life tried my hand at writing poetry"). The theory behind the exam is that each statement belongs to one or more scales, and dis/agreeing with a statement either increases or decreases one's affiliation to that scale. From these scales are built one aspect of a person's psychological profile.

Completing this exam takes about 40 minutes, making it harder than one might expect. The two statements which I quoted above make it fairly easy to decide whether to agree or not, but some are more complicated, generally revolving around moral issues. Some tend to be ambiguous, so it's difficult to decide if one agrees or not. Anyway, the psychologist suggested that people with learning disabilities might have difficulty in reading and understanding the statements, let alone answering them. Thus was born the idea of the exam speaking the statements.

Well, of course, the exam itself, being a computer program, can't talk (although 20 years ago I spent much time with a blind person, a speech synthesizer and text-to-speech software which was years ahead of its time). So in January I recorded over two evenings a well spoken lady reading each of the 400 statements. Since then, I have been editing those recordings into a series of 400 wave files, each file containing one statement being spoken. This is a very tedious process, which is why it took me so long to do. During the Passover holiday, I decided that I would edit one big file (5 minutes, about 35 statements) a day; I actually managed to keep to this schedule and finished creating all the files.

Then came the fun of getting these files into a Delphi program. This is actually a lot easier than it sounds. First, I needed to declare a resource file listing all of the wave files and their statement numbers. This is a text file (rc) which looks like this:
q1 WAVE q1.wav
q10 WAVE q10.wav
q101 WAVE q101.wav
q102 WAVE q102.wav
q103 WAVE q103.wav
q104 WAVE q104.wav
q105 WAVE q105.wav
There are 403 similar lines. This text file is then passed to the resource compiler, which produces a compiled resource file (res). As there are many resources used and they're all large, this file is about 40 megabytes in size (whilst today this may be considered small, I recall that the first hard drive I ever bought for my XT-compatible computer in the late 80s had a 20MB capacity!). Linking this file into the Delphi executable is trivial; accessing each wave file within the resource is also fairly simple, with the use of the following procedure:

Procedure TMivhan.PlaySound (n: integer);
 hFind, hRes: THandle;
 song: pchar;
 question: string[6];

 question:= 'q' + inttostr (n) + #0;
 hFind:= FindResource (HInstance, @question[1], 'Wave');
 if hFind <> 0 then
   hRes:= LoadResource (hInstance, hFind);
   if hRes <> 0 then
     song:= LockResource (hRes);
     if assigned (song)
      then SndPlaySound (song, sndflags);
     unlockResource (hres)
   FreeResource (hFind)
The procedure is called with a statement number (eg 1). The first line in the procedure creates a string variable, prefixing the statement number with 'q', so that the string will match the name of the wave file in the resource file (that's the "q1" in the line "q1 WAVE q1.wav"). The trailing zero in the string is because the string has to be passed to an internal Windows function (FindResource), and this needs a zero terminated string.  "@question[1]" is a zero terminated string which is also lacking the length byte at the beginning of the Delphi string - this is a time honoured method of converting Delphi strings to C strings, as needed by Windows. The rest of the procedure deals with extracting the required resource from the executable file and 'playing' it. This is very much black box code and needn't be explained (and in case one asks, I took this code from an excellent article on the subject.

A note about the parameters passed to the Windows procedure SndPlaySound: the first parameter is a pointer to the wave file, and the second parameter controls how the sound should be played. Earlier in the program, the global variable 'sndflags' was set to the value 'snd_Async or snd_Memory': play the sound asynchronously from memory. This is generally the way that one wants the sounds to be played, so why did I use a variable instead of using the constant values each time, as the article does?

The answer has nothing to do with my procedure and everything to do with the program. At the beginning, the instructions how to use the program are read out, via this procedure. I discovered that sounding these instructions asynchronously and then sounding the first statement displayed asynchronously caused the instructions not to be 'sounded' at all. Should the procedure be called whilst a wave file is being played asynchronously, the second wave file will cause the termination of the first wave file. I thus caused the instructions to be 'sounded' synchronously - the user can't do anything with the program during this time - and only afterwards are the statements 'sounded' asynchronously. Instead of putting a conditional statement in the PlaySound procedure to define the flags, I used a global variable which is set to 'snd_Sync or snd_Memory' before reading the instructions, and then permanently to 'snd_Async or snd_Memory'.

Monday, April 05, 2010


I've been on holiday for the past week, spending all the time at home. Maybe it looks like I've been doing nothing, but actually I've made good use of my time. I've been reading (and completing) a book a day, I've been doing some good programming (more about that next time) and I've been cooking every day, trying out some new recipes.

Here's a recipe for what has been termed "Chicken ratatouille" (if you want to impress your friends, note that 'ratatouille' contains all five vowels, although not in the correct order. 'Facetious' is a shorter word which contains all five vowels in the correct order). This is a very simple dish to make, especially for those who feel challenged in the kitchen. One dices vegetables, such as onions, red and yellow peppers, courgettes, sweet potato and potato, and spreads the mixed, diced vegetables into an glass oven dish. I put greaseproof paper into the dish first and poured the vegetables onto this, but I doubt that this is essential. One then drizzles olive oil onto the vegetables. On top of the vegetables one puts slices of chicken breast (the bigger the better) and these are also drizzled with olive oil. Into the oven for about 45 minutes at 180 degrees Centigrade. I probably turned over the chicken breasts after about half an hour and maybe even stirred the vegetables a little. 

That's all! The family were very pleased with the dish, although they thought that they were eating fish at first (that's before tasting)! The chicken breasts shriveled somewhat whilst cooking, which is why they should be fairly large prior to cooking.