There is an actual appropriate tool for that:
http://www.parktool.com/product/dera...nt-gauge-dag-2 .
When I have had this problem, I've used the tool at the local bicycle cooperative. If you don't have this option consider buying the tool or having a shop do it: the accurate alignment of the hanger is fairly important for accurate shifting.
If you really have to effect a ghetto repair don't yank on the derailleur itself.
http://www.utahmountainbiking.com/fix/rhanger.htm is a search result I found. I've also heard of straightening with a hex key in the rear derailleur attachment bolt for emergency roadside repair.