Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

JavaScript

Sleep function

1
2
3
4
5
6
7
8
function sleep(milliseconds) {
  var start = new Date().getTime();
  for (var i = 0; i < 1e7; i++) {
    if ((new Date().getTime() - start) > milliseconds){
      break;
    }
  }
}
https://snipt.net/embed/96d28bd420f3f3b132986ec996fbad67/
https://snipt.net/raw/96d28bd420f3f3b132986ec996fbad67/
96d28bd420f3f3b132986ec996fbad67
js
JavaScript
8
2016-12-09T06:56:17
True
False
False
Apr 14, 2014 at 05:21 AM
/api/public/snipt/129781/
sleep-function
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a> <a href="#L-8">8</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="kd">function</span> <span class="nx">sleep</span><span class="p">(</span><span class="nx">milliseconds</span><span class="p">)</span> <span class="p">{</span> </span><span id="L-2"><a name="L-2"></a> <span class="kd">var</span> <span class="nx">start</span> <span class="o">=</span> <span class="k">new</span> <span class="nb">Date</span><span class="p">().</span><span class="nx">getTime</span><span class="p">();</span> </span><span id="L-3"><a name="L-3"></a> <span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="mi">1</span><span class="nx">e7</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span> </span><span id="L-4"><a name="L-4"></a> <span class="k">if</span> <span class="p">((</span><span class="k">new</span> <span class="nb">Date</span><span class="p">().</span><span class="nx">getTime</span><span class="p">()</span> <span class="o">-</span> <span class="nx">start</span><span class="p">)</span> <span class="o">&gt;</span> <span class="nx">milliseconds</span><span class="p">){</span> </span><span id="L-5"><a name="L-5"></a> <span class="k">break</span><span class="p">;</span> </span><span id="L-6"><a name="L-6"></a> <span class="p">}</span> </span><span id="L-7"><a name="L-7"></a> <span class="p">}</span> </span><span id="L-8"><a name="L-8"></a><span class="p">}</span> </span></pre></div> </td></tr></table>
javascript, sleep

Bash

Linux update time - vmware too

ntpdate pool.ntp.org
https://snipt.net/embed/e54fc60bbb0bb431662d786ab3dd7179/
https://snipt.net/raw/e54fc60bbb0bb431662d786ab3dd7179/
e54fc60bbb0bb431662d786ab3dd7179
bash
Bash
1
2016-12-09T07:24:55
True
False
False
Apr 05, 2013 at 08:06 AM
/api/public/snipt/58825/
linux-update-time-vmware-too
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>ntpdate pool.ntp.org </span></pre></div> </td></tr></table>
linux, sleep, standby, vmware

PHP

Pausa de segundos

1
2
3
4
5
<?php

   sleep(int second);

?>
https://snipt.net/embed/5dd40ab51a908417f7ed514b0933e714/
https://snipt.net/raw/5dd40ab51a908417f7ed514b0933e714/
5dd40ab51a908417f7ed514b0933e714
php
PHP
5
2016-12-09T21:16:43
True
False
False
/api/public/snipt/36327/
pausa-de-segundos
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a> <span class="nb">sleep</span><span class="p">(</span><span class="nx">int</span> <span class="nx">second</span><span class="p">);</span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
pausa, php, sleep

Batchfile

Sleep in batch

:Pause the program until -w (miliseconds) passes
PING 1.1.1.1 -n 1 -w 60000 >NUL
https://snipt.net/embed/41a53943d52a27684212fc8fd18616ec/
https://snipt.net/raw/41a53943d52a27684212fc8fd18616ec/
41a53943d52a27684212fc8fd18616ec
bat
Batchfile
2
2016-12-09T13:04:29
True
False
False
/api/public/snipt/35473/
sleep-in-batch
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="p">:</span><span class="nl">Pause</span><span class="c1"> the program until -w (miliseconds) passes</span> </span><span id="L-2"><a name="L-2"></a>PING 1.1.1.1 -n 1 -w 60000 <span class="p">&gt;</span>NUL </span></pre></div> </td></tr></table>
batch, sleep, windows

Java

Sleep

1
2
3
try{
  Thread.currentThread().sleep(1000);//sleep for 1000 ms
}catch(ItrerruptedException ie){}
https://snipt.net/embed/c9fab33e9458412c527c3fe8a13ee37d/
https://snipt.net/raw/c9fab33e9458412c527c3fe8a13ee37d/
c9fab33e9458412c527c3fe8a13ee37d
java
Java
4
2016-12-10T04:47:53
True
False
False
/api/public/snipt/26724/
sleep
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="k">try</span><span class="o">{</span> </span><span id="L-2"><a name="L-2"></a> <span class="n">Thread</span><span class="o">.</span><span class="na">currentThread</span><span class="o">().</span><span class="na">sleep</span><span class="o">(</span><span class="mi">1000</span><span class="o">);</span><span class="c1">//sleep for 1000 ms</span> </span><span id="L-3"><a name="L-3"></a><span class="o">}</span><span class="k">catch</span><span class="o">(</span><span class="n">ItrerruptedException</span> <span class="n">ie</span><span class="o">){}</span> </span></pre></div> </td></tr></table>
java, sleep, thread

Text only

Sleep in windows shell

ping 1.1.1 -w 10 >/null
https://snipt.net/embed/2c6e7a76e120bb97f9c66391d77c3d7c/
https://snipt.net/raw/2c6e7a76e120bb97f9c66391d77c3d7c/
2c6e7a76e120bb97f9c66391d77c3d7c
text
Text only
1
2016-12-09T07:26:41
True
False
False
/api/public/snipt/16085/
sleep-in-windows-shell
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>ping 1.1.1 -w 10 &gt;/null </span></pre></div> </td></tr></table>
cmd, sleep, windows

Python

Pause 1 second

1
2
3
    import time

    time.sleep(1)
https://snipt.net/embed/a860b759de92bed6bda53ae601b467fe/
https://snipt.net/raw/a860b759de92bed6bda53ae601b467fe/
a860b759de92bed6bda53ae601b467fe
python
Python
3
2016-12-09T07:27:08
True
False
False
/api/public/snipt/7667/
pause-1-second
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a> <span class="kn">import</span> <span class="nn">time</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a> <span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> </span></pre></div> </td></tr></table>
pause, python, sleep
Copyrighted, illegal, or inappropriate content? Email [email protected].