Often it happens with us that while working on our Mac we get engaged in other activities. The computer goes to sleep and its a proper pain to enter in the login details again and wait for things to get functional again. One way of handling this is by simply increasing the sleep time of the device so that you do not have to worry about this, but that does put the security of the device under question. An easier way to solve the problem is to have a small programme which you can simply activate with one click and your Mac would not sleep and turn it off when you want normal sleep settings to be followed.
This is exactly exactly what Caffeine does. It is a must have utility application for your mac. The app adds a small cup in your Menu bar where if you click on the cup and is full of coffee, it would not put the system to sleep for the period you specify. One more click on the coffee cup and you can disable this. The app hardly takes up any memory on the system and is incredibly light.
Here is the description of the app from the Mac App Store:
Caffeine is a tiny program that puts an icon in the right side of your menu bar. Click it to prevent your Mac from automatically going to sleep, dimming the screen or starting screen savers. Click it again to go back. Right-click (or ⌘-click) the icon to show the menu.
Important: Caffeine lives in the MENU BAR, and this is where its state is indicated. App Store puts the Caffeine icon in the dock, but you can just remove it if you want to.