Go to class with some caffeine in your system
Sit with a friend so you have someone to poke you if you start to fall asleep.
If you aren't directly in sight of your professor take out sudoku or a crossword puzzle.
If all else fails, just text people on your phone or bring a laptop and talk on AIM. You will be surprised how much you learn just by osmosis.