snipt

Ctrl+h for KB shortcuts

Bash

linux 10 largest files on folder

du -hsx * | sort -rh | head -10
https://snipt.net/embed/d0a999c2ea84cd11eb72be963e5d2c3c/
/raw/d0a999c2ea84cd11eb72be963e5d2c3c/
d0a999c2ea84cd11eb72be963e5d2c3c
bash
Bash
1
2019-08-08T06:54:13
True
False
False
Dec 23, 2013 at 05:01 AM
/api/public/snipt/102129/
linux-10-largest-files-on-folder
<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>du -hsx * <span class="p">|</span> sort -rh <span class="p">|</span> head -10 </span></pre></div> </td></tr></table>
"linux commands", linux

JavaScript

israel phone number regex

1
2
3
4
5
//cellular israeli regex
/^05\d([-]{0,1})\d{7}$/

//all numbers israel
/^0\d([\d]{0,1})([-]{0,1})\d{7}$/
https://snipt.net/embed/3de7626f89448ca0a807f37b123a5bf1/
/raw/3de7626f89448ca0a807f37b123a5bf1/
3de7626f89448ca0a807f37b123a5bf1
js
JavaScript
7
2019-08-09T08:56:47
True
False
False
/api/public/snipt/27506/
israel-phone-number-regex
<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="c1">//cellular israeli regex</span> </span><span id="L-2"><a name="L-2"></a><span class="sr">/^05\d([-]{0,1})\d{7}$/</span> </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="c1">//all numbers israel</span> </span><span id="L-5"><a name="L-5"></a><span class="sr">/^0\d([\d]{0,1})([-]{0,1})\d{7}$/</span> </span></pre></div> </td></tr></table>
"regular expression", javascript, js, regex

Bash

change all files in directory modification date

 find . -exec touch {} \;
https://snipt.net/embed/69971c8558a1e76384e7044439811f13/
/raw/69971c8558a1e76384e7044439811f13/
69971c8558a1e76384e7044439811f13
bash
Bash
1
2019-08-17T08:22:47
True
False
False
/api/public/snipt/27437/
change-all-files-in-directory-modification-date
<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> find . -exec touch <span class="o">{}</span> <span class="se">\;</span> </span></pre></div> </td></tr></table>
bash, files, linux, touch

PHP

detect iphone browser

