generally, sleep before class. There are some occasions wewe just can't stay awake but there is really nothing wewe can do no matter how hard wewe try...
Try having some coffee before the boring class commences. wewe will not only drive away the sleep but also remain alert and ask maswali and actively participate in the classroom to ensure that wewe are on juu of your attention. If it's not possible to have coffee before the class, then, take a quick break to the washroom and splash some water on your face and have a chewing gum and return to the class. Sit up straight, feet planted flat on the floor. Don't lean back au slouch in the seat,don't rest your chin on your hands, etc. If you're in a posture that discourages sleeping, it will be easier to stay awake. Try and focus on the lecture. Take notes. Maybe skim a little ahead in your textbook so wewe have an idea of what the lecture will be on. Listen for key words au ideas wewe saw in the reading..