Mustique, let me remind you again, you deserve so much better. You are in a long distance relationship (LDR), so you cannot spend too much time together. That is awful in itself, but if the both of you were willing to work at the relationship, you could manage that.
His friend comes, but instead of keeping it short, and give the two of you all the time you could grab, his friend stays there to at least 03:00 AM. He starts to put you down, big time. Everything you do is wrong in his eyes. He tells you that. The websites, the things you like, the only thing you like that he has not put down is himself. He even makes it impossible for you to sleep

.
Your boyfriend should love you, should cherish you, and time you spend together. You made all the effort to travel to his place, the only thing he did, was to offer you a place to stay. He should make you feel great, and not as awful as you feel now.
Added:If he has cheated on you, he totally has no excuse to behave in such an apalling way to you.
End of addition
And don't make any excuses for him. If your boyfriend does not stand up for you, that is bad, but if he even insults you, that is outrageous. It's degrading, and you should not put up with that.
So, spend the night there, because you have to, and leave in the morning. Leave a note, if he is not awake, but don't wake him. And seriously consider breaking up with him, as you deserve so much better.
I wish you the best of luck.