Stuff for Web Professionals

Does it .match?

Steve Slayer - 2 hours 9 min ago

I've been doing some work in AS3 of late and stumbled onto a bit of a gotcha last week that I thought I'd share since it caused me about 15 minutes of frustration.

The gotcha pertains to a significant difference in how Javascript and AS3 handle the match method of the String object when the global flag is passed. Consider the following Javascript snippet:

var r = /[a-z]/g
var s = "abc";
var x = s.match(r);

This will return an Array with values "a,b,c" in both Javascript and in its AS3 equivalent.

Now, consider this code, replacing the value of s with something that will not match:

var r = /[a-z]/g
var s = "123";
var x = s.match(r);

In Javascript, this will return null, but AS3 will return a zero length Array. Which means that this...

if(s.match(r)) {
// do stuff...
}

..would always be true in AS3, but false in Javascript. I spent about 10 minutes thinking there was something wrong with my regular expression, and another five thinking there was something wrong with AS3's regexp engine before I realized what was happening.

So who has it right? According to the ECMA 262 spec, AS3 does (see page 101-102). Of course, Mozilla's documentation claims that it will return an Array as well with no mention of null on that page, while Microsoft's JScript documentation admits it will return null if no match is found.

Good times.

Emre Grayson Chipman

Steve Slayer - 2 hours 9 min ago

My son, born this evening weighing in at 9.33 pounds, measuring 20 inches.

(And that's why I wasn't in Austin this year!)

SXSW Time!

Steve Slayer - 2 hours 9 min ago

And I'm not gonna be there this year. I know, I know - I should have told you sooner. You're probably already in Austin or in flight, now wishing you had advance notice of this turn of events so you could have just stayed home. I'm sorry, I really am. This really was terribly inconsiderate of me.

Soldier on, brave geeks, and know that with enough Shiner Bock, anything can be fun even if I'm not there. Be strong. And take lots of pictures. And twitter a lot. Let me experience Austin through your internets.

(Any day now I'll have an announcement of why I'm not there this year...)

Three Drawings and a PSA

Steve Slayer - 2 hours 9 min ago

These three drawings I did leading up to Christmas - I've kept them private on Flickr and not published them here as they were gifts for family and I didn't want to spoil the suprise.

Colored Pencil Drawing entitled Clara at 17 Months

  • Clara at 17 Months
  • 8 x 10"
  • Colored Pencil on Eggshell Mi-Tients Paper
  • November 20, 2007

Colored Pencil drawing entitled Big Smile

  • Big Smile
  • 8 x 10"
  • Colored Pencil on Cream Mi-Tientes Paper
  • December 11, 2007

Colored Pencil drawing entitled Clara at 18 Months

  • Clara at 18 Months
  • 10 x 8"
  • Colored Pencil on Eggshell Mi-Tientes Paper
  • December 21, 2007

And with those, I'll no longer be posting drawings on slayeroffice. 2008 seems a good a time as any to get the site back on the web development talk track. If you're interested in following my portraiture work, you can find it on my new drawing blog. Or, just grab the feed.

Page 222

Steve Slayer - 2 hours 9 min ago

My good pal Mr. Lawver has included a reference to my Page Info Favelet on page 222 of his new book.

Congratulations to Kevin, Kimberly, Christopher, Rob, Meryl and Mark on the book. I'm not sure when it comes out, but with that caliber of authorship (and obvious good taste) its a must-own.

Maya

Steve Slayer - 2 hours 9 min ago

Graphite portrait of a friend's new baby entitled Maya

  • Maya
  • Graphite on Cold Press Illustration Board
  • 11 x 8.5"

A portrait of a friend's new baby.

Self Portrait III

Steve Slayer - 2 hours 9 min ago

Graphite drawing entitled Self Portrait III

My first go at graphite in about 12 years. It didn't take nearly as long as a colored pencil drawing, and it was awfully nice to be able to use an eraser. I may stick with it for a little while.

The Angry Cow

Steve Slayer - 2 hours 9 min ago

Colored pencil portrait entitled Clara the Angry Cow

Clara in her Halloween costume impersonating her Daddy's scowl.

As well, Happy 5th Birthday, slayeroffice!

Brian

Steve Slayer - 2 hours 9 min ago

Colored pencil portrait entitled Brian

Max & Clara

Steve Slayer - 2 hours 9 min ago

Colored pencil drawing entitled Max

A finished this one a week or so ago but forgot to post:

Colored Pencil portrait entitled Clara at 15 Months II

Easier Static Pages for CakePHP 1.2 Update

Jonathan Snook - 12 hours 21 min ago

So it seems that the old code I had didn't work in debug mode, although on the current CakePHP 1.2 RC2, I'm not even sure it works at all. However, I decided to take some time to revisit the code. Last time, I simply hacked up the missingAction and missingController calls and it felt kludgy. It looked kludgy.

This time I took a closer look at how the dispatch was being handled. Daniel Hofstetter made mentioned how using the error handler seemed inappropriate since it's for handling errors. Unfortunately, the Dispatcher looks for a missing action or controller and if it can't find them, it sends it off to the AppError class well before anything else. As a result, it seems that overriding the AppError is really the approach that I want to take. I think you'll see, though, that the new code is more straightforward.

It uses the constructor to capture what kind of error is being called. If it's a missingAction or missingController then I look for the missing file. If the file doesn't exist, the flow continues on to the parent error class and the missingAction and missingController calls happen as they normally would. The old code actually handled both scenarios creating bulky code.

If the page exists then the AppController is instantiated and the view is rendered. The only problem currently is that CakePHP doesn't seem to load the custom AppController, if it exists. I've filed a ticket but I'm not entirely sure if this is by design, so this may not ultimately get resolved.

Without further ado, here's my AppError:

class AppError extends ErrorHandler { function __construct($method, $messages) { $params = Router::getParams(); if (($method == 'missingController' || $method == 'missingAction') && file_exists(VIEWS . DS . $params['controller'] . DS . $params['action'] . ".ctp")) { $this->controller =& new AppController(); $this->controller->_set(Router::getPaths()); $this->controller->params = $params; $this->controller->constructClasses(); $this->controller->viewPath = $params['controller']; $this->controller->render($params['action']); e($this->controller->output); exit; } parent::__construct($method, $messages); exit(); } }

Installed Ubuntu Again

Anne van Kesteren - 14 hours 11 min ago
My dad is running Ubuntu too now.

reboot10: Presentations

Anne van Kesteren - 14 hours 11 min ago
Presentations I gave at reboot10.

reboot10: Connected Rabbits

Anne van Kesteren - 14 hours 11 min ago
On the internet of things.

Microsoft: Cross-Site Requests Feedback

Anne van Kesteren - 14 hours 11 min ago
On the feedback from Microsoft regarding cross-site requests.

reboot10: interview

Anne van Kesteren - 14 hours 11 min ago
Interview about Web standards, HTML 5, reboot10, proprietary lock-in, et cetera.

Opera 9.5

Anne van Kesteren - 14 hours 11 min ago
Kestrel is out. Download it!

reboot10

Anne van Kesteren - 14 hours 11 min ago
Anyone going to reboot10 this year?

HTML5: Ruby Annotations

Anne van Kesteren - 14 hours 11 min ago
HTML5 has ruby support!

Installed Ubuntu

Anne van Kesteren - 14 hours 11 min ago
My mom runs Ubuntu.