If it's happening with stock (though if you didn't do a 'clean' install of stock, try one first), new battery, and if it's still happening, replace USB board/port. Quick/easy/cheap (US$10-$15 or so) to do yourself; KeithRoss39 has a guide in the General section which has all the info you need to get it done (it's not stickied, search for 'replace USB charger board' or similar).
If it's important enough to cause you grief if it's lost, back it up. No excuses
Trolling for thanks is lame
Does Samsung's auto-brightness implementation crap drive you to self-harm ? A solution !
Failure to search is the leading cause of male impotence on XDA
If you don't know how to recover if things go wrong, what are you doing flashing custom roms ?