Skip to Content Skip to Search Go to Top Navigation Go to Side Menu
Search on Site

Author Archive

UK communications database

Tuesday, May 20, 2008

The latest krazee plan from the Home Office’s policy department seems to be a massive database containing the details of every phone conversation and email sent in the UK.

Assuming it works (it won’t) then at least they’ll realise just how bad the spam situation is.

Popularity: 47% [?]

Running FMS 3 on Gentoo Linux

Thursday, April 24, 2008

I’ve been trying to install Macromedia Adobe Flash Media Server 3 on my local development box and have run into some problems.

To help out anyone else trying to do the same thing, here’s how I did it.

First you need to install nspr

  1. emerge -uDv dev-libs/nspr

Add a user/group for it to run under:

  1. groupadd fms
  2. useradd -g fms -d /dev/null -s /bin/bash fms

Then download and extract the media server as per usual. Before installing it, you need to fiddle the install script so that it will install on your “unsupported” platform. Open installFMS in your favourite text editor and find the line that reads

  1. DISTRO=`check_distro`

Change it to something appropriate like

  1. DISTRO=redhat-RHEL4-i686

Then start the installation script as normal. Tell it that you don’t want it to run as a daemon (as it requires the Red Hat only chkconfig command) and that you don’t want it to start the server when done.

After you’ve installed the server, you’ll need to make the bundled libasneu.so.1 library available for use:

  1. ln -s /opt/fms/libasneu.so.1 /lib/libasneu.so.1

For some reason the install messed up the configuration files, adding things like the administrative user name twice. Check conf/fms.ini to make sure this hasn’t happened to you.

The installer creates init scripts at /etc/init.d but in order to use them you first need to create a file called .autostart in the installation directory:

  1. touch .autostart

You should then be able to start and stop the server normally:

  1. /etc/init.d/fms start
  2. /etc/init.d/fms stop

And use rc-update to have the server start on boot:

  1. rc-update add fms default

Good luck.

Popularity: 69% [?]

Vista SP1 sales video

Thursday, April 17, 2008

I really hope this is a spoof as it makes me want to stab myself in the eye with a fork.

Popularity: 93% [?]

Prototype String.toQueryParams() weirdness

Tuesday, April 15, 2008

I just came across this while using Prototype:

  1. "section=blo%g&id=45".toQueryParams();

To save you the trouble of running it yourself, I’ll tell you what happens - the unescaped percent symbol causes a URI malformed error to be thrown.

Very odd. The Prototype documentation for toQueryParams says:

Parses a URI-like query string and returns an object composed of parameter/value pairs.

Since it’s a URI-like query string and not an actual query string (by which I mean one that’s been through the browser address bar and as such subject to whatever text munging the browser does), my example above should be a legal use case.

After a little digging around in prototype.js, it seems that the problem is caused by the JavaScript function decodeURIComponent() not enjoying being given a string that contains an unescaped percent symbol. Usually percent symbols are used in conjunction with a number to represent a non-alphanumeric character in a URL - %20 for space, etc, but in the above it’s a literal percent symbol.

My first attempt to fix it changed lines 98 and 100 of string.js in the Prototype source to use the built in escape function:

  1. var key = decodeURIComponent(pair.shift());
  2. if (value != undefined) value = decodeURIComponent(value);
  3.  
  4. to
  5.  
  6. var key = decodeURIComponent(escape(pair.shift()));
  7. if (value != undefined) value = decodeURIComponent(escape(value));

This worked for my use case but caused Prototype to fail a different unit test. Changing them to the following worked out okay:

  1. var key = unescape(decodeURIComponent(escape(pair.shift())));
  2. if (value != undefined) value = unescape(decodeURIComponent(escape(value)));

