Copy protection (anti-debugger and best practices)

This topic comes up every now and then on the forum. There’s some similar information in this thread: