Wednesday, March 27, 2013

Lost videocassettes reappear

My wife was cleaning out some cupboards the other day in the hope of finding some new storage space. To the surprise of us both, she discovered a hoard of video cassettes which we must have forgotten about. Almost all of the cassettes held recordings of television programmes, which have long left our television screen but not from our memory: Cold Feet, Coupling, Star Trek DS9, Star Trek Voyager. 

As I have the complete Cold Feet series on dvd, I had no problem in throwing those cassettes away. I'm not too interested now in watching old Star Trek episodes (especially as a few seasons of DS9 weren't shown here) so discarding them also wasn't a problem. I have 'Coupling' stored on my computer, but only after throwing them away did I remember that the computerised episodes have no subtitles whereas those televised episodes did. A little regret there.

Out of maybe thirty cassettes, there were four which interested me greatly: one labelled Cropredy 2001 (I wasn't there that year; maybe this is a television programme), the Lindsay Anderson film "If ...", and two labelled "Forty something". These hold all six episodes of a British comedy/drama programme from 2003 starring Hugh Laurie and Anna Chancellor; I wrote about this series in one of my earliest blog entries, from nearly eight years ago.

I have just finished copying the video to dvd; this is done of course in real time, and it was a real pleasure to revisit the programme. I'm looking forward to watching "If..." again.

Sunday, March 24, 2013

Pictures from a balcony (5)

Today's first picture comes from the same spot as in earlier photographs: on the ground, looking up to the balcony. The panasit tree is sprouting leaves and it's becoming difficult to see the balcony behind. As we have shortly passed the spring equinox, the tree will blossom soon.

The second picture is taken from the stairwell, looking out from the house into the gardens. There's so much vegetation in the picture that it's difficult to get one's bearings. In the top left hand corner is the kumquat tree outside our kitchen window. 

Wednesday, March 20, 2013

Another Holy Grail achieved: sending email from a separate thread

As I have noted, I have spent no small amount of time updating and expanding the use of email in the Occupational Psychologist's management program. Email is now sent via GMail and works very nicely ... except for one not so small problem: when one is sending an email with an attached file, the program apparently stops working for a minute or so. The solution to this problem is to send the email via a separate thread but until now I have lacked the programming knowledge to implement this.

After playing around with a few ideas (and not succeeding), I decided to ask the question on Stack Exchange and received perfectly cromulent code from Mr Indy, Remy Lebeau. As written, this works perfectly.

What is missing is logging - previously, whilst the email was being sent, there was a certain amount of diagnostic information presented to the user which basically meant "Although the program appears to be hung, it is doing something which takes some time so please wait". Due to well known technical problems with displaying in the main program output created by a worker thread, Remy's code does not address this problem.

I attempted to add a few types of logging to the program, none of which were particularly successful. I am reminded of the old academic adage, which has a lecturer talking to a student about a paper that the student has produced: "There is much here that is original and there is much which is correct. Unfortunately, what is correct is not original, and what is original is not correct".

One partially successful attempt had the thread writing its log to a file which was opened and closed all the time. This seemed to work until the program sent two emails almost simultaneously: one thread could write to the log whereas the second couldn't. As usual, one has to be away from the keyboard in order to find a solution. The initial improvement which my thinking suggested would have each thread create a string list and write all its logging to its list; after sending the email, the thread saves the stringlist's contents to a text file (each thread has a separate file). Then presumably something would concatenate the text files so that the program could display the entire log. This would require some form of identification within the log so that the log of two emails which were sent within seconds of each other can be traced.

The problem with this solution is the 'something' that concatenates; if two people are running the program at the same time (as frequently happens), then they may interfere with each other. Running a daemon - a separate program which runs only on one computer - would solve this problem, but I am currently considering a third option: instead of writing the stringlist's contents to disk, the contents get written to the database. This means that each thread has to have its own connection to the database. This actually is simpler than it seems.

Following is the code which I added at the end of the 'execute' procedure in Remy's code.

  messagebeep ($40);

  ibdb:= TIBDatabase.Create (nil);
  with ibdb do
    loginprompt:= false;
    params.add ('password=masterkey');
    params.add ('user_name=sysdba');
    databasename:= dbdir;
    sqldialect:= 1;
    connected:= true;

  trans:= TIBTransaction.create (nil);
  trans.defaultdatabase:= ibdb;

  with TIBQuery.create (nil) do
    database:= ibdb;
    transaction:= trans;
    // add primary key via trigger
    sql.Add ('insert into emailog (msgnum, curdate, details)');
    sql.add ('values (:p1, :p2, :p3)');
    ParamByName ('p1').AsString:= FMsgNum;
    ParamByName ('p2').asdate:= date;
    for i:= 1 to log.count do
      ParamByName ('p3').AsString := log[i-1];

A few notes: 
  • The 'messagebeep' command has a parameter - I've always passed the value 0 to this function but it turns out that there are specific values producing specific sounds. The idea of including it in the thread is to give the user confirmation that the email has been sent. Making a noise doesn't compromise thread security.
  • 'dbdir' is a global variable whose value is the location of the database.
  • Databases are optimised for handling large amounts of data arriving in a short period of time. In the example above, there is a very small loop which basically sends some strings (in practice, seven) to the database, one after each other. Two threads could be doing this almost simultaneously - but the database can handle this easily.

Tuesday, March 19, 2013

Motorbikes (2)

I can definitely get used to my new motorbike! It's very quiet even though it's moving fast. The bike is heavier than the previous one - 110 kg as opposed to 85 kg - which becomes apparent when cornering or taking it on or off its stand. There is a bigger fuel tank - 7.5 litres - which means that I need refuel only once every three weeks (I'm assuming 20 km/l, which may be a modest assumption). Now that I think of it, my 120cc London bike's fuel tank capacity was 1 gallon and I used to get 100 miles/gallon. That seems to be equivalent to 35.2 km/l!

After posting those pictures the other day, I remembered that I had some early photos of myself and motorbikes. The first is from December 1970 when I was 14 - obviously too young to drive! I was just posing on my father's 50cc scooter on which I used to ride pillion every morning to school. I thought that the picture was from a year or two earlier. Unfortunately, the camera angle is too high: there's more tree than motorbike. Of course, in those days, the time between taking a photograph and actually seeing it could be a matter of days, if not months, so there was never any chance to review one's shots. Photography was so expensive that we never took multiple pictures; instead we took a long time framing the shots (obviously I didn't take this picture). It's not like today when there is instant review and one can take as many pictures as one likes.

The second picture is from June 1976, when I was nearly 20 (note the clogs which I had just started wearing). This is clearly taken outside of the house where I used to live in London and shows the motorbike in loving detail. There were a few other pictures from this time but they didn't concentrate on the bike.

Monday, March 18, 2013

Pictures from a balcony (4)

The first picture is not from the balcony nor of the balcony but rather the entrance to our building. From this angle, it's hard to see the entrance as the kumquats are hiding it. I am trying to give the impression that we live in a tropical paradise and that the vegetation hides ugly things such as buildings. That's not far from the truth.

For years, I wondered how we had such a vigorous kumquat tree on our side of the building as no one planted it and no one seemed to look after it. Presumably a seed fell from the tree on the other side of the entrance which took root; water came from the tap in the bottom right hand corner of the picture (if one looks closely, one can see a coiled hosepipe stored on the wall). There must have been a leak in the plumbing and the young kumquat drew its water from this source.

Whilst looking at the collection of pictures on my computer, I came across the one below which must have been taken just after the balcony had been built but before we had begun to decorate it. Somehow it looks larger in this naked state.

Sunday, March 17, 2013

Sumptuous Sunday 6

I see that I haven't written about cooking for some time. Over the weekend I cooked five different meals -
  • Friday lunch - grilled fish and vegetables
  • Friday dinner - roast chicken pieces, chipped potatoes, vegetables
  • Saturday lunch - grilled St Peters Fish, mashed potatoes, vegetables
  • Saturday evening - spaghetti with tomato sauce and grated cheese
  • For the coming week - chicken breast and vegetables
I wrote some months ago that I was making antipasti: dicing vegetables then placing them on a tray and baking them in the oven. Apart from the fact that this takes some time (30-35 minutes in a hot oven), it also uses electricity (to heat the oven). This isn't always a problem - for example, I cooked the chipped potatoes and chicken pieces in the oven at the same time on Friday evening - but sometimes it seems like a waste.

In order to avoid using the oven, I've been using a new technique for the past few weeks: using a ceramic pot which is called a 'garlic oven' in Hebrew.

One simply cuts the vegetables into little pieces then places them in the dish. I've discovered that it's easiest to take the bell part of the pot, invert it and then put the cut vegetables directly into the bell, instead of using another dish. When I've finished cutting, I put the base on the top of the pot and invert it again. 10 minutes in the microwave is the required cooking time!

I've had this pot for a few months after friends raved about it. At first, I was disappointed for I thought that the pot would give the vegetables a special taste, but after a while, I realised that this was a very quick and simple way to cook vegetables without losing any nutritional values. Regular steaming in the microwave requires a little water which probably leaches some vitamins B and C, but here there's no water at all.

Here's a picture of my grilled fish, along with the varicoloured vegetables and some mashed potato. To decorate the plate even more, I served the fish with a slice of lemon.

Due to the parsley which I sprinkled on the fish and the potatoes, it may be a bit difficult to tell them apart: the fish is on the right hand side of the plate whereas the mash is at the bottom.

Thursday, March 14, 2013

Minimising the overhead

One of the factories in my company works with wood: the first step in any process is to cut the planks into pieces of the correct size as needed for production. The planks normally are sized 2.44 X 1.22 metres, so several parts can be cut from one plank. Laying out the parts on the plank is a specialised job: someone who does this well can save a great deal of raw material. Naturally, this is a job for a computer - this kind of program is called an optimiser.

The optimiser too has its raw materials: the dimensions and quantities of parts which have to be cut. This information comes from our ERP program and is manually entered into the optimiser. Someone wondered whether it would be possible to create a file in the ERP program and then input the file into the optimiser, thus optimising the operative's time and reducing the number of mistakes. This is where I came into the picture.

"Is the optimiser capable of reading an external file?" was my first question, and when it was answered in the affirmative, my next question was "What is the structure of this external file?". The answer to this question was a long time coming. I started by analysing the structure of existing files; whilst I could see that there was a definite structure, its details weren't clear to me. The next step then was to contact the manufacturer of the optimiser program (in Italy) and obtain the necessary technical data.

Unfortunately, it seemed that the defined structure was not equivalent to the structure that I was observing in files which had been created by the program itself after the data had been entered manually. There were hundreds of attempts made to create a file in the correct structure but I could never find the correct format. 

At one stage, I seemed to be making progress, only to receive a letter from my Italian contact which ended with the words "oh by the way, today is my last day at work with .... From now on, please contact X". Ouch.

To make a long story only slightly shorter, we eventually received a new mapping of data, and suddenly my files were being accepted by the optimiser. The values weren't particularly correct but at least I could see what needed to be replaced. After a few more attempts (I should point out that I am about 150km from where the optimiser is), I eventually found the magic format!

So we've now saved a great deal of work - the user can run a report in ERP, run my program on that report and create a file which can the optimiser can read. Can this be improved? I was idly thinking about this last night when it occurred to me that I can minimise the overhead even more: have the ERP program create its file then call my program to read this temporary file and then output an optimiser file. From my point of view, it's five minutes work, but from the user's point of view, it minimises the overhead.

As it happens, today I have been involved in implementing something else which promises to reduce overhead: our delivery notes will now bear a barcode (the delivery note's number). When we receive the delivery note signed by the customer, we scan the note in a scanner which is connected to special software; this software then assigns the scan to the delivery note in the database. If we had wanted to do this in the past, I would take the signed delivery note and scan it with a multi-function printer which sends me the scan as a pdf file via email. I would then save the pdf file in a directory and manually tell the erp program where the scan is. This would take about five minutes per document; this overhead has now been cut to around ten seconds (although of course we have to pay for the privilege).

It occurs to me that before starting work on the barcodes, I helped someone else minimise their overhead (maybe I should change my job description!). It began with an innocent question of how to get a inventory list for a given warehouse where the status is 'Goods'. It might be that the user was using the wrong report for this, but that's not the point; I showed her how she could get the list directly from the warehouse. Then I was told that she wanted to make a list of old work orders for these parts. My immediate reaction was to ask why; who needs a work order when the parts (chairs) already exist. "X needs the work orders so that he can print labels for them" was the reply. For every chair which is made, we print a label (which is stuck on the underside of the chair's seat) and it's easiest to source these labels from the work order.

Once I had got that straight, I pointed out that one could simply print labels for a given list of parts without having to find a work order. People are so used to a rigid set of rules that they don't see what lies behind those rules and procedures. It turns out that they had been dancing this dance every few weeks; hopefully now I will have minimised the overhead for them and saved a few minutes which can be spent on more useful pursuits.

Wednesday, March 13, 2013

Ring out the old, bring in the new! (My motorbikes)

Way back in 1975, in what now seem to be prehistoric times, I owned a Suzuki 120cc 'student' motorbike (I'm not sure why it had this nickname). I used it to drive around London for the next three years, as well as driving from London to Cardiff every now and then to visit my parents. When I left London and moved to Cardiff (prior to emigrating), I drove home on the bike, then drove it every day to Newport and back - I had found a job in a laboratory there. When I emigrated, I thought for a few minutes about loading the bike into our container but decided against; in those day, kibbutzim were very anti-personal transport and I doubt that a motorbike would have been a good thing to have brought with me. My parents gave it away to someone local who didn't look after the bike and crashed it after a few months (or so I believe).

Sometime during the mid 1990s, I became the ashamed user of a Piaggio 50cc 'motorbike'. This vehicle was bought by the financial manager of the company at the time; he used it to commute from the kibbutz to the factory, which was then about 1km from the kibbutz. Later, he was assigned a car and the bike was transferred to me. It was a good workhorse for the next few years but often had mechanical problems and surprisingly was even stolen about four times (although each time recovered quickly). The picture on the left is somewhat reminiscent of the bike I had (mine was certainly dirtier) but I think that it must have been redesigned in the following years. I was ashamed because frequently it didn't have enough energy to drive up mild slopes and I had to pedal in order to achieve enough speed.

After the factory burned down in June 2007, the various departments found homes in different buildings in the area; eventually the offices moved to a building about 5km from the kibbutz. It became clear that the Piaggio would not be capable of transporting me to these various buildings and so a 'new' motorbike was purchased. Just as I started looking, someone on the kibbutz offered a Peugeot Vivacity 50cc for sale which I promptly snapped up. It turned out that the owner was the son of one of my neighbours - I didn't know that he had a bike. The model was very similar - if not identical - to the scooter which I had hired whilst on holiday in Santorini, so I didn't have any problems in switching from the slim-line Piaggio to the wider Vivacity.

This bike has served me well in the past six years but there have been problems which have got worse in the past year. From day one, the electric starter didn't always work; this became a problem of Sunday mornings when whatever charge had accumulated would disappear (I don't use the bike on Fridays and Saturdays), meaning that I would have to start the bike with the kick starter. The electric starter has not worked at all since coming back from Croatia last summer and after spending a few weeks of staying at home (remember the whooping cough?); as a result, I have ruined a few pairs of shoes starting the bike with the kick starter. Although this motorbike did have a few regular services, the starter problem was never fixed.

The situation has been getting worse and worse; after one Sunday morning when I needed about ten minutes to start the bike, I informed the company's "transport officer" that it was time to find me a new steed. After about a week, he informed me that he had found a 125cc machine (Kymco Movie) which had barely been used. Since then, three weeks have passed in which the machine passed its MOT test and insurance obtained (I note that the cost of the insurance for the new bike is almost exactly double that of the old and nearly as expensive as our car insurance)... and eventually the bike has arrived!

Apparently the bike is very zippy and a great improvement on the Vivacity. I never dared to make a trip longer than 5km on the old bike, but this one should allow me to make much longer journeys - although I doubt that I will drive it to Tel Aviv! The problem is not so much the motorbike as Israeli drivers.

Tuesday, March 12, 2013

Pictures from a balcony (3)

It's been a few weeks since the last picture; Spring is in the air and the tree in front of our house (in Hebrew, it's called 'panasit', which means 'little lamp') is beginning to grow buds.

