The NYPD has issued a set of social media rules after a number of officers were found posting "racist and offensive comments" to Facebook.