snipt

Ctrl+h for KB shortcuts

Bash

IP Netstat Count - RHEL5

sudo netstat -tan | perl -lane '$_ = $F[4]; $_ =~ /::ffff:(.+)(\:\d+)/; print $1' | uniq -c | less
https://snipt.net/embed/0eb8ecb61fcc92c6ae8448a2637cce60/
/raw/0eb8ecb61fcc92c6ae8448a2637cce60/
0eb8ecb61fcc92c6ae8448a2637cce60
bash
Bash
1
2019-07-15T04:50:50
True
False
False
/api/public/snipt/59762/
ip-netstat-count
<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>sudo netstat -tan <span class="p">|</span> perl -lane <span class="s1">&#39;$_ = $F[4]; $_ =~ /::ffff:(.+)(\:\d+)/; print $1&#39;</span> <span class="p">|</span> uniq -c <span class="p">|</span> less </span></pre></div> </td></tr></table>

Bash

Ubuntu purge old Kernels - free up /boot

sudo apt-get purge $(dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve "$(uname -r | sed -r 's/-[a-z]+//')")
https://snipt.net/embed/e74c670f9bfe59a05756f9978f9911b0/
/raw/e74c670f9bfe59a05756f9978f9911b0/
e74c670f9bfe59a05756f9978f9911b0
bash
Bash
1
2019-07-15T17:56:28
True
False
False
/api/public/snipt/55285/
ubuntu-purge-old-kernels-free-up-boot
<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>sudo apt-get purge <span class="k">$(</span>dpkg -l linux-<span class="o">{</span>image,headers<span class="o">}</span>-<span class="s2">&quot;[0-9]*&quot;</span> <span class="p">|</span> awk <span class="s1">&#39;/ii/{print $2}&#39;</span> <span class="p">|</span> grep -ve <span class="s2">&quot;</span><span class="k">$(</span>uname -r <span class="p">|</span> sed -r <span class="s1">&#39;s/-[a-z]+//&#39;</span><span class="k">)</span><span class="s2">&quot;</span><span class="k">)</span> </span></pre></div> </td></tr></table>

Bash

Find IPs in file

1
2
3
4
5
#!/bin/sh
grep -Eo "[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}" /usr/local/psa/var/log/maillog |
    while read i;do
    echo $i
done
https://snipt.net/embed/2587db67e85935effe7f60b8ae72dc76/
/raw/2587db67e85935effe7f60b8ae72dc76/
2587db67e85935effe7f60b8ae72dc76
bash
Bash
5
2019-07-16T01:09:24
True
False
False
/api/public/snipt/49357/
find-ips-in-file
<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="ch">#!/bin/sh</span> </span><span id="L-2"><a name="L-2"></a>grep -Eo <span class="s2">&quot;[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}&quot;</span> /usr/local/psa/var/log/maillog <span class="p">|</span> </span><span id="L-3"><a name="L-3"></a> <span class="k">while</span> <span class="nb">read</span> i<span class="p">;</span><span class="k">do</span> </span><span id="L-4"><a name="L-4"></a> <span class="nb">echo</span> <span class="nv">$i</span> </span><span id="L-5"><a name="L-5"></a><span class="k">done</span> </span></pre></div> </td></tr></table>

VimL

camelCase to under_score notation regex (vim)

%s/\<\u\|\l\u/\=len(submatch(0)) == 1 ? tolower(submatch(0)) : submatch(0)[0].'_'.tolower(submatch(0)[1])/gc
https://snipt.net/embed/02d6e4bda7d78ebbb723ac5fd2159fed/
/raw/02d6e4bda7d78ebbb723ac5fd2159fed/
02d6e4bda7d78ebbb723ac5fd2159fed
vim
VimL
1
2019-06-23T05:26:36
True
False
False
Feb 18, 2013 at 06:48 AM
/api/public/snipt/31541/
camelcase-to-underscore
<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>%s<span class="sr">/\&lt;\u\|\l\u/</span>\<span class="p">=</span>len<span class="p">(</span>submatch<span class="p">(</span><span class="m">0</span><span class="p">))</span> <span class="p">==</span> <span class="m">1</span> ? tolower<span class="p">(</span>submatch<span class="p">(</span><span class="m">0</span><span class="p">))</span> : submatch<span class="p">(</span><span class="m">0</span><span class="p">)</span>[<span class="m">0</span>].<span class="s1">&#39;_&#39;</span>.tolower<span class="p">(</span>submatch<span class="p">(</span><span class="m">0</span><span class="p">)</span>[<span class="m">1</span>]<span class="p">)</span>/gc </span></pre></div> </td></tr></table>
camel_case, vim

Bash

.htaccess php debug

1
2
3
4
5
6
7
php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on
php_flag log_errors on
php_flag ignore_repeated_errors off
php_flag ignore_repeated_source off
php_flag report_memleaks on
https://snipt.net/embed/d35480cb869eddf80dd4814b8717f073/
/raw/d35480cb869eddf80dd4814b8717f073/
d35480cb869eddf80dd4814b8717f073
bash
Bash
7
2019-07-16T08:17:02
True
False
False
/api/public/snipt/30249/
htaccess-php-debug
<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></span><span id="L-1"><a name="L-1"></a>php_flag display_startup_errors on </span><span id="L-2"><a name="L-2"></a>php_flag display_errors on </span><span id="L-3"><a name="L-3"></a>php_flag html_errors on </span><span id="L-4"><a name="L-4"></a>php_flag log_errors on </span><span id="L-5"><a name="L-5"></a>php_flag ignore_repeated_errors off </span><span id="L-6"><a name="L-6"></a>php_flag ignore_repeated_source off </span><span id="L-7"><a name="L-7"></a>php_flag report_memleaks on </span></pre></div> </td></tr></table>
apache, debug, php

PHP

code igniter e-mail regex

1
2
3
<?php

$email_regex = "/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/";
https://snipt.net/embed/cabba05a4806bd98c99637ee62438711/
/raw/cabba05a4806bd98c99637ee62438711/
cabba05a4806bd98c99637ee62438711
php
PHP
3
2019-07-12T17:21:54
True
False
False
/api/public/snipt/30226/
code-igniter-e-mail-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></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">$email_regex</span> <span class="o">=</span> <span class="s2">&quot;/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/&quot;</span><span class="p">;</span> </span></pre></div> </td></tr></table>
e-mail, regex