Seven

Seven years ago was wonderful, and now is more so.

The Pareto Principle: 80/20 rule.

The Pareto Principle was discovered when Vilfredo Pareto observed that 80% of the land in Italy was owned by just 20% of the population. Since then, many other people in different disciplines have observed similar 80/20 distributions.

In programming this often means that the last 20% of a development project can require 80% of the cost. Knowing this, it would make sense to concentrate on producing a 80% solution; this would happen if you use the "worse is better" philosophy.

It seems that the same principle can also apply to car repair. My car had been sluggish and inefficient recently, so I went to the garage today. The mechanic examined the engine and determined that the problem was a build-up of carbon on the valves that stopped them closing correctly. He told me that the correct way to fix this problem was to remove all the valves and clean them by hand: this would cost at least

Selective recursive file copy

Tony suggested I post useful tips to my blog. He persuaded me to start the Vim category, and now suggested I post this too.

There are lots of little things I do that I don’t think are interesting or useful, but Tony thinks they are when he sees them. I suppose this could be a case of familiarity breeds contempt; I don’t recognise how useful something could be because I use it all the time.

Anyway, today Tony wanted to recursivly copy all the regular files from his current directory to another one; he didn’t want to copy symlinks or anything else. As usual, he wanted a one-liner. So, I did this:

tar cf - `find . -type f -print` | tar xCf /home/tony/otherdir -
Published
Categorized as Uncategorized Tagged

Help me, vim

Have you ever been editing a script or program in vim and had to open a man page for a command, function, class, or Perl module you’re trying to use? If so, you should use the K command to do it for you. Move your cursor over the command word, hit K, and vim will display the man page for you.

Published
Categorized as Uncategorized Tagged

Love your SMTP neighbour

Postfix is my favourite MTA for reasons I’ll not go into at the moment. It’s much better than sendmail.

Recently there has been yet another sendmail vulnerability, but I didn’t care because I use Postfix. Wietse Venema, the author of Postfix, did care. He could have said "sendmail sucks; use Postfix", but instead he wrote a patch for Postfix to remove the sendmail exploit from messages before they reach sendmail. Kudos.

Published
Categorized as Uncategorized Tagged

Round them up, put ’em in a field, …

4 hours is enough time to watch a good film and have a good meal. It’s also just enough time to find a very annoying bug.

My script wasn’t inserting all its stuff into the database, but it was inserting part of it so I knew it wasn’t a database connectivity problem; it was also reaching the end without complaint, so I knew it wasn’t dieing somewhere. It thought it was doing the right thing.

The code looked correct, and I had similar scripts that worked, so I starting cutting bits off (the code). Eventually I had two scripts, one working and one failing, with the following diffs:

-my ($username) = "marty" or exit 65;
+my ($username) = ($rcpt =~ /(\w+)\@$MX/) or exit 65;

Now I knew I would be here for quite a while: someone somewhere in the code was using one of those irritating regex variables without checking if their match had actually worked! AARGH!

The offending code looked something like this (I’ve simplified it so it won’t distract from the bug):

    $text =~ m/:(\w+);|==(\w+)==/;
    return $+;

So, when $text was "foobar", the match failed and $+ still contained the last bracketed part of a previous unrelated match.

The code should have been something like:

    $text =~ m/:(\w+);|==(\w+)==/  or return;
    return $+;

I do try to be thankful in all circumstances: I’m glad I was using Free Software that I can debug and patch.

Published
Categorized as Uncategorized Tagged

TyreServe can’t

New Year’s Eve, somebody slashed 3 of my tyres while my car was in a car park in Belfast. We suspect it might have been the car park staff, but we can’t prove that.

I phoned the AA and they sent someone out to take us home, with car; they tried to get replacement tyres, but couldn’t find any.

I phoned them early yesterday morning to see if they could help, and they arranged to send TyreServe to help. TyreServe phoned me back and promised to be here at 11:30, so I waited.

At 11:30 TyreServe phoned again and said they were on their way. 25 minutes later the TyreServe man in the van phoned to say he was about 15 minutes away. I asked where he was, and he said he had just left the M6. This concerned me, as we don’t have an M6 in Northern Ireland! I explained this to him; he sounded confused and promised that someone would get back to me. They never did.

I called the AA again, told them what had happened, received more empty promises, complained, waited until 14:00, and then got the train.

TyreServe suck!

This morning I phoned ATS who promised to fit my new tyres at 9:30, and they did. I also discovered that the AA used to ask ATS to fit tyres until they bought TyreServe.