292
votes
Accepted
I've been told to create a "runnable" example with "Stack Snippets". How do I do that?
Stack Snippets are an on-site tool similar to jsfiddle.net, codepen.io or plnkr.co. They're more limited than those tools, but they have the advantage of being on-site, so your code/markup is in your ...
Community wiki
250
votes
Accepted
How do I create a React Stack Snippet with JSX support?
Here's a step-by-step guide, first summary, then details with pictures. There are a couple of live demonstration snippets after the detailed instructions.
Summary:
Open the Stack Snippets editor by ...
Community wiki
43
votes
Accepted
Is this 'Run code snippet' with payload an attempt to infect SO users' machines with a virus?
At the moment, Stack Snippets are, to the best knowledge of experts who've considered the problem (both SE employees and standard users like ourselves), completely sandboxed and pretty safe to run. ...
40
votes
Accepted
Stack Overflow reputation and profile link in email sign
You could use Flair.
Navigate to your profile -> "Edit Profile and Settings" -> Flair (under the Site Settings subheader). There you'll find an HTML snippet for a generated image with contains your ...
38
votes
Accepted
Unrunnable/useless Stack Snippets in Suggested Edits
You have four options. The first three are in order of most to least recommended:
You can flag one of the posts they've edited for moderator intervention and ask a moderator to intervene. I've done ...
38
votes
How to deal with a user reformatting snippet data to be in a single line
When the data is quite long, verbatim from the question (where the user left it expanded), not an important part of the answer, and the edits are to the answers that copied the extremely long sample ...
Ryan MMod
- 20k
36
votes
Accepted
Guideline on edits that only add/remove stack snippet
Edits adding a snippet
If the snippet demonstrates the issue the OP is asking about when you click Run code snippet, approve. If not, reject.
Edits removing a snippet
If the snippet demonstrates ...
35
votes
Accepted
Why won't this snippet with async await work here on Stack Overflow snippet editor?
Update: This is fixed as of Oct 3 2024, see the updates in this bug report (which SE called a "feature request").
The problem is that the version of babel-standalone used by Stack Snippets ...
34
votes
How can I add code to the head element when posting a code snippet?
If dynamically creating the <meta> tag isn't enough, there's a way to put the tag in directly, without JavaScript, through a hack. The text in the CodeMirror textareas will be inserted verbatim ...
34
votes
How do I demonstrate a preventDefault problem on a link in a Stack Snippet?
Although Stack Snippets prevent you navigating to a different document (or opening a new window), you can navigate within a document using a fragment identifier, which is all you need to demonstrate ...
30
votes
Accepted
All my code is properly formatted, yet I am unable to post an answer due to unformatted code. Why?
In the first version of this question where you post your original markdown, you had indented code only one line down from your quoted text. When posting blocks of code there has to be a blank line ...
27
votes
Accepted
Code snippets are not runnable on the Stack Overflow mobile website
I agree that this distinction should be removed.
Nowadays, mobile devices that can run JS are perfectly capable of running it properly.
The only issue SO would have with implementing this, would be ...
27
votes
Accepted
Stack Snippets that assign `var location` at the top scope redirect and produce “Server Error in '/' Application.”
It's due to the var location, which assigns to window.location and attempts to replace the page. But you assigned an object to location, resulting in a request to
https://stacksnippets.net/[object%...
26
votes
Sharing data between snippets, such as test inputs
Live shared data between Question and Answers: Don't do it
We should not have a shared snippet context between the question and answers. Doing so inherently sets up a dependency on the question for ...
MakyenMod
- 33.2k
24
votes
Accepted
Can we have an option to add more files in stack snippet like Plunker?
duplode alluded to it in the comments, but it's probably more concise to distill this point.
This would be extraordinarily prone to misuse.
Here's why:
We already have users who believe taking a ...
23
votes
Accepted
How to provide additional code to comment an answer?
Or should I edit my question (risking that my question gets longer and longer)?
Do not edit and scope-creep your original question. If you have additional requirements exposed by the answer, ask a ...
23
votes
Accepted
How are Stack Snippets implemented?
The origin of the iframe is null because of the iframe's sandbox attribute (and the absence of the allow-same-origin clause).
Since the iframe's origin is null it can't access its .parent and thus can'...
23
votes
Accepted
Should I suggest edits to transform code blocks into Stack Snippets for HTML/CSS/JS questions?
I think I'll avoid suggesting adding them however unless there are other fixes I can make at the same time... Daniel Black
That's probably the safest thing to do. I would also add:
If it relies on ...
22
votes
Accepted
How to improve questions to make them easier to comprehend?
I have two suggestions to offer. Both involve putting psychological distance between yourself and the question. That distance gives you a valuable perspective on how other people will view and ...
22
votes
How to make a working snippet with a library not available in HTTPS?
The best solution is to find an HTTPS based source for the file you desire to use.
Files in GitHub repositories are always available via HTTPS
jsDelivr (instructions for GitHub links)
Example:
...
MakyenMod
- 33.2k
22
votes
Accepted
Stack Snippets Console can't output ES6 data types
I don't know that we can really expand those weak structures.
That said, a newer version of the console visualizer was mentioned back in January. That particular version replaced our JSON-flavored ...
20
votes
Accepted
How to edit a snippet once inserted in the Stack Overflow answer?
You have a link, "edit the above snippet" under the "Run code snippet" button when you edit your post.
20
votes
Accepted
How to use "code snippet" vs "code block"
Your assumption is correct, see this blog post for more information.
Not all users know how to format their code. If you come through such posts, simply edit them.
Removing the useless code snippet ...
20
votes
Accepted
Is it possible to have Python code snippets in Stack Overflow?
This is not feasible.
Stack snippets run entirely in the browser. You can't run Python in everyone's browser, not the CPython (main) implementation.
Python is a very, very rich ecosystem, with ...
20
votes
Accepted
Are Stack Snippets always safe to run?
No, not yet.
First, we need RFC 3514 to be adopted that would require evil doers on the internet to set the evil bit in IPv4 packets to signify they are evil.
RFC 3514 is not a technical requirement ...
19
votes
Sandbox the console separately?
Don't change this.
I regularly see users leverage this to change the console output:
console.log("Gee,\n\nthis\n\nis\n\na\n\nlo\no\no\no\no\no\no\nng\n\nstring!");
.as-console-wrapper { max-...
19
votes
Accepted
Is it bad to introduce snippet formatting?
The post was rejected by the OP, with the Reject and Edit button. This button carries an automatic reason. Given that the user is not that experienced with Stack Overflow yet, and has made several ...
18
votes
Accepted
Removing Fiddle links
No, these links needs to be preserved. I'm not a lawyer but I do know that JSFiddle uses a different license for their code submission then SE does. Only the OP is allowed to copy over the code from a ...
18
votes
Is there an option to run my code snippet automatically when opening Stack Overflow questions?
No, there is no such option.
I also think such option would be open to abuse.
Some argue you will miss the juicy animation as it is already done once the snippet scrolls into view.
I prefer to click a ...
18
votes
Accepted
Add a warning about snippets being dangerous when they are run
So can Stack Snippets be confirmation-to-run when they have dangerous items (e.g. infinite loops, cookies, or infinite server requests)?
This is provably impossible. It would require solving the ...
Ryan MMod
- 20k
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
stack-snippets × 492bug × 201
feature-request × 165
discussion × 107
support × 84
status-completed × 54
design × 26
editor × 21
code-formatting × 17
edits × 16
suggested-edits × 11
code × 10
status-bydesign × 9
google-chrome × 9
user-experience × 8
jsfiddle × 8
answers × 7
asking-questions × 7
markdown × 7
tidy × 7
documentation × 6
user-interface × 6
help-center × 6
markdown-rendering × 6
status-declined × 4