In the book, The Power of Habit: Why We Do What We Do in Life and Business, Charles Duhigg describes a process that seems to hit at the core of rooting out bad habits.
He breaks habits down to three aspects; a cue, a routine response to that cue, and the reward. Many techniques focus on changing the response, which is the ultimate goal, yet by focusing on the cue the ability to change that habit becomes much more accessible.
This is called the habit loop model.
For example, if the habit is going straight to the computer to check facebook or email when one gets home at the end of the day, the answer would be to identify the cue, then make a new routine based on that cue and reward oneself by making that new routine in a healthy manner. The feeling that one gets once the behavior starts to change will eventually be the reward itself, but in the beginning it can be assisted with an additional reward that is healthy, of course. In this case, the cue is walking in the door. Pre plan what to do once you walk in the door, like spend 10 minutes sitting in silence, or immediately soak your feet in hot water, or if you are living with someone else, immediately ask them how their day went. Be systematic and do the same thing each time you walk in the door. This disengages the previous habitual pattern of going strait to the email or facebook. In this case the reward is the benefit of the meditation, or the hot foot soak or the pleasure of engaging with someone else.
The key is the cue. Know when it comes and practice the new response to it until it become automatic.