How to choose a proper contour for a contour integral?
In response to the comment, I will do my best to attempt to explain how I choose contours for integration.
I first look at the bounds of integration. If it is over $[0, \infty)$ and even, make it over $(-\infty,\infty)$.
Next, I look at how the function behaves around infinity in the top half of the plane. If it decreases fast enough (e.g. $\frac{\exp(ix)}{x^2+1}$), we can integrate with a semicircle contour. If not, find a value $a$ such that when you integrate a rectangle with vertices at $-R, R, R+ia, -R+ia$ (as $R\to\infty$), the vertical sides disappear and the horizontal integrals are equal when multiplied by a constant.
If the function cannot be made even, there is still some hope left to contour integrate. If the function has a branch cut (e.g. $\frac{\sqrt x}{x^2+1}$), try a keyhole contour if the function decays fast enough around $\infty$. Otherwise, try a rectangle.
If the integrand can be simplified as $f(x+ia) = g(x)$, where the integral of $g$ is known or is in the form $A f(x)$, it may be able to be exploited using a rectangular contour. For example, a rectangular contour of infinite width and height $a$ along the real line along with the knowledge that $\int_{-\infty}^\infty e^{-x^2}\, dx =\sqrt{\pi}$ can easily demonstrate that $\int_{-\infty}^\infty e^{-(x+a)^2}\, dx =\sqrt{\pi}$.
Wedge contours can be used in situations like the rectangular contours can, but instead of having $f(x+ia)$ being well-behaved, we have $f(e^{i\theta}x)$ being well behaved. For example, taking again $f(x) = e^{-x^2}$, we see that $f(xe^{i\pi/4}) = e^{-ix^2}$. Thus, taking a wedge contour with $\theta=\pi/4$ we can deduce from the integral $\int_{0}^\infty e^{-x^2}\, dx =\sqrt{\pi}/2$ that $\int_{0}^\infty \sin(x^2)\, dx =\int_{0}^\infty \cos(x^2)\, dx =\sqrt{\pi/2}/2$.
Other contours exist and can be used (e.g. the trapezoid contour for integrating the gaussian integral), though I've found the above contours work for most standard integrals.
If the contour travels through a pole, indent it with a semicircle - with a simple pole, $z_0$, the contributed value from that integral equals $i\theta\operatorname*{Res}f_{z=z_0}$ where $\theta$ equals the angle traversed around the pole.
It is often convenient to change $\sin$ or $\cos$ in the numerator to $e^{ix}$ (which is better behaived for integration around the top half of the plane) and take the real or imaginary part after integration - this can even be done if the other part diverges.
When dealing with exponents, use trigonometric identities to reduce the function into an exponential that decays. For example, it is easier to deal with $\Re \left[\frac{1-e^{2ix}}{2}\right] = \sin^2(x)$ instead of just $\sin^2(x)$.