When resigning from your place of employment, you should always try to leave on good terms. However, this can be difficult if you're in a situation where you're dealing with a bad employer or working in a hostile work environment. Regardless, you should still try to do your best to leave on the best terms possible despite the situation. The industry standard for resignation is to give two weeks' notice, but this is a general rule-of-thumb, and not a requirement. Just give as much notice as you feel comfortable with.
Analyze your current job situation to make sure you really want to resign from your position. Try making a list of the pros and cons to compare them. If there are more pros than cons, or if you find yourself wanting to leave because of one manager's bad behavior, you may want to try to find a solution rather than resign.
Write a journal or list detailing your bad experiences. You'll want to take note of any incidences when you feel you were treated unfairly, or where you feel your manager stepped outside of the boundaries.
Meet with your boss and discuss the items you listed in your journal of bad experiences. If you don't feel comfortable talking with your boss, work your way up the chain of command and talk to his boss. Try and come up with a compromise to remedy the situation. Depending on the severity of the accusations, the bad boss could be eliminated or transferred or you could be transferred to another department. If you can't come up with a reasonable solution, proceed with your resignation.
Write a resignation letter for your employer. It's best to keep the letter short and to the point. Avoid the temptation of telling the employer what you feel is wrong with the company or venting your frustrations. Try to put your best foot forward and salvage whatever you can to get a good reference. Address the letter to your direct supervisor.
State your intention of leaving the job and provide an exact date. It's ideal to give at least two weeks' notice, but if things are so bad you don't wish to give any notice, you can state your resignation is effective immediately.