  We consider nonlinear Schr\"odinger equations on flat tori satisfying a
simple and explicit Diophantine non-degeneracy condition. Provided that the
nonlinearity contains a cubic term, we prove the almost global existence and
stability of most of the small solutions in high regularity Sobolev spaces. To
this end, we develop a normal form approach designed to handle general resonant
Hamiltonian partial differential equations for which it is possible to modulate
the frequencies by using the initial data.
