There's four ways for code to not be copyrighted (in the US):
1. The author died more than 70 years ago or it was owned by a corporation and it's been 95 years since publication
2. It was written prior to 1989 and did not include a copyright notice.
3. It was written by the government
4. The author explicitly released it into the public domain
1 and 2 probably don't cover much code on the Internet. So unless it's a government repository and/or explicitly marked with a public domain notice, you can probably assume it's copyrighted.
1. The author died more than 70 years ago or it was owned by a corporation and it's been 95 years since publication
2. It was written prior to 1989 and did not include a copyright notice.
3. It was written by the government
4. The author explicitly released it into the public domain
1 and 2 probably don't cover much code on the Internet. So unless it's a government repository and/or explicitly marked with a public domain notice, you can probably assume it's copyrighted.