I think one of my favorite techniques is REALLY hamming it up when my players "derail" my plans.
I'm going to build stuff into my adventures I think, sparingly, to be the DMs "screw up". Let the players think like they've really gotten ahead and outsmarted me.
My infamous story is my BBEG, slain before he could attack. The bit I do leave out: he did have a regeneration ability. I saw the way the wind was going and didn't use it.
Likewise, this last week, I had my players surprised by a polar bear in the snow. I was gonna have them run from it, find clever ways to fight it. They had speak with animals. I made a big overly hammy deal that my plans were foiled.
The bear wanted soup.. made from a nasty yak that was insulting him.
The players got to "outsmart" me, show off their character abilities, and it made the encounter more memorable.