Escaping and Backslashes, Oh Joy
February 18, 2006 by Eric Richardson
Over the past few days I noticed an annoying issue where a by-address search wasn't behaving properly. I would search for, say, "santa fe" and would get only four results even though I knew there were five in the database.
The Rails code that was generating the search was pretty simple:
@buildings = Building.find(:all,
:conditions => [
'address regexp ?',
'^[^\n]*' + building[:address].downcase
],
:order => "address ASC")
So for that santa fe search I should get:
SELECT *
FROM buildings
WHERE (address regexp '^[^\n]*santa fe')
ORDER BY address ASC
But that's not what I'm getting. I'm actually getting that regexp as '^[^\\n]*santa fe'. So instead of preventing newlines before the address, I'm actually preventing backslashes or n's. The missing result -- on "N. Santa Fe". — Continue Reading...
Now on to Performance
February 18, 2006 by Eric Richardson
For work I have a Rails app that we're going to be taking into production on Wednesday. As such, I figure I should probably start taking more than a passing interest in things like performance.
During development I've just been using WEBBrick, which has been great since I just use svn to update the server and boom there are my changes. Unfortunately, though, it's not all too quick. And even more importantly, it can't scale past one CPU. Seeing as the server has two, and with hyperthreading it thinks it has four, I figure that's an issue. But at least WEBBrick gives me a baseline performance number of 7.2 requests per second (for an arbitrary but fairly intense operation) that I can build off of.
I installed lighttpd yesterday (which I keep trying to misspell as libghttpd), but all I've managed to get Rails to do in FastCGI mode is segfault.
More Browser Fun
February 16, 2006 by Eric Richardson
Firefox (and Camino) on the Mac apparently can't pop an element up over the scrollbar on a div. The scrollbar just shows through, cutting into your popped up element. This is not the case with Firefox on Windows. Neither IE or Safari have a problem with it.
On the other hand, I've managed to create a bold style that Safari decides to just not show sometimes the first time you display a list that features it. As soon as you touch the scrollbar it pops into view. Sometimes I even see the text before it disappears. Changing the tag doesn't alter the behaviour. Of course it has no problem if I load the same HTML and style into a flat HTML file, so I don't know how to even begin to debug that one. None of the other browsers have an issue with it.
Oh Yeah
February 15, 2006 by Eric Richardson
The other thing I discovered this morning was that I've apparently written some javascript that causes Firefox 1.5 on Linux to segfault. It works fine in Firefox on OS X, Camino on OS X, Safari on OS X, IE on Windows, etc, but as soon as i activate a certain form element on Firefox/Linux the browser vanishes.
Not a big loss, though, as the main part of the app doesn't work there anyway thanks to Macromedia not releasing a Flash 8 plugin for Linux.
When a Form's Not Really a Form
February 15, 2006 by Eric Richardson
When's a form not really a form? When it's being used and abused the way HTML forms have to be to do interesting work these days.
Over the past few weeks forms have been out to get me. You wouldn't think that would be. I mean, forms are pretty simple stuff. You put in some fields, there's a submit action, and boom there you go.
If only life were so simple. — Continue Reading...