Spectral inequalities for discrete and continuous differential operators