May 20, 2008

What’s in your phone number?

Filed under: Uncategorized — Leigh @ 3:58 pm

Recently I’ve been entering a lot of phone numbers in a database. This is dull. Phone numbers do, however, open up a load of (slightly) interesting geekery.

One of the problems I had was with the London dialling code. Numbers in London tend to start with 0207 or 0208. I decided that this seemed like a reasonable dialling code. Some people tended to list their phone number as (020) 8…… but I discounted that - after all it looks very European and not at all like other British numbers.

Unfortunately my slightly Euro-phobic decision turned out to be completely wrong. I was labouring under a common misapprehension. Luckily I’m not alone, and it isn’t really my fault. After all, even BT seem not to understand, listing 0207, 0208, and 0203 as separate codes.

From quite an amusing rant:

Worse still, on some telephone networks the call return (1471) service reads out numbers in these wrong forms. For any company to have let this bug slip through in the first place is bad enough, but I can’t for the life of me understand how any of them can have not fixed it by now. You’d think that basic knowledge of how phone numbers work is essential to the ability of a phone service to function. In any case, anybody who cannot understand such a simple aspect of a phone numbering system has absolutely no business to be working in a phone company. But perhaps worst of all is that some websites devoted to providing information on dialling codes, such as UK Phone Info, are giving false information in this department.

Luckily reading further down the page gives some clear instructions. UK area codes are either:

  • (02x) [London]
  • (011x)
  • (01×1)
  • (01xxx)
  • (01xxxx) [very rare]

If you want to know what all the area codes are, then you can, as always, consult Wikipedia. Their list is particularly useful in that it reveals the origins of many area codes as mnemonic versions of their place name. For example, Cambridge starts with the letters “CA”. If you wanted to text that on a mobile phone you’d use the number 2 key twice. So the Cambridge area code starts 0122x. In this case it’s the third area code of this form, some others being Cardiff, Aberdeen, Bath and Carlisle.

I think it’s very satisfying learning about the origins of complex systems such as the UK area codes and their history. And now you can too.

May 19, 2008

Link of the day

Filed under: Uncategorized — Leigh @ 11:39 pm

MSDN:

All print providers must export the initialization function, InitializePrintProvidor. Pointers to all the other functions must be supplied in a PRINTPROVIDOR structure. (Note that these two names are misspelled, but are consistent with the names that appear in the header file, winsplp.h.)

Of course, one can’t correct the spelling of one’s functions, else one breaks the principal of backwards-compatibility. (via Raymond)

Open Source Software - a Chink in the Armour

Filed under: Uncategorized — Leigh @ 4:09 pm

The collective wisdom of the Internet states pretty categorically that Microsoft is evil, Google is never evil, Macs are cool and Linux is best of all.

Of course not all of that is true, and you can’t always believe what you read on the Internet. Google isn’t evil but colludes with dictatorships to oppress freedom of their citizens, Macs look cool but have an increasing tendency to break, and Linux has a few small issues.

We’ll get over the fact that I couldn’t install it on my new PC, and the fact that for non-technical users it’s a bit of a nightmare to use and configure.

A couple of days ago I was amused to receive an email from one of the hosting companies I use along the following lines (paraphrased):

Big exploit in Debian!

Bad!

Change all your passwords and run for your lives.

Linux distributions all exist in a sort of family tree. One of the big strengths of open source software (OSS) is that you can edit the source and create your own version of it to suit your needs. This becomes a problem. Looking at this chart we can see that this problem probably effects:

  • Debian
  • Ubuntu
  • KNOPPIX
  • About 20 other derived distributions

And the problem itself?

The problem is with the implementation of OpenSSL, some security software which is widely used. The Debian package editors commented out a line which turned out to be quite important, dramatically reducing the security offered. There’s some good links available from Schneier on Security.

Ben Laurie explains more about the problems:

I’ve ranted about this at length before, I’m sure. But now Debian have proved me right (again) beyond my wildest expectations. Two years ago, they “fixed” a “problem” in OpenSSL. The result of this is that for the last two years anyone doing pretty much any crypto on Debian (and hence Ubuntu) has been using easily guessable keys. This includes SSH keys, SSL keys and OpenVPN keys.

What can we learn from this? Firstly, vendors should not be fixing problems (or, really, anything) in open source packages by patching them locally - they should contribute their patches upstream to the package maintainers. Had Debian done this in this case, we (the OpenSSL Team) would have fallen about laughing, and once we had got our breath back, told them what a terrible idea this was. But no, it seems that every vendor wants to “add value” by getting in between the user of the software and its author.

