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)$.
Best Answer
In complex analysis, you might want to think of contour integrals as anti-derivatives. This helps to explain why the path can be moved (as long as it does not pass over a singularity) without altering the integral; it is just the difference of the anti-derivative at the endpoints.
Another way to express this is using Green's Theorem applied to a complex differentiable function: $$ \oint_{\partial\Omega} f(z)\,\mathrm{d}z =\iint_\Omega(if_x-f_y)\,\mathrm{d}x\,\mathrm{d}y\tag{1} $$ The Cauchy-Riemann Equations are simply $$ if_x=f_y\tag{2} $$ Applying $(2)$ to $(1)$ yields Cauchy's Integral Theorem: $$ \oint_{\partial\Omega} f(z)\,\mathrm{d}z=0\tag{3} $$ when $f$ is holomorphic (i.e. satisfies the Cauchy-Riemann Equations) in $\Omega$.
$\hspace{2.5cm}$
Thus, the difference of the integral along the green path and the integral along the red path is the integral along the blue path. According to $(3)$, that is $0$.
There are points at which otherwise holomorphic functions go bad. These are singularities. The residue is $\frac1{2\pi i}$ times the integral counter-clockwise around such a point.
$\hspace{2.5cm}$
Note that the difference between the integrals along the green and red paths is the integral along the blue path, taking the integral in along the bottom of the blue line and out along the top (the integrals along the lines cancel, being in opposite directions). The blue contour is the boundary of the "C"-shaped area which avoids the singularity, so the integral along the blue contour is $0$. Therefore, the integral along the green path equals the integral along the red path. Thus, it does not matter which contour around the singularity we take, the residue will be the same.