the Official Robert Churchill

Line drawing lion drawing

September 10th, 2011
Line drawing lion drawing

Drawn as a birthday card for the nephew

 

Dear MySQL

June 1st, 2011

Dear MySQL, thanks for your limited regular expression support:

SELECT
    REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(name, '2006', ''), '2007', ''), '2008', ''), ' ', ''), '/', ''), '.', ''), '\'', ''), '!', ''), '&', '') AS name,
    description
FROM courses;

(Of course I forget to not look a gift horse in the mouth ; )

Why should we change our voting system?

April 24th, 2011

As the referendum on the Alternative Vote approaches I’m getting more worried that the change will be voted out and we’ll be stuck with First Past the Post for another umpteen years. So I did a little xkcd-style cartoon to help illustrate some of the points and why, from my perspective, we should vote ‘Yes’. (With ‘No’ as second-choice, ha ha…)

The Alternative Vote has its problems too, but I see it as a ‘gateway’ voting system that might lead to proportional representation in the future.

Internet Explorer 9 vs CSS: don’t do this

April 6th, 2011

TridentMicrosoft is now pushing out its latest and greatest Internet Explorer 9 through Windows Update. Immediately noticed some problems on some sites with default serif fonts appearing in unexpected places.

The F12 development tools didn’t throw much light, suggesting that the element was correctly inheriting Arial. Turned out to be some empty style rules tripping up Trident, the likes of:

font-family: ; font-size: ;

Removed, and all was back to normal.

Recipe for debugging with XDebug, Netbeans and CakePHP

March 30th, 2011

It took me a while to get this working so I didn’t spend all my time debugging the debugging. I’ll be brief and hope that you don’t run into any problems following this : )

Ingredients:

  • XDebug latest (new version out I notice, must try that soon)
  • PHP 5.2 or 5.3
  • Netbeans 7.1
  • Local install of Apache HTTPD server
  • CakePHP 1.3
  • Windows 7

Cooking time:

5 – 15 mins according to taste.

Preparation:

  1. Add XDebug extension to your php.ini file. Note with PHP 5.2 you must use zend_extension_ts and with PHP 5.3 you must use zend_extension. Restart Apache.
  2. Set the run configuration for your Netbeans project so that index file is webroot/index.php (or webroot/test.php works, I think webroot/ is the key). Open the Advanced dialog and tell it not to open the web browser, “Do Not Open Web Browser”!
  3. Open Netbeans / Options / PHP / General / Debugging and check “Stop at first line”. Haven’t had much success otherwise. Check “Watches and Balloon Evaluations” if you want but this sometimes causes problems.
  4. Select Debug / Debug Project. Netbeans will start listening for the debugger.
  5. Use Firefox. Install easy XDebug plugin.
  6. Click the green bug icon at the bottom-right of Firefox. XDebug will turn on.
  7. Refresh the page on your site and you should be able to step through your scripts and set breakpoints as necessary.

You might find in some situations Netbeans loses the connection to XDebug. Closing and reopening Netbeans is usually necessary to get it working again, but nevertheless, this is the best experience I’ve had debugging PHP so far. Comments and suggestions welcome.