licensing
How to dual licencing code on SE
<p>From the footer on all SE sites, user contributions are licensed as CC BY-SA 3.0:</p>

<blockquote>
  <p>site design / logo © 2018 Stack Exchange Inc; user contributions licensed under <a href="https://creativecommons.org/licenses/by-sa/3.0/" rel="nofollow noreferrer">cc by-sa 3.0</a> with <a href="https://stackoverflow.blog/2009/06/25/attribution-required/">attribution required</a>.</p>
</blockquote>

<p>Whilst licensing it as CC BY-SA 3.0 I sometimes want to license my code as MIT, GPL or any other license. This would allow users to take the code from one of my posts under a license which isn't CC BY-SA and have more freedom with the code.</p>

<p>And so my question is how could you dual license code in a code block?</p>

<hr>

<p>I think something like the following would work, but I'm not sure if it's ok:</p>

<blockquote>
  <p><sub>The following codeblock is licensed under <a href="https://creativecommons.org/licenses/by-sa/3.0/" rel="nofollow noreferrer">CC BY-SA 3.0</a> and <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html" rel="nofollow noreferrer">GPLv2</a></sub></p>

<pre><code>print("Hello World")
</code></pre>
</blockquote>

<p>Yes, you can do that, but the effect might not be exactly what you expect.</p>
<p>According to the <a href="https://stackexchange.com/legal">Stack Exchange TOS</a>:</p>
<blockquote>
<p>You agree that all Subscriber Content that You contribute to the Network is perpetually and irrevocably licensed to Stack Exchange under the Creative Commons Attribution Share Alike license.</p>
</blockquote>
<p>This says that you must license under CC-SA.  Nothing prevents you from also licensing under something else.</p>
<p>However, if someone is getting information from Stack Exchange, they themselves must follow the TOS, and the TOS says:</p>
<blockquote>
<p>In the event that You post or otherwise use Subscriber Content outside of the Network or Services, with the exception of content entirely created by You, You agree that You will follow the attribution rules of the Creative Commons Attribution Share Alike license as follows:</p>
<p>You will ensure that any such use of Subscriber Content visually displays or otherwise indicates the source of the Subscriber Content as coming from the Stack Exchange Network. This requirement is satisfied with a discreet text blurb, or some other unobtrusive but clear visual indication.<br />
You will ensure that any such Internet use of Subscriber Content includes a hyperlink directly to the original question on the source site on the Network (e.g., <a href="https://stackoverflow.com/questions/12345">https://stackoverflow.com/questions/12345</a>)<br />
You will ensure that any such use of Subscriber Content visually display or otherwise clearly indicate the author names for every question and answer so used.<br />
You will ensure that any such Internet use of Subscriber Content Hyperlink each author name directly back to his or her user profile page on the source site on the Network (e.g., <a href="https://stackoverflow.com/users/12345/username">https://stackoverflow.com/users/12345/username</a>), directly to the Stack Exchange domain, in standard HTML (i.e. not through a Tinyurl or other such indirect hyperlink, form of obfuscation or redirection), without any “nofollow” command or any other such means of avoiding detection by search engines, and visible even with JavaScript disabled.</p>
</blockquote>
<p>To remain in compliance with site TOS, I think they'd still have to obey those rules if they get the code from your post, even if your alternate license allows otherwise.  (Of course, if they get the code from somewhere else, they could ignore this.)</p>

<p>According to the <code>CC BY-SA 3.0</code> <a href="https://creativecommons.org/licenses/by/3.0/legalcode" rel="nofollow noreferrer">license text</a>, you may only relicense the respective work in compliance with <code>CC BY-SA 3.0</code>. Accoring to the list of <a href="https://creativecommons.org/share-your-work/licensing-considerations/compatible-licenses" rel="nofollow noreferrer">compatible licenses</a> you may re-license your work e.g. under a newer version of <code>BY-SA</code>, e.g. <code>CC BY-SA 4.0</code>. The work then published under <code>CC BY-SA 4.0</code> may be relicensed under the <code>Free Art License 1.3</code> or <code>GPLv3</code> as per the aforementioned list.</p>

<p>That means that you can not relicense your work posted on SE on any license not compatible with <code>CC BY-SA 3.0</code> without violating it.<br>
If you want to license your code using a not <code>CC BY-SA 3.0</code> compatible license, you cannot do this on SE, but maybe your private website.<br>
As soon as you publish your work on SE, it becomes subject to <code>CC BY-SA 3.0</code> as per the <a href="https://stackexchange.com/legal">TOS</a> and any use of the work obtained from SE must comply with <code>CC BY-SA 3.0</code>.</p>
