2. Try self-derision. "Oh man, I must have had too much to drink that night!!!!" or "yeah I got pretty lazy there...". Always very appreciated. Especially if the comment from the co-worker is intentionally snarky.
3. Try and be pre-emptive about it. If someone says: "hey wtf is going on in prod?", you should answer: "shit, it's probably me, I'm looking into it", or if you think it's not you, you can do something like: "I fiddled with this code yesterday, but I am fairly confident that it's unrelated, let me know if I screwed up".
4. Own up your colleagues' mistakes too: "Sorry guys we screwed up on that one". Clients love people who tell them they're sorry rather than people who come up with shitty excuses.
5. If it's far in the past, insult your past self at will. "Well when I wrote this, I was pretty lame I didn't know better".
6. Always remember that what's in the past can't be changed. Only the present and the future matter.
7. Be kind to other co-workers who own up their mistakes.
8. Thank people who fix your bugs.
There are a lot of hidden benefits hidden in distanciating yourself emotionally from the code you wrote:
- You won't want to continue working on "your baby" when your boss offers you a promotion
- It makes the team work a lot more human. We aren't geniuses, and even geniuses screw up. It's all fine.
- If you own up your small mistakes, no one is going to throw you under the bus if you make a much bigger mistake.
Good luck.