All Posts

On new beginnings

Friday, March 2nd, 2007

New beginnings are often a good thing, especially when you get stuck. I freely admit that towards the end of last year, I was stuck.

This year I’m starting a new course (I’m technically a first year - aargh!) and I hope I’m starting a new way of looking at uni and life in general.

I’m looking forward to looking at things from a new perspective. It’s been tough going at uni so far and, although I’ve got some pretty good results at times, I think that I’ve missed out on a lot of opportunities to get excited about what I’m learning.

I’ve lost sight of what fun it is to learn new things - new ideas, new concepts, new ways of looking at the world around me - and it’s sad. But things can change, and I will change them…as long as I can remain positive and look on the bright side. Always looking at the bad possibilities doesn’t make the experience of existence particularly fun, so I’m just not going to do it anymore.

Well, that’s the theory, anyway. Come and see me in six months and see if I’m screaming about how I hate uni and can’t wait for it to be finished ;)

Brownie points: del.icio.us +1

Monday, October 30th, 2006

I have to say that del.icio.us has pleasantly surprised me - they showed me Opera bookmarklets automatically during sign-up. Since most sites can’t be bothered dealing with Opera (heck, many can’t be bothered dealing with Firefox) I nearly fell off my chair with surprise. Good work, del.icio.us.

“Strunk and White’s vile little compendium of tripe about style”

Friday, September 29th, 2006

I never thought I’d say this, but a post on Language Log has actually made me laugh out loud. Who else would have the balls but the posters there, experts in linguistics and English grammar, to call the “classic” English style guide The Elements of Style:

Strunk and White’s vile little compendium of tripe about style (link)

I love it. Prof. Geoffrey K. Pullum rips in to it deliciously in that (vaguely) recent post* on the subject of the passive voice.

Now, those who know me will be able to predict that I couldn’t resist grabbing a copy of the just-mentioned pathetic booklet (it was hard to find one; [Adj. Prof. Bill] Poser says he threw his away) and checking on whether Strunk and White managed to get to the end of the page without accidentally using a passive themselves. And of course they didn’t, the bald-faced hypocritical morons. [emphasis mine]

Of course, this is hardly the first time such a post has been made. Language Log is officially a candidate for the title of Best. Blog. Ever.

*Alright, it’s months old - but I’ve got so many things in my RSS reader that I don’t get to it all, and I missed it the first time around. I hereby swear to read Language Log more religiously in future.

Treating myself

Sunday, July 16th, 2006

I treated myself today.

For years I’ve wanted to get myself an MP3 player, but I’ve never been able to:

  1. Justify the stupid prices most of them are worth (yes, iPod, I’m looking at you)
  2. Feel comfortable carrying around something worth that much money
  3. Afford the stupid prices most of them are worth.

However, today I found a good deal so now I am the proud owner of a new baby Sandisk Sansa e140, a 1GB flash-based MP3 player. It’s an old model (which is why it was pretty cheap) but based on my first impressions, I love it.

  • It’s seriously small. Not small enough that I’d have to worry about losing it, but small enough that I can put it in a pocket and not be irritated by it. It’s also light as a feather.
  • The included earphones are pretty good - certainly good compared to the cheap crap I usually use, anyway. Nice and bassy, they block out a lot of external noise and they’re comfortable.
  • It came with a case! I hate getting scratches and dirty marks on stuff, so the clear plastic case that came in the box was a godsend.
  • It’s easy to put files on it - just drag-and-drop MP3s to it. It shows up as a normal USB Mass Storage Device (you know, like a USB thumb drive or whatever.)
  • It doesn’t support OGG files, which is mildly irritating, but I hardly have any OGGs anyway.
  • It doesn’t do crossfading either, but I can live with that for the price.
  • The sound boosting settings are nice and work pretty well, but I would’ve liked a ‘dance’ preset on the equaliser.
  • The FM radio is very handy. My phone has an FM radio but I can never be bothered to carry the special attachment you need to use it (you can’t just plug in a normal 3.5mm plug.)
  • It came with the older 1.x firmware, and I haven’t worked up the courage to flash it up to the newer 2.x firmware yet.

