1. As soon as your offended, say something. It does not have to be angry, or make a scene (unless you need help, then make a big ole scene). Try saying something like "Whoa, that was aggressive and creepy." But say it as if you meant it. The point here is to be direct and honest.
2. Another method that is simple and honest is to say, "I don't like that, don't do that again." Being so direct will usually end the behavior. If it is consistent or your not being taken seriously, make sure your body language is matching your words, i.e. don't say it like your joking, be serious. If that doesn't work then...
3. Make a scene. Be loud and say for others to hear exactly what's going on. Example: Your LGBT and everyone knows, but this one guy keeps brushing your tush with his hand when he walks by. At first you thought it was a mistake and let it go as harmless, but he did it again and this time he smiled. So, put him on blast, tell him for everyone to hear just how you feel.
4. If you witness someone being harassed, say something. Don't wait, dont hesitate. i.e. "Hey, that's really aggressive, are you comfortable with this?" We are using words like aggressive, inappropriate, distasteful, classless, unwanted, harassing. Making the person see that they are crossing boundaries is crucial.
These tips will usually result in a quick apology, which is what you want. You aren't trying on make enemies here, just nipping something in the bud before it turns into something that is uncomfortable later on.
So these tips are for situations that are somewhat common and are the lead ups for bigger problems. We are trying to AVOID being victimized, not wait for it.
There are situations that warrant more aggressive action like immediate reporting, calling for help, even fighting. But you really want to set the precedent that you are intolerable of this stuff, by being vocal and direct every time it will send messages to everyone around you that you are not to be played with.
Know your companies policies on harassment, don't be afraid to use them. Outside of work don't think you have to tolerate this crap either. This stuff is really effective in day to day life.