I go build some tiny and completely unrelated to get me to enjoy programming again. Usually works.
After awhile you realize the pain of doing messy everywhere, and do it only where it makes sense (Prototypes, quick fixes, first implementations, etc).
But you know what runs worse than messy code? No code at all.
For me learning to "Refactor your code when you see an abstraction" came only when I had to work in an environment where failing to do this caused pain (writing Win16 OLE/COM code in C)
I don't advocate masochistic practices as a means of self improvement per se, but the same habits can be built using intentional practice wherein you choose (for the purpose of the exercise) to take strong constraints on the style of your code.