‘C’ is for Coincidence

5 11 2010

The beauty One of C++’s problems is that there is no built in string type. Even if you’re very comfortable with one type of string you’re completely unprepared for the next.

I was writing a part of a Firefox plugin that clears the browser’s cookies, looking at the header file I saw this:

  NS_IMETHOD GetPath(nsACString & aPath) = 0;

Well I thought to myself naïvely, I guess I’ll have to use a variable of type nsAString. But first I have to create a cookie manager, what should I name it?

The answer was obvious.

  nsCOMPtr<nsICookieManager> cookieMonster;

When I tried to get a cookie’s path I crashed, well it was time to go home so I decided to give it another shot the next day.

On the morrow I figured out that I needed to use a variable of type nsEmbedCString and not nsAstring (who knew?). <edit> Apparently pippy from reddit knew, this has got something to do with the fact that the plugin in question is in fact an extension not a plugin, why this should matter is beyond me</edit>

    nsEmbedCString name;
    nsEmbedCString path;
    spCookieMonster->Remove(host, name, path, PR_FALSE);

Now to check the damn thing works.

Those of you out of the US know that if you go to www.google.com it will take you to your country’s Google, this is a bit of a pain in Israel since the whole right to left thing tends to mess thing up. Luckily Google supplies the No Country Redirect option which sets a cookie telling Google to give you the international site. Little did I know that there’s another difference, NCR doesn’t (or didn’t) display doodles.

Google ncr

Imagine my surprise when after using my cookie monster to clear cookies, refreshing Google.com displayed this:


I mean it’s bad enough Google knows what searches I made, decompiling a plugin and commenting on my variable name selection is going too far!

P.S. The reason I mentioned that I was foiled by nsAstring is to prove that I didn’t see the doodle and subconsciously name the variable accordingly, I named the variable the day before the doodle went live.


P.P.S. The events described above happened on the day my wife and I  celebrated out bronze wedding anniversary and is scheduled to be published on our pottery anniversary, congrats us :).




2 responses

26 11 2010
Tweets that mention ‘C’ is for Coincidence « I will not buy this blog, it is scratched! -- Topsy.com

[…] This post was mentioned on Twitter by reddit_prog_hot, Proggit Articles. Proggit Articles said: C is for Coincidence: submitted by night_of_knee [link] [8 comments] http://bit.ly/ebpfPe […]

9 08 2015
Cookie Lover

How do you do that I am obsessed with Cookie Monster

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: