Nonlinear optics on the nanoscale: solid state and quantum applications