I've spent several decades writing software. Got laid off 1-2 times per decade.

I still tried doing a good job every day, and feel very good about that.

To me, being realistic about the risk of losing my job at any time means having enough money that I can be unemployed for 6-12 months.

The major way good programmers get jobs is by being recommended by people they've worked with at previous companies. That doesn't happen if you deliberately do as little good work as you can get away with.

My "shitty attitude" comment is maybe more a personal philosophy that something universal. But I do not want to spend each work day being bitter and resentful. You may intend to punish your shitty employer, but I think you're mostly poisoning your own mind.