First of all I am assuming these integrals are over all of
Well basically the way residues work is you pick a carefully chosen complex valued function and use the residue theorem in this case just replace x with z and let it be complex valued. In these types where you have a polynomial in the bottom typically what you want to do is take a path integral that is a semi circle of radius R with diameter along the real axis. This will envelope the some of the roots of your polynomial on the bottom. Then just use the residue theorem Residue theorem - Wikipedia, the free encyclopedia.
You can evaluate the path integral that way and get one value. Then what you do is evaluate the two paths separately the one on the real axis and then the arc part. If the degree of the denominator is 2 or more greater than the numerator the arc integral will go away and you will get that the integral over is equal to the one you calculated using the residue theorem.
Unfortunately what you may have noticed is that this method will only work in your first integral since in the second one the numerator is only 1 less than the denominator. You may need to use standard calculus techniques to solve something like that. Completing the square with some fancy substitutions? Tough to say in general, but I hope this might be a refresher at least in the idea of residue integrals.