I use a tool to block certain applications (like Facebook and Twitter). Furthermore I set goals for myself and hold myself accountable (created a [weekend project][1] for that).

Monthly meetings with my supervisor help as well.


  [1]: http://www.bohrresearch.com