Fixed Problems Following Upgrade

January 27th, 2010

I think I’ve fixed all the problems following an upgrade that have left the blog down for a few days but if you spot any broken links please let me know.

In the meanwhile, I’ve been trying to recapture the spontaneity of early blogging with a tumblr blog which I’ve been enjoying.

This weblog has become a little stagnant and I may retire it.

Our Future Robotic Overlords

November 8th, 2009

Many humans, on the other hand, don’t learn or grow all that much once they get to adulthood. A world of robots that were programmed to be competent at their jobs, but not to learn much, wouldn’t be enormously different from our current one.

Human Level AI: The Foresight Institute

Given that most customer-facing employees of large corporations would struggle to pass a Turing test, the threshold machines need to reach to replace humans in customer service roles is not particularly high. Anyone who has attempted to resolve a problem with a bank, utility company or government body in the last decade would probably welcome the chance to interact with a machine instead of a minimum-wage, script-reading, disempowered, indifferent human – outsourced or otherwise.

It’s a fallacy to imagine that decades of exponential growth in processing power means that computers will necessarily continue to get faster and more powerful every year – Moore’s law is catchy phrase to describe an observation nothing more. It is also a questionable belief that the difference between a machine and a human is simply one of complexity, that given enough interlinked processors we could brute force intelligence. Nonetheless, it is very hard to imagine a future in which technology does not advance to the point that many social roles could not be carried out by sophisticated, automatic machines.

What then for dreams of full employment? What then for the issue of leisure? People who believe in the Singularity tend to view it with quasi-religious awe as a coming techno-rapture in which the geek shall inherit the earth and the coming SuperIntelligence will solve all problems.

There is more than enough surplus wealth already to feed and clothe the poor of the world – and yet there is no sign of this happening. Why do we imagine that the future owners of unimaginably powerful technology will be any more benevolent than the current rich?

The Only Progressive Force in British Politics Today

July 21st, 2009

Nick Clegg recently gave a rousing speech at the National Liberal Club in London.

He emphasised the strengths of the Liberals as

The first party to identify the dangers of an overleveraged banking system. The first to advocate radical political reform. Consistent in our defence of civil liberties. Principled in our defence of the international rule of law. Outspoken in correcting our woefully imbalanced tax system. Radical on the need to make Britain environmentally sustainable. Brave in standing up to failed populism on law and order. Determined to use childcare and education policies to break cycles of deprivation handed down from one generation to the next.

The Conservatives are dismissed succinctly as spin masters who will never change their spots, a party -

at ease standing shoulder to shoulder in the European Parliament with bigots, climate change deniers and homophobes.

In my view David Cameron has done a relatively good job at re-branding the toxic legacy he inherited. But no amount of airbrushing can make conservatism progressive. It’s just not in their bones.

And Labour’s failure is given short shrift:

I can remember Peter Mandelson saying “judge us after ten years of success in office. For one of the fruits of that success will be that Britain has become a more equal society.”

It’s been twelve years. The gap between rich and poor has widened. We have more children in prison than anywhere else in Europe. If you’re poor you’re still far less likely to go to university than if you’re better off. If you’re a woman you’ll still probably be paid less for doing the same work as a man. If you’re a child born in the poorest neighbourhood in my City, Sheffield, you will probably die 14 years before a wealthier child born down the road….

Liberals believe in the raucous, unpredictable capacity of people to take decisions about their own lives.
Whereas for us power should be shared, for Labour it is to be hoarded. And as night follows day, monopolies over power in both the economy and in politics end badly; this government ticks all the boxes: Captured by vested interests; hence their continuing failure to clamp down on greed in financial services… And driven solely by an obsession to cling on to power.

If you are one of the generation of voters who are too young to remember the Conservatives but know only too well how badly your hopes have been sold out by the Labour Party, then consider the Liberal Democrats as a viable alternative. However bad Labour may have been, the Conservatives will be far worse.

Just Set up a Tor Relay

June 20th, 2009

I’ve just set up a Tor relay in the hope that every extra little bit of bandwidth will help the protesters in Iran preparing for today’s big rally in Enghelab Square, Tehran. If you’re technically minded and can spare some bandwidth then please consider doing the same. If you’re not technically minded and want a simple, fictionalised and very readable introduction to this kind of technology and why it matters, consider Cory Doctorow’s book Little Brother.

The Manuscript Found in Saragossa

March 1st, 2009

