Can the following integral be computed using residue theory?
$$\int_0^{2 \pi} \frac{1}{|e^{i \theta}-a|^2} d \theta, \ \ |a|<1. $$
I rewrote the integral in terms of $z=e^{i \theta}$, but I end up with a non-analytic function for which I can not apply the residue theorem.
Your integral becomes $\oint_{|z|=1}\frac{dz}{iz(z-a)(z^\ast-a^\ast)}$, which we can render analytic using $|z|=1\implies z^\ast=1/z$, so the integral is $-i\oint_{|z|=1}\frac{dz}{(z-a)(1-a^\ast z)}$. As the integration contour encloses only one pole, namely $a$ rather than $1/a^\ast$, the residue theorem now says the integral is $2\pi\lim_{z\to a}\frac{1}{1-a^\ast z}=\frac{2\pi}{1-|a|^2}$. The case $a=0$ provides a sanity check, as does the $|a|=1$ divergence.