I don't understand the following derivation:

$$ e\_i = y\_i - ax\_i - b$$

$$ e\_i = (y\_i - \bar{y}) - a(x\_i - \bar{x}) - (b - \bar{y} + a \bar{x}) $$

I don't really understand what they do and why they do it. 

To clarify:

$e\_i = y\_i - \hat{y}\_i$, where $ \hat{y}\_i$ is the regression function I believe it's called.