This is a problem with all code in general, but is a real problem with OSS. Someone writes code one way for a reason, but that reason isn’t always obvious to those maintaining the software. All it takes is someone to do something daft and break it.

Is the Network Timeout Dead?

Filed under: Uncategorized — Leigh @ 3:17 pm

Computers are quite good at waiting. My computer spends a substantial proportion of its day in an idle state waiting for me to do something. It also spends time waiting for network resources, and it makes me wait too.

When I go to a webpage or request something online the computer needs to download everything it needs from a server in the cloud. This might be hundreds of miles away, and the data might need to propagate through tens of separate machines before it gets here. This inevitably takes time, and computers deal with this by waiting. What if the item can’t be found, however? I don’t mean “the item isn’t on the server” but “we can’t even find the server - it’s not answering.” This is dealt with by waiting - but not waiting too long. If a response doesn’t come back after a certain amount of time then the computer decides that it isn’t going to come at all.

This all seems quite sensible. It’s difficult to detect the absence of something at the end of your wire except by seeing whether it responds or not. This decision is complicated by the latency in the network. So we have to set a threshold, i.e. a network timeout. If the server usually takes .5 seconds to respond, and we’ve waited for 3 seconds, then it probably isn’t going to answer.

“Connection timed out” error messages via your web browser of choice are annoying, but not infuriatingly so. There are more significant problems inherent in operating systems, however. If your computer uses a logon script to connect to shared network drives then subtle problems start to develop. Usually you’d log on in a few seconds, but now a blank screen appears for half a minute after clicking the “Enter” button.

A better solution would be helpful, but it doesn’t seem likely that there is one. The network timeout isn’t dead at all and isn’t going away anytime soon. All I have to do now is figure out how to decrease it…

May 16, 2008

Misinformation on the Internet

Filed under: Uncategorized — Leigh @ 10:41 pm

Recently I’ve been writing code to produce a database of Alumni in the University’s Architecture Department where I work. Somewhat irritatingly the servers all run on IIS which required me to learn how to talk to SQL Server with ASP. The irritating part being that I’ve only just learnt how to talk to MySQL with PHP in order to make bits of this site work (like the diary).

During this process I’ve spent quite a while looking through the Microsoft documentation available on MSDN as well as searching the Internet. It’s laborious to search through documentation when so much is available just by firing up a search engine.

For my latest project at work I’ve had to rename photographs to match details in an Excel Spreadsheet. Since I already had Excel up-and-running, I decided to use Visual Basic for Applications to write a Macro to do the job. Although I’ve been programming in BASIC for years there’s lots of API calls to learn to make Excel do what you want it to.

In my youth I had never learnt the mysteries of escaping character strings. Now in many programming languages character strings are delimited using double quotes (”). Thus to store a string one could use a command like the following:

$poem = "Mary had a little lamb."

Now let’s see what happens if we store a more complicated string. I’m going to try: Mary had a little lamb, whose name was “Flossy.” Now let’s put that in the code:

$poem = "Mary had a little lamb, whose name was "Flossy.""

Now there’s a problem. The character string starts with the first set of quotes, and ends with the second set. So our string becomes “Mary had a little lamb, whose name was “, and the remaining characters cause an error.

So I fired up the Internet, and searched for “visual basic escape quotes.” I found several solutions along the following lines:

$poem = "Mary had a little lamb, whose name was " & Chr(34) & "Flossy." & Chr(34)

That is, instead of writing the quotes as part of the string, we join them in using their character code. A little guess work (and further searching) established the proper way of doing things:

$poem = "Mary had a little lamb, whose name was ""Flossy.""

I.e. you double each set of quotes.

I suppose the moral of the tale is not to trust everything you read on the Internet, but you knew that anyway. Perhaps it isn’t such a good substitute for buying decent programming books and downloading the proper specifications.

Wordpress

Filed under: Uncategorized — Leigh @ 10:22 pm

I was amused to have finished migrating this blog over to Wordpress to read this article on Coding Horror:

I’ve been thoroughly impressed with the community around WordPress, and the software itself is remarkably polished. That’s not to say that I haven’t run into a few egregious bugs in the 2.5 release, but on the whole, the experience has been good bordering on pleasant.

Or at least it was, until I noticed how much CPU time the PHP FastCGI process was using for modest little old blog.stackoverflow.com.

