Saturday, December 24, 2011


Negotiations and love songs
Are often mistaken for one and the same
(Paul Simon)

I started my eighth MBA course, Negotiation, a bare week ago, but already we've had four sessions as the timetable calls for one session on Thursday evening and another on Friday morning. This is quite a taxing schedule and it's not clear why this was adopted; I suspect it might be that the lecturer far lives away from Tel Aviv and this schedule minimises his traveling time by allowing him to sleep over in Tel Aviv on Thursday evening. We have six weeks like this (twelve meetings) and one more Friday morning meeting which takes us up to the end of January. There are no lectures whatsoever during February, then there is a revision meeting at the beginning of March and the exam on 10 March. This isn't the sort of schedule which I would have preferred, but as the youth of today say, "Deal with it".

The opening lectures gave an introduction into the subject of negotiation (the text was written by Professor Gavin Kennedy), in which we initially learnt that negotiation is but one of ten ways of resolving disputes (or making decisions). The other ways are refusal, persuasion, problem solving, chance (tossing a coin), arbitration, coercion, postponing, instruction and giving up. The major difference between negotiation and the other methods is that in negotiation, both sides give up something in order to achieve a mutually agreed conclusion, whereas in the other methods, one side gives up nothing and the other side gives up everything.

After this, we learnt about the four stages of negotiation:
  1. Prepare
  2. Debate
  3. Propose
  4. Bargain
The following lecture was about preparing for negotiation; this includes identifying interests, deriving tradables  from these interests, prioritising these tradables and then defining entry and exit values for them.

