Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

PHP

What is an elegant way to force browsers to reload cached CSS/JS files?

<link rel="stylesheet" href="mycss.css?v=<?php echo filemtime('mycss.css') ?>"/>
https://snipt.net/embed/435dc58927adef9244f309063dc94bef/
https://snipt.net/raw/435dc58927adef9244f309063dc94bef/
435dc58927adef9244f309063dc94bef
php
PHP
1
2016-12-02T16:40:41
True
False
False
Oct 28, 2013 at 12:36 PM
/api/public/snipt/90557/
-5193
<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><span class="x">&lt;link rel=&quot;stylesheet&quot; href=&quot;mycss.css?v=</span><span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nb">filemtime</span><span class="p">(</span><span class="s1">&#39;mycss.css&#39;</span><span class="p">)</span> <span class="cp">?&gt;</span><span class="x">&quot;/&gt;</span> </span></pre></div> </td></tr></table>
browser, file, force, reload

Bash

osx > chrome > open with inspector on a port

$ open -a "Google Chrome" --args --remote-debugging-port=9333
https://snipt.net/embed/c2b02ab2e7ef475b4e1f95543ff741c9/
https://snipt.net/raw/c2b02ab2e7ef475b4e1f95543ff741c9/
c2b02ab2e7ef475b4e1f95543ff741c9
bash
Bash
1
2016-12-04T05:43:20
True
False
False
May 12, 2013 at 02:57 AM
/api/public/snipt/61154/
osx-chrome-open-with-inspector-on-a-port
<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>$ open -a <span class="s2">&quot;Google Chrome&quot;</span> --args --remote-debugging-port<span class="o">=</span>9333 </span></pre></div> </td></tr></table>
bash, browser, chrome, osx, web-development

JavaScript

Reveal password with javascript

1
2
3
Paste into url bar:

javascript:(function(){var s,F,j,f,i; s = ""; F = document.forms; for(j=0; j<F.length; ++j) { f = F[j]; for (i=0; i<f.length; ++i) { if (f[i].type.toLowerCase() == "password") s += f[i].value + "\n"; } } if (s) alert("Passwords in forms on this page:\n\n" + s); else alert("There are no saved passwords in forms on this page.");})();
https://snipt.net/embed/f5fd9839d056cd80066d86ff6f624a61/
https://snipt.net/raw/f5fd9839d056cd80066d86ff6f624a61/
f5fd9839d056cd80066d86ff6f624a61
js
JavaScript
4
2016-12-05T14:51:05
True
False
False
/api/public/snipt/60188/
reveal-password-with-javascript
<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="nx">Paste</span> <span class="nx">into</span> <span class="nx">url</span> <span class="nx">bar</span><span class="o">:</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="nx">javascript</span><span class="o">:</span><span class="p">(</span><span class="kd">function</span><span class="p">(){</span><span class="kd">var</span> <span class="nx">s</span><span class="p">,</span><span class="nx">F</span><span class="p">,</span><span class="nx">j</span><span class="p">,</span><span class="nx">f</span><span class="p">,</span><span class="nx">i</span><span class="p">;</span> <span class="nx">s</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span><span class="p">;</span> <span class="nx">F</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">forms</span><span class="p">;</span> <span class="k">for</span><span class="p">(</span><span class="nx">j</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span> <span class="nx">j</span><span class="o">&lt;</span><span class="nx">F</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="o">++</span><span class="nx">j</span><span class="p">)</span> <span class="p">{</span> <span class="nx">f</span> <span class="o">=</span> <span class="nx">F</span><span class="p">[</span><span class="nx">j</span><span class="p">];</span> <span class="k">for</span> <span class="p">(</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="nx">f</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="o">++</span><span class="nx">i</span><span class="p">)</span> <span class="p">{</span> <span class="k">if</span> <span class="p">(</span><span class="nx">f</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">type</span><span class="p">.</span><span class="nx">toLowerCase</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;password&quot;</span><span class="p">)</span> <span class="nx">s</span> <span class="o">+=</span> <span class="nx">f</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">value</span> <span class="o">+</span> <span class="s2">&quot;\n&quot;</span><span class="p">;</span> <span class="p">}</span> <span class="p">}</span> <span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">)</span> <span class="nx">alert</span><span class="p">(</span><span class="s2">&quot;Passwords in forms on this page:\n\n&quot;</span> <span class="o">+</span> <span class="nx">s</span><span class="p">);</span> <span class="k">else</span> <span class="nx">alert</span><span class="p">(</span><span class="s2">&quot;There are no saved passwords in forms on this page.&quot;</span><span class="p">);})();</span> </span></pre></div> </td></tr></table>
browser, hack, js, password

JavaScript

Target IE10 with jQuery

1
2
3
4
//Detect IE10 and set an appropriate <html> class, considering that IE10 doesn't have conditional classes
if ([email protected]_on!@*/false && document.documentMode === 10) {
    document.documentElement.className+=' ie-10';
}
https://snipt.net/embed/1c3e25e7e89355c0fcb858ac4deb06b9/
https://snipt.net/raw/1c3e25e7e89355c0fcb858ac4deb06b9/
1c3e25e7e89355c0fcb858ac4deb06b9
js
JavaScript
4
2016-12-03T05:17:09
True
False
True
Mar 05, 2013 at 08:28 AM
/api/public/snipt/57032/
target-ie10-with-jquery
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c1">//Detect IE10 and set an appropriate &lt;html&gt; class, considering that IE10 doesn&#39;t have conditional classes</span> </span><span id="L-2"><a name="L-2"></a><span class="k">if</span> <span class="p">(</span><span class="cm">[email protected]_on!@*/</span><span class="kc">false</span> <span class="o">&amp;&amp;</span> <span class="nb">document</span><span class="p">.</span><span class="nx">documentMode</span> <span class="o">===</span> <span class="mi">10</span><span class="p">)</span> <span class="p">{</span> </span><span id="L-3"><a name="L-3"></a> <span class="nb">document</span><span class="p">.</span><span class="nx">documentElement</span><span class="p">.</span><span class="nx">className</span><span class="o">+=</span><span class="s1">&#39; ie-10&#39;</span><span class="p">;</span> </span><span id="L-4"><a name="L-4"></a><span class="p">}</span> </span></pre></div> </td></tr></table>
"internet explorer", browser, css, ie10, javascript, jquery
Copyrighted, illegal, or inappropriate content? Email [email protected].