I'm working through some equations in a statistics textbook, but am confused over some steps...

Let be Residual Sum of Squares (doesn't really matter)

be an matrix

We have (for linear regression)

Question:

How would you get to the following?

I'm especially confused over ... also, are there 'rules of differentiation' with vectors that could be easily remembered?