On Thursday night we learnt how to conduct the debate stage of negotiation, which means trying to maximise one's constructive behaviour whilst minimising one's destructive behaviour (I won't list what constructs these behaviours). 

I wasn't feeling very well that evening and had to leave halfway through the evening; on Friday morning I was feeling a bit - but not much - better, so I decided to drive to Tel Aviv. Fortunately, we didn't have a lecture - instead we had to simulate a negotiation; the scenario was taken from an old exam paper. The class (very small: we started off at 8am with maybe eight students and the number doubled by 8:30am) divided into two groups, where each group took one side of the negotiation. Each group was tasked with identifying the interests and deriving the tradables  etc, as per the earlier paragraph. We were also advised to try and do the same for the opposite side so that we wouldn't been surprised during the negotiation.

During this time, most of my group were silent; only two other people and I contributed to the discussion. This was slightly annoying as I was having difficulty in speaking and had to maintain a constant infusion of tea. Nevertheless, I and one other were nominated to conduct the negotiation. At least I won't have to do this again in the future.

I won't describe how the simulation went (not that anything extra-ordinary happened); afterwards, everyone else in the class was invited to make comments about what they saw. Unknown to the negotiators, one extra person from each group had been specifically nominated to analyse each team's behaviour (constructive and destructive). Whilst there was a fair amount of constructive behaviour (I was very conscious of all four negotiators being extremely polite, not interrupting and trying to be 'good'), there was also a certain amount of destructive behaviour. What was lacking primarily, though, was a lack of connections between tradables (I'll give you this if you give me that), which made the negotiation problematic.

I will paraphrase a comment made by someone yesterday (who came late): at first, I thought this was going to be a boring exercise,  but by the time it had finished, I came to understand the theory much better. Indeed, the criticism brought home how we could have better run the negotiation (in mitigation, I point out that none of us were personally involved, so the other side's reduction of its price by "five million pounds" would not have happened in real life).

The lectures are held in the same room as my previous course, finance (in fact, all my lectures for the past two years have been held in this room). In the previous course, one had to arrive early in order to get a good seat (the lecturer had a quiet voice, so I preferred to be near the front in order to hear her properly). In this course, one can arrive half an hour late, bring two friends and still get a good seat! I'm not sure how many students are actually registered to take the course, but most have only made token appearances. Apart from a 'hard core' of maybe eight who appear every time, the course seems to have attracted a floating set of students who appear now and then. This seems to bother me more than it bothers the lecturer.

Wednesday, December 21, 2011

The sense of an ending

Although I grew up reading literary novels, these days I read more non-fiction than fiction, and more police procedurals than anything else. Despite this, I very much enjoyed reading Julian Barnes' novel, "The sense of an ending", which won the 2011 Man Booker prize (I didn't know this when I started to read the book).

I think that my enjoyment stemmed more from identifying with the protagonist than anything described in the book, which means that I will have to reread the book in a few weeks in which time I hope that my emotional involvement will have lessened.

It's not as if anything specific which happened in the book happened to me in real life (in fact, I would be hard pressed to find anything which happened in the book that also happened to me); it's just that the opening half of the book is, (quoting the Guardian)
[a] memoir of "book-hungry, sex-hungry" sixth form days, and the painful failure of his first relationship at university, with the spiky, enigmatic Veronica. It's a lightly sketched portrait of awkwardness and repression. This is something which makes a great deal of sense to me and seems very familiar. I too look back on my formative years from a 30-40 year distance.

Sunday, December 18, 2011

Watching the weight / 3

Even though I finished my course of acupuncture and massage about six weeks ago, I continue to eat according to the diet that the naturopath gave me, and continue with my 'heavy' walking in the evenings. I had an appointment with the naturopath the day of my finance exam (two weeks ago already!) and she was very pleased by the fact that I had lost over 5kg in weight.

I asked her about the flax seeds which I had been eating - it turns out that these should be ground before eating them! I was eating and excreting them without deriving any benefit. She gave me some alternatives to the flax seeds which don't require any treatment prior to eating - wheat germ and chi'a seeds (? I'm not sure what these are in English). I bought some wheat germ which I have been adding to my morning yoghurt; this has no discernible taste but definitely thickens the yoghurt. Yesterday evening my wife surprised me by grounding some flax seed, so I added this to my yoghurt this morning - the result was near enough the same as with the wheat germ. Both of these items seem to provide many micro-nutrients.

My weight did decrease to 79.1 kg prior to the exam but it's crept up by about half a kilo since then. I'm not sure what I was doing then or since which might have caused the change - apart from a great deal of mental exercise. I know that the brain requires as much as 15% of the body's energy intake, but I don't think that one can increase this amount by thinking hard!

Thursday, December 15, 2011

Front end program for converting HTML to PDF

I was approached by someone (not in my company) with a peculiar problem, connected with our mutual ERP program, Priority. This person has to send to a medical insurance company copies  of invoices issued to certain customers each month, in PDF format.

Until she approached me, she had been selecting and displaying each invoice separately (Priority uses Internet Explorer as its default display mechanism for all reports, including invoices), then sending the invoice to be 'printed' via a PDF printer (thus creating a PDF file) and then renaming the file to be the name of the customer (unfortunately, Priority gives an arbitrary name to files it creates). This process was taking a few hours every month and I was asked to speed it up.

My initial action was to change a definition in the PDF printer driver, so that the driver would create a separate file for every page sent to it. I then showed the person how to select and display all the necessary invoices in one go and send the data to the PDF printer, thus creating several files. Unfortunately, there still existed the need to rename each file. This simple action maybe cut the time needed by 25% but it wasn't enough.

There had to be a better way. The first stage in improving the process was to write a little program (a stored procedure, really) in Priority which creates one html file per invoice, where the file is named according to the customer name and the invoice number. Unfortunately, it transpired that it was not possible to create such a file when the customer name was in Hebrew, and as all the customers' names are in Hebrew, this was quite a problem. So I substituted the customer identity number (not the customer number) for the customer name and was able to create separate html files.

Then there only remained the problem of creating pdf files from these html files. At one stage, I asked whether the medical insurance company would be willing to receive html files, but the answer was negative. After contemplation, I realised that I needed a program to convert html to pdf in order to provide a complete solution.

Like many problems, this was easier said than done. I spent several hours googling html pdf convert and then checking out the links. Most of the answers which I received pointed to online services, which would not be suitable. Of the answers remaining, most of these were for commercial programs. I found one program which seemed to be free; I downloaded it and tried it out but saw that it lacked a batch mechanism (my idea required to convert 10+ files in one go). I tried a trial version of a commercial program: whilst this had a batch interface, it included a 'trial message' version in the pdf, and more damning, failed to convert a Hebrew html file.

Eventually I found a command line program (CLP) called wkhtmltopdf, written by a enthusiast programmer (as opposed to a commercial program written by a professional programmer). My experience is that such programs are often better than commercial ones, although getting them to work can be awkward. First I checked that this program could convert a Hebrew html file correctly (yes). Then I set about writing a front end interface program - this program would list all html files found in a specific directory, allow the user to choose which files to convert and then pass these files to the CLP for conversion.

My first version of the front end program wasn't too successful as it tried to start about ten simultaneous instances of the CLP; this brought my computer to its knees. Whilst waiting for my computer to reboot, I realised that I needed to send one file to the CLP, wait for it to finish converting, and then send the next file.

Another problem which I encountered was that the CLP couldn't handle files which were stored in a subdirectory of c:\program files. I solved this program by using a routine which creates short directory names (eg c:\progra~1). The 'executing' flag was added as a precaution that the user not close the program before all the chosen files were converted; the program's CanClose procedure checks the value of this variable and refuses to close if executing is true. Edit1.text hold the location of the CLP.

Here is the interesting part of the code.
procedure TForm1.ConvertBtnClick(Sender: TObject);
 i: integer;
 ExitCode: DWORD;
 mydir, htmlname, pdfname: string;
 SEInfo: TShellExecuteInfo;

 ConvertBtn.enabled:= false;
 executing:= true;
 FillChar (SEInfo, SizeOf (SEInfo), 0);
 with SEInfo do
   cbSize:= SizeOf (TShellExecuteInfo);
   Wnd:= Application.Handle;
   lpFile:= PChar(edit1.text);

 mydir:= IncludeTrailingPathDelimiter (shortdir (;
 for i:= 1 to lb.items.count do
  if lb.Checked[i-1] then
    htmlname:= mydir + lb.items[i-1];
    pdfname:= copy (htmlname, 1, length (htmlname) - 4) + 'pdf';
    seInfo.lpParameters:= PChar(htmlname + ' ' + pdfname);
    if ShellExecuteEx (@SEInfo) then
      GetExitCodeProcess (SEInfo.hProcess, ExitCode);
     until ExitCode <> STILL_ACTIVE;
 executing:= false;
It's not enough to use the Windows API ShellExecute procedure as this simply executes the given program; this is how I managed to create all the simultaneous instances of the CLP.

Sunday, December 11, 2011

50 words for snow - Kate Bush

I've been listening to this album on and off for the past few weeks, ever since an advance copy was available on the NPR website. I've been dreading writing about it, because I find the album difficult to categorise.

I was a very early adopter of Kate Bush, marveling at her 'Wuthering Heights' single and buying her first album in January 1978. I enjoyed all of her first five albums, although there were often songs which didn't find favour in these courts. The sixth and seventh albums were bought and almost never played. I obtained 'Aerial' when it came out but again hardly ever played it. It seemed as if time had stood still for Ms Bush and her music seemed anachronistic. 'The directors cut' again was hosted on NPR prior to its official release, earlier this year. The reworked album was quite listenable but again wasn't really the sort of music to which I listen these days.

'50 words for snow' is different from almost everything else Ms Bush has recorded. Unusually, it is very sparse, featuring mainly piano and vocals only. Of course, there are other instruments (Steve Gadd's drums are a highlight, as are the orchestral instruments which add shade here and there) but they're subdued.

In my humble opinion, the sequencing could have been improved. The album starts in a very risky manner, with Kate's son Bertie taking lead vocal on "Snowflake". I find this song very precious (in the non-complimentary sense of the word) and I can imagine many listeners being put off by the first minute of the song (which lasts almost ten minutes). The second song, "Lake Tahoe", also starts in a testing manner, with some operatic vocals. This song continues for just over eleven minutes.

But the third song, "Misty", is where it all comes together. Even though the track lasts for thirteen and a half minutes (!), one never gets the feeling that the track is over-long, or indeed, long. It is a master lesson in dynamics, especially the drums. The next three tracks are much more accessible than everything that has gone before whilst the closing track is a return to the amorphous ballad.

My wife has picked up on this album as well. Yesterday we had the bizarre situation in which I was listening to the album on headphones whilst writing a blog entry; when I finished, I went into the lounge only to hear the same album on the stereo, albeit not the same song (that would have been too weird).

This is an impressionistic piece of music full of prosody; as a musician who lives by harmony, I feel that I don't appreciate it as much as I could.

Saturday, December 10, 2011

Preventing "MDI creep": how to decascade a child window

I confessed a terrible feeling of emptiness to my Occupational Psychologist (OP) during our weekly meeting yesterday: until the day before, I been concentrating almost entirely on learning Finance, and now that the exam is over, I don't need to know how to price an option nor what the theory of indifference to dividend policy is. "Don't worry", she said, "I'll find you things to fill you up". And so she did (Happy birthday, by the way!).

One side effect with using MDI applications (such as the management program which I wrote and constantly improve) can be described as follows: when the program's first child window is opened, this window will have its top left hand corner placed in the screen's top left hand corner (coordinates 0, 0). The second child window will be opened automatically at 10, 10 and the third at 20, 20. This was a good idea when screen resolution was not particularly high as it makes good use of the screen's 'real estate'. But times have changed; the OP has one of those extra wide screens and she uses it in a mode which provides a huge amount of real estate. All the child windows congregate on the left hand of the screen and the right hand side is unoccupied.

So the OP drags certain child windows to the right hand side so that she can see several complete and unhidden child windows simultaneously. All is fine until a new child window is displayed; within the program I followed each new window creation with the 'cascade' command - and then the personalised display disappears when all the child windows line up again on the left hand side. This was easy to fix by removing the 'cascade' command after new window creation.

But more insidious is that the MDI screen manager (to which we have no access) will create new child windows as if cascade is still in effect. In other words, the first child window will be created at 0,0, the second at 10,10 and the third at 20,20 - even if the second child window has been moved to a location 200, 600. Worse, this behaviour continues even after the child windows have been closed: new child windows will appear at a location which would be consistent with cascading all the previous child windows.

I researched this behaviour a little yesterday afternoon and discovered that it has been named MDI creep. Whilst naming the behaviour makes it easier to talk about, it doesn't make it any easier to solve.

I posted a question of the Stack Overflow site and master programmer David Heffernan gave an answer which pointed me in the correct direction [I often wonder how David actually gets any work done as he seems to be found almost permanently on SO, answering people's esoteric questions]. It took me about an hour of to-ing and fro-ing with his idea before I had something that worked and about another hour of polishing the entire solution.

The solution boils down to three different parts:
  1. How to enable a child window to signify that it wants to be 'uncascadable'
  2. How to universalise this ability
  3. How to prevent the main MDI window from cascading the uncascadable child windows
The answer to the first part is to use each form's system menu; this is the menu that pops up when one clicks on the form's icon sitting in the top left hand corner of the caption bar.  I used to use the system menu in the early days of Windows programming, but haven't touched it in over a decade. Each form has to add an option to the system menu whose effect will be to toggle the 'cascadability' of the form; so the form has to detect when that option has been chosen and to toggle an internal variable. At the same time, it would be good to give visual feedback on the menu what the state of that variable is at any given time.

Here's the article which I used as the basis for developing the code to add the menu option and detect its being pressed. Finding out how to give the visual feedback was a bit more difficult but eventually I found out how to do this (and more importantly, how to do this correctly!). I'll show the complete code a bit further on.

When I originally wrote this code, it was sitting in the form which needed to be decascaded, but it occurred to me that the technique would be much more valuable if I could use it in almost every form and I wasn't going to copy the code fifty times. The solution is to use form inheritance - to define an ancestor form type which contains the code and then define the actual forms to inherit from this ancestor type. This is one of the huge strengths of Delphi (the entire VCL works on this principal) but is something which I have barely touched.

unit ManageForms;


uses Windows, Forms, Menus, Messages;

 TNoCascadeForm = class (TForm)
                    SysMenu: HMenu;
                    nocascade: boolean;
                    Procedure GetSysMenu;
                    Procedure WMSysCommand(var Msg: TWMSysCommand); message WM_SYSCOMMAND;
                    Procedure SetCheck;
                    Procedure SaveCheck; virtual; abstract;


 SC_NoCascade = WM_USER + 1;

procedure TNoCascadeForm.GetSysMenu;
 SysMenu:= GetSystemMenu (Handle, FALSE);
 AppendMenu (SysMenu, MF_SEPARATOR, 0, '');
 AppendMenu (SysMenu, MF_STRING, SC_NoCascade, 'Decascade');

procedure TNoCascadeForm.WMSysCommand (var Msg: TWMSysCommand);
 if Msg.CmdType = SC_NoCascade then
   nocascade:= not nocascade;
 else inherited;

procedure TNoCascadeForm.SetCheck;
 iChecked: Integer;

 if nocascade
  then iChecked:= MF_CHECKED
  else iChecked:= MF_UNCHECKED;
 CheckMenuItem (SysMenu, SC_NoCascade, mf_bycommand or ichecked);

Procedure GetSysMenu first gets a pointer to the form's system menu, then adds two options: the first is a separator bar and the second is the 'decascade' option. When this option is pressed, a system message of type 'SC_NoCascade' will be sent to the form. Of course, the form has to know how to handle this message.

The final line in this procedure (which will be called once during the inherited form's create method) is to SetCheck - this procedure draws (or erases) the check mark next to 'Decascade' on the system menu, according to the value of the variable nocascade. This is initially set in the inherited form by reading a value stored in the registry; if there is no registry value then the variable is false (no check mark).

When the system message of type 'SC_NoCascade' is sent, it is intercepted by the form's WMSysCommand method. As all system menu messages pass through this method, it is vital to check what the actual message is; if it is not the specific message, then it is passed on to the inherited message handler. Assuming that the message received is SC_NoCascade, then first the method reverses the value of the internal flag, then calls SetCheck to have the menu option updated and finally calls an abstract method called SaveCheck (this probably should have been defined as a stub in the ancestor form).

The SaveCheck procedure is located in the inherited form and stores the value of nocascade in the registry. This is necessary, for if a new inherited form were to be displayed, its nocascade variable would contain the value previously stored in the registry - which would be oblivious to the change which has just occurred. This procedure has to be located in the inherited form as it is dependent on specific registry values which the ancestor form cannot know.

Here is part of the code of a form which inherits from TNoCascadeForm:
unit Manage57;


  Windows, Messages,  ManageForms, ,,,;
  TShowCallsTree = class(TNoCascadeForm)
   Procedure SaveCheck; override;


{$R *.dfm}
procedure TShowCallsTree.FormCreate(Sender: TObject);
 myheight = 440;
 mywidth = 816;

 constraints.MinWidth:= mywidth;
 constraints.MinHeight:= myheight;
 with reg do
   height:= ReadInteger (progname, 'ShowCallsTreeH', myheight);
   width:= ReadInteger (progname, 'ShowCallsTreeW', mywidth);
   nocascade:= ReadBool (progname, 'ShowCallsTreeCas', false);

procedure TShowCallsTree.FormClose(Sender: TObject; var Action: TCloseAction);
 with reg do
   WriteInteger (progname, 'ShowCallsTreeH', height);
   WriteInteger (progname, 'ShowCallsTreeW', width);
   WriteBool (progname, 'ShowCallsTreeCas', nocascade);
 action:= caFree

procedure TShowCallsTree.SaveCheck;
 reg.WriteBool (progname, 'ShowCallsTreeCas', nocascade);
After this excursion into the worlds of system menus and inherited forms, we can know address the issue for which we have gathered: how to decascade a child window.

David says in his answer: looking at WM_MDICASCADE it has an option to skip disabled MDI children from cascading. So you could disable certain child windows, send a WM_MDICASCADE message yourself and then re-enable the child windows. Probably easier said that done. The program's main form has a method called cascade, but this is an encapsulation of the WM_MDICascade message and leaves no room for manoeuvre. It has to be replaced by sending the actual WM_MDICascade message, and this message has to have the parameter 2 in order to ensure that disabled windows are ignored.

The main form iterates over the child windows, looking for a form which is decended from TNoCascadeForm; if its nocascade variable is set to true, then the form is disabled. Once this has been done, the form can send the above message to its MDI container window, which handles the cascade. Then the form iterates once more over the child windows, re-enabling those which had previously been disabled.

procedure TMainForm.mnCascadeClick(Sender: TObject);
 i: integer;

 for i:= 0 to MDIChildCount - 1 do
  if MDIChildren[i] is TNoCascadeForm
   then if TNoCascadeForm (MDIChildren[i]).nocascade
    then TNoCascadeForm (MDIChildren[i]).enabled:= false;

 sendmessage (mainform.clienthandle, WM_MDICASCADE, 2, 0);

 for i:= 0 to MDIChildCount - 1 do
  if MDIChildren[i] is TNoCascadeForm
   then if TNoCascadeForm (MDIChildren[i]).nocascade
    then TNoCascadeForm (MDIChildren[i]).enabled:= true;
The proof is in the pudding - this really works! Thank you, David, for the help in pointing the way.

Thursday, December 08, 2011

Post mortem on the Finance exam

I've been quiet for the past few weeks mainly because I've been revising for the MBA Finance exam, which was held today. Other than this, there hasn't been much to write about (not that this will stop me...).

The exam was in two halves; 50% of the marks come from multiple choice questions (MCQ) and 50% come from open questions. The agreed tactic was to start with the MCQs, do those which could done without too much thought or effort, then do the open questions, and in the remaining time one does the MCQs which were previously skipped over.

The examiners don't care how one arrives at the answers of the MCQs; they could come from calculation, from intuition or from guessing (I prefer to calculate). The class had passed around a collection of MCQs collected over the years, and I don't think that there was one question today which appeared in the collection (so much for those students who memorised the questions and answers!). Of course, there were questions of the kind "If someone receives a loan of X pounds and repays so much for four years, what is the rate of interest?" and "How much do I have to save every year if I want to receive a pension of 1 million pounds in 25 years, with an interest rate of 6%", but apart from that, almost everything was new. I skipped maybe four questions the first time around; three became obvious when doing them at the end, and the fourth question I guessed (even though there are four options, two were algebraicly the same, presented in slightly different forms, so the possibility of getting the question right is 50%). There were a few questions which I am slightly doubtful about in retrospect, but I imagine that I got about 40 out of 50 marks here.

The first open question started off with a calculation comparing leasing buses or taking a loan in order to buy them, For ten marks, one had to lay out the cash flow, calculate the the company's weighted average cost of capital (WACC) and say which option was better. We've done similar exercises in the past, so this wasn't problematic. Even so, talking with someone after the exam, I discovered that I might well have made a mistake here regarding one of the sums of money. Even so, I'll probably only lose one mark, because I used the correct methods throughout.

A further five marks were to be made by listing the advantages of leasing (easy), four or five with a strange question about a company selling its shop and then leasing it back straight away, and then a few more marks about 'agency problems'. I would like to think that I did very well on this question.

The final question (20 marks) started off with calculating spot and forward interest rates before demanding the calculation of a bond's current price and a question about the bond's duration. As it happens, I had ignored spot and forward interest rates until the subject came up at a revision meeting about two weeks ago when I relearnt the material, which is not too complicated. The data, however, were presented in an unfamiliar manner and I made a false start before I hit on the correct method (or at least, I hope that it's the correct method) of making the calculations. The subquestions about the bond were easy although on reflection, I made a small mistake regarding the duration (lose one mark).

Unless I have made a gross miscalculation, I should have done very well on this exam. Results in about six weeks.

As it happens, I've been reading (when not revising) a very interesting book on the Kindle, called "The ascent of money" by Niall Ferguson. This should be required background material for both the Economics and Finance courses. Apart from the interesting historical background, it is also written after the 2007 crash, which changed the rules of finance. At times, I found the course amusing with remarkably high interest rates (10% is not to be sneered at, when the interest rate in Britain or USA is about 1% these days); even more amusing were the statements that "real (inflation less) interest rates are the same in every country" and that "exchange rates can be calculated on the basis of inflation rates". Will someone please explain to me why the exchange rate for shekels to sterling has remained around six for some time? The interest rate in Britain is maybe 1% and the inflation rate 5%, whereas the interest rate in Israel is 2.75% (just lowered from 3%) and inflation is also about 2.75%. The exchange rate should be completely different. 

Despite being told that there are no arbitrage opportunities for long, the above shows possibilities: if I were to take a loan in Britain for (say) 1000 pounds at 2% per annum (I don't know whether that's accurate), I would have to pay 1020 pounds back after a year - but as there is 5% inflation, that would only be 971 'real' pounds. I could invest that money here in Israel, get a higher rate of nominal interest and then repay the loan, making a profit. But I won't do this.

Next Thursday, I start my penultimate course, "Negotiation". Unfortunately we have one lecture on Thursday evening and one lecture on Friday morning for six weeks but no lectures in February (the exam is in March). I wish I could sleep in the college on Thursday night instead of returning home and then returning the next morning.

Friday, November 25, 2011

Crisis averted: no need for oral surgery

You know the story about the man who goes into hospital for an examination of his left knee and ends up having his right leg amputated? That nearly happened to me, albeit on a much smaller scale.

The story starts about a month and a half ago when I went to the dental clinic for a routine checkup. The only thing that the dentist could find that needed treatment was the wisdom tooth on the left upper hand side (let's dispose with technical terms such as maxilla and mandible). I was surprised as I thought that I had had all my wisdom teeth extracted; it turns out that I had the teeth on the right hand side extracted but not on the left. The tooth was decaying and as there was no corresponding tooth on the lower side (the jaw), the dentist thought it best that the tooth be extracted. 

She tried to take x-rays of the offending tooth but because of its position, she wasn't able to get a good picture, so she sent me to get a panoramic x-ray of my teeth. This I did, which I returned to the clinic; then I waited for the expert to decide whether the extraction could be performed in the clinic or in hospital (both of my children have had wisdom teeth extracted in the oral surgery department of the hospital).

Yesterday I kept my appointment with the expert; he looked at the x-ray and saw a wisdom tooth embedded on the lower left hand side, at 90 degrees to the rest of my teeth: a perfect case for surgical extraction. He wrote an explanatory note for the surgeon at the hospital and sent me on my way. Outside, I was stunned for a few moments until I recalled that my regular dentist had sent me for a panoramic x-ray because she couldn't get a good picture of the decayed tooth. If she could see the tooth then it couldn't be embedded!

I went back to the expert and explained why I had been referred to him in the first place. He consulted my dental notes, saw what my dentist had written and confirmed that he had indeed been looking at the wrong tooth. Instead of an operation, I needed a relatively simple extraction, which he could do in half an hour. Crisis averted.

He still thinks that the embedded tooth should be extracted, but as long as it's not causing any problems, there's no real need to do so. Dentists are divided on whether such teeth should be extracted as a manner of course. The surgical extraction of the wisdom tooth on the upper right hand side some 25 years ago caused me many after-affects, including low blood pressure for a few years. That's not something that I will willingly undergo again if there is no real acute cause.

Sunday, November 20, 2011

Two spy novels

Despite having invested in a Kindle, I found myself ordering two real books a week ago, as either there aren't Kindle versions available yet or the Kindle version is more expensive.

First off was the third book by Stella Rimington in her Liz Carlyle series, "Illegal action". The basis of this book was more to my liking that the previous ones: Liz has been transferred to Counter-Intelligence (i.e. working against the Soviet threat) from Counter-Terrorism. As an old cold warrior, I much prefer the deviousness of the Soviets. I can't put my finger on the exact cause, but all the way through the book, I kept feeling unsatisfied. As I have pointed out before, Rimington is no literary stylist and seems to write by the numbers (at five sixths of the way through the book, there will be a huge twist in the story which changes one's entire outlook). There are always a few chapters in which the main character of the chapter is referred to solely as "He" or "She", meaning that Rimington is describing someone's actions but that she doesn't want the reader to guess who that person is. I won't reveal the detail for this book, but it wasn't too hard to figure out who the mystery person was. At the end of the book, I found myself so unimpressed that I decided probably not to bother buying any more books in this series. A shame, because a better writer could have done so much more with the story elements.

On the other hand, "The Trinity Six" by Charles Cumming was the real thing. Dense, intriguing and cerebral, this is a worthy successor to Le Carre, mixing fact with fiction almost seamlessly. I've read most of the books listed in the 'bibliography' at the end, so the the historical parts of the story were very familiar. Cumming's anti-hero, Dr Sam Gaddis, does come over as slightly too resourceful for an academic, but that only makes for a better story. He is also a tad too trusting during at least the first half of the novel; I would have thought that someone as well versed in all things Russian would have been more suspicious. Presumably I had an advantage over Gaddis in that I could read what other characters in the book were doing when they were not interacting with him, and so I was able to identify his babysitter well in advance. I also found the fact that Gaddis repeatedly was able to slip under the Russians' radar unbelievable. Maybe they too have lost their touch since the end of the cold war.

Looking back on the story (and this is one that deserves a second and third read, without doubt), it occurs to me that the focus of the story changes in a subtle manner about half way through: the sixth man becomes abandoned and someone else takes his place as being the the book's raison d'etre. The sixth man essentially becomes a red herring.

I hope that Cumming's other book, "A Spy by Nature" is of a similarly high quality. I note that Cumming was approached to join MI6 but turned them down.

Sunday, November 13, 2011

Relieving the pressure

I wrote a few days ago about waking up every morning and feeling anxious about the finance exam, which will take place in another 25 days. I found the perfect solution - I sat down and solved some of the questions from previous exams.

The lecturer pointed out a few questions from previous papers; these were so old that there was no printed solution, which actually is a good thing as one can't cheat. I solved about 80% of the questions correctly, and asked her (the lecturer) on Friday about the points which I wasn't sure about. I'm going to sit down either tonight and tomorrow night and resolve the questions, thus reinforcing the techniques which I need. She will demonstrate how to solve the questions on Tuesday and I want to be super-prepared.

I point out that during the Marketing course, we 'solved' the same exam question again and again until we had it down perfectly and could reproduce the answer from memory. There, the answer took five pages of A4 paper, filled with writing. Solving a finance question is much shorter.

It has become clear what the tactics are: first of all, one has to find the cost of capital which to be used, which is the weighted cost of equity and debt (WACC). There are two ways of calculating the cost of equity and two ways of calculating the cost of debt; in both cases there is one simple method (SML) and one slightly more complicated method (dividends and yield to maturity). I knew the simple methods but wasn't too familiar with the more complicated methods; this has now been rectified.

Then one has to lay out a cash flow table. This isn't complicated but it can be finicky. Once the cashflow is known along with the cost of capital, then one can calculate the net present value (NPV). These are the basics of every question.

The questions which will be answered on Tuesday have the same characteristic in that one has to compare two projects with different lengths. In these cases, it's not enough to calculate the NPV; one also has to calculate the average cost per year. It's not correct to divide the NPV by the number of years that the project runs; one has to perform another calculation on the NPV in order to calculate the annual payment. The lecturer tells me that one will still be able to calculate which project is better if one performs simple division, but that the figure won't be right.

One question was about two machines, one having a life time of four years and the other seven. Another question was about renewing the parquet floor of a basketball court (four and eight years); this latter question can also be solved by changing the cash flow so that there is a second investment after five years. Put simply, which is better - investing $1,000 in a washing machine which will last eight years, or $600 in a washing machine which lasts four years and will then have to be bought again? 

Once one has finished with these questions, the examiners always twist the knife a little and change the scenario. How would the washing machine answer change if there is 3.5% annual inflation? What would happen if the more expensive washing machine lasts nine years instead of eight?

As one can easily get confused about inflation, I think it wise to note a few things here. One can either work with nominal figures (no adjustment for inflation) or real figures (adjusted for inflation), although of course one has to know whether the figures are nominal or real. Rule of thumb: unless otherwise explicitly noted, all figures are nominal. Thus, if we have to pay $600 for a washing machine now and there is 3.5% annual inflation, then in four years time we will have to pay 600 X 1.035 X 1.035 X 1.035 X 1.035 = $668.5; this is the figure than one puts into the cash flow whilst leaving the cost of capital unchanged. The other way of doing this is by leaving the price at $600 and reducing the cost of capital by 1.035 to the power of four, but this seems to be less intuitive even though mathematically it is exactly the same.

Anyway: the pressure is relieved and I am confident.

Kindle arrives

I received my Kindle on Friday lunchtime. At first, I thought that I was missing a cable, but it turns out that the power cord is one of those new-fangled dual-function cables which serves as both USB and power cable. My first act upon arriving home was to connect the Kindle to mains electricity via the USB charger.

After a few hours, I became inquisitive as to whether the Kindle was fully charged (apparently not) and whether I could use it. After a fair amount of scratching my head and looking at web sites, I was just about to write to a technical support site when I noticed another post in which someone wrote about having problems turning the Kindle on. "One has to turn the Kindle on?", I asked myself. I then had a close look at the user guide (which is on the web and on the Kindle, but of course I couldn't access the Kindle version yet) and discovered that there is a recessed power button. I pressed the button and the Kindle came to life. I laughed for about five minutes.

Once I crossed this minor hurdle, I saw fairly quickly how to use the controls. There are still some things which I haven't learnt yet but I'm sure that I'll catch on quickly. I connected the Kindle to my computer and loaded all the books which I have stored in preparation for this great event. Then I was indeed able to read books.

Two observations: one can sort the books by title, by author or by last loading date. It would be more useful if I could sort by last access date. I will have to see whether this is possible.

Secondly, most books - even if they were originally PDF files - converted well and are readable. It seems that the PDFs aren't as navigatable as the MOBI files, as they are lacking chapters. I had converted the PDF text to my current MBA course to MOBI and looked at this on the Kindle. When the text was pure text, then it was easily readable, but tables and formulae came out in a wrong format and are useless. Reading the finance text was very difficult, so I think I'm not going to bother with this again. On the other hand, my next MBA course will be 'Negotiation', and I imagine that this will be mainly text so it should be readable.

Early days yet, but the machine seems promising.

Wednesday, November 09, 2011

Feeling the pressure

My exam in finance will take place in four weeks (and one day), theoretically plenty of time to become even more acquainted with the material. Despite this, every morning I awake with the emotion of anxiety running through my body.

Every week there is a lecture on Friday morning and a 'practice session' on Tuesday evening, in which the lecturer goes over previous exam questions and solves them. Yesterday evening was the first time that I attended such a session, and noted that there was almost 100% attendance. The first question which the lecturer chose to solve covered about 60-70% of the curriculum, so obviously it was a good choice. 

I haven't attended these sessions for a few reasons; first of all, I can manage quite well on my own to solve the questions (although a bit of help will go a long way!), and secondly I imagine that the pace of these sessions is quite slow. It wasn't quite as slow as I had thought that it would be but I still had plenty of time in which to twiddle my thumbs and progress within the question (which is really a scenario with five or six questions to be solved) before the lecturer caught up.

She has given us a few more questions to do as homework; I am going to work on these on my own and hopefully finish them before Friday's lecture (it depends how much time I will have to devote to them). If the homework goes ok, then I won't bother attending next week. We have the answers to all the questions so I'm not dependent on 'handing in the homework' in order to see how well I have done. Of course, the temptation exists to read the answer before attempting the question, but the value of doing so is negative - the idea is to learn how to solve the questions and not particularly to solve them.

I will definitely go over the exam questions which she solved last night as it is important to get into the habit of solving them, to recognise which fact means what, which details can be ignored and which are very important.

Apparently the lecturer had provided in a previous session an analysis of subjects and in which exams they had occurred. I don't like playing 'exam lotto' very much as it can be dangerous. Even so, it is clear that certain subjects such as cash flow (the most basic concept), CAPM and risk in a company which has two separate divisions are going to appear in the exam.

Unfortunately for me, there are quite a few sub-questions which require writing about theoretical models as opposed to calculating values. I imagine that most people find the written material easier to regurgitate as opposed to the numbers, but I'm inclined the other way.

Friday, November 04, 2011

User defined menus

In our weekly meeting today, the Occupational Psychologist raised the possibility of adding user defined menus to her management program. At first I demurred, as the menu is something which is fixed at compile time, but later I figured out a way in which to implement this.

Fortunately, I have already defined a table ('progs') in the program which lists all the forms which I use to track program usage. To this table I added two new fields: the option's name in Hebrew, as it appears in the main menu, and a flag to show whether this is indeed an option which appears on the main menu. Then I added to the form which adds data to the above table fields so that I could mark the required forms.

The next stage was to define a table ('usermenu') which contains the data regarding the user defined menus: an id, the user's internal id number, the menu option's program number and the display order of the option. Then I defined a pair of forms which allow the user to maintain a list of her options, to set the order and to add/remove items.

I haven't gone into much detail regarding the above because it's all fairly straight forward. The challenging part was figuring out how to read the table and turn the entries into real menu entries at run time. Creating menu entries at real time is not difficult, but connecting a random menu entry to the correct event handler (what should the program do when the new option is clicked) is the crux of the matter.

I handled (sorry about the pun) this by finding the pre-defined event handler for the menu option and copying its event handler into the new menu option. For example, if there is an entry in the 'usermenu' table for the program 'DoDockets', then the function FindOption, which appears in the code below, traverses the fixed menu structure looking for a menu item whose caption is 'DoDockets'. The function exits when the match is found, and this menu item's event handler is copied.

The program knows that it is to add the dynamic entries to a main menu whose name is mnUser.
procedure TMainForm.FormShow(Sender: TObject);
 item, original: tmenuitem;
 menucaption: string[31];

 Function FindOption (const s: string): TMenuItem;
  found: boolean;
  i: integer;
  tmp: tmenuitem;

  found:= false;
  i:= -1;
  while not found do
   begin // traverse main menu
    inc (i);
    tmp:= mainmenu1.items[i].find (s);
    if tmp <> nil then
      found:= true;
      result:= tmp

// handle user defined menu
 with qUserMenu do
   params[0].asinteger:= user;
   while not eof do
     menucaption:= fieldbyname ('hebrew').asstring;
     original:= FindOption (menucaption);
     item:= TMenuItem.Create (self);
     item.caption:= menucaption;
     item.OnClick:= original.OnClick;
     mnUser.Insert (fieldbyname ('disporder').asinteger, item);
I think that this is a really neat piece of code. It occurred to me when I was documenting this that I could add hot keys to the dynamic menu options: F1 would activate the first option, F2 the second, etc. At the moment, the F keys have been assigned to what I thought were the important options but the importance changes as time goes by.

Coffee addicts (Millennium trilogy)

Here's a paragraph which I filched from the New York Times book review about the Millennium trilogy:

But these transparently “activist” moments are forgivable, as is the pathological coffee drinking, a tic that recurs so relentlessly that I don’t think Larsson realized it was a tic. A thought on this subject: Many of the Larsson faithful subscribe to a belief that the author’s premature death was not of natural causes. He had been threatened in real life by skinheads and neo-Nazis; ergo, the theories go, he was made dead by the very sorts of heavies who crop up in his novels. But such talk has been emphatically dismissed by Larsson’s intimates. So let me advance my own theory: Coffee killed him. If we accept that Blom­k­vist is, in many respects, a romanticized version of Larsson, and that Blomkvist’s habits reflected the author’s own, Larsson overcaffeinated himself to death. Of course, the cigarettes and junk food to which both men are/were partial couldn’t have helped, either.

Not being a coffee drinker myself, I tend to ignore people's coffee consumption in the same way that I tend to ignore the amount they smoke. I point out that "The time traveler's wife" also has coffee addicts and I lazily assumed that this was an American habit (not that the Millennium trilogy is American). I have often wondered why in the film "You've got mail", Tom Hanks and Meg Ryan frequently drink tea (a British habit) but not coffee.

Thursday, November 03, 2011

The thousand-dollar penalty for reusing passwords

This is from a computer orientated newsletter which I received this morning. There is some personal relevance which I will mention at the end.

The thousand-dollar penalty for reusing passwords
Right-click here to download pictures. To help protect your privacy, Outlook prevented automatic download of this picture from the Internet.
Woody Leonhard By Woody Leonhard

You can find no end of advice on creating strong passwords, using clever tricks, stats, mnemonics, and such.

But all too frequently we (and I include myself in this rebuke) tend to reuse little passwords at what we think are inconsequential sites. It's a big mistake — here's why. This story is true. As the admonition goes: only the names have been changed to protect the innocent.

I live in a small town a couple of hours away from a big city we'll call Metropolis. There are several daily newspapers in Metropolis, and one of the largest (let's call it the Daily Planet) boasts a very nice website. The people who create and maintain the Daily Planet site are excellent designers and programmers — but they aren't security experts.

One of Metropolis's citizens is a regular guy named, oh, Joe. He's pretty good with computers, and he knows enough to use strong passwords on bank and stock-market sites. But Joe just got hacked — and bilked in a most unexpected way.

Using simple passwords for unimportant sites
The Daily Planet's website, like most big newspaper sites, lets its readers set up accounts for a variety of services. For example, subscribers can receive e-mail notifications about important breaking-news stories. They also need an account to comment on editorials and to submit photos for the newspaper's photo-judging contest. About 25,000 people have accounts.

Years ago, Joe signed up for a Daily Planet account, using JoeKewl as his user name and for his e-mail address. And because the Daily Planet site should not have posed any real security issues — no sensitive personal information was at stake — he used an easy-to-remember password he frequently employed for such occasions: 12345678.

At some point, Joe's Daily Planet account fell into disuse; he rarely thought about it. Meanwhile, the Daily Planet's website admins were focused on online publishing, applying their energy on search-engine optimization and site layout with a bit of SQL Server and PHP on the side. They knew about security but weren't terribly worried about hackers. Their thinking was: Who in their right mind would want to steal sign-in data for people commenting on news stories?

A new black-hatter beats a site's security
But there was a who — a self-styled password cracker residing in a completely different country. Someone driven to show his hacking moxie by cracking a Web server. He acquired a free version of Havij (more info), a SQL Injection hacking tool with a "user-friendly GUI and automated settings and detections, to make it easy to use for everyone, even amateur users," according to the IT Security Research & Penetration Testing Team's Havij 1.15 user manual. He watched the YouTube video and went through the Havij tutorial — and soon knew how to run a SQL injection attack.

The cracker didn't really care what website he cracked; he was simply looking for a site with simple sign-up routines. Eventually, he discovered that the Daily Planet's website fit the bill nicely. Within a couple of hours, the cracker had figured out how to access the Daily Planet's reader database. He was able to crack only one of the four SQL tables at the site, but that netted him 5,200 user records. He got really lucky because (and this is key — no pun intended) the Daily Planet's site stored user data in the clear — none of it was encrypted.

Then the cracker decided he was hot stuff and wanted to tell the world. So he posted 200 of the stolen records on a public website, claiming he'd post more if enough people subscribed to his Twitter feed. To publicize his accomplishment, he convinced one well-known underground tweeter to send out details about where to find the stolen data.

Using a password once too often spells 'break-in'
This is where I came in. All of this happened in a town not far from where I live. But I caught wind of it only when I checked an underground tweeter account I monitor. By then, the cracker had posted 3,400 user names and more than 300 people had viewed the list. Joe's name was at the top of the list.

One of these 300 visitors soon signed onto a local financial site, using Joe's stolen e-mail address and password. (I won't mention the site by name, but it's an institution in Metropolis.) The password didn't work, so the bad guy clicked the Forgotten Password link. As expected, the financial institution's automatic password-recovery routine offered to e-mail a new password to Joe's Yahoo account.

Next, the bad guy signed onto Yahoo Mail using Joe's e-mail address and entered the password (12345678) he'd stolen from the Daily Planet password list — and sure enough, he got into Joe's Yahoo account. From there, just a couple of clicks gave the bad guy full access to Joe's online financial account.

There are countless other ways Joe could've been compromised, but Joe made the bad guy's job much easier by using the same password for both the Daily Planet and the Yahoo Mail accounts. Joe will most likely get his money back — eventually. But he could have avoided a lot of hassle by simply using a unique, throwaway password for the Daily Planet.

My personal part
As it happens, there was an article in one of the online British newspapers yesterday that so annoyed me that I felt compelled to write an online comment about it. The website demanded that I create a user account; for a change, I decided to use my work email address and a password which is not in use any where else. Thus if the newspaper's web site gets hacked as described above, the email containing a one-off password will be sent to my work email. This password won't allow anyone to access my online bank account. I doubt whether my work email will be hacked either, but that's another story. The 'forgotten password' trick won't work because on the bank's website I use a different email address.

Wednesday, November 02, 2011

The girl who kicked the hornets' nest

Whilst collecting books for my soon to arrive Kindle, I read the electronic version of the above book, which is the third (and final) installment of the Millennium trilogy). I very much enjoyed this, so much so that I went back and reread the first two books. Doing so changed my mind about the series.

My review of the second book had left a slightly sour taste in my mind, and indeed this ends with the words: On the basis of GPF, I can't see myself reading the third part of the "Millenium trilogy", "The girl who kicked the hornets' nest". I would probably see any film made from these stories but I won't be investing any more money or time in these books. Well, there's nothing like consistency in personal decisions.

Again, as I wrote then, These pages give one the (post-reading) feeling that Larsson was making the whole thing up as he went along, and inserted events (or "hooks", as the musician or computer scientist might call them) as they occurred to him. If later events revolve around prior knowledge which is given by these hooks, then the reader feels satisfied, but if the hooks are left unresolved, then the feeling is awkward.

The third book resolved the hooks displayed in the second and so I finished the trilogy in a much better state of mind. Even so, my criticism of the series, that the books needed an editor, is still valid. The third book doesn't seem to suffer so much from this problem, but still there are paragraphs that could easily be excised. It is good that Larsson invents a back story for his characters, even the most fleeting, but most of this material should have remained as reference material for him and not placed in the books. I got the feeling that the entire series could be improved if one paragraph per page were removed.

After having completed the series, I began asking myself what it was all about. The second and third books seem closer to each other (the third is a direct continuation of the second) which deal with Lisbeth Salander's heritage and legal status. Viewed from this aspect, the first book seems strangely out of place - all the business about Harriet Vanger seems to be one giant red herring.

But bearing in mind that the book's original Swedish title was Men Who Hate Women, a different reading is possible. The Vanger story is also about two men who hate women and serves as a story within a story for getting Larsson's point across. The problem is that Larsson writes with a blunt sledge-hammer instead of a sharp lancet.

There are still issues which irk (aside from the writing style). Co-protagonist Mikael Blomkvist sleeps with virtually every female character in the books but no one has any problems with jealousy. Lisbeth Salander can break into any computer in the world and extract knowledge from them, but no one has a problem with this. She even manages to extract illegally a fortune from a corrupt financier in the first book (as we say in Hebrew, he who steals from a thief is protected from the law), but as only Blomkvist knows about this (or rather, he suspects this as he has no real proof), one can gloss over this. The moral of the story is not to save any document of importance on one's computer, or at least, computers which are connected to the Internet.

Maybe one shouldn't dig too deep.

Sunday, October 30, 2011

Succulent Sunday

I saw a new (to me) recipe for chicken legs the other day so I thought that I would try it on the family. Technically, this is a simple recipe: one takes chicken drumsticks and thighs, marinades them for a few hours and then cooks them in the oven. The unusual part is the marinade:
  • mayonnaise: three spoonfulls
  • orange jam: four spoonfulls
  • ground ginger: one spoonfull
  • sesame seed: two spoonfulls
  • soy sauce: two spoonfulls
  • onion soup powder: two spoonfulls
One mixes this seemingly random list of ingredients together then pours the resulting brown liquid onto the chicken pieces. One cooks them uncovered for an hour and a half at 150-175 degrees Centigrade, turning the pieces over at half time. When I turned them over, I sprinkled more sesame seeds onto the chicken, giving them a speckled appearance. I think that one can leave the sesame out of the marinade and only use it to dust the pieces, as they didn't seem to add any crunchiness.

When one of my children noticed the tangy aftertaste arising from the jam, they started asking what the ingredients were. I playfully included some fantasy touches, such as bat and ground unicorn horn; I have a suspicion that it wouldn't have made much difference had I included these, as the family were quite amazed at what I did include.

Yesterday I prepared deboned chicken drumsticks stuffed with cranberries and apple puree, cooked in the slow cooker. This was delicious. The drumsticks were larger than the previous batch of deboned drumsticks, making them easier to stuff and easier to eat. Even so, I'm not totally satisfied with them and will try and find a better source (these came from a butcher). The price was also surprisingly high; I normally buy frozen drumsticks at around 27 NIS/kilo whereas these cost 44 NIS/kilo with an extra 6 NIS for the deboning (they were weighed before the bones were taken out). The dog was disappointed that there were no bones left for her to chew.

Sir Jimmy Savile

Yet another one goes

Wednesday, October 26, 2011

Thursday, October 20, 2011

Firebird DB management tool (4) - Corrections

I was struck by an insight the other day: instead of using special buttons in my db management tool for inserting, deleting and updating, I could use the dbNavigator component. This is a component which I never use as it seems to be most effective when directly editing grids, an activity which I never program. So the component was far from my mind, but exactly what I needed for this tool. I didn't even have to program the navigator's buttons - they 'knew' exactly what to do. I define which buttons are active depending on whether the query is live or not.

It also turned out that there was a problem with the tokeniser in the parse routine: I hadn't really checked any semi-complex queries. This wasn't too difficult to fix but was rather annoying.

Tuesday, October 18, 2011

Dennis Ritchie: The man who created Unix

Read this article:
It's funny how fickle fame can be. One week Steve Jobs dies and his death tops the news agenda. Just over a week later, Dennis Ritchie dies and nobody -- except for a few geeks -- notices. And yet his work touched the lives of far more people than anything Steve Jobs ever did. In fact if you're reading this online then the chances are that the router which connects you to the internet is running a descendant of the software that Ritchie and his colleague Ken Thompson created in 1969.

That's just the opening paragraph. 

Monday, October 17, 2011

Getting ready for the Kindle

Even though I won't be receiving my Kindle for another few weeks, I thought it prudent to utilise my holiday time in order to start building an e-book library. It turns out that there are plenty of e-books available, if one knows how (and where) to look. I have managed to collect around 280 books, of which I own (or have owned) about 90%.

It will be interesting to see how my reading habits will change. I have managed to find books which I once owned and lost/gave away/discarded over the years; I wonder whether these books will find favour in the 55 year old me. A case in point is Philip Roth's "Portnoy's Complain", an archetypal book for adolescents. I was informed about this book by my History teacher whilst in the fourth year of secondary school, aged 14. I have no idea what happened to my copy of the book; it probably disappeared a few years after I bought it. I'll read the book and probably delete it immediately afterwards. This behaviour will be interesting from a psychological point of view. Should I keep the book even though I know I'll never read it again (regret)? Should I delete the book from the Kindle but keep it on my computer?

One very useful tool for the Kindle is the ebook library manager/conversion tool Calibre. It took me a few hours to figure out how to use this program effectively, but once on the right track, there was no stopping me. Apart from maintaining a database of my e-books (title, author, tag/style and other bits and pieces), the program excels by being able to convert a multitude of formats into a multitude of formats. As the native format of the Kindle is MOBI, I was only interested in converting to this format. The books which I have found have been in formats txt, pdf, doc, rtf, zip, lit, epub and probably a few more; Calibre had no difficulty in converting them. 

To be honest, I haven't looked at the output so I don't know how good the conversion engine is. I imagine that there should be little problem in converting lit or epub books to mobi, but I understand that doc files - with tables and diagrams - are liable to be problematic. Fortunately I don't think any of the books I found fit into that category.

I also discovered that the Edinburgh Business School, in whose MBA programme I am enrolled, does offer its course material (to registered students) as PDF downloads, so I downloaded the material for the Finance course and converted it. This will be useful to look at the closer I get to the exam (first week in December).

From a programming point of view, Calibre is interesting because it implements a database without a traditional database manager. I think it does this via text (or similar) files but I haven't been interested enough to examine this yet. The interface is also interesting; the conversion part of the program seems to be implemented as a separate thread whereas the rest of the program typically used modal dialog boxes only.

Saturday, October 15, 2011

A new dish makes its debut

I related how my daughter cooked us roast beef for our New Year's dinner two weeks ago; she used a cut of sirloin and cooked it in the oven. I made a rare appearance in a local supermarket and noticed that they were selling cuts of frozen beef (apparently the cut is "cross rib pot roast") for about a third of the price of the sirloin. I make an instant decision to buy such a cut (just over 1kg) in order to cook roast beef in the slow cooker.

I had found a suitable recipe a few weeks ago which I tried on this cut. Yesterday, I took the defrosted cut of meat and made stab holes in the sides which I then filled with chopped garlic. I placed the entire cut in a marinade of olive oil, rosemary, salt, pepper and paprika; this I placed in the fridge for 20 hours. Early this morning, I placed the marinaded meat in the slow cooker; I added diced carrots, green beans, onions and potatoes (the usual suspects) and turned the cooker onto high for five hours. As opposed to the oven method of cooking, there didn't seem to be any need to let the meat rest, as five hours in the slow cooker should have let the heat disperse equally throughout the meat.

The results were very good, so much so that I am adding this dish to my repertoire. It's not too expensive, and the rest of the family enjoys a cut of beef (I don't care for beef myself, and normally bits get caught in my teeth, but today, my teeth seem beef-free). I'm doubtful about the garlic and marinade; next time, I think I'll brush the cut with olive oil and sprinkle the spices onto the oil. 

It would have been nice to have a little gravy; maybe next time, I'll remove the liquid which forms in the cooker, add a little corn flour and prepare a separate gravy. My father and my wife spread mustard on the beef slices, a taste which I didn't care too much for.

Friday, October 14, 2011

Dieting has a number of destructive side effects

On the first of September 1993, I wrote the following in an email (slightly edited, mainly to correct the English):

I receive a weekly newsletter at work, written by a sort of computer consultant (he's actually a retired priest), focusing each week on a different subject. Sometimes it's not interesting, normally it's worth reading, and every now and then there's an issue which is really interesting. So it was a few weeks ago when he wrote about self-improvement, and in connection with that, he wrote about the psychologist Martin Seligman, who has written a couple of books, "Learned optimism" and "What you can change ... and what you can't " . I was very interested by what I read, and checked these books out at Amazon, which has 20 sample pages from each book. So impressed was I that I ordered "What you can change" there and then.

The book came a few days ago, and whilst it was more academic (or less populist) than I had expected, its message was still very strong, and in certain respects, surprising. One of the main thrusts of the book is that many of our behavioural patterns are genetic and cannot be changed; most of these traits derive from our prehistorical days, when the main goal of the human being was to survive and protect itself. But also there are patterns which can be changed, and it's important to recognise what can or cannot be changed, in order to concentrate one's efforts at self-improvement in an area which stands a chance of being improved. Thus he writes at great length about dieting, how the body settles at a certain weight, and how the actual process of dieting causes irreversible biochemical changes in the body with regard to fat metabolism, which causes people to put more weight on when they cease dieting.

That book was the first in a long series of purchases whose subject matter varied from psychology to neuroscience, with a great deal of interest in the brain. I've stopped buying such books, partially because it's difficult to find a book which is both interesting and well written, and partially because I am less interested in the subject now (or maybe I've read enough).

Anyway, something reminded me of the book and its chapter on dieting, so I pulled it from the shelf last night and read it again. Here are three concluding points:
  • Weight is almost always regained after dieting
  • Dieting has a number of destructive side effects including repeated failure and hopelessness, bulimia, depression and fatigue
  • Losing and regaining weight itself presents a health risk comparable to the risk of [being] overweight
I'm not being fanatic about my diet and there's no way that I'm going to become bulimic nor depressed, neither about my current weight nor the possible failure to maintain a lower body weight. 

I notice that in the past two days my weight has increased slightly, from 80.0 kg on Monday to 80.4 kg on Thursday. Again, it will be interesting to see what happens after next Sunday's acupuncture treatment. I only have three treatments left in this series; I may return for another series in January.

The fact that I am writing so much about my weight indicates that the subject is currently important to me; I would like to eat normally without having to calculate whether I can afford the calories. Actually, when I am at work, things are easier as I only have a very limited supply of food available and my mind is distracted with other matters (such as work, which is very much a cerebral activity in my case). It's harder when I'm at home - and as this is currently the holiday season, I worked three days this week and rested four days. Next week will be the same.