How to install packages behind a proxy?

A small guide on how to install packages while sitting behind a proxy server. I've explained the installation through the UI based Synaptics Pacakge manager instead of the normal apt-get commands.