If you're publishing a piece of code that you want to distribute as much as possible, maybe having other people helping you with the code, making sure you're not going to be sued as well as making sure that your name or your company's name are not going to be used by others without your approval, then the BSD 3 clause license is just what you're after. You can find it at the bottom of this document.
To apply the BSD license to your code:
-
Create a new LICENSE file at the root of your project, and paste the license there (copy at the bottom of this document).
-
At the beginning of all of your source code file, paste this:
Copyright (c) <year>, <copyright holder>
All rights reserved.