What should we do when getting stuck/ panic in programming?

i believe every programmers here must have time when feeling panic, or getting stuck in programming...just wondering what you doing when having this situation.... feel free to drop your experience or comment here...

At work, continue working on something else. At home, go to sleep.
The next time you get back to the code (or when you wake up), the solution to the problem will often be obvious (be it an unresolved bug or a matter of design).

This topic should really be in the lounge, not the beginners forum (not intended to sound mean or condecending; just for future reference)

When I have a problem with some code, I'll try debugging for a few minutes. When I can't think of anything else to do, and if the problem still exists, I do something else for a while, like listening to music (I find that helps me the most) or taking a short walk.

If I am stuck because I don't know how to proceed, I grab a teammate or two, walk up to whiteboard or into a small conference room, and discuss the problem I am facing. Software development (in the jobs I've had) is a group effort.
If I am stuck because I don't feel like working, I grab a coffee.

I just let my cat walk all over my keyboard and force myself to figure out what was meant to be there and what wasn't. Usually I end up finding the bug. :)

No, seriously. If I find myself seriously stuck (which thankfully doesn't happen to often), I take a break from the project for up to a week, then come back to it and try the problem from a completely different angle.