Having moxie means having enough cleverness, skill, creativity, fortitude and cajones to solve (or, at least, to get out of) a difficult and personally threatening situation.
Originally a Yiddish word, popularized by Moxie soda and the Kingdom of Loathing. The caffienated soda tried to add 'vigor and energy' to the idea of moxie; and KoL invented the adjective (moxious), and made 'moxie' also imply stylishness, accordion skills, and the ability to mix really good drinks.
(Having moxie doesn't always imply that you're the tricksy chutzpah who caused this situation in the first place, but the terms aren't mutually exclusive either.)
"Sure, you'd like to burn off his hair in his sleep. But do you have the moxie to get away with it?"
Todd: "Fuck no, Jimmy."