What needs to be done is fairly obvious, since it was already done successfully by Giuliani in NYC - strict enforcement of laws plus draconian penalties for violating those laws, applied over a sustained period of time.
Like it or not (and I'm certainly not suggesting everything about it was likeable), it worked wonders for Manhattan.
But what's far more appalling is that straight people in SF put up with it as part of the cost of doing business.
"When work crews pulled open a broken BART escalator ... they found so much human excrement in its works they had to call a hazardous-materials team."
http://www.sfgate.com/bayarea/article/Human-waste-shuts-down...
I don't mind sellers of various good (incl. drugs) so long as they are peaceable and not... in your face.