When to use a or an in a sentence?

Are you freaking kidding me? You use "a" in front of a consonant and "an" is used in front of a vowel.