Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

JavaScript

jQuery. Steps in $.each()

1
2
3
4
5
6
var eachItem = 4; // someFunction() will work on 1st, 5th, 9th ... element
$('.selector').each(function(i) {
	if(i++ % eachItem === 0) { // to select 4th, 8th etc. elements use ++i instead of i++
		someFunction();
	}
});
https://snipt.net/embed/48ddd2a0e4e231a034ac64ebf3fde8ac/
https://snipt.net/raw/48ddd2a0e4e231a034ac64ebf3fde8ac/
48ddd2a0e4e231a034ac64ebf3fde8ac
js
JavaScript
6
2016-12-09T16:57:34
True
False
False
/api/public/snipt/129927/
jquery-steps-in-each
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="kd">var</span> <span class="nx">eachItem</span> <span class="o">=</span> <span class="mi">4</span><span class="p">;</span> <span class="c1">// someFunction() will work on 1st, 5th, 9th ... element</span> </span><span id="L-2"><a name="L-2"></a><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.selector&#39;</span><span class="p">).</span><span class="nx">each</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">i</span><span class="p">)</span> <span class="p">{</span> </span><span id="L-3"><a name="L-3"></a> <span class="k">if</span><span class="p">(</span><span class="nx">i</span><span class="o">++</span> <span class="o">%</span> <span class="nx">eachItem</span> <span class="o">===</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span> <span class="c1">// to select 4th, 8th etc. elements use ++i instead of i++</span> </span><span id="L-4"><a name="L-4"></a> <span class="nx">someFunction</span><span class="p">();</span> </span><span id="L-5"><a name="L-5"></a> <span class="p">}</span> </span><span id="L-6"><a name="L-6"></a><span class="p">});</span> </span></pre></div> </td></tr></table>
each, function, hack, jquery

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-09T16:18:18
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

CSS

rgba colors in IE 7 & IE 8

