Detection And Polarization Of Nuclear And Electron Spins Using Nitrogen-Vacancy Centers