I practice meditation too, between periods of coding. I'm just an amateur in meditation, but I find it useful for controlling a big range of bad emotions (impostor syndrome, work overload stress, bad mood caused by toxic colleagues interactions...). As you explained so well, it's all about focusing on the external world and "relativizing" your thoughts. Doing a mindful walk in the park helps similarly: I feel like the important thing is to escape from your train of dark thoughts and let the mind "breathe" with new ideas. That's sometimes a hard thing to achieve, but it can be trained.