I’ve recently finished Jan Potocki’s “The Manuscript Found in Saragossa”, a fantastical novel written between 1800 and 1815 that consists of a series of stories within stories told over a period of sixty-six days in the manner of Arabian Nights or The Decameron.

The principal narrator, Alphonse van Worden, is the son of a man so pathologically obsessed with the finer points of honour manifested in the “tribunal of blood” that he thinks nothing of fighting a dozen duels in a day and punctiliously records the history of each in his notebook. His mother takes aristocratic traits to a similarly absurd degree. Having decided that the French are beneath her, she endures her stay in Paris by maintaining an absolute disdain: “She made it a rule not only not to learn French but also never to listen to it when it was spoken.”

Abandoned by his valet and mulateer while traversing the mountain range of Sierra Morena, a land rumoured to be inhabited by smugglers, bandits, murderous gypsies and terrifying ghosts, Alphonse finds himself bewitched by a pair of beautiful women who may be his cousins or may be succubi whose mysterious appearances and disappearances are woven into a narrative composed of encounters with a wide range of characters united in their love of story telling.

Stories interrupt stories in Tristram Shandy-esque digressions as each narrative introduces further characters who in turn narrate their own tales, the stories recursing back in on themselves until narratives are four or five levels deep and the listeners at the outer level announce themselves as confused as the reader would be in danger of becoming had Potocki not exercised considerable skill in managing the various threads.

The book’s end is slightly disappointing, perhaps inevitably since the beauty of the book lies in the digressions not in the forward impulse of the underlying plot, but the charm and humour of the stories carries the day.

Information is Not Knowledge

February 4th, 2009

Spent all day in meetings about the proposed ‘Bad Bank’ and kept wondering what their uniform might look like.

Alistair Darling

havent signed tonys card yet, can’t think of anything funny to put

Gordon Brown

Maybe it’s an age thing; perhaps I’ve already crossed that subtle threshold after which you become unable to understand the appeal of new fads – but I don’t understand the purpose of Twitter. The spoof tweets allegedly from the men currently crash landing the British economy are funny because of the frighteningly plausible, Pooteresque banality of their thoughts. The tweets of a nobody, however, lack such saving irony.

There’s a fine line between spontaneous and knee-jerk, between wit and bigotry, between the simple statement of fact and the simplification that distorts the truth.

We live at a time where politicians clash horns using sound bites and real policy is rarely debated, where newspapers and other media channels uncritically repeat information known to be false (“we only use ten percent of our brains”, “hair and fingernails continue to grow after death”, “house prices always go up in value”). It’s an era uniquely rich in data about the natural world and yet culturally we lack the critical facilities to evaluate this information, making us ripe pickings for every charlatan who appears on television dressed as an expert.

In such an age, do we really want our thoughts to be restricted to what can be expressed in 140 characters?

C++ Exception Safety Guarantee

January 14th, 2009

After stumbling on this one in a recent telephone interview, I thought I’d refresh my memory.

The following from Anthony Williams’s ACCU Overload Journal article last August provides a succinct summary of the topic.

The Abrahams Exception Safety Guarantee

These guarantees were first documented by Dave Abrahams when the C++ Standards committee were working on the 1998 C++ Standard. The idea is that code should provide one of the three guarantees – if it doesn’t, then an exception occuring in your code will result in leaked resources or corrupt data structures or both. The guarantees are:

The no-fail (or no-throw) guarantee

This is the strongest of all guarantees. A function that provides this guarantee will not throw any exceptions, and will not fail. All destructors should provide this guarantee, as should important operations like swap which provide the building blocks for the code that uses them to provide suitable exception safety guarantees.

The strong guarantee

A function that provides this guarantee is all or nothing: if it fails, then any effects are rolled back so the state of the data structure is the same as it was on entry. This requires that the function doesn’t do anything irreversible (like perform I/O), and that there are suitable operations that provide the no-fail guarantee which can be used to commit or roll back the changes.

The basic guarantee

This is the basic level you should strive for in all code: if a function fails, then it must leave the data structures in a valid state, even if that state differs from the original. For example, failure to insert a new item into a container must leave the container in a valid state, even if all the existing items have been deleted.

Any code that doesn’t provide even the basic guarantee is not exception safe.

Exceptions Make for Elegant Code, ACCU Overload Journal #86, August 2008

Writing exception safe code is hard. If you have any doubts about that statement consider the following challenge from Herb Sutter: Guru of the Week 8. In Exceptional C++, Sutter expands on his earlier post and provides the following guidelines –

