Essentially, the same as long division of numbers:

Look at the leading term. divides into 3x times. Now multiply the entire divisor, by that and subtract:

Now, will divide into 4 times. Multiply by 4 and subtract:

.

That is, divides into 3x+ 4 times with remainder -6x- 13.

For the second problem, do the same thing but with "ax+ b" rather than "x+ 7". The remainder will involve a and b- set the coefficient of x and the constant term equal to 0 and solve for a and b.