This is the view from the other side of the balcony. We had to prune the eucalyptus tree (it's on the right of the electricity pole which is in the middle of the picture) when the balcony was built. Many years ago, we thought that the eucalyptus was dead, but we pruned off most of the dead wood and it grew a new trunk. This tree is what gives me the feeling of living in a tree house.

Separating the two balconies are two loquat trees; obviously at the moment they're not blooming but there will be plenty of fruit in a few months.

On the other side of the building is a papaya tree. There's a huge fruit on the tree but it may be difficult to see: it appears to be growing out of the trunk at the bottom of the picture.

Saturday, March 09, 2013

I'll never get those wasted hours back

Several years ago, the Occupational Psychologist and I developed a program in which the user would be presented with a variety of occupations (over 100) and would choose which appeal and which don't. On the basis of the answers, we performed some psychological voodoo and then presented a list of occupations to which the user would be suited. We still use this program in our 'laboratory' setting.

We later thought that this program could be used as an alternative revenue stream: we would convert it from a native Windows program to an interactive Internet program, put it on the OP's site and then invite youngsters to 'take the exam', paying a small charge for the privilege. As this kind of programming is not in my CV, we turned it over to an external programmer, the OP's eldest son (this is not a case of nepotism: he works for Intel, in case anyone is doubting his competence). We arranged the online exam so that one would first have to pay via PayPal, then using the PayPal receipt number as a serial number, the youngster would 'take the exam'; the output file would be sent by email to a certain address. My part in this was to parse the letter that we received from PayPal, notifying us of the paid user, then download the email holding the output file, perform the voodoo then send the results back via email. A non-registered user could still take the exam but the results would not be returned. 

[For any brave souls interested, here is the link to the exam. But beware: it's all in Hebrew]

Unfortunately this did not turn out to be the revenue stream that we had envisaged so the OP made the brave decision to turn the online exam into freeware (but still no one has heard of it...). I had to change my program slightly so that it would ignore anything which was connected with serial numbers etc. This modification was quite simple but then I came across something else which needed my attention.

The program sent its results by email: it was using code which used Outlook as the sending mechanism. Unfortunately, this required that Outlook run continuously on the 'server' which had caused problems in the past. Also, considering the programming work which I had been doing in the past two months, it was time to free the program from the shackles of the proprietary Outlook and move to the freeware of GMail. 

Whilst it didn't take long to perform the conversion, the testing took hours and seemed inconsistent. Sometimes the program would send an email but more often that not, it would stall in the portion of the program which actually sends the email, with no clues being given as to the source of the problem. After knocking my head against a brick wall and coming exceeding close to giving up, the answer suddenly presented itself: when sending mail via GMail, there are two security DLLs which need to be present in the same directory as the program. As soon as I moved those DLLs into the correct directory, the program worked (it had worked before because sometimes I tested the program in a directory which contained those DLLs)!

This is what I have referred to before as the Gumption Trap; once again I fell into its jaws.

But what this really reminds me of is a thread in Nick Hornby's "Juliet, Naked", which I last read a few weeks ago. The book starts off with a couple, Annie and Duncan, making a pilgrimage to America in order to visit places which supposedly had a strong connection to Tucker Crowe, the fictional recluse musician who made the eponymous record. When they come back to their dreary British seaside town, Annie and Duncan separate; Annie makes a calculation that she wasted fifteen years with Duncan and that no one was going to give her those years back.

This is how I feel (on a slightly different level, of course): I wasted a few hours and no one is going to give me them back. I could have been doing something else more productive, like studying for my doctorate....

Friday, March 08, 2013

Searching for Sugarman

I saw the Oscar winning film "Searching for Sugarman" yesterday and have to admit that I fit right into the film's intended audience. For those who know nothing about the contents of the film (like I was, prior to watching), here's a precis: at the end of the 60s and beginning of the 70s, an otherwise unknown musician known solely by his surname, Rodriguez, recorded two albums. Despite the enthusiasm of the producers, the records did not sell and Rodriguez was dropped by his record company after which he basically left the music industry. An American visiting South Africa brought with her a copy of his album(s) and people enjoyed listening to them, so much so that there were local pressings of the records made. As one person puts it, if you walked into a white liberal home in South Africa, you would always find three records: 'Abbey Road', 'Bridge over troubled waters' and 'Cold fact', Rodriguez's first record. Due to the isolation of South Africa and the fact that Rodriguez had been dropped, the audience knew nothing of the artist.

When a South African cd was issued of Rodriguez's second album in the mid 1990s, people began to wonder what had happened to the artist: there were stories circulating that he had committed suicide, which each story varying in the details. After a long search, contact was made between Rodriguez and South Africa and he visited there six times, each time playing several sold out concerts. It's the sort of story where the truth seems more unlikely than the fiction.

Having recently finished rereading Nick Hornby's novel 'Juliet, Naked', I am struck by certain parallels in the story. No one in Hornby's novel ever suggests that Tucker Crowe, the disappearing musician who made the eponymous record, is dead, but that's only because the rabid Internet fans had decided on the basis of virtually no information that a neighbour and friend of Crowe was actually Crowe. In 'Searching for Sugarman', the fans decided - again on the basis of virtually no information - that Rodriguez was dead. There were people in South Africa who thought that the person coming to sing to them must be an impostor - the parallel to the book is how Crowe can prove that he is who he says he is - "there are such things as passports".

According to Wikipedia, the film leaves out the awkward fact that Rodriguez was also very successful in Australia in the 1970's and became aware of it enough to tour there extensively in 1979 and 1981. While it could be argued to be "lying by omission" by implying Rodriguez was completely unaware of his success anywhere in the world, it is perhaps forgivable within the framework of the documentary since the film focuses on his mysterious reputation in South Africa, and the attempts of music historians there to track him down in the mid-90's, who were unaware of his Australian success due to the harsh censorship enacted by the apartheid regime coupled with international sanctions made any communication with the outside world on the subject of banned artists virtually impossible.

I find it interesting to note that although Rodriguez's first tour of South Africa was in 1996 (and was filmed both by his daughter and by media interests in South Africa), the film was only made in 2011.

I saw a note referring to this film a few days ago, asking "where are the royalties?" The original record label owner is asked this during the film and avoids the question, disparaging the interviewer who should be asking questions about the music and not about the money. It's a valid question, though; presumably the South African distributors took their percentage and passed the rest on to the American label owner who spent it on other things and did not keep accounts. There were probably also many bootleg recordings made which profited only the bootleggers. There is also a note at the end of the film that Rodriguez gave away most (all?) of his earnings from the South African tours, so presumably the missing royalties wouldn't have been an issue with him anyway.

Thursday, March 07, 2013

Alvin Lee, RIP

The music lists are full of notices about the death of guitarist Alvin Lee, whose greatest claim to fame was probably 11 minutes of guitar pyrotechnics in the film 'Woodstock'. David Hepworth was quicker on the ball than I to write about this.

My major connection with Lee was in December 1969, only a few months after Woodstock, when I went to see his group, Ten Years After, along with Blodwyn Pig and Stone the Crows. I've written about this before, but from the outlook of BP. I was familiar with some of the TYA material - I had heard their album 'Sssh' and had sniggered over the lyrics of 'Good morning, little schoolgirl' - and was to understand the connection between the riff and rock music from TYA.

A few months later, I was to buy their next album, 'Cricklewood Green' and even the one after that ('Watt'), but the writing was already on the wall: all the songs sounded the same and they were all based on the twelve bar blues. In my defense, I will note that I was only 13 at the time of the concert, and 13 year olds were much more callow in the late 1960s than they were in the late 2000s. 

That period was climaxed by their single 'Love like a man': one side of the record played at 45 rpm whereas the other side (a live recording from the Fillmore East, IIRC) played at 33rpm; this live recording was about seven minutes long. The single version was actually an edit from a longer, studio, version which appeared on 'Cricklewood Green', but I think that the live version was the best of all three. I have a memory from about March 1970 of fixing a pickup onto a cheap acoustic guitar whilst listening to this song (along with 'Hot Rats' by Frank Zappa) and learning how to play it.

I read an article a few days ago which was written in response to the death of Kevin Ayers; the author was writing about the different generations of rock musicians who were dying. He noted sardonically that soon it will be the turn of the punk rockers - and unfortunately the only thing which I share with them is a similar year of birth: John Lydon aka Johnny Rotten, the Sex Pistols, is six months old than I am [A few days later, I remember that John Lydon also liked Van der Graaf Generator, which means that we have something else in common]