279
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 https://jsfiddle.net or https://codepen.io or https://plnkr.co. They're more limited than those tools, but they have the advantage of being on-site, so ...
Community wiki
229
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
143
votes
Feedback Requested: Code Editor and Stack Snippets
Usually I paste the code from my IDE where it's already correctly indented and formatted :).
In the rare cases where there aren't four leading spaces on the code lines (e.g. I've copied the code from ...
ChrisFMod
- 133k
89
votes
Accepted
How can we discuss malicious code?
Honestly, I'm of the opinion that we should post exploit code. BUT I think there are certain guidelines to how we post exploit code:
It should be very clearly marked as exploit code (mark it in bold)....
- 7,715
70
votes
Accepted
Should questions with unnecessary Stack Snippets be edited?
Edit them
The snippet feature is of no use to posts where the code isn't meant to run. It only wastes space.
I usually also add a comment along the lines of:
"Please don't use Stack Snippets for ...
- 69.1k
69
votes
Accepted
"JavaScript snippet"? But I use it for HTML and CSS as well!
My suggestion:
Live demo (HTML/CSS/JS only)
It makes clear what languages are supported, and is a clear indication that this is not just a "code snippet" or "code block" feature but an actual ...
57
votes
Feedback Requested: Code Editor and Stack Snippets
As ChrisF♦ answered, as long as nothing changes when code is selected and I then press the button, I doubt there's anyone whose current workflow is interrupted by your change.
At least I doubt there's ...
- 44.1k
47
votes
Stack-Snippets vs PasteBin, jsFiddle, and JSbin
Always prefer hosting the content on SO.
Thus, prefer having your pictures on SE's imgur-account, thus ensuring they will stay available as long as the SE network exists, instead of using any other ...
- 44.1k
46
votes
Accepted
Some posts with snippets do not have a run button - Why?
After some digging, this is not a bug. The Stack Snippet is explicitly disabled when the post reaches a score of -3 or lower (i.e. when the post is greyed out), which is the case here.
Quoting Haney ...
- 130k
45
votes
Should "Run Snippet" option have a reputation requirement? (To prevent... user stupidity and SE as an attack vector)
I think the problem is not in the snippets but with the owner of the router.
If your router can be hacked by a stack snippet, it can also be hacked by a malicious banner ad or by any website for ...
- 113k
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. ...
- 345k
40
votes
Stack Snippets and non-runnable code
If it's not a stack snippet (HTML+CSS+JS), don't use the stack snippet feature.
Copying a bog-standard code-sample to the answer is easy enough, the copy-to-answer button is not valuable enough to ...
- 44.1k
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 ...
- 290k
37
votes
Accepted
For how long are we allowed to use sandboxes for new features?
It's a sandbox. Play in it.
There's no sense in yelling at people that play in it, regardless of when it was put there.
To that point, Stack Snippets don't support PHP, and the hope/intent is that ...
- 103k
37
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 ...
- 4,467
35
votes
Accepted
Stack-Snippets vs PasteBin, jsFiddle, and JSbin
Where possible I usually try to include both a Stack-Snippet and a jsFiddle.
I still prefer working on people's problems in jsFiddle, not that jsFiddle is inherently better, I'm just used to the ...
- 16k
34
votes
Feedback Requested: Code Editor and Stack Snippets
If the most common use case is not a runnable snippet (since it's only JavaScript, HTML, and CSS right now), what about an interface that goes immediately to a plain code editor, but has a big callout ...
- 3,224
34
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 ...
- 1.0m
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 ...
- 345k
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 ...
- 1.0m
33
votes
Stack Snippets Sandbox - Try It Out Here!
PHP Code
(don't mind the scrollbar)
<?php ?><script>
$store = array(0, ...
Community wiki
32
votes
Accepted
Why does target="_blank" break links in snippets?
Stack Snippets are run inside a sandboxed iframe which only allows modals and scripts, and does not allow access to the top navigation. So anything but _self on a link will not work because it cannot ...
- 53.2k
31
votes
Stack Snippets and document.write
even if it's clearly only for the purpose of demoing it on Stack Overflow?
My problem with willy-nilly tossing document.write into answers without disclaimer is that many new JavaScript developers ...
- 17.4k
31
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 ...
- 4,467
29
votes
Accepted
Why won't this snippet with async await work here on Stack Overflow snippet editor?
It's a Stack Snippets bug (but SE won't call it a bug, they call it a "feature request"), please see this question.
The problem is that the version of babel-standalone used by Stack Snippets ...
- 1.0m
28
votes
Would it be feasible to add a regex snippet tool?
Very often answers linking to one of the popular online tools are the bad answers ignoring the specificity of the question.
There are too many differences between
flavors
implementations (and bugs)
...
- 366k
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 ...
- 69.1k
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%...
- 345k
26
votes
Should it be more obvious that stack snippets are only meant for HTML/CSS/JS?
I've managed to create a data explorer query, which I believe shows questions with stack snippets included based on the body containing: '%div class="snippet"%', which is the markup used to surround a ...
- 21.8k
26
votes
How can we discuss malicious code?
Post the malicious code with a note saying it is malicious. Avoid posting something in a form that a click-happy user may be tempted to run (e.g. a snippet or a link to a compiled binary or something)....
- 37.6k
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
stack-snippets × 468bug × 189
feature-request × 156
discussion × 105
support × 81
status-completed × 47
design × 25
editor × 21
code-formatting × 17
edits × 16
suggested-edits × 11
code × 10
status-bydesign × 9
user-experience × 8
google-chrome × 8
jsfiddle × 8
asking-questions × 7
status-review × 7
documentation × 6
user-interface × 6
markdown × 6
help-center × 6
tidy × 6
answers × 5
markdown-rendering × 5