1
2
3
4
< ?php
$browser = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone");
if ($browser == true)  { echo 'Code You Want To Execute'; }
?>
https://snipt.net/embed/94e9ef8d3e0da48dad0b4df25019e76b/
/raw/94e9ef8d3e0da48dad0b4df25019e76b/
94e9ef8d3e0da48dad0b4df25019e76b
php
PHP
4
2019-08-18T23:38:56
True
False
False
/api/public/snipt/25064/
detect-iphone-browser-1
<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="x">&lt; ?php</span> </span><span id="L-2"><a name="L-2"></a><span class="x">$browser = strpos($_SERVER[&#39;HTTP_USER_AGENT&#39;],&quot;iPhone&quot;);</span> </span><span id="L-3"><a name="L-3"></a><span class="x">if ($browser == true) { echo &#39;Code You Want To Execute&#39;; }</span> </span><span id="L-4"><a name="L-4"></a><span class="x">?&gt;</span> </span></pre></div> </td></tr></table>
browser, detect, iphone, php

Bash

Exim remove all messages from the queue

1
2
3
4
5
exim -bp | awk '/^ *[0-9]+[mhd]/{print "exim -Mrm " $3}' | bash

# OR 

exim -bp | exiqgrep -i | xargs exim -Mrm
https://snipt.net/embed/324ff771fa41aa76b8d5e9adb308ea00/
/raw/324ff771fa41aa76b8d5e9adb308ea00/
324ff771fa41aa76b8d5e9adb308ea00
bash
Bash
5
2019-08-19T04:15:26
True
False
False
/api/public/snipt/25061/
exim-remove-all-messages-from-the-queue
<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>exim -bp <span class="p">|</span> awk <span class="s1">&#39;/^ *[0-9]+[mhd]/{print &quot;exim -Mrm &quot; $3}&#39;</span> <span class="p">|</span> bash </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="c1"># OR </span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a>exim -bp <span class="p">|</span> exiqgrep -i <span class="p">|</span> xargs exim -Mrm </span></pre></div> </td></tr></table>
exim, linux, queue

PHP

joomla redirect outside controller

1
2
3
4
5
6
<?php

 $app = &JFactory::getApplication();
 $app->redirect("index.php?option=com_XXXXX&view=XXXXXX&Itemid=X");

?>
https://snipt.net/embed/3ba87480ec77a46625fefa5aa56607c3/
/raw/3ba87480ec77a46625fefa5aa56607c3/
3ba87480ec77a46625fefa5aa56607c3
php
PHP
6
2019-08-18T11:15:58
True
False
False
/api/public/snipt/24575/
joomla-redirect-outside-controller
<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="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="nv">$app</span> <span class="o">=</span> <span class="o">&amp;</span><span class="nx">JFactory</span><span class="o">::</span><span class="na">getApplication</span><span class="p">();</span> </span><span id="L-4"><a name="L-4"></a> <span class="nv">$app</span><span class="o">-&gt;</span><span class="na">redirect</span><span class="p">(</span><span class="s2">&quot;index.php?option=com_XXXXX&amp;view=XXXXXX&amp;Itemid=X&quot;</span><span class="p">);</span> </span><span id="L-5"><a name="L-5"></a> </span><span id="L-6"><a name="L-6"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
application, jfactory, joomla, redirect

PHP

check SSL and redirect to SSL if not

1
2
3
4
5
     if ($_SERVER['HTTPS'] != "on") {
    $url = "https://". $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
    header("Location: $url");
    exit;
}  
https://snipt.net/embed/ba9fe48af19d756ebbce3331afb3e4c2/
/raw/ba9fe48af19d756ebbce3331afb3e4c2/
ba9fe48af19d756ebbce3331afb3e4c2
php
PHP
5
2019-08-14T14:02:25
True
False
False
/api/public/snipt/24394/
check-ssl-and-redirect-to-ssl-if-not
<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="x"> if ($_SERVER[&#39;HTTPS&#39;] != &quot;on&quot;) {</span> </span><span id="L-2"><a name="L-2"></a><span class="x"> $url = &quot;https://&quot;. $_SERVER[&#39;SERVER_NAME&#39;] . $_SERVER[&#39;REQUEST_URI&#39;];</span> </span><span id="L-3"><a name="L-3"></a><span class="x"> header(&quot;Location: $url&quot;);</span> </span><span id="L-4"><a name="L-4"></a><span class="x"> exit;</span> </span><span id="L-5"><a name="L-5"></a><span class="x">} </span> </span></pre></div> </td></tr></table>
php, redirect, ssl

JavaScript

Get Latitude and Longitude values from Google Maps

javascript:void(prompt('',gApplication.getMap().getCenter()));
https://snipt.net/embed/b1e4ed445503e7ab09d1bca031692634/
/raw/b1e4ed445503e7ab09d1bca031692634/
b1e4ed445503e7ab09d1bca031692634
js
JavaScript
1
2019-08-15T22:49:40
True
False
False
/api/public/snipt/24359/
get-latitude-and-longitude-values-from-google-maps
<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="nx">javascript</span><span class="o">:</span><span class="k">void</span><span class="p">(</span><span class="nx">prompt</span><span class="p">(</span><span class="s1">&#39;&#39;</span><span class="p">,</span><span class="nx">gApplication</span><span class="p">.</span><span class="nx">getMap</span><span class="p">().</span><span class="nx">getCenter</span><span class="p">()));</span> </span></pre></div> </td></tr></table>
google, maps