Several years ago I picked up a way to trick my ego into getting out of the way. I offer it here in the hope that it'll resonate, or at least get others thinking.
My trick is to imagine that I had a fever when I wrote the code I'm now looking at, and that someone else had looked at it and pointed out that there were problems, but hadn't explain what they were.This has a couple of effects. First, it gets my brain out of "there's no problem here" mode and into search-and-destroy mode. I really, really don't like having others find bugs in my code. (It's that damn perfectionist upbringing.) And to have somebody spot a bug and then not tell me... that gets me fired up even more.
By imagining that I'd had a fever, I sidestep overconfidence, and open my mind to the possibility that I was actually fallible at the time my hands were busily typing. I also pre-excuse myself for any problems that I find. (When I run a fever, my mind can play some mean tricks. I've learned to triple-check anything I try to do while sick.)
Thus tricked, my ego stays out of the way long enough for me to find lurking problems. When I remember to use this technique, my code comes out a lot cleaner.
That's what works for me. What works for you? How do you get your ego our your way?