If I'm trying to stay up, I'll usually just load myself up with caffeinated drinks and play some games or something. Regular snacking keeps me going as well.
The longest I've ever been awake is around three days straight, or 72 hours approximately (I'm not sure of the exact time, since I wasn't exactly keeping score), during a rather irritating episode of insomnia. That was not fun. The longest I've slept is probably around 18 hours, which incidentally followed immediately after those 72 hours.