Nanophotonics with metals and dielectrics : exploiting resonances for applications in energy, optics, and communications