+4  A: 

Go out for a walk (wait... I think I answered that before)

Otávio Décio
You did. Well - can't remember if it was definitely you, but a very similar question has come up, and *someone* gave this answer.
Peter Boughton
+2  A: 

I either change up to some "fun code" or go for a hike with my camera (assuming I'm not at work)

Matthew Whited
A: 

Answer questions on stackoverflow, of course!

McWafflestix
@McWafflestix: Ha - great minds think alike!
RichieHindle
+2  A: 

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.

RichieHindle
A: 

Read up on stackoverflow :).

Morph
+1  A: 

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.

Autocracy
Ah! A metal slinky! That sounds more like how I am with my Original Rubiks Cube - often I'm not looking at the colours, just aimlessly twisting it.
Tom Wright
+1  A: 

well i love to do some research and development work when i feel to take a break

Searock
+1  A: 

I write unit tests

John Weldon
A: 

read up stackoverflow, watch friends / 2 & a half men, practice some "putting" in the office, chit chat with friends over phone or in person.

Vikram
A: 

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.

smok1
+1  A: 

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.

SergioL
+1  A: 

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.

Macha
A: 

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.

Jas Panesar
A: 

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!

Jrgns
+2  A: 

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.

Nico