snipt

Ctrl+h for KB shortcuts

JavaScript

Change url without refreshing

1
2
3
4
5
6
7
document.location.hash = "show_picture";


//You cannot change the whole url without redirecting, what you can do instead is change the hash.

//The hash is the part of the url that goes after the # symbol. 
//That was initially intended to direct you (locally) to sections of your HTML document, but you can read and modify it through javascript to use it somewhat like a global variable.
https://snipt.net/embed/0f567553963553461ce4fc49f2829650/
https://snipt.net/raw/0f567553963553461ce4fc49f2829650/
0f567553963553461ce4fc49f2829650
js
JavaScript
7
2016-09-26T17:25:49
True
False
False
/api/public/snipt/46056/
change-url-without-refreshing
<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></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="nb">document</span><span class="p">.</span><span class="nx">location</span><span class="p">.</span><span class="nx">hash</span> <span class="o">=</span> <span class="s2">&quot;show_picture&quot;</span><span class="p">;</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="c1">//You cannot change the whole url without redirecting, what you can do instead is change the hash.</span> </span><span id="L-5"><a name="L-5"></a> </span><span id="L-6"><a name="L-6"></a><span class="c1">//The hash is the part of the url that goes after the # symbol. </span> </span><span id="L-7"><a name="L-7"></a><span class="c1">//That was initially intended to direct you (locally) to sections of your HTML document, but you can read and modify it through javascript to use it somewhat like a global variable.</span> </span></pre></div> </td></tr></table>
"url redirect", tabs, url

Bash

Recursive Convert Leading Tabs to Spaces

for i in $(find . -name '*.php'); do expand -i --tabs=2 $i >$i.tmp && mv -f $i.tmp $i; done
https://snipt.net/embed/78718217bbc080b77faf7e27b1538d9d/
https://snipt.net/raw/78718217bbc080b77faf7e27b1538d9d/
78718217bbc080b77faf7e27b1538d9d
bash
Bash
1
2016-09-27T10:08:06
True
False
False
/api/public/snipt/41449/
recursive-convert-leading-tabs-to-spaces
<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 id="L-1"><a name="L-1"></a><span class="k">for</span> i in <span class="k">$(</span>find . -name <span class="s1">&#39;*.php&#39;</span><span class="k">)</span><span class="p">;</span> <span class="k">do</span> expand -i --tabs<span class="o">=</span><span class="m">2</span> <span class="nv">$i</span> &gt;<span class="nv">$i</span>.tmp <span class="o">&amp;&amp;</span> mv -f <span class="nv">$i</span>.tmp <span class="nv">$i</span><span class="p">;</span> <span class="k">done</span> </span></pre></div> </td></tr></table>
indent, shell, spaces, tabs

JavaScript

Tabs - Jquery

1
2
3
4
5
<script type="text/javascript">
	$(document).ready(function() {
		$( "#tabs" ).tabs();
	});
</script>
https://snipt.net/embed/2440c48db311ce89f5b640fb4f55dcc9/
https://snipt.net/raw/2440c48db311ce89f5b640fb4f55dcc9/
2440c48db311ce89f5b640fb4f55dcc9
js
JavaScript
5
2016-09-22T10:40:38
True
False
False
/api/public/snipt/35173/
tabs-5
<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 id="L-1"><a name="L-1"></a><span class="o">&lt;</span><span class="nx">script</span> <span class="nx">type</span><span class="o">=</span><span class="s2">&quot;text/javascript&quot;</span><span class="o">&gt;</span> </span><span id="L-2"><a name="L-2"></a> <span class="nx">$</span><span class="p">(</span><span class="nb">document</span><span class="p">).</span><span class="nx">ready</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span> </span><span id="L-3"><a name="L-3"></a> <span class="nx">$</span><span class="p">(</span> <span class="s2">&quot;#tabs&quot;</span> <span class="p">).</span><span class="nx">tabs</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="o">&lt;</span><span class="err">/script&gt;</span> </span></pre></div> </td></tr></table>
jquery, tabs
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.