Wordpress vs. Luke

Sunday, July 16th, 2006

This blog runs the excellent Wordpress blogging software. In addition, to be nicer to the system it’s hosted on (at Dreamhost), I’ve got the WP-Cache plugin installed (which caches pages so that they don’t have to be regenerated on every page load.)

At the moment I’ve got things running under CGI, which isn’t the most efficient way of doing things (but it’s easy.)

In order to satisfy my own curiosity, as well as squeeze a little bit more performance out, I tried the other day to get this Wordpress install to play nice with PHP running through FastCGI, with the APC PHP opcode cache. I say ‘tried’ because it was a complete and utter failure. APC and WP-Cache definitely don’t like each other one little bit.

Exceptions > Errors

Friday, July 7th, 2006

Today, whilst working with some PHP code, I wanted to catch an error like an exception.

PHP’s errors are a kludgey solution left-over from before PHP had objects. When PHP 5 introduced proper Exception support, I was overjoyed - until I learned that all the existing inbuilt PHP functions would continue to trigger errors rather than throwing exceptions. I understand that it’s necessary for backwards-compatibility, but it still really, really sucks when you want to write clean code.

So, today I was writing my own code to convert errors into exceptions when I hit a frustrating roadblock: the PHP Exception class doesn’t allow you to alter the stack trace. This is a Bad Thing in this case because you must throw the exception inside your error handler - which means that the stack trace starts at your error handling function, making the entire stack trace bloody useless.

Whilst Googling around I happened upon a few snippets here and there about the existence of an ErrorException in the SPL extension of PHP 5.1+. It is a wonderful thing - it’s basically an exception, with the added ability to pass in the stuff passed to a custom error handler, which is then put in the stack trace. It is truly a godsend for debugging.

Anyway, because I have a memory like a sieve and mentions of ErrorException are scarce, here’s the minimal code to use it:

function errorToExeption($errno, $errstr, $errfile, $errline) {
    throw new ErrorException($errstr,0,$errno,$errfile,$errline);
}
set_error_handler('errorToException');

That’s it - now you can treat any function that triggers errors like it throws exceptions instead. You might like to create a couple of subclasses of ErrorException for errors, warnings, etc. and then throw the appropriate exception inside your error handler. Don’t forget that a custom error handler can’t catch every type of error, such as those that might leave PHP in an unstable state, or those that occur inside the Zend Engine before your script is executed.

Hooray for things working!

Monday, March 6th, 2006

Well, the good news is that, after much trouble, I’ve sorted out my timetable by changing subjects. Twice.

Anyway, for what is the first time I’ve been at uni, I only have to go to class three days a week! On the downside, I have long breaks on Thursdays and Fridays after early (for me) starts, and I have a CLASH!!! on Fridays. Still, for once I seem to have a fairly good timetable! :D

Ah, the joy of Chaos

Friday, March 3rd, 2006

I go back to uni on Monday and, when I was finally able to get my timetable yesterday, I was overjoyed to discover that, not only did I have three days with less than 2 class hours each, but I also had three subjects clashing. Sigh. Now I’ve gotta try and change my subjects so that I can still do the subjects I need to do later on without having clashes now.

Alarm Clock - Snooze Button + 4 Piece Puzzle Puzzle = Awake

Friday, March 3rd, 2006

I need one of these. Seriously, I’d never be late anywhere again! Well….maybe that’s going a bit far.

read more | digg story

The Click That Broke China’s Grip

Tuesday, February 21st, 2006

“The top editors of the China Youth Daily were meeting in a conference room last August when their cell phones started buzzing quietly with text messages. One after another, they discreetly read the notes. Then they traded nervous glances.”

I suppose it shouldn’t surprise me that people use the Internet to get around the draconian restrictions of China, but it’s really cool to read about people actually doing it.

read more | digg story