Cover your ass. People appreciate when you do this and there's no dishonor in it if it's done transparently. When somebody hands you stuff at the last second that needs to be done by the end of the week and you've already got 5 other things to handle, it's time to email all of your ridiculous bosses to explain the load your under and that you can not in fact focus on all of this stuff with the same level of priority and meet anybody's expectations much less everybody's. Leave it to them to sort out what you really need to get done first.
Let go of the disagreements and don't forget that you're a technology/problem-solving person. You have internet don't you? There are plenty of ways to communicate with and train people who are on the other side of the planet, much less one floor up. Rapport is built just as easily on Skype or slack.
Prefer solving the problem to dwelling on injustice. It's something most full-blown programmers who've been at it for a while figure out. When you're often smarter than the people you work for, you can't afford to get indignant about it. They're where they are because they're less interested in solving puzzles than you are and you're often where you're at because you'd actually be horrible at getting anything done worrying about the inane crap the not-particularly-skilled office worker/manager typically needs to be good at handling. You get to do thatwhat you do. Just embrace the idea that the scope of the problem-solving projects that interest you now can actually be wider than just the stuff you wanted to be left alone to solve.
IMO, you really don't need somebody to tell you that you screwed up. I suspect on some level you knew but wanted to have the scales balanced by hearing that your work situation isn't great. It doesn't sound like it is. But all you really proved by walking out whenbecause you didn't think anybody would say yes when you asked permission, is that you don't really love or care about this job. That's okay, but it's easier to find the one you might eventually with decent recommendations. So try to remember that even if you're frustrated with your circumstances that there are in fact people who need you for what you know and not all of them necessarily, are total assholes, and you never know which of those might end up somewhere you'd like to be.
Learn to value and be helpful to the people who make it possible to do the things you enjoy doing to the extent that you can and treat the parasite-types like problems to be worked around. They never go away. You have to learn to sidestep.