I’m not alone; just do a web search on WordPress CPU usage or WordPress Digg Effect and you’ll find page after page of horror stories, most (all?) of which are solved by the swift and judicious application of the WP-Cache plugins.

It’s not like this a new issue. Personally, I think it’s absolutely irresponsible that WP-Cache like functionality isn’t already built into WordPress. I would not even consider deploying WordPress anywhere without it. And yet, according to a recent podcast, Matt Mullenweg dismisses it out of hand and hand-wavingly alludes to vague TechCrunch server reconfigurations.

Oh well, I’ve installed the caching plugin and thus won’t get stroppy messages from my hosting company about server load. Hopefully.

I’ve finally managed to make the blog page look vaguely like the rest of the site, though this was a somewhat frustrating problem. Making changes to the theme isn’t anywhere near as easy as on Blogspot.

The hardest bit was dealing with my blogroll. This is auto generated by Bloglines, as I described a while ago. Annoyingly Bloglines spits out a bit of HTML with each link contained within a <div> element. I needed <li> elements as the sidebar is built as sets of bulletted lists. In the end I managed to do the conversion using XSL Transforms. They’re neat.

May 13, 2008

Further reading - Godwin’s Law

Filed under: Uncategorized — Leigh @ 8:08 pm

Having recently discussed the strategy of comparing one’s antagonist’s actions to those of the Nazis, I was amused to notice Dr Crippen referring to a similar technique:

Over the years, I have seen far too many women who have been raped. There will be others, patients of mine, who have not sought help from me and possibly, indeed, not sought help from anyone. I have also seen some women who have had bad obstetric experiences. Sometimes not anyone’s fault. Sometimes, sadly, there have been problems with unsympathetic doctors or midwives. I have seen patients who, as a result of their bad experiences, have developed post-natal depression. I have never had a patient compare their experience to rape. A bad obstetric experience is not rape, nor is it anything like it.

In this case women are comparing their poor birthing experiences to being raped. Admittedly giving birth can be traumatic if things go wrong. Medical staff often don’t have time to explain everything going on when they try to act in a crisis. I would suggest that nothing which occurs as part of the process of childbirth could ever be described using the term rape.

One of the commenters on the post described the practice via Godwin’s Law. The law states:

As a Usenet discussion grows longer, the probability of a comparison involving Nazis or Hitler approaches one.

Clicking on the right link yields the correct name for the practice previously described:

Reductio ad Hitlerum is a modern fallacy in logic. Engaging in this fallacy is sometimes known as playing the Nazi card.

(via wikipedia)

Nazi Germany: an argument technique?

Filed under: Uncategorized — Leigh @ 1:34 pm

Comparisons to the holocaust seem rife today. Any attack on civil liberties is compared to the way the Nazis treated the Jews. Another example crops up today via the UK’s leading anti-vaccine site, JABS (no link love, search for it yourself).

The government is considering making vaccination compulsory for children as a way of improving the current low uptake of vaccines, including MMR. The low uptake is a problem; with vaccination rates below the level required for herd immunity measles outbreaks are starting to appear again. So what does JABS have to say about this?

Even raising the issue of compulsion is the thin end of the wedge. If vaccines are made mandatory before school age even with the most liberal of exemptions (i.e. parents allowed to opt out for whatever reason) then the genie will be out of the bottle and as the Americans have discovered, exemption conditions will be made increasingly more stringent until non-vaccinators find themselves treated not unlike the Jews in the early days of Hitler’s Germany.

(via Black Triangle, emphasis mine) (note that the comment was attributed to “Scotmum,” who may well not represent the official JABS point-of-view).

Admittedly your interpretation of this may depend on your personal viewpoint with regard to vaccination, but the commenter above seems somewhat morally bankrupt. I think that making comparisons between our democratic state and a system which arranged for the killing of six million innocent people is rather poor. If I were Jewish then I could see myself becoming quite cross. Kenneth Jacobson, of the Anti-Defamation League has this to say (admittedly about a different case):

From every side, I think the use of these kinds of holocaust analogies is counterproductive, disturbing, and offensive. People who use these kinds of arguments are trying to be deliberately provocative, knowing full well that the Holocaust is the epitome of evil in the world. But I think there’s a price to be paid, in terms of the offensive element for Holocaust survivors, and it also debases the currency of genocide. It trivializes what the Holocaust was about.

(via dot earth)