The Art of Pulse Crafting: Applications to Magnetic Resonance and Laser Spectroscopy