Monday, 22 November 2010

Apple device fragmentation

Apple's Steve Jobs went on an anti-Android rant earlier this year, focussing in particular on market fragmentation. Apparently, there are so many configurations of Android device that it's writing software for the platform is next to impossible. This came as a surprise to people who actually develop for it.

Apple, on the other hand, dodge the issue of fragmentation completely. iOS is a completely unified platform, with only one catch: you must be up-to-date with the latest shiny toys. The new iOS 4.2 is now available, with the following small caveat:


The iOS 4.2 update is available today to download to iPad, iPhone and iPod touch by syncing the device with iTunes 10.1. iOS 4.2 is compatible with iPad, iPhone 3G, iPhone 3GS, iPhone 4, second and third generation iPod touch (late 2009 models with 32GB or 64GB) and new iPod touch. Some features may not be available on all products. For example, Multitasking requires iPhone 3GS, iPhone 4, third generation iPod touch (late 2009 models with 32GB or 64GB) or later.

So, as with recent OS updates, it won't work with my first generation iPod Touch (or second gens, for that matter). Owners of those devices are left with older versions of iOS, with no upgrade path that doesn't require a hardware purchase.

Meaning that, if you're an application developer looking to target the broadest user base, you're hit with platform fragmentation...

Sunday, 21 November 2010

Apple's 'Restart your computer' U-Turn

Once upon a time, Mac users could chuckle heartily at Windows users. After every Windows Update, you'd get that prompt to restart your computer, and it was annoying. If you're the kind of person who thinks that computers should serve rather than be served, you've probably got about a half dozen or more applications open, each containing reference material or partially completed work.

Damn, those restarts were annoying.

However, it's almost every other week that there's some update to Quicktime, Safari or iTunes, each adding more features that I don't care about (Ping? Yet another social network, but one that's only accessible via the locked-down iTunes ecosystem? Seriously..?) I don't need my iTunes to support the latest devices from Apple: I haven't bought anything from them since my first-generation iPod touch (which still works superbly, by the way: I have no intentions of replacing it).

Going back to that 'once upon a time', apps used to run on top of Mac OS. Now, Apple does what got Microsoft into so much hot water at the turn of the millennium: integrating home-grown apps into the operating system (otherwise known as 'gaining unfair advantage over competitors'). So, after updating to Mac OS 10.6.5 and restarting (ok, operating system updates require restarts), I find that iTunes and Safari are both needing updated, also nagging for a restart.

Well done, Apple. You are the new Microsoft. Enjoy the bubble.

Saturday, 30 October 2010

The Ultimate Programmers' Keyboard

A professional in any craft needs quality tools, and for a computer programmer, the primary interface between the human and the computer is the keyboard. End users of mass market software may be convinced that touch screen devices are the way forward, but for a programmer, nothing looks to be a serious threat to keyboards in the near to mid future.

A quick google for 'best programmer keyboard' turns up the prime candidates: the Microsoft Ergonomic 4000; das keyboard; the IBM Model M; and the uniquely shaped keyboards from Kinesis.

The Logitech G15 seems to be popular among high-end users, but it's primarily a gaming keyboard, so I'm not including it here.

