Nonvanishing of quadratic twists of modular L-functions and applications to elliptic curves