Wear a big heavy rubber band around your wrist. When you catch yourself doing the thing you want to stop doing, pull the rubber band way back and let it snap back to your wrist hard. It'll sting a little bit, do this often enough and you'll soon associate your habit with pain and that should make it easier to break the habit.