3

I've been starting to put my code on Github. I added the GNU Public License to most repos. Am I allowed to add spinets of code from the internet that doesn't have a license? For example if I used this reference to implement depth first search and copied some of the code?

Another example is I found a good pretty_print function on a website with no license. While I can change the names of things, the idea remains the same. Can I include the pretty_print function in my own code with the GNU Public License?

Should I at least try to change the code in someway so it's not an exact copy? Should I add the URL where I got it from? What if it's just some random wordpress website?

  • 1
    Possible duplicate of Is it OK to remove the license terms for a code snippet? – congusbongus Jun 7 '16 at 6:27
  • You can learn from the concepts in the code and write it yourself. But you can't use it if it's not licensed to you appropriately. – Tim Malone Jun 7 '16 at 20:03
  • @TimMalone could you please elaborate on the difference between learning from the code and writing it yourself vs. copying the code and changing it? Sometimes there's only a limited number of ways to doing a simple task. – inertiablobby Jun 9 '16 at 6:03
  • If it is impossible to rewrite because it's so simple, then it might not be copyrightable. But not neccessarily. It might be worth asking that as a new question actually! (check if it's been asked already first) – Tim Malone Jun 9 '16 at 6:11
  • @congusbongus I think that is a different question – Tim Malone Jun 9 '16 at 7:20
1

Am I allowed to add snippet of code from the internet that doesn't have a license?

No license means no license meaning you are not licensed to use it beyond looking at it in most cases.

For example if I used this reference to implement depth first search and copied some of the code?

The site you are linking to links to this Copyright page:

The content may not be redistributed or reproduced in any form without 
the written permission from Sanfoundry. However, if you are linking the
content from our website, you can use a short description (no more than
25-30 words) from our website with the content in quotes plus you must
provide a link to our original article or post.

You cannot use the content (either whole or partial) for any commercial
purpose.

So it has a clear license that does not allow you to do much and would be conflicting with the terms of the GPL. Contact the author for a proper license compatible with the GPL.

Another example is I found a good pretty_print function on a website with no license. While I can change the names of things, the idea remains the same. Can I include the pretty_print function in my own code with the GNU Public License?

Same answer as above: you are not licensed by default and the lack of an explicit license means you have no rights. By default all rights are mostly reserved. Masquerading the code by doing some renaming would be even worse. Do not do that!

  • Oops I missed that as I was looking for terms of use instead of copyright. – inertiablobby Jun 9 '16 at 5:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.