Measurements of the longitudinal diffusion coefficient and the drift velocity for electron swarms in hydrogen and nitrogen using a time-of-flight technique