Once you start playing with the Google Maps API, making your own maps using various bits of JavaScript, you’ll eventually come under attack from single quotes.
Look at this code, for example, which is a mixture of Javascript and PHP:
var point = new GPoint(<? echo $longitude . "," . $latitude; ?>); var marker = createMarker(point, '<? echo $html; ?>'); map.addOverlay(marker);
The role of this snippet is to add a marker to the map at the given longitude and latitude, with the given HTML appearing when the marker is clicked.
So you stick this JavaScript inside a loop that grabs the appropriate values from a database, and sticks a bunch of markers on the map. Things go horribly wrong, however, when you try and create a marker for St. Dunstan’s Basilica, and you can’t figure out why. Here’s what’s happening:
var point = new GPoint(-63.12516,46.23367);
var marker = createMarker(point, 'St. Dunstan's Basilica');
map.addOverlay(marker);
I’ve highlighted the problematic area. And the problem is this: your browser’s JavaScript interpreter is getting confused by the single quote (aka “apostrophe”) in the string St. Dunstan’s Basilica — it thinks that single quote is the end of the string. And if you look in your Javascript console (Tools \| JavaScript Console in Firefox), you’ll see an error like:
Error: missing ) after argument list
How to solve this problem? Simply escape all of your single quotes in your HTML, using PHP, before you insert the HTML into the JavaScript. So:
var point = new GPoint(<? echo $longitude . "," . $latitude; ?>); var marker = createMarker(point, '<? echo str_replace("'","\\'",$html); ?>'); map.addOverlay(marker);
The change has the effect of converting all of the single quotes into escaped single quotes (\'
). Note that you use \\'
in your str_replace because the backslash is also an escape character in PHP, so you need to “escape your backslash” in PHP too.
The resulting JavaScript will now look like:
var point = new GPoint(-63.12516,46.23367); var marker = createMarker(point, 'St. Dunstan\'s Basilica'); map.addOverlay(marker);
And it will no longer cause problems.
I’m the first to admit that I am not a paragon of cleanliness. And you don’t want to know how long it has been since I cleaned the bathroom here at the office.
So today, with a good dose of long-running SQL queries to run to break up the time, I set about to right this horrible wrong.
First stop was the True Value Hardware in the basement of the Confederation Court Mall. I find it always makes cleaning go much easier when you make a run to the “cleaning products” section before starting (I am bolstered in this thinking by Catherine’s revelation that you can’t simply use dish soap to clean everything).
For a hardware in such an obscure location, I gotta say that True Value has pretty well anything someone on a cleaning frenzy could ever want: I returned with a sponge mop, vinyl floor cleaner, new hand towels and dish towels, poster hangers for our YANKEE Magazine 70th Anniversary Poster, a rug for the bathroom floor and some green-apple scented LYSOL bathroom cleaner.
I started with a first pass over the floor with the wet sponge mop and the vinyl floor cleaner. Then a second pass. Then a soak. Then a third pass, this time on my hands and knees with a J-cloth. Left the floor to dry and took a break.
Next it was the fixtures. Generous dollops of green-apple guck got sprayed everywhere germs my linger; soak; rinse; repeat.
The toilet got special triple-action cleaning, as did the sink. I even cleaned the door handles and the light switch (who knows where germs might lurk!).
I left everything to dry, then returned to polish up the stainless steel garbage can, clean out the bathtub, give the radiator a rub-down and neaten up the curtains. Finally I hung up the YANKEE poster, gave the corners a vacuum, and I was done.
I realize that for most normal people this is no feat at all. Heck, most of you probably clean your bathroom every day. Or at least every week. I indeed I will endeavour to become like you as the days and weeks progress.
Now that the gentle scent of artificial green apple fills the office, I welcome any of you with an urge to pee in the vicinity of the office to consider dropping in for a test-run.
Of course you’ll be expected to mop up after yourself. The cleaner is in the closet behind the door.
Apparently I have succeeded in registering the domain name reinvented.travel: here’s my WHOIS record. For now, this will redirect to a list of the travel-related posts here on the weblog.
For more on the “dot travel” domain, see these earlier posts:
And, of course, Edward Hasbrouck’s Internet domain names for travel, which is the definitive resource on this new domain.
For the record, I established Reinvented’s eligibility as a member of the “global travel and tourism community” (see here) by pointing to (a) our eligibility under “Travel Media” for the travel writing here on ruk.ca (see here) and (b) our eligibility under “Computer Reservation/Travel Technology Provider” for Reinvented’s work with travel clients like NewEngland.com.
Also for the record, I continue to agree with Edward’s take on .travel, and proceeded with the registration as much as an experiment in going through the process as for use as a practical business resource (although I’ll likely find a practical use too — I did invest $100!). I do realize, however, that my registration — and thus my investment in the enterprise — do give a tacit endorsement to the project.
Just discovered one of those things I should have discovered a long, long time ago: in MySQL (and, I assume, every-other-SQL), this:
insert into table (field1,field2,field3) values (1,2,3) insert into table (field1,field2,field3) values (4,5,6) insert into table (field1,field2,field3) values (7,8,9)
…can also be expressed like this:
insert into table (field1,field2,field3) values (1,2,3), (4,5,6), (7,8,9)
The difference is that the second form, especially if you’ve got lots of inserts to do, is much, much faster.
This morning’s trip to the Charlottetown Farmer’s Market will forever be remembered as the day that Oliver’s social life exceeded mine in breadth and depth.
This was to be expected of course: I’m not exactly a social butterfly. I’m more like a “nerd hermit” most of the time, save for those rare occasions when I put on my dancing shoes and rock out. (Okay, that’s never happened, but there’s always hope…)
So this morning at the market Oliver simply decided that he would no longer be held back by my social reticence, and plunged into the crowds on his own (Catherine is afraid that I let him out of my sight; I didn’t).
Things began with a hearty hello in the parking lot to Maggie Brown and son (I’ve been living here for 13 years now, and this is the first time Maggie Brown and I have every exchanged a hello, so Oliver is also proving a useful catalyst for my own social growth).
Moving inside he began with conversations with Ann and David. Then along came Karin and Haida. He then moved on to an extended conversation with fiber artist Lynn Douglas (he had seen a picture of her work earlier in the morning and wanted to discuss it with her).
In the middle of all this there was a casual shout out to his friend Lily from kindergarten.
Next it was into the seating area for a talk with Jenni Zelin (mother of Oliver’s occasional friend Noah) and CBC’s Laura Chapin.
Before leaving for the day Oliver stopped to discuss his podcast with Cynthia.
Meanwhile, I ate a bagel with smoked salmon.
Sigh.
Last year I set up a simple Drupal-based website for my friend Art Rhyno’s family’s newspaper, the Essex Free Press. Art’s wife Laurie Brett’s family is celebrating 110 years of ownership of the Free Press this year; for a family business to remain vital for so long is a testament to a lot of dedication, and they deserve a collective tip of the hat (send congratulations here if you like!).
Another client, The Old Farmer’s Almanac, will publish their 215th consecutive edition this year.
Perhaps we should narrow our business focus and work only for “venerable institutions?”
If you do the math, it’s clear that making the rounds of the New Years Day levees provides a good vector for the transmission of communicable illnesses: I must have shaken 100 hands on Sunday, and each of those had shaken 200 or 300 other hands already. I think this means, from an epidemiological perspective, that I’ve indirectly shaken hands with most of the people in Charlottetown.
It seems inevitable that some of those people are carrying bacteria or viruses, and that some of those bacteria or viruses made their way to me.
Or at least it sure seemed that way yesterday when I was parked in front of the couch with a wicked sore throat, chills, and a touch of headache.
Fortunately I seem to have bounced back today, which suggests that this is a short-lived disease, easily recovered from (I took G.’s recommendation and slept most of yesterday, which surely helped).
So as I type this I’m wading through a post-sickness delirium, not quite sure how to put together cogent sentences. But the end is near.
Reminder for 2007: Purell.
From my friend Leah Tremain comes a pointer to StoryCorps, a National Public Radio project “to instruct and inspire people to record each others’ stories in sound.” Neato.
On Monday night Catherine decided to go to the movies, leaving Oliver and I to our own devices. Unable to watch Frosty The Snowman another time, and without sufficient energy to properly engage the Little People, of course we decided to record a podcast. This is the result.
We’re both particularly fond of the opening theme. There’s a big jump in volume about 1/3 of the way in — I think I hit the wrong slider in Sound Studio during post-production.
Oliver hits his stride with the telling of the apple picking story.
Our colleague Ian Williams from the New York Office gives the official U.S. position on the Zap Your PRAM delay; in part:
This was a fascinating thing to do, in my opinion. Tessa called it very Taoist. I’m so used to forcing things to happen, like the Jartaculars or other random events, that I would never contemplate calling anything off. The fire in my belly is self-generating and seemingly inextinguishable, and I’m always afraid that if I don’t make something happen, suddenly “not making something happen” would be okay, and then nothing would ever happen again.