This post is dedicated to testing out the newly announced Stack Snippets feature. Feel free to answer with your own Stack Snippets, and have some fun!
106 Answers
Loading external image
document.getElementById('foo-image').parentNode.style.border = '4px solid black';
<p id="bar-p">
<img src="http://via.placeholder.com/500x500/404F5C/F5EDDF?text=Placeholder Image" id="foo-image" alt="Placeholder Image" />
</p>
<!-- alert("You can even do alerts."); -->
console.log("AND log to the console.");
.hello {
font-weight: bold;
font-size: 1.5em;
}
.ref {
font-size: 1em;
}
<div><p class="hello">Stack Snippets allow you to make code runnable.</p>
<p class="ref">Reference: <a href="https://meta.stackoverflow.com/questions/269753">https://meta.stackoverflow.com/questions/269753</a></p>
</div>
-
"Obviously the same rules apply: code-only questions or answers will still be blocked" https://meta.stackoverflow.com/questions/269753 - Is this sandbox an exception?– HenkeJul 11, 2020 at 6:44
-
Since my code-only answer here was not blocked, I conclude this sandbox is indeed an exception to the rule that code-only questions or answers will be blocked.– HenkeJan 22, 2021 at 15:10
To create a tag, one must apply it to a question. Any user with at least 1500
reputation may add new
tags to any question by typing the new tag into the question tags field, and
submitting1.
A tag can be created by adding it to a new question, or by editing it into an
existing question. The person who adds the new tag is the creator of the tag.
If you have enough reputation to create the tag, and if you think there is a clear need for a tag, go ahead and create it yourself. Uncommon topics are perfectly valid for a tag, as long as they're still clearly defined. Make sure to submit at least an excerpt for the tag wiki so others can see its intended use. If the new tag causes controversy, you can always come back to Meta to ask the community to judge it.
If you do not have enough reputation to create the tag, then add a comment on your question. Say that you wanted to add the tag to the question, but do not have enough reputation. Consider including a reason why you think this tag is appropriate. If someone with enough reputation agrees with you, they will be able to create the tag. Please delete your comment once this has happened.
As an alternative, you can request the creation of a tag by starting a new meta discussion. This gives other people the opportunity to discuss if the new tag is needed.
Topics to be addressed by you in the Meta question are, but not limited to:
- Existing questions where the tag would be appropriate
- Explain why the tag and such questions are on-topic for Stack Overflow
- Explain how the tag helps in categorizing and finding those questions
- Provide an initial tag wiki excerpt and a tag wiki description
for the new tag, see here.
The main purpose of the tag wiki excerpt - also known as user guidance - is to tell people what the tag should be used for. Its length is limited to ~500 characters. It cannot include markdown.
The tag wiki description is written in markdown, and should stand alone as a detailed description of the tag, and should include all the information present in the excerpt. 2
The excerpt is by far the most important of the two tag wikis - no tag should ever be created without having a guide on how to use it. - Propose a good fitting name for the tag as they are always lowercase, don't take spaces and have a maximum length of 35 characters.
When is it appropriate to create a tag?
Tags should be created if there is a clear need for them. For example, on Stack Overflow, if a new programming language has been created and is in wide use, but no one has asked any questions about it, a new tag should be created for it. 3
Tags connect experts with questions they will be able to answer. 4
The most important purpose of a specific tag is to filter its questions to an audience of qualified answerers. This way answerers can mark specific tags as interesting or subscribe to the RSS feed for that tag. 5Tags are for sorting your question into specific, well-defined categories. 4
Another purpose of a tag is to make it easier to find similar questions. This is accomplished by sorting tags into narrow, well-defined categories. Sorting into categories only works if users all sort into the same set of categories as other users. Thus, creating new tags should be done with care, because a new tag by definition is not used by anyone else. 5
Common misconceptions about tags
The purpose of tags is specifically not to summarize or index your question, but rather to categorize it, and that is a subtly different thing. 5 A typical invalid argument goes as follows:
"Oh, but this new tag concerns only a handful of questions and is already perfectly covered by this other much more generic tag which covers thousands of questions."
That's indexing, not categorizing. Don't fall for it.Don't use meta tags. Not even those that already exist. A meta tag is any tag that doesn't categorize the topic of the question, but simply indicates the nature of the question. Examples include homework or hard-question. 6
Make sure you understand the purpose of tags as described above and why we tag questions. 4
1 Exception: a small number of tags have been blacklisted because they've been deemed harmful; these tags cannot be recreated.
References:
2 What is a tag wiki?
3 When should a tag be created?
4 Why do we tag questions?
5 Creating new tags
6 Tagging Don'ts
document.write(JSON.stringify(...["Hello world!"]));
-
-
This does not demonstrate anything about Stack Snippets. ~ * ~ Rather than writing a comment like that, I would have preferred if you had explained why you rolled back the question. Note that I am not saying it was wrong to roll it back - just that I would have preferred an explanation.– HenkeMar 18, 2021 at 14:01
-
This does not demonstrate anything about Stack Snippets. ~ * ~ Not sure if it makes you any happier, but now it does.– HenkeMar 18, 2021 at 14:55
-
There are already Formatting Sandboxes available. There was a question on Meta about its existence. I would have preferred if you had created a meta post about asking about making the edit to the question in the first place, instead of taking a long-standing question that had a single defined purpose and adding another one. Mar 19, 2021 at 11:28
The following Stack Snippet reproduces the error.
function rightNow() {
const currentTime = new Date.getTime();
return currentTime;
}
console.log(rightNow().toString());
// ^^ No error if I comment out the previous line! ^^
.as-console-wrapper { max-height: 100% !important; top: 0; }
-
3That's a syntax error in your JS, not a problem with stack snippets...
new Date().getTime()
would be correct.– CerbrusApr 4, 2022 at 12:41 -
I know. I never said there is anything wrong with stack snippets. I just used a Stack Snippet to reproduce an error. (And it's not a syntax error.)– HenkeApr 4, 2022 at 12:58
-
-
April fools!!!
var $reasons = ['collecting fees', 'grabbing cookies', 'logging in secretly', 'setting a million +500 bounties', 'awarding them to non-answers', 'posting spam', 'reading e-mail address', 'sharing e-mail address online', 'flagging nothing', 'getting declined flags', 'posting help vampire questions', 'using images of code', 'downvoting others', 'serial voting', 'more spam', 'get to 1 reputation', 'posting non-answers', 'more non answers', 'stop machine'];
globalThis.number = 0;
setInterval(function() {
if ($reasons[window.number] != undefined) {
document.getElementById('log').innerHTML += $reasons[window.number] + "\n";
globalThis.number += 1;
window.scrollTo(0, document.body.scrollHeight);
} else {
clearInterval(self);
}
}, Math.random() * 1500);
body {
font-family: monospace;
background-color: black;
color: white;
}
<pre id="log">Please wait while we do something.
Logging on to SE
</pre>
#demo {
border: 2px solid red;
min-height: 5px;
}
<meta name="viewport">
<script>
var today = new Date();
var date = today.getDate();
var text = "ఉదా: తేదీ " + date + " అయితే సామెతలు " + date + " నుంచి" ;
document.getElementById("demo").innerHTML = text ;
</script>
<h5 style="color:darkblue"> 2022 సంవత్సరం పూర్తి సిలబస్ </h5>
<p>ఒక సంవత్సరంలో బైబిల్ ను పూర్తిచేయు ప్రణాళిక<br>
సోమవారం నుంచి శనివారం వరకు 3 అధ్యాయాలు<br>
ఆదివారం 2 అధ్యాయాలు + జనరల్ ప్రశ్నలు</p>
<p> తేదీని బట్టి ప్రతిరోజు సామెతలు నుంచి 1 ప్రశ్న ఉంటుంది </p>
<p id="demo"></p>
<div style="margin: 0 auto"><iframe id="syllabus" src="https://docs.google.com/spreadsheets/d/e/2PACX-1vReY-tDEwKYjTiSjsfAN42qjFUwMv_OD3_64bFdGrgL-2p3otc13elLcCq3pkb5xqhTA-bW3QXobpqh/pubhtml?gid=0&single=true&widget=false&chrome=false&headers=false&range=a1:b366"></iframe></div>
$(function () {
$.getJSON('http://anyorigin.com/get?url=' + encodeURIComponent('http://chat.meta.stackoverflow.com/rooms/info/89/tavern-on-the-meta') + '&callback=?', function (data) {
parser = new DOMParser();
htmlDoc = parser.parseFromString(data.contents, "text/html");
var a = htmlDoc.getElementsByClassName('username');
var b = htmlDoc.getElementsByClassName('user-gravatar48');
var c = document.getElementsByTagName('ul')[0];
for (var i = 0; i < a.length; i++) {
c.innerHTML = c.innerHTML + "<li><img src='" + b[i].src + "'/>It's " + a[i].innerHTML + '\'s fault!</li>';
}
var li = $('ul li'),
spinBtn = $('#spin');
for (var i = 0; i < 3; i++) {
li.clone().appendTo('ul');
}
var randNum;
function spin() {
randNum = Math.random();
spinBtn.attr('disabled', true).text('Hang on!');
li.first().animate({
marginTop: -(li.first().outerHeight(true) * (Math.floor(randNum * li.length * 2) + li.length * 2)) - 2
}, 5000, 'easeOutQuad', function () {
spinBtn.attr('disabled', false).text('Spin Again!');
});
}
spinBtn.click(function () {
li.first().css('margin-top', 0);
spin();
return false;
});
spin();
});
});
body {
font-family: Arial, sans-serif;
margin: 20px;
}
.clearfix {
clear: both;
}
ul {
float: left;
margin-left: 20px;
height: 24px;
background-color: #efefef;
padding: 10px 20px 10px 10px;
overflow: hidden;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
-moz-box-shadow: 0 2px 2px rgba(0, 0, 0, 0.3);
}
ul li {
font-size: 20px;
margin-bottom: 30px;
}
ul li img {
width: 24px;
height: 24px;
margin-right: 5px;
vertical-align: bottom;
}
#csharp {
display: inline-block;
width: 24px;
margin-right: 5px;
}
#blame {
float: left;
font-size: 12px;
margin-top: 15px;
}
#spin {
float: left;
margin: -5px 0 0 15px;
padding: 1px 3px 2px;
}
#sub {
font-size: 11px;
color: #ccc;
clear: both;
padding-top: 20px;
}
#sub a {
color: #346C95;
}
#sub a:hover {
color: #59B3EF;
}
#sub code {
font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace;
}
#spin {
position:absolute;
-moz-box-shadow:inset 0px 0px 0px 0px #fce2c1;
-webkit-box-shadow:inset 0px 0px 0px 0px #fce2c1;
box-shadow:inset 0px 0px 0px 0px #fce2c1;
background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #ffc477), color-stop(1, #fb9e25) );
background:-moz-linear-gradient( center top, #ffc477 5%, #fb9e25 100% );
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffc477', endColorstr='#fb9e25');
background-color:#ffc477;
-webkit-border-top-left-radius:42px;
-moz-border-radius-topleft:42px;
border-top-left-radius:42px;
-webkit-border-top-right-radius:0px;
-moz-border-radius-topright:0px;
border-top-right-radius:0px;
-webkit-border-bottom-right-radius:42px;
-moz-border-radius-bottomright:42px;
border-bottom-right-radius:42px;
-webkit-border-bottom-left-radius:0px;
-moz-border-radius-bottomleft:0px;
border-bottom-left-radius:0px;
text-indent:0px;
border:1px solid #eeb44f;
display:inline-block;
color:#ffffff;
font-family:Arial;
font-size:15px;
font-weight:bold;
font-style:normal;
height:65px;
line-height:65px;
width:131px;
text-decoration:none;
text-align:center;
text-shadow:-1px -1px 0px #cc9f52;
}
#spin:active {
background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #fb9e25), color-stop(1, #ffc477) );
background:-moz-linear-gradient( center top, #fb9e25 5%, #ffc477 100% );
}
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fb9e25', endColorstr='#ffc477');
background-color:#fb9e25;
}.spin:active {
position:relative;
top:1px;
}
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js"></script>
<p id="blame">The Wheel of Blame!</p>
<br class="clearfix" />
<ul>
<li><img src="https://i.stack.imgur.com/DdIcm.png" alt="" /> It's the SO Dev Team's fault!</li>
<li><span id="csharp">C#</span> It's C#'s fault!</li></ul>
<button id="spin">Spin it!</button>
Testing YouTube URL Embedding
Regular https://www.youtube.com/watch?v=gocwRvLhDf8
https://www.youtube.com/watch?v=gocwRvLhDf8
Timestamped https://www.youtube.com/watch?v=gocwRvLhDf8&t=22
https://www.youtube.com/watch?v=gocwRvLhDf8&t=22
Shortened https://youtu.be/gocwRvLhDf8
Embed https://www.youtube.com/embed/gocwRvLhDf8
https://www.youtube.com/embed/gocwRvLhDf8
Embedded HTML <iframe width="854" height="480" src="https://www.youtube.com/embed/gocwRvLhDf8" frameborder="0" allowfullscreen></iframe>
Mobile https://m.youtube.com/watch?v=gocwRvLhDf8
https://m.youtube.com/watch?v=gocwRvLhDf8
Flash Player https://www.youtube.com/v/gocwRvLhDf8
https://www.youtube.com/v/gocwRvLhDf8
YouTube TV https://www.youtube.com/tv#/watch/video/idle?v=gocwRvLhDf8
I think that it is time to make a c snippet.
#include <stdio.h>
{
printf("Hello, world.\n");
}
Welp, it wouldn't run (yet).
Hi Meta Stack Overflowers!
Sorry for bumping this to the top, but this is part of on ongoing experiment.
If the experiment works out well, I will not disturb you for (at least!) the next 60 days.
Thanks for your patience!
-
-
@Scratte, sorry. I misunderstood you at first. I get it now - these answers are meant for stack snippets only, whereas I am using it as a general formatting sandbox. That's your point, right? ~ * ~ * ~ * ~ Well, I guess that if people get really upset with me doing this, I may have to consider putting in a stack snippet somewhere in the answer - or just (vote to) delete it?– HenkeFeb 19, 2021 at 8:32
-
Yes, I was expecting to find a snippet, due to the title of the Question :) I suppose you could just edit it for any new experiments with general formatting.– ScratteFeb 19, 2021 at 8:35
-
1
-
@Scratte, > Note that every time you edit this post, it dumps the Question to the top. ~ * ~ * ~ * ~ - I was not aware of that. Too bad that a code snippet / formatting sandbox cannot be used without having such a side effect! I will try to be more restrictive in the future. Concerning markdown: I can easily write and "preview" markdown locally on my computer by using for example Visual Studio Code. But that is never quite the same as actually posting it at Stack Overflow. Even the "preview" here is not truthful to the final outcome. (Which I guess you have noticed too?)– HenkeFeb 19, 2021 at 12:32
-
I have not noticed that. But I write a lot of typos, so I generally miss something and then edit it in the 5 minute grace period (where they do not cause revisions). On meta you can be almost sure that someone will edit your post anyway..– ScratteFeb 19, 2021 at 12:53
-
@Scratte, yeah. I have noticed the five minute time frame. I use it all the time ... I would have loved it if that time frame had been 15 minutes rather than 5. Anyways, I will try to be more restrictive with editing / re-posting after the 5-minute time frame, I promise.– HenkeFeb 19, 2021 at 12:58
-
1Since we already have a small conversation here, I'll just let you know that any new Answers also bumps the Question to the top of the homepage ;) ..in case you didn't know that :) I'm not sure, but I think one can create a Question and a self-Answer and delete the Question and then edit the Answer. (One cannot edit a self-deleted Question)– ScratteFeb 22, 2021 at 10:11
-
> I'm not sure, but I think one can create a Question and a self-Answer and delete the Question and then edit the Answer. - What a creative suggestion! Thanks!! :-) - I think I must try that any time soon ... However, my guess would be that you have to delete the answer before you delete the question, or else the answer will get deleted with the question. Once you have deleted the question, you should of course un-delete the answer. (?)– HenkeFeb 22, 2021 at 11:05
-
1I know that deleting a Question that has an Answer on it will count on the Question ban (assuming it has not had it's 60 days on the site before deletion), but I don't think one has to worry too much about that on meta. I have one Question on main with a self-Answer that I deleted a long time ago. I did not delete the Answer before deleting the Question and it seems I can edit the Answer nonetheless. You just need to make sure the Answer doesn't get any upvotes, since that prevents you from deleting the Question. Also, remember to keep a direct link to it, so it's not lost ;)– ScratteFeb 22, 2021 at 12:03
-
1Note that creating an Answer on an non-deleted Question will bump the Question when you edit the deleted Answer, even if only 10K'ers can see the Answer.– ScratteFeb 22, 2021 at 12:06
-
> I did not delete the Answer before deleting the Question and it seems I can edit the Answer nonetheless. - Interesting. That suggests my assumption was wrong. Even better! :-) Thanks again! 👍– HenkeFeb 22, 2021 at 12:06
-
> Note that creating an Answer on an non-deleted Question will bump the Question when you edit the deleted Answer, even if only 10K'ers can see the Answer. - Even more of a reason then to (self-)delete the question before editing answer(s) to it! 😊– HenkeFeb 22, 2021 at 12:09
-
@Scratte, I actually got a little stressed when I was not allowed to delete my own question. Thanks for helping me out! 👍 What next? Should I now try to un-delete my answers? Or would that un-delete the question as well??– HenkeFeb 22, 2021 at 13:55
-
1You can't ping a user that didn't post a comment on the post :) I do not know how community wiki's work. But my suggestion was for you to test the markup and result on a deleted Answer (of your own) on a deleted Question (also your own). Then you could reuse it every time you need to test something. If you can edit a community wiki Answer on your own Question, then all is well, no? :) In my own test, I edited my own deleted Answer on my own deleted Question. It's pink, but it works.. :)– ScratteFeb 22, 2021 at 14:28
alert("Hello world"); document.getElementsByTagName("button")[0].addEventListener("click",()=>{alert("Hello world!")})
<button>Click me</button>
Sorry for another snippet from me, but I couldn't resist a stack overflow example for Stack Overflow:
function so(){
try
{
so();
}
catch(e)
{
alert(e);
}
}
so();
This could crash your browser. Have a nice day :-)
a=[];while(true){a.push(a)};
-
2Didn't realize this would crash the browser until I expanded it. I wish stackoverflow would protext against this.– EricOct 2, 2015 at 8:43
Let
- $(\Omega,\mathcal A)$ be a measurable space and $\mathbb F=(\mathcal F_n)_{n\in\mathbb N_0}$ be a filtration on $(\Omega,\mathcal A)$
- $E$ be an at most countable set equipped with the discrete topology
- $X=(X_n)_{n\in\mathbb N_0}$ be a discrete Markov chain on $(\Omega,\mathcal A)$ with respect to $\mathbb F$ with values in $(E,\mathcal E)$
Let $x\in E$ be recurrent, $$\tau_x^k:=\inf\left{n>\tau_x^{k-1}:X_n=x\right}\;\;\;\text{with }\tau_x^0:=0\;,$$ $t_0:=x$ and $$t_k:=\tau_x^k-\tau_x^{k-1}\;\;\;$$ for $k\in\mathbb N$. How can we prove, that $(t_k)_{k\in\mathbb N_0}$ is independent and identically distributed?
Let $k\in\mathbb N_0$. Then, $\tau:=\tau_x^{k-1}$ is a $\mathbb F$-stopping time. Let $$\tilde X:=\left(X_{\tau+n}\right)_{n\in\mathbb N_0}\;.$$ The strong Markov property yields for all $n\in\mathbb N_0$ \begin{equation} \begin{split} \operatorname P_x\left[t_k=n\right]&=\operatorname P_x\left[\tilde X_1\ne x,\ldots,\tilde X_{n-1}\ne x\text{ and }\tilde X_n=x\right]\ &=\operatorname P_{X_\tau}\left[X_1\ne x,\ldots,X_{n-1}\ne x\text{ and }X_n=x\right]\ &=\operatorname P_x\left[X_1\ne x,\ldots,X_{n-1}\ne x\text{ and }X_n=x\right] \end{split}\tag 1 \end{equation} $\operatorname P_x$-almost surely, since $\operatorname P_x\left[\tau<\infty\right]=1$ by the recurrence of $x$. Since the right-hand side of $(1)$ doesn't depend on $k$, the $t_k$ are indeed identically distributed.
How can we show, that they are independent, too?
Thankyou for the downvotes; I confirmed Fullscreen rendering when the answer is greyed out was wrong. They've now disabled the running of code snippets when the post gets downvoted.
<h1>Just testing...</h1>
-
Hmm. I'm not sure we should worry too much about fullscreen rendering for a negative-points question, but the transparent overlay isn't exactly functional.– AmeliaBRSep 9, 2014 at 1:07
-
@AmeliaBR It's not the rendering per se, but the fact that most of the rest of the display is still interactive while you're in fullscreen mode! I edited this comment while fullscreen was active, for example. Sep 9, 2014 at 1:19
-
1Hadn't even thought to try that. But I think you'll have to leave a bug report on the current feedback thread to get something to happen -- unless someone is trying out the sandbox themselves,they aren't likely to discover your -13 answer when there are two pages of posts!– AmeliaBRSep 9, 2014 at 3:16
-
@AmeliaBR Good point, but this was based upon a downvoted feedback post from the original feedback Q. Sep 9, 2014 at 3:20
-
-
-
7@modiX, you don't lose rep on this meta site, so downvotes don't hurt you.– gunr2171Sep 10, 2014 at 19:12
-
-
2@gunr2171 I should mention I did think this was Meta Stack Exchange too. Sep 11, 2014 at 5:54
whateverNumberOfPointsYouWant * -1
and let's settle in the middle?-9001
points please ;)