An absolutely vital question:
How much am I accomplishing by staying up?

Many people become less intelligent, more distractable, and less conscientious as they become more sleep-deprived. If you're up long past your bedtime, your efficiency may be dropping so much that it would be worth going to sleep. Let's say it's 4AM, and you're so zonked that your productivity is only half-normal. Instead of pushing on, rejuvenate yourself with a two-hour nap. By 8AM, you'll have amortized out the cost of the nap and be getting ahead!
(you may want to nap at your seat, if you think you won't be able to get back out of bed)

Be aware of how stupid you're getting

I refuse to submit something I've completed after 3AM without having another person look at it. It may look fine to me, but something is going to be wrong. One of the lousy things about being mentally impaired is that you lose the ability to tell how impaired you are (as a great many drunk drivers can attest). If you're up eight hours late, you are not doing your best work. You may be on a wild stream of consciousness creative streak, but your coherence, fact-checking, and spelling and grammar are all suffering.

The solution presents itself easily. As night turns to day, your friends are fresh out of bed and ready to catch your gross errors. The internet is an especial blessing here. It's also very important to schedule some time at the end for proofreading. Very important.

Choose your drugs wisely

Stimulants will help a great deal, but you don't want to become too jittery -- and you don't want to crash. Many people find green tea to be more gentle than coffee. Ritalin, if you can get it, is one of the best speeds to use. It helps concentration, stays in your blood for a long time, and at the end it puts you down slowly. If you can't, try ephedrine, which is also less jittery than caffeine. Ephedrine can be obtained in sleazy convenience-store mini-thins, or in pill form at many truck stops. Finally, B-vitamins are helpful in this respect, and combine well with any of the above.

Light

Light is vital to your body's sleep-wake cycle. Work in the most brightly-lit room you can. If it's past dawn, take a walk outside.
Also, a brief addendum to beaneater's nice writeup: dextrose is another name for glucose, which is the body's standard simple sugar. There's nothing fancy or trademarked about it. I believe dextrose tablets are sold because of their extremely quick effect on blood sugar -- diabetics can use them if their insulin level gets too high.