My requirements are pretty simple:

  1. it must be durable and sturdy

  2. it must be amenable to team-based working

  3. and—most importantly—it must have a standard UK layout, with absolutely no dicking around with the positions of keys that are important to programmers, including the hash key (#, to the left of the large Enter key, shared with ~), the back-quote (‘, top-left key on the main key cluster) and the pipe (|, shared with the backslash, between left-shift and the Z key)

Anything from Apple is right out. Even on their 'UK' keyboards, the double-quote (") is where the @ should be, and vice-versa.

I immediately ruled out anything with the Dvorak layout. Yes, I'm familiar with the statistics about how it's a superior layout for computers, but it's simply not widespread enough for point 2. I have a colleague on my current contract who has a typematrix Dvorak keyboard, and he's very happy with it, but when it comes to a paired session or showing how to do something, it's a total pain. The fastest way to get anything done is leave all the typing to him.

Partly for point 2, I also ruled out anything with an extreme ergonomic layout (basically anything from Kinesis). Also, while less-deformed ergonomic keyboards are good for a single user typing for a long time, paired programming is often about quickly shoving the keyboard over to a partner or grabbing it briefly to type a few lines, and ergonomic keyboards are obviously designed for someone sitting directly in front of them. It's like you have to re-align yourself at the beginning of every switchover, which I find interrupts the flow.

So, from my original list, I'm left with the Model M and Das Keyboard, both distinctly traditional in their non-ergonomics. But then, from a front-page review endorsement on their own website, "Das Keyboard compares to the legendary IBM Model M." So, which to go for? The imitation or the original?

Unsurprisingly, I'm typing this blog entry on my Model M. The sticker on the bottom dates it from 1991, made in Greenock, Scotland—about a half-hour's drive from where I live. It's got all its key caps, has that satisfying two-stage click for each key press, and is solid enough to be used as a not-insignificant weapon if anyone breaks into my house.

I simply can't find a better keyboard anywhere, and I'm beginning to think that there isn't one.

Sunday, 26 September 2010

More Homophobic Lunacy from the Catholic Church

"I admire the gays and lesbians. They're small in number. But they're well-organised."

"They've persuaded our legislators that the supreme moral values of the day are freedom and equality. Well they're not."

"The supreme moral values are truth and goodness, and if you forget that, you end up with the mess we're in today."
Bishop of Motherwell, Joseph Devine, in an interview with the BBC

Once again, we see the catholic persecution complex in action: they're being systematically attacked by a 'well organised' group. It's as though the church thinks that there's some kind of gay hierarchy, with lay-gays, event-organising gays and maybe even leader-gays, all plotting against the church and its bronze age values.


There is simply a group of people who have human rights, voting power and a voice, qualities the church has traditionally abhorred.

And isn't it convenient that the moral values of the day are unquantifiable and subject to varying definition? There's little ambiguity about freedom and equality; it's obvious when one is being stomped on. But 'truth' and 'goodness'? The church defines what those are for its members, freeing them from the need to think about them, to make their own decisions. Because that's the last thing the church needs its people doing—thinking.

And why, when asked "can a loving relationship between two people of the same sex not be true and good?"

"Because it's not creative".

I'm assuming that he means pro-creative here, not just generally creative: the love shared between two people of the same sex is on even par with any other, and is creative in way that it enriches their lives and the lives of those around them. But he's right, it's not pro-creative: it doesn't bring new life into the world. But then, neither does a heterosexual marriage where one side or the other is sterile—does he propose nullifying such marriages, tearing such couples apart? Surely if one of them is capable of reproduction, it's a sin against god and humanity if that person doesn't find a fertile mate?

Sunday, 19 September 2010

Crazy Proselytising

There were a few street preachers in Argyle Street in Glasgow today. You know, the ones who brandish a bible and shout loudly about how you can be saved. The lead of the small group—a surprisingly young looking gentleman—was busy proclaiming how morally corrupt society is today, filled as it is by people who live by the creed of "if it feels good and no one gets hurt, then it's ok". While I was puzzling over exactly what the problem with that viewpoint is, he continued that we should return to the "moral certainty of the old days".

Would those be the days when we stoned people for disobedience, I wonder? Burned them at the stake for witchcraft? Or seared them with irons for blasphemy?

Throughout all this, the placard by his side read:

I am the way and the truth and the life. No one comes to the Father except through me — John 14:6

This passage, more than just about any other in the bible, highlights the "we're right, everyone else is wrong" mentality of Christianity that belies talk of unity with other religions.

I could only chuckle as I walked past.

Friday, 17 September 2010

The Pope Slanders Free Thinkers

The Pope was in my nearest city of Glasgow yesterday, offering his sermon in Bellahouston Park, just south of the River Clyde. His message was at once one of optimistic hope for his faithful flock and an out-and-out slanderous attack against the largely secular, non-theistic people of the UK.

Even in our own lifetimes we can recall how Britain and her leaders stood against a Nazi tyranny that wished to eradicate God from society and denied our common humanity to many, especially the Jews, who were thought unfit to live.As we reflect on the sobering lessons of atheist extremism of the 20th century, let us never forget how the exclusion of God, religion and virtue from public life leads ultimately to a truncated vision of man and of society and thus a reductive vision of a person and his destiny.
Pope Benedict XVI, Bellahouston Park, Glasgow, 16-Sep-2010

Umm... excuse me? Hitler was a Catholic. The Catholic church, while refusing to back the Nazi party of Germany, similarly refused to condemn it. Hitler's attack was against the entire Jewish race, not entirely unmotivated by the church's own hatred of the race thanks to the charge of decide that was only lifted in the 1960s (which has always slightly confused me: if Jesus's defining sacrifice is what frees us all from sin, surely he had to die in order to rise, ascend into heaven, etc.).

"Oh, no", whine the apologists. "Hitler wasn't Catholic. He just used religion to control the people". Is that so? Well, in order to control the people with religion, what religion would those people have to follow? So, given that Hitler didn't personally murder millions of Jews,what's their excuse?

And how about this little gem from the megalomaniacal 'atheist' dictator?

The Government, being resolved to undertake the political and moral purification of our public life, are creating and securing the conditions necessary for a really profound revival of religious life

Adolf Hitler, in a speech to the Reichstag onMarch 23, 1933

Do those sound like the words of an atheist to you?

Stepping away from the distortions of the past that the Pope seems to enjoy, we find that his view of the present is no less warped:

There are some who now seek to exclude religious belief from public discourse, to privatise it or even to paint it as a threat to equality and liberty. Yet religion is in fact a guarantee of authentic liberty and respect, leading us to look upon every person as a brother or sister.
Pope Benedict XVI, Bellahouston Park, Glasgow, 16-Sep-2010

Again... excuse me? Doesn't the Catholic church tell us that women are not fit to be priests, and therefore cannot be part of the church's own heirarchy except at the lowest levels? Doesn't it teach us that gays are abominations in the sight of god, and forever damned unless they 'repent' for making that 'choice'? All this from a church that refuses even to discuss the possibility of ordaining women, forbidding it from being mentioned.

The church is an open threat to liberty and respect, not its guardian.

Saturday, 28 August 2010

Online Stalking: it's not the ISPs Fault.

The BBC is running an article about how ISPs are 'thwarting' a crackdown on online stalking. Apparently, they should not only deliver Internet connectivity (their job), they should also police it (not their job). It's like saying that the makers of paper should be responsible for what's written on it, or that the makers of envelopes should be responsible for what's delivered in them.

Of course, what's barely mentioned is that you should be very careful about personal details that you post online. Do NOT post details of your current location, places where you can often be found, your home address, your phone number, etc. Doing so is just asking for trouble, and blaming the ISP—even when social networking sites (still not the ISP) encourage you to yield such information—is equivalent to blaming manufacturers of junk food for forcing you to eat rubbish by making appealing adverts.

The last thing we want is ISPs policing Internet access according to a private set of rules formed by a mob committee. I'm even wary of the Law of the Land applying to the delivery of content (the hosting is another matter). It's a slippery slope when your government gets used to being able to filter content that it finds objectionable.

Friday, 27 August 2010

h264 is not Free

With news of the sudden royalty free amendment to the h264 license by the MPEG LA sweeping the web, it's easy to forget that this actually changes very little, indeed. You now won't ever be charged for viewing free video on the Internet.

You will still be charged for distributing an h264 encoder or decoder.

This means that if you're someone like the Mozilla group, you can't include h264 support for the HTML5 <video> tag without paying hefty royalties for the privilege. You might wonder what the problem is: surely it's right that one company licenses the right to distribute the technology of another? No. Not when it comes to the Web and the standards that underpin it (such as HTML5). Paying a royalty to take part in the Web defeats the entire point of an open internet, where ideas can be freely exchanged using the promise that the base standards are available to everyone on a royalty-free basis.

There's some sanity on this 'sweeping change' from the MPEG LA at Create Digital Motion.

H264 is not the only codec out there. You can distribute the encoders, decoders and content with WebM/VP8 and Ogg/Theora without restriction.

Use 'em.

Wednesday, 25 August 2010

Being an Ex-Catholic Atheist at a Catholic Funeral

My gran died last Thursday. At 88 years old and of frail health, her increasingly common mental lapses meant that it wasn't unexpected when it happened, but nothing quite prepares you for that phonecall.

Her funeral was today, attended by the two generations behind her—probably the best turnout at a family gathering for many years. Religiously, my family is traditionally Catholic, at least in name. We traditionally only see the inside of a church at funerals, with weddings being secular affairs and not much interest in baptising our children. Still, if you were to ask my sisters, aunts, uncles or cousins what religious affiliation they belong to, it'd be Catholic.

As far as I know, I'm the only openly declared atheist. Before going on, the reason I left the church is simply because I couldn't reconcile my beliefs about how to live a good life with what I was reading and being taught. I have no stories about abusive priests, psychological trauma induced by images of hell, or any of the stuff that commonly makes it into the Reasons to Hate the Catholic Church™.

So the ceremony itself was a little weird. Having gone through Catholic education, I knew exactly what to say at what times, and when to stand, sit or kneel. It's slightly odd that I remembered the prayers: they must have been burned into my brain when I was a boy.

But, aside from standing and sitting and that shaking of hangs thing they do prior to communion, I didn't do any of it. I didn't recite or respond to the prayers, sing hymns, bless myself with water, bow my head or press my hands together in front of me. While the priest was asking people to honour god, I was instead remembering my gran.

When I was paying attention to what the priest was saying, the thing that generally struck me was the occasional reminder that we're born sinners, achieving grace only through Christ. There was even a dig at non-believers in the reading from the book of 'Wisdom', where we are collectively labelled as 'fools' for believing that death is the end of a persons life.

As a foolish non-believer, what I found very odd was the tinkling of bells by the altar boy when the priest blessed and raised the bread and wine, a process which—according to believers—transubstantiates them into the actual body of blood of Jesus Christ. The communion itself seemed similarly strange, with people treating these little, mass-produced flecks of unleavened bread with such incredible solemnity. Knowing that most of the congregation in front of him probably hadn't communed in years, and bearing in mind the Catholic no-no about taking communion with a sin-stained soul, the priest offered blessings to those who remembered enough of the dogma to stay away because of that.

With with mass almost at its end, all that remained was to sprinkle 'holy' water over the coffin and wreath it with smoke from burning incense. This done, the coffin was taken to the cemetery and interred alongside my granddad, laid to rest seventeen years earlier.

After all this, what I'm most shocked with is myself. For quite an extended period of time, I believed this stuff. I took part in the rites and rituals, saw value in the prayers and songs and material paraphernalia. And it wasn't even that long ago: I was a practising Catholic up until about ten years ago, a lapsed one for about five years after that, finally moving on to agnosticism and finally atheism over the course of the following two or three years. Not coincidentally, all of this happened alongside actually reading the bible, learning about its origins, learning about other religions, and seeing the harm inflicted by the church thanks to its views on contraception, sex education, and homosexuals.

How times change.

Saturday, 21 August 2010

Net-Connected Consoles with Hard Drives Deliver Poor Quality Games

A while ago, I bought Uncharted 2 for the PS3. Unfortunately, with the arrival of my daughter into the world, it was one of those titles that barely got loaded at first.

Today, I put the disk into the console, and then BAM!, several hundred megabytes of updates are required before I can play the game. It would appear that there have been one or two bugs in the shipped version.

Which got me wondering: why, with the console's predecessors, was this never an issue? The answer is kinda obvious: you've got a network, a hard drive and a very competitive market. With previous generations of console, you had to make damn sure that what you burned onto that CD for shipping was a quality product. Your update channel amounted to a return of the physical medium for a fixed copy. Not very attractive. Now, however, you can ship with any half-arsed, bug-ridden product and patch it later.

One thing that console games used to have over their PC siblings was that they just worked. Stick the disk in and go. No configuring audio and video drivers, no checking the specs of your machine against the overly optimistic listings on the side of the box (only to find out that the screen shots on the packaging must have been taken from some next-generation video hardware), and no patching shoddy software with updates to fix problems that should never have made it through testing.

EDIT: apparently, a couple of hundred megabytes of patches aren't enough. It took only a half hour of playing (in the raid on the museum in Instanbul) to be bitten by this glitch:


Sunday, 1 August 2010

Encoding x264 Video for the iPod Touch with mencoder

Update, 18-Aug-2012: I've changed to using an ffmpeg/mplayer combo to do this, as it's much more reliable and stable. See my new post for a breakdown.

I tend to view a lot of video content on my first-generation iPod Touch. It's great for travelling, with its these-days-paltry 16GB capacity able to store well over a dozen half hour episodes of whatever I'm following at the time.

While there are some wonderful graphical encoders out there (HandBrake springs to mind), what I was looking for was something I could script. I know that HandBrake has a command line interface, but I prefer mencoder's support for embedded subtitle streams, which is something I use often.

If you're on a fairly recent SVN of mplayer (say >= r31363), you'll find that mencoder now supports a profile in x264encopts. This is important! The default is high, which the iPod explicitly doesn't support. What you need is baseline, leading to something like this:

 -vf scale=480:-10,harddup# resize the video to whichever height is suitable for the max 480px width
 -sws 9# Choose a really good scaler (lanczos)
 -of lavf# use lavf for output
 -lavfopts format=mp4# specifically, mp4
 -oac faac# AAC audio for output
 -faacopts mpeg=4:object=2:raw:br=128# Audio coding parmeters
 -mc 0 -noskip# Really work at keeping A/V sync
 -ovc x264# x264 video
 -x264encopts nocabac: bframes=0: level_idc=30: global_header: threads=auto: subq=5: frameref=6: partitions=all: trellis=1: chroma_me: me=umh: bitrate=768: profile=baselineVideo coding parameters. Note the baseline
 -aid 0 -sid 0# Audio and subtitle tracks
 -subfont-text-scale 4# Better subtitle scaling for an iPod sized device

(or, for a more cut n' paste friendly version:

mencoder INPUT-FILE -o OUTPUT-FILE -vf scale=480:-10,harddup -sws 9 -of lavf -lavfopts format=mp4 -oac faac -faacopts mpeg=4:object=2:raw:br=128 -mc 0 -noskip -ovc x264 -x264encopts nocabac:level_idc=30:bframes=0:global_header:threads=auto:subq=5:frameref=6:partitions=all:trellis=1:chroma_me:me=umh:bitrate=768:profile=baseline -aid 0 -sid 0 -subfont-text-scale 4)

This transcodes the source in a single pass. Lots of people strongly advocate two-pass encoding, but really, I find the quality of a single pass encode good enough for the iPod screen. There's no denying that two-pass is higher quality, but the extra time to encode disposable content just isn't worth it in my opinion.

Saturday, 5 June 2010

Netgear's Broken Firmwares

I bought a Netgear DG834G from Amazon earlier this week. It arrived on Friday, and promptly replaced the crash-tastic BT Home Hub that preceded it. Having been using Netgear products for years, I quickly set up and secured my wireless LAN, made a couple of DHCP reservations for servers on my home network, forwarded ports for various services from the Internet to those servers, hooked up to my DynDNS account, and was content. Then I noticed that the forwarded ports weren't forwarding: my web and mail servers were inaccessible. Much tinkering later, and I decide that the unit is defective, and arrange to return it to Amazon (who, it must be said, have a superbly streamlined returns process).

But I still didn't want to go back to the BT Home Hub—the frequent crashes were just too frustrating. So I dig out an old Netgear router that I found in The Pile in the bits n' pieces cupboard, and find that it still works. And hey, port forwarding even works!

Feeling good about it, I let the old kit do its thing, stable and reliable. So why not treat it to a firmware upgrade? I grab the latest (v1.03.22) from the Netgear product page, re-flash the unit, and port forwarding stops working! Crawling around some forums, I find that I'm not alone. It would appear that Netgear have broken something as fundamental as port forwarding in their recent firmwares!

Incredulous, I download v1.02.19. Still doesn't work (and almost bricks my unit in the re-flashing process). By now more than a little annoyed, I resort to v1.02.13, which I think was the original version. And you know what? It works.

Not all upgrades are upgrades, it would seem.

Wednesday, 5 May 2010

h264 shenanigans

Engadget has an excellent article that attempts to clarify the muddy waters of licensing and patents surrounding the h264 video codec. One of the snippets from the article, important enough that they list it in a side-box, is "using H.264 to distribute free internet video to end users doesn't cost a thing, and won't cost anything until at least 2015. After that, it's up in the air, and that's a bridge we'll have to cross when we come to it — there's a chance the MPEG-LA could start charging a royalty for free video in five years."

Two parts of that sentence should cause any sane person cause for concern:

...won't cost anything until at least 2015.

That's only five years away. Just enough time to generate an awful lot of content that would take a lot of effort to get away from.

After that, it's up in the air...

That's not exactly something to be happy about. There's no point making extensive use on h264 and then hoping that it'll turn out ok, especially when there are perfectly workable alternatives.

The article does do a good job of dispelling a lot of the scaremongering that's been going on, but what's left is still distinctly unpleasant.

Tuesday, 4 May 2010

Labour Promote Political Sabotage

Now that it's blindingly obvious that the UK Labour Party is going to lose the General Election later this week, they've resorted to abusing the voting system in order to prevent their long term rivals, the Conservatives, from winning a complete victory. In areas where the Liberal Democrats are a larger threat to the Tories than Labour themselves, the advice is to vote Lib Dem in order to prevent them gaining the seat.

Does anyone else think that the system is broken?

Sunday, 2 May 2010

Apple's vision of an 'open' web

Apple are certainly 'thinking different' when it comes to the definition of 'open'. In their spat with Adobe regarding Flash on Apple's mobile products, Steve Jobs responded almost convincingly about why Flash isn't on the Apple mobile product line. The primary reason? Openness. Flash is a closed platform, whereas JavaScript, CSS and HTML 5 are all open.

The 'but' here comes from the HTML 5 part, which includes a <video> tag that essentially renders Flash video obsolete, with decode and render available natively in the browser, rather than through a plugin. The standards committee overseeing HTML 5 still hasn't agreed on what format that video should be delivered in. The de-facto standard of h264, a high-quality, industry-driven standard that's nevertheless mired in patent and licensing issues that are really sticky. Or Xiph's Theora, which has been designed to avoid using techniques covered by patents, and is available royalty-free (which most of us think of when we think 'free').

When it comes to browser support, the big three unsurprisingly lend their weight to h264. Mozilla's Firefox—distinct from the others in being the only organisation that's an actual browser company and also non-profit—throws its weight behind Theora, with that crazy idea that participating in the web shouldn't involve licensing fees just to access it.

Of the corporations, Google has interestingly promised to open source the VP8 codec and, since they own YouTube, could theoretically swing the balance by offering VP8 support in Chrome and VP8 YouTube videos, especially if Firefox supported the same.

But, back to Apple.

Steve Jobs reckons that there's no such thing as a free video codec. Furthermore, he issues a threat to Xiph over Theora (without including useful specifics, which relegates it to FUD).

So Steve: get a grip. The i-whatever ecosystem is locked down tight, and you're free to do that to whatever extent your customers are willing to put up with, but don't hide behind a wall of righteousness when dissing other technologies. Your 'open' arguments are empty with a platform and environment that is increasingly developer hostile.

As for me, I've owned a G4 PowerBook and am typing this on a two year old Macbook Pro. With each statement from Jobs regarding criticism of his closed platform, I find it increasingly unlikely that I'll buy a third. So hey, Apple marketing-types: your CEO's statements are costing you a £1500 sale, and most likely not just from me.


Apparently Apple once believed in a royalty-free Web, too. However, despite the original having lived here on for years, it's recently been pulled.

Thankfully, George Orwell's Memory Holes are a difficult thing to accomplish with an open Web.

Hat-tip to ZeroGravitas on Hacker News for the info (and to Create on the comments page for the Memory Hole reference).

Thursday, 8 April 2010

Simple File Renaming in Emacs

I stumbled across this tip while browsing reddit/emacs. In summary, it allows for the possibility of having a 'write file' (C-x C-w) variant that deletes the original file, essentially performing a simple rename without having to invoke dired or fire up a shell.

Putting on my Emacs cap, I came up with something similar, shorter and (debatably) more 'emacs-y':

(defadvice write-file (around write-file-possibly-rename activate)
(let ((old-filename (buffer-file-name)))
(and current-prefix-arg
(not (string-equal old-filename (buffer-file-name)))
(delete-file old-filename))))

defadvice allows you to hook a new function up to an existing one, to be invoked either before, after or around it (around advice invokes the original function with its original arguments with ad-do-it, and can do that zero or more times). This form of advice is what hits the spot for this task. Subsequently, when write-file is called, this advice intercepts it, captures the current filename and then invokes the old behaviour. After the write has happened, it checks to see whether or not it should delete the old file, and does so if the preconditions are met.

This preserves the existing C-x C-w behaviour, creating a completely new copy of your file if you choose a different name. Invoked as C-u C-x C-w, however, it deletes the old filename, performing the same rename with less code and less duplication of the existing file-writing plumbing.

Gordon's Pledges?

Gordon Brown pledges 'five more years' as Prime Minister if Labour wins.

That's not a pledge, Gordon. That's a threat.

Sunday, 4 April 2010

Institutional Abuse is not "Petty Gossip"

Cardinal Angelo Sodano has said the Roman Catholic faithful will not be swayed by "petty gossip" about child sex-abuse allegations.

I find myself stunned.

The church faces far more than "petty gossip", at least as far as Giuseppe dalla Torre, head of the Vatican's tribunal, seems to be concerned, compelled as he was to remind us that the pope cannot be called to trial because he enjoys immunity as head of state. And yet here we have one of the most senior members of the Catholic church dismissing repeated charges of the most disgusting violations of trust and abuse as "petty".

Nothing quite reveals a man-made god as much as the dismissal of "petty" concerns.

Saturday, 3 April 2010

PS3 System Update 3.21

Sony appear to be breaking new ground with the PS3: the only games console that loses features with firmware 'upgrades'. Yes, that's right: version 3.21 drops support for the 'Install Other OS' feature. This is almost on-par with the decision to drop software emulation of the Playstation 2, cutting off those large libraries of games that long-time users of Sony's console series have built up.

The best part of it is being held hostage: you can't use the Playstation Network with anything but the latest firmware, so those who stubbornly refuse to upgrade will find themselves stuck with local-only access.

Way to go, Sony! Really making your customers feel valued here.

Thankfully, George Hotz, who is similarly bemused has some advice: don't update. He's already hacked the PS3, and is looking to get a 3.21 firmware that doesn't lose the feature.

The strange thing is, he's the one that Sony will think is out of order.

Wednesday, 10 February 2010

Determining the Function Name of a CODE Ref in Perl

One of the great things about Perl that it inherits from functional programming is the ability to treat functions as data. You can create an function and assign it to a scalar reference. You can take a reference to an existing, named function and do the same. You're then free to pass that reference around, to be invoked later (the latter case is similar to function pointers in C, but the former is very different as the created sub can make use of variables defined in its lexical scope as it forms a closure).

While defining an API to a service I've been writing, I suddenly encountered the need to be able to differentiate between references to named functions and references to anonymous subroutines. Quite simply, once I'd established a set of objects to operate on, a named routine should be invoked once for each, whereas an anonymous routine should be given the entire set to work with (this allowed a great deal of reuse within the existing codebase without limiting flexibility).

While I suspected that Perl might be able to do this, it seemed like it would be some serious magic. Data::Dumper displays sub { DUMMY } when printing CODE references, so it's largely opaque.

However, Perl comes with the B module, providing access to Perl's internals as it's running.

use B;

sub named_routine {}

my $named_ref = \&named_routine;
my $unnamed_ref = sub {};

printf "%s\n", B::svref_2object($named_ref)->GV->NAME;
printf "%s\n", B::svref_2object($unnamed_ref)->GV->NAME;

this yields:


So, provided that you're willing to avoid calling your subroutines __ANON__, you've got a good indication of what your CODE reference actually points to.

Friday, 8 January 2010

Centring Emacs on Screen

Something I've wanted to do for a while that's nevertheless eluded me is how to centre Emacs on-screen when it launches. I'm a bit old fashioned and so like the default 80 character width, but I like as many rows as possible.

At first, with functions like (set-frame-height), (frame-pixel-height) and (display-pixel-height), it seems like it should be trivial, but the problem is that Emacs measures its frame height and width in characters, whereas the pixel functions (obviously) work in pixels.

The link comes in the from of (frame-char-height) and (frame-char-width), which give the height and width of an idividual character in pixels. Just evaluating the following expression should centre Emacs on your primary monitor:

(set-frame-height (selected-frame)
(floor (* 0.95 (/ (display-pixel-height)
(set-frame-position (selected-frame)
(floor (/ (- (display-pixel-width) (frame-pixel-width))
(floor (* 0.02 (display-pixel-height))))

If you like this (maybe after some tweaking), you can just stuff the instructions in your .emacs to get it every time.