What you are asking cannot be a free/open-source license because it does not grant users the freedom to pass along copies, or to use the software for any purpose, or to publish modified versions – see the Open Source Definition.
However, what you describe is very close to the default copyright, if you do not issue any license. When you publish the code, it is automatically protected via copyright. People may obviously read the code that you published. But they do not have the right to redistribute your code, or publish their own changes to the code. People may use parts of your code under a copyright exemption of their applicable jurisdiction, for example under the fair-use doctrine in the U.S., or if the used part is too trivial to be protected by copyright.
One risk with this is that many people mistake “published copyrighted work” for “it's on the internet, so that's basically public domain”. But even formal licenses don't solve the problem of people ignoring copyright.
You are not the first to have this problem. It may be worth looking into Microsoft's non-free “shared source” license family. E.g. The MS Reference Source License includes a non-transferable license to reproduce the code and a non-transferable patent grant, but both only for reference use. Note that you can probably achieve your goals without giving similar permissions.