Go out for a walk (wait... I think I answered that before)
I either change up to some "fun code" or go for a hike with my camera (assuming I'm not at work)
Come and answer questions on Stack Overflow. Gets the brain working on something completely different, then you return with a clear mind to your problem.
I have a slinky. One of the metal ones. It's totally awesome, and provides a great semi-distraction that lets me think while still being a bit spacey.
Legos probably do the same thing: they're not taking all your attention, but they do let your mind wander. Wandering minds come up with all sorts of related thoughts to whatever they were recently working on... e.g., your code, and super cool Lego cities.
well i love to do some research and development work when i feel to take a break
read up stackoverflow, watch friends / 2 & a half men, practice some "putting" in the office, chit chat with friends over phone or in person.
Kill time, go to sleep, set up timer for awfully early hour (say, 4Am or so), wake up, make good coffe and try to rework the problem. It usually works.
I usually try to refactor some of my code, especially some of the last things I've written. I find that an idea or two will crop up when I'm refactoring.
During personal projects I play a video game for a while.
Otherwise, read up on some programming concept I'm unclear on that could be applicable.
When a walk doesn't work, work on a pet project for an hour or so to get the creativity flowing..
Sometimes I'll read, tinker, try out a library or something i've been meaning to look into. The key is to set a timer and end at a good stopping point, to transfer the energy to the real work, and so you can pick up later on.
Apart from my serious projects, I have a number of pet projects - non mission critical projects which usually contain some kind of new technology or some aspect that I want to learn.
It needs to be fun, and interesting, and not take up too much time, otherwise the serious projects won't get their due attention!
I tend to do anything but think about programming. Generally go out for a walk, a run, a refreshing drink, or even for a beer. It seems to me that programmer's block, like writer's block, stems from the brain getting stuck in a sort of tunnel vision constrained by it's own thought process. Just thinking about other things lets mind back out and eventually will attack the problem from other angles subconsciously, and this is the brain being creative :)
I find that often have moments of revelation while randomly chatting, whether it be about programming, women, cars, or anything else with my friends/colleagues (sort of like Dr. House has talking with Wilson). As if the brain was putting what troubled it on the backburner, but not completely out of sight, occasionally tackling it with novel perspectives.