Stuff for Web Professionals
Does it .match?
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]/gvar 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
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!
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
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.
- Clara at 17 Months
- 8 x 10"
- Colored Pencil on Eggshell Mi-Tients Paper
- November 20, 2007
- Big Smile
- 8 x 10"
- Colored Pencil on Cream Mi-Tientes Paper
- December 11, 2007
- 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
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
Self Portrait III
- Graphite on Cold Press Illustration Board
- 8.5 x 11"
- Source Photo © Kevin C. Smith
- In-progress scans
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

- Clara the Angry Cow
- Colored Pencil on Cold Press Illustration Board
- 11 x 8.5"
- Source photo © S.G. Chipman
- In Progress Scans
Clara in her Halloween costume impersonating her Daddy's scowl.
As well, Happy 5th Birthday, slayeroffice!
Brian

- Colored Pencil on Cream Mi-Teintes Board
- 11 x 8.5 "
- October 29, 2007
- Source Photo © Kevin Lawver
Max & Clara
- Colored Pencil on Cream Mi-Teintes Board
- 11 x 8.5"
- October 24th, 2007
- Source Photo © Kevin Lawver
A finished this one a week or so ago but forgot to post:
- Colored Pencil on Cream Mi-Teintes Paper
- 8.5 x 11"
- October 14th, 2007
- Source Photo © S.G. Chipman
Easier Static Pages for CakePHP 1.2 Update
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(); } }