Observe the canonical exception-safety rules: (1) Never allow an exception to escape from a destructor or from an overloaded operator delete() or operator delete[](); write every destructor and deallocation function as though it had an exception specification of “throw()“. (2) Always use the “resource acquisition is initialization” idiom to isolate resource ownership and management. (3) In each function, take all the code that might emit an exception and do all that work safely off to the side. Only then, when you know that the real work has succeeded, should you modify the program state (and clean up) using only nonthrowing operations.

The standard for the C++ Standard Library contains the guarantee that no destructor operation defined in the library itself will throw an exception. The C++ Standard, however, does not enforce this requirement for all C++ code so your compiler will not prevent you from creating a class that breaks the golden rule: never throw exceptions from a destructor.

Anyone looking for more information should consult the links above and also look at Abrahams’s essay: Exception-Safety in Generic Components: Lessons Learned from Specifying Exception-Safety for the C++ Standard Library.

Editing and Removing Pages from PDF Documents

January 11th, 2009

I’ve been using Google Docs to store and edit my CV, however I’ve recently run into a number of problems when exporting the file.

Word documents are invariably mangled. This is a common problem because Word format is a de facto standard by virtue of the number of companies using Microsoft Word but formatting varies from version to version, platform to platform so it’s not really a standard at all. It’s more frustrating than web development at times. You spend hours laying out your CV on a Mac only to find that it looks like hell when opened and printed on a PC.

Recruiters and employers that use text-processing algorithms to assess candidates for positions hate PDF documents but for anyone who cares about presentation and wants to guarantee that their potential employers see their CV exactly as they intended, there is no other choice.

Unfortunately, Google Docs insists on adding a line feed to the last line of every document and when you export the file as a PDF this can result in a blank page being appended to the end.

Fortunately you can edit PDFs on linux using pdftk.

For example, to create a new two page PDF from the first two pages of an original try:

pdftk originalCV.pdf cat 1-2 output editedCV.pdf

The application enables many more useful ways to manipulate PDF documents. Read the man pages for further details.

Connecting to Ubuntu from iBook G4 Using NxMachine

January 3rd, 2009

I’ve been using my girlfriend’s iBook recently and am very impressed by it.

The Good
Things I love include the fact that it feels like unix, the build quality of the hardware itself and the failsafe reliability of its sleep/resume.

(I’ve long forgotten the number of hours I spent a couple of years back disassembling then recompiling the buggy DSDT on my old IBM Thinkpad T20 to fix all the warnings and errors before linking it against a patched kernel in order to get ACPI working. Sure it gave me a taste of the days “when men were men and wrote their own device drivers” but sometimes it’s nice when things Just Work.)

The Bad
Things that niggle include the lack of right-mouse button, the unfamiliar keyboard layout and the absence anywhere on the keyboard of a hash/pound key which makes writing bash scripts a little tricky (it’s ALT+3 but for some reason this isn’t printed on the key itself).

The Ugly
Things that seriously annoy include the monolithic, closed nature of the operating system that requires you to upgrade the whole damn thing in order to use a more recent version of Java.

Early observations aside, connecting to my Ubuntu box using NxMachine was pretty straightforward.

The mac client is straightforward to download and install. Apt-get makes setting up the server on the linux box utterly painless. The instructions on the site are more than sufficient for getting the connection up and running.

Getting the key mapping right takes a little longer – out of the box several keys did not behave as expected.

Anyone looking to save a little time is welcome to use my keyboard settings. To apply them use xmodmap:


xmodmap keyboardsettings

Retrieving Rapidshare Files with Python

January 2nd, 2009

A cursory google search will reveal several scripts for retrieving rapidshare files using python, but each one I’ve seen delegates the actual retrieval to wget.

This is not necessary.

Rapidshare uses basic authentication to identify logged in members and urllib2 can handle this easily.

The following method would do the trick without the need to call external executables:

def rapidget(url. login, password):
    "Retrieve files from rapidshare using only python"
    request = urllib2.Request(url)
    base64string = base64.encodestring('%s:%s' % (login, password))[:-1]
    request.add_header("Authorization", "Basic %s" % base64string)
    i = url.rfind('/')
    filename = url[i+1:]
    print url, "->", filename
    file = open(filename, 'wb')
    handle = urllib2.urlopen(request)
    buffer = ''
    buffersize = 1024*1024
    while True:
        buffer = handle.read(buffersize)
        if not buffer:
            handle.close()
            file.close()
            break
        file.write(buffer)
        buffer = ''
        print '.',

This assumes, of course, that you have an account at rapidshare.