Cufon not Working in IE

A buddy was having trouble with Cufon not working in Internet Explorer (and, as usual, it was working in other browsers). His site was in Drupal, and we couldn't find any problems. It was also weird that IE didn't have the little error indicator in the bottom corner. The only thing that made me uncomfortable was the number of link and script tags in the document head. So with no real error apparent, we started a wide search in Google. I quickly found, buried in a forum, that (as you may have known or guessed) IE only loads the first 31 CSS files and ignores the rest. So my friend turned on Drupal's CSS optimization option (which condenses the CSS files into a single file) and it instantly worked (the site had numerous modules installed -- and each brought its own CSS).

This is something worth remembering (hence this little post) because of the ambiguous nature of the problem. It may be something widely-known, but I've never come across it myself. ... since, you know, my sites don't have that many HTTP requests </backdoorBrag>

Drupal has a nice solution to this issue of too many HTTP requests (at least for the CSS files). My platform of choice is ASP.NET MVC, and Mark Berryman has created the Sprite and Image Optimization library (also available in NuGet). I haven't had the chance to use it yet, but I definitely plan to.

Introduction to Pluralizer for .NET

Let's say you want to output a sentence that varies slightly, depending on the number of users that are in your system. For example, you want it to say one of these variations (a common predicament in my experience):

  • There is 1 registered person.
  • There are 398 registered people.

To achieve this, you typically have to write something ugly like this (I'm using the Razor view engine for brevity… aspx would be even worse):

There @(numUsers == 1 ? "is" : "are") @numUsers registered @(numUsers == 1 ? "person" : "people").

Ugh… So tedious. With Pluralizer, you can get the same result with this line of code:

@Pluralizer.Pluralize("There {is} {_} registered {person}.", numUsers)

What Is Pluralizer?

Definition in English: Pluralizer is a small library to make simple string formatting easier. It allows you to use one string to express two variations of a sentence that are dependent on a numeric value.

Definition in Code:

var str = "There {is} {_} {person}.";
var single = Pluralizer.Instance.Pluralize(str, 1);
Assert.AreEqual("There is 1 person.", single);

var several = Pluralizer.Instance.Pluralize(str, 47);
Assert.AreEqual("There are 47 people.", several);


First, here is the most basic signature (note that there are a couple of overloads, but more on those next time):

public string Pluralize(string sentence, double number);

You provide the sentence (or, more accurately, the sentence template), and the number that will be used.

For the sentence (in over-simplified terms), follow these basic guidelines:

  • start by writing the sentence in its singular form.
  • wrap any words that you want "pluralized" in curly braces
  • nouns are handled automatically by the built-in PluralizationService class in Entity Framework for .NET 4
  • only the most simple verbs and pronouns are automatically handled. You'll probably have to handle those by yourself, separated by the pipe character.
  • the number itself is displayed using the special underscore placeholder (i.e. write this to get the number itself printed: {_})
  • manually define the singular and plural words by separating them with a pipe character (e.g. {singular|plural}).

Simple Examples

The following are using a simple, static (i.e. singleton) implementation. It is possible to instantiate a pluralizer and teach it, but we'll get into that next time. Also, for these examples to work, you'll have to include "using Pluralize;" at the top of your file.

var str = "There {is} {_} {person}.";

var single = Pluralizer.Instance.Pluralize(str, 1);
Assert.AreEqual("There is 1 person.", single);

var plural = Pluralizer.Instance.Pluralize(str, 67);
Assert.AreEqual("There are 67 people.", plural);

A couple of very common verbs and pronouns are handled automatically; also, we won't display the actual number this time:

var str = "{She} {is} going to the store.";

var single = Pluralizer.Instance.Pluralize(str, 1);
Assert.AreEqual("She is going to the store.", single);

var plural = Pluralizer.Instance.Pluralize(str, 5);
Assert.AreEqual("They are going to the store.", plural);

Define the singular and plural values manually by separating them with a pipe character, like this: {singular|plural}.

var str = "There {he} {goes|go}.";

var single = Pluralizer.Instance.Pluralize(str, 1);
Assert.AreEqual("There he goes.", single);

var plural = Pluralizer.Instance.Pluralize(str, 42);
Assert.AreEqual("There they go.", plural);

// A tiny step further...
str = "{She} {is} going to {her|their respective} {home}.";
var customPlural = Pluralizer.Instance.Pluralize(str, 5);
Assert.AreEqual("They are going to their respective homes.", customPlural);

That's a basic introduction. This alone should save you time and frustration when making friendly messages in your UI. For the next post, we'll into into some more things that you can do like define multiple numeric variables, format numbers, etc.

How to Get it


The easiest way to get your hands on .net assemblies. The package is called "Pluralizer" and it's up at the NuGet official package source.

PM> get-package Pluralizer -remote |fl
PM> install-package Pluralizer

Manual Download

If for some reason you enjoy pain, you can ignore NuGet and manually download and add the assembly to your project yourself.

What's Up with the Project?

First, this is in very early stages (i.e. version 0.1). It will be open source; I'll post the source on GitHub as soon as I get a chance.

Basically, it's a single public class (Pluralizer) with a few overloads of the Pluralize() method (and of course, some tests to get started with).

I was reading a post on Scott Hanselman's blog and it inspired me to take things a step further... Pluralizer was born.

Manage OpenID Access to Your Google Account

I am a huge fan of federated authentication technologies such as OpenID and OAuth. I've finally started diving into the DotNetOpenAuth library (more on this in the future, I'm sure). So I downloaded the MVC Relying Party sample project, F5'd it, authenticated using my Google account, and all was peachy. By the way, anyone with any Google account can use the following as an OpenID URL:

