Learning by Stimulation Avoidance: A Principle to Control Spiking Neural Networks Dynamics