A New York City judge has ruled that the shutdown of illegal cannabis shops by the state and city is unconstitutional.