Transportation Alternatives has published a comprehensive set of guidelines for street cyclists. Applicable not just to New York City, but everywhere.
Having been flipped off by an angry dumpster truck driver yesterday(ironically, while standing well off to the side of the road), all I can say is: follow these guidelines and do your part to stop the hate.