Your Google OpenID:

I ran into a little hiccup when I ran it a second time. I entered the URL above, and, since I had already authorized "localhost" access to my Google account, I was immediately logged in. All without getting the chance to say "Yes, Google, allow this site to authenticate me through my Google account." Of course, this is how OpenID is supposed to work (one of the things that makes it so wicked awesome), but as a developer I need to be able to go through all the steps sometimes.

I needed a way to revoke access to "localhost", and where/how to do this was not apparent. Google has a magic URL that allows you to manage which sites are allowed to authenticate you using your Google account. That URL is this:

Manage Authenticated Sites:

Google Apps Users

Currently, Google is in the process of opening up Apps accounts to have all of the benefits of "regular" (i.e. Gmail) Google accounts (things like Reader, etc.). If you have opted into this when managing your domain, the link above should work for you.

For regular Apps users, here is your URL to manage the authenticated sites (of course, substitute "" with your actual domain):

Manage Authenticated Sites for Google Apps:

This little post should help to remind me of this URL in the future, and hopefully helps some of you!

Recover From the iPhone Recovery Mode

I finally agreed to apply the iOS 4.0.2 update that iTunes was nagging me about. I'm a very security-conscious person, but I wasn't in a hurry to patch the PDF vulnerability because it was easily avoided (indeed, I avoid using the browser at all these days because it's abhorrently slow), and there are many reports of this update not going so smoothly. When I finally agreed to do it, iTunes backed up my phone and started the upgrade. Suddenly I saw a dialog box stating that it had failed. Crap. I tried disconnecting and reconnecting and it still didn't work. iTunes sent me to this page which was completely useless. Everything was locked down on the phone. No fancy button combination could rescue me. I was starting to get scared that it had been bricked.

Recovery mode screen

It was clear to me that my goal was to revert back to a previous version of iOS; but I couldn't get rid of the recovery mode screen. I tried removing the downloaded file and forcing iTunes to download a new one. That didn't work. So I thought I'd try and recover using a backup that iTunes takes every time I sync. Apparently recovering using a backup requires that the iPhone not be in Recovery Mode. Wow.

Then I thought: I'm stuck in this because of Apple's walled garden. Their bug has caused this. They don't play nice with anything open. Obviously their programmers have trouble with exceptional cases (heck, iTunes doesn't even seem to use a background process!!), so the answer is to remove them from the equation. Look elsewhere!

So I did. And it was solved.

The Recovery

I came across this post that referenced RecBoot, a utility that forcefully takes the phone out of recovery mode. I downloaded it (scanned the download), and ran it with my phone still displaying that Recovery Mode screen. My phone instantly started rebooting. Presto!

Eventually it finished booting and I could enter my password, as if the last hours of fighting with iTunes had never happened! Thank you RecBoot!! I was back in business, nothing changed, settings intact, apps installed, etc. Take Apple out of the solution, and it's solved in minutes!

Don't We Jump Through These Hoops With Other Devices?

Absolutely. From time to time this happens with any high-tech device.

My issue here is this: my phone was actually fine, it was just stuck in Recovery Mode (I think this qualifies as ironic). It was Apple's need for total control, their forcing me to use iTunes (worst. software. ever.), that couldn't seem to flick off the Recovery Mode switch that itself flicked on.

I can forgive other operating systems because they are faced with supporting literally millions of different configurations of hardware and software. iPhone OS has only had to support new 1 configuration per year. If Apple insists on employing a closed, vertically-controlled M.O., I expect my experience be next to perfect if I comply. I got my phone for Christmas 2008. I started having serious issues with it when it was 18 months old. It's damn-near unusable now (maybe I'll really rant later). It can't even recover from it's recovery mode. Seriously, Apple?

I very strongly doubt that, at 18 months old, my user experience would be this bad on another device. And, even if it were, I could forgive to a degree because no other company enforces this much control over its customers. If Apple is going to force me to use iTunes with their products, then it should work. If I had stuck to Apple's products, who knows how long it would've taken to simply disable Recovery Mode (if ever)?

Silhouette of woman whose hands are tied up behind back by iPod earbuds cord.

I know I'm not forced to use this product. I chose to when it was the only real smart phone out there. Now it's not, but unfortunately I'm stuck with a terrible contract length (3 yrs) with a worse carrier (Rogers) and the worst selection of smartphones. I'm drooling at the new Android phones that have been coming out and putting even the iPhone4 to shame. I'm sure the iPhone 4 is a nice phone, but it already seems outdated. Will it be usable in 18 months, long before my new contract is up? Will it live through all of the inevitable patches? Do I have strength to endure three more years of iTunes?

Not likely. The day I pitch this iPhone can not come soon enough.

Hello Android.