1
2
3
/* found here : http://stackoverflow.com/a/3977240 */
background: rgba(255, 255, 255, 0.3); /* browsers */
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#4cffffff', endColorstr='#4cffffff'); /* IE shit */
https://snipt.net/embed/6e770b31dd7181a60ba2d17f316037ac/
https://snipt.net/raw/6e770b31dd7181a60ba2d17f316037ac/
6e770b31dd7181a60ba2d17f316037ac
css
CSS
3
2016-12-10T07:40:15
True
False
False
/api/public/snipt/43498/
rgba-colors-in-ie-7-ie-8
<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="c">/* found here : http://stackoverflow.com/a/3977240 */</span> </span><span id="L-2"><a name="L-2"></a><span class="nt">background</span><span class="o">:</span> <span class="nt">rgba</span><span class="o">(</span><span class="nt">255</span><span class="o">,</span> <span class="nt">255</span><span class="o">,</span> <span class="nt">255</span><span class="o">,</span> <span class="nt">0</span><span class="nc">.3</span><span class="o">);</span> <span class="c">/* browsers */</span> </span><span id="L-3"><a name="L-3"></a><span class="nt">filter</span><span class="o">:</span> <span class="nt">progid</span><span class="nd">:DXImageTransform</span><span class="nc">.Microsoft.gradient</span><span class="o">(</span><span class="nt">GradientType</span><span class="o">=</span><span class="nt">0</span><span class="o">,</span><span class="nt">startColorstr</span><span class="o">=</span><span class="s1">&#39;#4cffffff&#39;</span><span class="o">,</span> <span class="nt">endColorstr</span><span class="o">=</span><span class="s1">&#39;#4cffffff&#39;</span><span class="o">);</span> <span class="c">/* IE shit */</span> </span></pre></div> </td></tr></table>
"internet explorer", color, css, hack, ie7, ie8, rgba

JavaScript

safar and chrome hack

1
2
3
4
5
@media screen and (-webkit-min-device-pixel-ratio:0) {
.dealsTabNav{
		margin-left: -1px;
	}
}
https://snipt.net/embed/d8716140f27e048eaab1ecf2a1cd4b95/
https://snipt.net/raw/d8716140f27e048eaab1ecf2a1cd4b95/
d8716140f27e048eaab1ecf2a1cd4b95
js
JavaScript
5
2016-12-06T13:52:39
True
False
False
/api/public/snipt/36420/
safarchormeopera-hack
<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="err">@</span><span class="nx">media</span> <span class="nx">screen</span> <span class="nx">and</span> <span class="p">(</span><span class="o">-</span><span class="nx">webkit</span><span class="o">-</span><span class="nx">min</span><span class="o">-</span><span class="nx">device</span><span class="o">-</span><span class="nx">pixel</span><span class="o">-</span><span class="nx">ratio</span><span class="o">:</span><span class="mi">0</span><span class="p">)</span> <span class="p">{</span> </span><span id="L-2"><a name="L-2"></a><span class="p">.</span><span class="nx">dealsTabNav</span><span class="p">{</span> </span><span id="L-3"><a name="L-3"></a> <span class="nx">margin</span><span class="o">-</span><span class="nx">left</span><span class="o">:</span> <span class="o">-</span><span class="mi">1</span><span class="nx">px</span><span class="p">;</span> </span><span id="L-4"><a name="L-4"></a> <span class="p">}</span> </span><span id="L-5"><a name="L-5"></a><span class="p">}</span> </span></pre></div> </td></tr></table>
chrome, hack, safari

JavaScript

opera css hack

1
2
3
noindex:-o-prefocus, .class {
  color:#fff;
}
https://snipt.net/embed/76e5fc9c030c3f1b8d1b1a1a619476d1/
https://snipt.net/raw/76e5fc9c030c3f1b8d1b1a1a619476d1/
76e5fc9c030c3f1b8d1b1a1a619476d1
js
JavaScript
4
2016-12-09T13:03:39
True
False
False
Jul 23, 2012 at 05:09 AM
/api/public/snipt/36419/
opera-css-hack
<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">noindex</span><span class="o">:-</span><span class="nx">o</span><span class="o">-</span><span class="nx">prefocus</span><span class="p">,</span> <span class="p">.</span><span class="kr">class</span> <span class="p">{</span> </span><span id="L-2"><a name="L-2"></a> <span class="nx">color</span><span class="o">:</span><span class="err">#</span><span class="nx">fff</span><span class="p">;</span> </span><span id="L-3"><a name="L-3"></a><span class="p">}</span> </span></pre></div> </td></tr></table>
css, hack, opera

CSS

CSS flow hack

1
2
3
4
5
/* Source: http://www.pupinc.com/boxflowhack/ */
.flowhack {
  overflow: auto;
  height: 1%;
}
https://snipt.net/embed/0d416cf12e92738d08362844e5345ca3/
https://snipt.net/raw/0d416cf12e92738d08362844e5345ca3/
0d416cf12e92738d08362844e5345ca3
css
CSS
5
2016-12-09T08:23:35
True
False
False
Jan 27, 2014 at 02:28 AM
/api/public/snipt/31720/
css-flow-hack
<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="c">/* Source: http://www.pupinc.com/boxflowhack/ */</span> </span><span id="L-2"><a name="L-2"></a><span class="nc">.flowhack</span> <span class="p">{</span> </span><span id="L-3"><a name="L-3"></a> <span class="nb">overflow</span><span class="o">:</span> <span class="nb">auto</span><span class="p">;</span> </span><span id="L-4"><a name="L-4"></a> <span class="nb">height</span><span class="o">:</span> <span class="m">1%</span><span class="p">;</span> </span><span id="L-5"><a name="L-5"></a><span class="p">}</span> </span></pre></div> </td></tr></table>
css, hack
Copyrighted, illegal, or inappropriate content? Email [email protected].