Sign your code.
Doing this attaches your reputation to your code. Anybody reading it knows to expect a certain level of quality given it is written by you, and you get the much needed motivation to write good code.
Amazing piece of advice I picked from the Pragmatic Programmer.