Stable standing waves of nonlinear Schrödinger equations with potentials and general nonlinearities