I occasionally worry that when I borrow snippets of code from websites, etc. there's at least the theoretical possibility that this will be copyright infringement. However, small pieces of code to accomplish common tasks may be too unoriginal for copyright and in practice this kind of sharing happens all the time. What are some rules of thumb, ideally supported by legal precedent, as to how substantial and original a piece of code must be to be copyrightable?
P.S. I know there are no hard and fast rules on this and that a definitive answer to a specific case requires a lawyer. However, since I'm only looking for rules of thumb here, answers to this effect will be downvoted.