Depends where you get it from, and what licence it uses.
If you get code from an answer to a question, or from a forum, then it's covered by
CPOL: Code Project Open License[
^], but articles and tips can have different licences which is shown in the document itself.
Generally though, it's ok - provided you follow the licence provisions.