With regard to eating out:
0-10% of bill for poor service (based on severity)
15% average service (empty glass for a couple of minutes, sever checks once
on you after food comes out)
20+% good-excellent service (Glass is never empty, multiple server checks, free stuff)
With regard to drinking at a bar:
$1 per drink standard (bar tenders make a lot of money)
With regard to other services performed:
This can vary widely I usually stick to somewhere between $5-$20. When in doubt ask the person what they usually receive.
Of course if you are asking how you actually calculate gratuity then follow these steps:
Lets say your total is $27.82 and you want to give the server 20% because she got you a free beer.
Take 27.82 and move the decimal place so that would 2.78 (that's 10%) now double it to get 20% and that's $5.56. But you got a free beer so give the girl $6.