Solution (source code)

= Solution

With $s^2=\sum(Y_i-X_i\hat\beta)^2/(n-1)$,
$$
\frac{\hat\beta-\beta}{s/\sqrt{S_{xx}}}\sim t_{n-1}.
$$
Thus the interval is
$$
\boxed{\hat\beta\ \pm\ t_{n-1,1-\alpha/2}\frac{s}{\sqrt{S_{xx}}}.}
$$