One of the key methods to staying awake through the night is to be active/busy. This keeps your brain
occupied and distracted
from the desire to be sleeping
From my experience, doing assignments often isn't enough to keep you awake (no matter how panicked you are about the impending deadline).
So how do you combat sleepiness? The trick is to break up your routine.
Schedule regular breaks where you go off and do something active for a while - be it lifting weights or playing another level of Quake. The purpose of this is that you are doing an activity which doesn't require too much thinking (ie give your brain a quick 'nap').
I have personally used this technique many a time and reckon it's one of the best ways of staying awake. For example, I had a 3000 word essay to complete by 9am, it was midnight and I hadn't started, and I was dead tired. I set up a routine where for every 300 words that I wrote, I would play another level of Carmageddon. By 8am, I had finished the essay and Carmegeddon. By 9am, I had submitted the essay and was fast alseep in bed.