Granted the unescape(…(escape(…)) is a little clumsy, but it seems to get the job done.

Adding the following unit test to string.html allows to test for the above:

  1. this.assertHashEqual({‘key1′: ‘va%lue1′}, ‘key1=va%lue1′.toQueryParams(), ‘rogue percent symbol test’);

I’ve created some test pages which demonstrate the problem.

There is also a patch file available. Apply it to /src/string.js in your Prototype source tree.

Update

I’ve also filed a bug.

Popularity: 100% [?]

Code

Friday, April 11, 2008

I haven’t posted here for a while, mainly due to the time sink that is Facebook, but I have been writing code in my spare time, honest.  I thought I’d have a little skim through what’s on my machine and share a few choice nuggets.

Recently I’ve been trying to get into programming applications for Mac OS X - I use it on a day to day basis so thought it would be best to get involved.  I’ve put some new things on the Stuff page for your perusal.  They are:

Backgrounderer

A little app to download desktop wallpapers from veer.com. If you wish to build from source, you’ll need to install RegexKit first.

Mail RSS Exporter

An application that exports your RSS feeds from Apple Mail and stores them in either OPML format or Safari Bookmarks.

TouchMe

A program to run AppleScripts on a computer on your local network from your iPhone or iPod Touch - I use this to control a Mac mini attached to a projector.  The projector is not always switched on so Front Row was insufficient.  It also allows you to force quit applications that have hung.

SimpleHTTPd

A Cocoa native web server packaged as a framework so you can use it in your own projects.  Based on Jurgen Schwiezer’s SimpleHTTPServer.

All of the above require OS X 10.5 Leopard as coming from a Java/PHP background I have a strange fetish for garbage collectors and consequently find manual memory management tedious.

They are all BSD licensed and source is included with each program so go crazy.

I’ll get round to posting about each one in more depth in the near future.

Popularity: 97% [?]

Brain IV

Wednesday, March 19, 2008

Welcome to version 4 of Aching Brain. It’s been an awfully long time, but I promise to post more often.

The major change is that I’ve switched from a custom back end to pre-written blog software as maintaining it became a bit of a nightmare. I say maintaining - what I mean is writing new versions of it as who wants to administer crufty old code when they get home? AB4 has been in the works for over a year but I never seemed to be able to finish it without wanting to re-write great big chunks of it so I’ve bitten the bullet and gone down the shoulders-of-giants route. And I have to say, so far it’s been relatively painless - the only thing that’s really given me trouble is getting apostrophes to play nice in code tags, but more on that later.

All the old content should be here somewhere. The only difference is a slight change in the URL structure but a little bit of .htaccess fiddling should mean that incoming links still point in the right place.

If you spot anything amiss, do let me know.

Popularity: 95% [?]

Button, button, who’s got the button?

Thursday, July 26, 2007

From an article on the Wall Street Journal about Steve Job’s button phobia.

When the company introduced the iPod in late 2001, the most common calls to Apple’s technical support lines for a time were about how to turn the device, which lacked a clearly defined power button, off and on, says a former Apple executive.

Wow, I’d forgotten all about that. Years ago Will left his iPod at our house for a week or two and I had such trouble trying to figure out how to turn the damn thing on.

Popularity: 98% [?]

Apache2 and OS X

Friday, July 20, 2007

This is more a note to myself than anyone else, but to compile Apache2 on OS X, use the following configure:

  1. ./configure –with-included-apr –enable-so –enable-mods-shared=most

When Apache starts whinging about “dlname not found, assuming libtool archive” and shit, and refuses to produce .so modules instead kicking out a bunch of .a and .la files in their place, it means you’ve fucked up somewhere along the line, probably because this isn’t the first time you’ve tried to run the configure script.

Delete the entire Apache source directory and start again. If you are lucky you’ll even get a nice copy of libexpat.0.dylib at the end of it all.

Popularity: 98% [?]

Orwellian

Tuesday, June 26, 2007
The BBC … has always taken a platform agnostic approach to its internet services.

And then a little later:

It is not possible to put an exact timeframe on when BBC iPlayer will be available for Mac users.

–bad, indeed.

The corporation’s governing body asked the BBC to ensure that the iPlayer could run on different systems - such as Apple Macs - within “a reasonable time frame”, initially twenty-four months.

Twenty four months for porting to Mac OS X is reasonable?! I dread to think about the poor old Linux users out there.

The BBC has previously said it cannot commit to a two-year time frame as many decisions would have to be made by third parties.

i.e. Either Microsoft decide to port their DRM software or someone else will have to decide to write some.

A statement from the BBC read: “Our ability to deliver this open approach will be influenced by the availability of alternative DRM systems on the market.

i.e. Microsoft have no plans to port their DRM software to any other operating system so the BBC will have to find some other system to use and so far haven’t so we’ll just have to wait.

What a load of rubbish. I’ve always been a strong supporter of the BBC but this is utterly unacceptable.

http://news.bbc.co.uk/1/hi/technology/6236612.stm

Popularity: 96% [?]

Warranty

Friday, April 27, 2007

From the little booklet in the box:

Off road riding extracts a severe toll on footwear. On and off the pedals thousands of times, lots of walking, days of 150 degree heat rotting the shoes in your trunk all means these shoes will eventually wear out. When the rubber is worn smooth off the bottoms and your riding buddies locate you by following the flapping noise of your torn uppers, BUY NEW SHOES. Don’t return them to your dealer with your altar boy face on and mmble, “Uh, I only used them once and look what happened. Gimme new for nuthin.” (sic)

Of course, if we screwed up and forgot to send you (sic) your particular pair through our patented top secret bulletproofing process and they come apart for no good reason, give us a call at the number listed below and we will see what we can do to remedy the problem or come up with another bit of creative customer relations to keep you happy. Just give us a call.

I appear to have just bought a pair of shoes from a company that not only regards its customers as a bunch of scroungers but also feels the need to press this point home in a rather patronising manner.

It’s a shame - they are rather nice shoes.

Popularity: 94% [?]

Glastonbury tickets

Sunday, April 1, 2007

Alex is currently wondering if the Glastonbury ticket website is run off of a beige box in the corner of someone’s flat with a cat chewing on the network cable.

Honestly, what with all the pre-registering bollocks it’s not like they were unaware of the demand. Why can’t they design a server infrastructure that can handle enough requests?

Popularity: 97% [?]

Whither Wii?

Monday, February 12, 2007

It’s hard to believe just how difficult a Nintendo Wii is to acquire. I made a vague stab on release day, trawling the electronics drags on Tottenham Court Road and Oxford Street. Everywhere I was greeted with smirks, and laughter accompanied by pointing and other gesticulation. The guy I spoke to in Virgin Megastore looked like he was going to hit me.

So I thought I’d leave it for a bit until the demand died down. It’s just a new games console whose sales are feeding of the intense hype surrounding it. It will sort itself out after a month or so.

On Saturday while ktm was queueing in Argos for a replacement bathroom light (it’s a rented property - what, you want us to go to Habitat?), I nipped out to see if, on the off chance, there was any Wii in Woolworths.

No

I was told, but I could order one. How long?

3-5 days, if they are in stock

said the pimply faced youth. Wicked, I think. So I queued to be greeted by the very same PFY at the counter.

Ah, you want a Wii. I’ll just pull it up on the computer. Oh, they are out of stock. My gosh! You can’t even order them!.

My gosh indeed.

So to WHSmiths. Nope. To Dixons. Nope. Return to Argos. Nope. Having picked up the better half, we headed back to Dixons in search of a FM radio aerial and I took the opportunity to quiz a member of staff on their availability. Nope. I thought I might as well go for it and ask if I could order or join some sort of waiting list. She laughed.

We got a couple in last week, but we are still filling our pre-orders.

!

From November

!!

There are Wii available, however. Game’s online store occasionally has stock. However they are opportunist bastards and only sell the console in a bundle with four non-discounted games. Then again I did really want one and the games it comes with are rather good. I took one for the team.

Having come into possession of possibly the most elusive bit of gaming kit currently on the market (save a copy of Duke Nukem Forever) I thought it would be an easy ride from here on in.

The thing is, I haven’t told ktm that there’s a Wii arriving at some point in the near future*. Consequently, I need to be able to placate her when it arrives. This may be possible via a game or two of Wii tennis. For this, as any 12 year old will be able to tell you, I need two controllers, or Wiimotes to use the approved lingo, and the console only comes with one. I stepped out of my Wii owning friend’s trendy Farringdon design studio at lunch time to attempt to locate a second of these fabled devices.

Dixons. Nope. WHSmiths. Nope. Hmm, not so good. Having exhausted the local possibilities, I resolved to head to Oxford Street after work. Virgin Megastore. Nope. Dixons. Nope. Game. Nope. HMV. Nope.

Against my better judgement, I tried some of the little nameless electronics stores at the bottom of Tottenham Court Road who take no greater pleasure than in ripping off gadget crazed geeks with their inter-shop price fixing database. No Wiimotes there either.

?!?@?!?!?@?!

Urgh, this was becoming a little silly.

Since every major store and most minor ones have come up empty, I was forced to try the black market. Computer Exchange.

Yes, we have one Wiimote in stock, but it’s ¬£35

the little goth pixie behind the counter tells me.

??!?!?!??!!@@@@?!?@1/

I looked at her incredulously, trying to come with some counter argument about how dare they have the nerve to sell me a second hand controller at above RRP. She stared blankly back at me. I opened my mouth. She put her hand on her hip and tilted her head slightly, as if she was about to begin lecturing me on market forces dictating the price of goods in a free market. ktm’s disapproving look as I open the box from Parcel Farce loomed out of my imagination. All right, I’ll have it, I grumble. When I protest sarcastically at the lack of box, the happy capitalist goth chirpily informs me that there’s a one year guarantee. Hooray. I grab the bag and walk out.

I can’t help but feel ever so slightly taken advantage of.

* = It’s just possible that I may have blown my cover

Popularity: 97% [?]

svn:externals and different usernames

Wednesday, January 3, 2007

How to use a different username with svn:externals.

Genius. Well, almost. Close enough.

Popularity: 96% [?]

Pink Zune

Tuesday, November 28, 2006

Me: Oh look, they’ve released a pink Zune. Would you like one for Christmas?

Her: I’d rather stick my head on a pike.

Although on closer reading of the article, it seems that the pink Zunes are a very rare limited edition and they are not marked as such. Consequently the guy who bought it thought he was getting a white one, didn’t like the pink, saw an opportunity and promptly put it on eBay.

Honestly, that’s a stroke of genius only matched by releasing a brown Zune in the first place.

You can just see little Jimmy’s parents in some electronics shop going:

Parent: Oh look, there’s one of those Zune things Jimmy wants. Excuse me, Mr Shop Assistant, we’d like to buy a Zune.

Shop Assistant: Wonderful, here you go.

Parent: Excellent, he’s going to be so pleased.

Of course, the parents left it to the last minute and the black/white Zunes sold out a long time ago - something the shop assistant neglects to mention lest it should damage his chances of making a commission and/or missing his sales target.

Little Jimmy then spends the next six months being bullied at school for having a poo coloured Zune before it’s finally stolen and destroyed by muggers on the bus who can’t bear to suffer it’s existence any longer. Little Jimmy is secretly thankful.

Popularity: 96% [?]

Tiny growl

Monday, November 27, 2006

This just dropped into my inbox:

Hi,

VjAGRA_zd_$1,78
CjALiS_lx_$3,00
LEVjTRA_fz_$3,33

www [dot] removed [dot] info

——–

tiny growl is permitted.

Tiny growl indeed. Fuckers.

Popularity: 95% [?]

Vista

Friday, November 24, 2006

I downloaded the release version of Vista today via my work MSDN account and my first impressions were:

Hmm. I can’t quite focus on the text on this screen. Either my hangover is really, really bad or I need to get my eyes tested.

Oh, wait, it’s just ClearType.

Aside from that, I’m amazed at how complicated they’ve made everything. For example, when downloading files through IE7, you now have a “Downloads” folder in your home directory. Can you get to this via the start menu? No. Is it a sub-folder of your Documents folder? No. What’s wrong with just putting them on the Desktop? Isn’t it what it’s there for - files you are currently working on and/or might not want to keep?

The Windows Explorer seems to have become a maze of semi-coherent short cuts and file system abstractions - see the address bar for what I mean. Even the Control Panel has succumbed to this mess. It seems they’ve sat around a table and gone “What are the most popular things people do with the Control Panel” and made shortcuts to them all, rather than organising the different areas in a logical manner in the first place.

And then there’s the whole off button thing.

Never mind the hundreds of pop ups “This program wants to do this” “Do you know this program?” “Do you want to let this program do this?” “Are you sure you want to let this program do this?”. And the really obnoxious one that greys out your entire screen and puts the dialogue box right in the middle. “LOOK AT ME”, it screams. “FUCK OFF”, I think.

And what happened to the File/Edit/etc menus? It took me a good twenty minutes to work out how to show hidden files and folders. In the end I had to ask Google for the answer.

Ugh. Maybe I’m just getting old, but does it really have to be this way?.

Popularity: 100% [?]

Magic bullet

Friday, November 17, 2006

Biometric passports cloned. It seems all it takes is 174 quids worth of hardware and 48 hours of a programmer’s time to write the software.

Given the government’s track record for IT, is anyone really surprised by this?

Popularity: 67% [?]

Beta software

Tuesday, November 14, 2006

John Gruber has a go at shonky software hiding behind the “Beta” label (so hot right now).

Too bloody right.

Popularity: 55% [?]

eBay infrastructure

Wednesday, November 1, 2006

There’s an article on eWeek.com about the storage requirements of eBay.com. It’s mostly large number willy waving, but this quote from the third page caught my eye:

eBay’s application servers, according to Strong:

* use monolithic two-tier architecture
* boast 3.3 million line C++ ISAPI DLL (150MB binary)
* have hundreds of developers, all working on the same code
* are hitting compiler limits on number of methods per class.

Now, I could be wrong, but the last three points don’t really strike me as much to be proud of, not to mention possibly inaccurate in the case of the first two.

In other news, this morning I did something that some people might find a little odd. I cleaned my bike.

Truly, I am entering into the realm of the unwell.

Popularity: 34% [?]

ClassLoader

Monday, October 30, 2006

I have a sort of love hate relationship with OO support in PHP. On one hand it looks like a dirty hack due to a combination of the duck typing, lack of function overloading, no proper namespaces and the way everyone talks about object methods when the code itself calls them functions. On the other hand it just feels right (although I’m told this kind of wooly thinking is my degree showing) and if you are putting anything together where scripts run to more than a hundred lines or so it’s really the only way to do it and keep it all manageable. One of the major problems I have with the whole thing is that there is no standardised way to store your class definitions and consequently no way to import them in a neat and tidy way. I personally favour having each class and interface in it’s own file, named thus:

DatabaseConnection.class.php
SQLQuery.class.php
JSONableItem.interface.php
etc..

This way you can identify what is in each file just by reading the name and you can order them in directories like so:

ajax
JSONableItem.interface.php
database
DatabaseConnection.class.php
SQLQuery.class.php
etc..

Even giving you a sort of memetic namespace of

ajax.JSONableItem
database.DatabaseConnection
database.SQLQuery
etc..

Which encourages code re-use by making it very easy to transfer classes between projects. This brings me on to the next problem in that there is no standardised way of importing these classes into your script files. I normally have one file that imports all the class definitions into the project, somewhere high up on the bootstrap page but this means that every single class in the project is being loaded for each request to the server that is answered by PHP - not exactly ideal. I found a little class on the Pure PHP website called Include_once which is based on an interesting little idea - keep a list of imported files and only import a requested file if it is not in the list. Inspired by this I’ve written a little utility class rather unimaginatively named ClassLoader which does the above but via a sort of namespace that allows for nice structuring of class definition files in the file system and also the importing of whole folders of class files (packages). An example of it’s use is as follows:

  1. ClassLoader::import(‘database.DatabaseConnection’);
  2. ClassLoader::import(‘database.SQLQuery’);

or even

  1. ClassLoader::import(‘database.*’);

There are also a couple of other fun methods

  1. ClassLoader::getClassesLoaded()

tells you how many classes have been loaded and

  1. ClassLoader::getLoadAttempts()

tells you how many times ClassLoader has been asked to load class definition files. The reason that these may be different is because you can use ClassLoader to include class definition files at the top of other class definition files much in the same way you’d use the import statement in Java. So for a trite example, with the following file structure:

classes
  pretend
    InterfaceA.interface.php
    ClassA.abstract.php
    ClassB.class.php
    ClassC.class.php
  util
    ClassLoader.class.php
index.php

InterfaceA.interface.php

  1. interface InterfaceA {
  2. public function someMethod();
  3. }

ClassA.abstract.php

  1. ClassLoader::import(‘pretend.InterfaceA’);
  2.  
  3. abstract class ClassA implements InterfaceA {
  4.  
  5. }

ClassB.class.php

  1. ClassLoader::import(‘pretend.ClassA’);
  2.  
  3. class ClassB extends ClassA {
  4.   public function someMethod() {
  5.  
  6.   }
  7. }

ClassC.class.php

  1. ClassLoader::import(‘pretend.ClassB’);
  2.  
  3. class ClassC extends ClassB {
  4.  
  5. }

index.php

  1. require(‘classes/util/ClassLoader.class.php’);
  2.  
  3. ClassLoader::import(‘pretend.ClassC’);
  4.  
  5. $foo = new ClassC();

Neat. Of course, you don’t have to follow my file naming convention, feel free to do whatever you want, as long as the file has the name of the contained class before the first ‘.’ and the last four characters are ‘.php’ Configuration of the class is pretty simple - just change the static member variable ClassLoader::$classPath to suit your set up. Just make sure it’s readable by PHP. So, for example:

  1. require(‘classes/util/ClassLoader.class.php’);
  2. ClassLoader::$classPath = $_SERVER[‘DOCUMENT_ROOT’] . ‘/includes/myclasses/’;

or

  1. require(‘classes/util/ClassLoader.class.php’);
  2. ClassLoader::$classPath = ‘/usr/local/share/php5/myclasses/’;

or similar. Given the above, there’s a really tiny part of me that says I should start using proper stuff like J2EE or something. I try not to listen to it.

Popularity: 40% [?]