There's probably a whole ton of psychology to go along with it, but I've never felt bad about being disgusted with my old work. I find that it's entertaining to look back and find things that I've done inefficiently or straight up wrong in the past. Every once in a while I even find a nice little gem of accidental genius that I had forgotten about. Never usually enough to prevent me from making the same face as our friend above.
How can someone really be okay with such "awful" code?
Because it's absolute proof of advancement. In a lot of cases it's something that could be done way better and in a fraction of the time it took the first time around. Some efficiencies may be due to technological advancements, but likely not all, also who the hell cares? These things don't write themselves and you're only disgusted because you are better now.
Smart people do the same thing
In case you weren't aware of this behavior being quite common, here's a quote from someone that I'd consider to be relatively more intelligent than most of us:
I know quite certainly that I myself have no special talent; curiosity, obsession and dogged endurance, combined with self-criticism have brought me to my ideas.
You probably aren't an imposter
Unless you need to be? You certainly aren't the only one.
Impostor syndrome (also known as impostor phenomenon, impostorism, fraud syndrome or the impostor experience) is a psychological pattern in which an individual doubts their accomplishments and has a persistent internalized fear of being exposed as a "fraud". Despite external evidence of their competence, those experiencing this phenomenon remain convinced that they are frauds, and do not deserve all they have achieved. Individuals with impostorism incorrectly attribute their success to luck, or as a result of deceiving others into thinking they are more intelligent than they perceive themselves to be.
Self-criticism is difficult to balance
It's super helpful to take a step back once in a while and focus on the significantly more noteworthy and positive aspect of this sort of situation. If your new stuff is better than your old stuff, for the sake of all that is good and holy, keep that up and give yourself a pat on the back!