To keep it simple, you use an when the first letter of the next word sounds like a vowel when pronounced (vowel sound) and appplies to ancronyms too. Otherwise you use a.
Yes, I'm well aware. I'm responding to the code in the OP's article (you need to click through the link at the bottom of the HN submission--I have no idea why the OP blog has two separate pages for this).
The MRI example is perfect, but I feel like the yogurt one is a bad example given the "and sometimes Y" (is a vowel) thing, or do we just ignore that for a vs an?
Like in this context, do we always treat Y when pronounced like "Yes" or "Yogurt" as a consonant?