snipt

Ctrl+h for KB shortcuts

Bash

Fix Cygwin fork problem

1
2
3
4
5
6
7
# close all cygwin app
# in cmd.exe type:
cd \cygwin\bin
dash
PATH=.
rebaseall -v
exit
https://snipt.net/embed/515d7dd584294936e8d0d7db5170f8aa/
/raw/515d7dd584294936e8d0d7db5170f8aa/
515d7dd584294936e8d0d7db5170f8aa
bash
Bash
7
2019-06-15T13:35:20
True
False
False
/api/public/snipt/42513/
fix-cygwin-fork-problem
<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><span class="c1"># close all cygwin app</span> </span><span id="L-2"><a name="L-2"></a><span class="c1"># in cmd.exe type:</span> </span><span id="L-3"><a name="L-3"></a><span class="nb">cd</span> <span class="se">\c</span>ygwin<span class="se">\b</span>in </span><span id="L-4"><a name="L-4"></a>dash </span><span id="L-5"><a name="L-5"></a><span class="nv">PATH</span><span class="o">=</span>. </span><span id="L-6"><a name="L-6"></a>rebaseall -v </span><span id="L-7"><a name="L-7"></a><span class="nb">exit</span> </span></pre></div> </td></tr></table>
cygwin, fork, rebasell, windows

ApacheConf

Virtual Host redirect

1
2
3
4
5
<VirtualHost *>
  ServerName www.example.com
  Redirect 301 / http://example.com/
  # 301 = perm, 302 = temporarily
</VirtualHost>
https://snipt.net/embed/5534d09e510ceea8a1a962d74d24dd01/
/raw/5534d09e510ceea8a1a962d74d24dd01/
5534d09e510ceea8a1a962d74d24dd01
apacheconf
ApacheConf
5
2019-06-01T02:38:23
True
False
False
/api/public/snipt/37608/
virtual-host-redirect
<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="nt">&lt;VirtualHost</span> <span class="s">*</span><span class="nt">&gt;</span> </span><span id="L-2"><a name="L-2"></a> <span class="nb">ServerName</span> www.example.com </span><span id="L-3"><a name="L-3"></a> <span class="nb">Redirect</span> <span class="m">301</span> / http://example.com/ </span><span id="L-4"><a name="L-4"></a> <span class="c"># 301 = perm, 302 = temporarily</span> </span><span id="L-5"><a name="L-5"></a><span class="nt">&lt;/VirtualHost&gt;</span> </span></pre></div> </td></tr></table>
apache, http, redirect

Bash

From epoch to date

1
2
3
4
5
6
date -d @1208941833 +"%Y-%m-%d %H:%M:%S"
# 2008-04-23 11:10:33


date +%s
# 1208941833
https://snipt.net/embed/aa7b8d0fb2fc75b6e5ac967eb8459cad/
/raw/aa7b8d0fb2fc75b6e5ac967eb8459cad/
aa7b8d0fb2fc75b6e5ac967eb8459cad
bash
Bash
6
2019-06-12T06:26:49
True
False
False
/api/public/snipt/28287/
from-epoch-to-date
<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>date -d @1208941833 +<span class="s2">&quot;%Y-%m-%d %H:%M:%S&quot;</span> </span><span id="L-2"><a name="L-2"></a><span class="c1"># 2008-04-23 11:10:33</span> </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a>date +%s </span><span id="L-6"><a name="L-6"></a><span class="c1"># 1208941833</span> </span></pre></div> </td></tr></table>
bash, date, epoch

SQL

Create constants in SQL

1
2
3
4
CREATE VIEW V_UTIL_CONSTANTS AS
SELECT 1 AS ONE, 2 AS TWO, 3 AS THREE

SELECT ONE FROM V_UTIL_CONSTANTS
https://snipt.net/embed/675b00599d237ab80fbab669848b0ee0/
/raw/675b00599d237ab80fbab669848b0ee0/
675b00599d237ab80fbab669848b0ee0
sql
SQL
4
2019-06-15T15:22:57
True
False
False
/api/public/snipt/27944/
create-constants-in-sql
<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="k">CREATE</span> <span class="k">VIEW</span> <span class="n">V_UTIL_CONSTANTS</span> <span class="k">AS</span> </span><span id="L-2"><a name="L-2"></a><span class="k">SELECT</span> <span class="mi">1</span> <span class="k">AS</span> <span class="n">ONE</span><span class="p">,</span> <span class="mi">2</span> <span class="k">AS</span> <span class="n">TWO</span><span class="p">,</span> <span class="mi">3</span> <span class="k">AS</span> <span class="n">THREE</span> </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="k">SELECT</span> <span class="n">ONE</span> <span class="k">FROM</span> <span class="n">V_UTIL_CONSTANTS</span> </span></pre></div> </td></tr></table>
constants, sql

Bash

My rsync command

rsync -rtv --delete --size-only --progress -e ssh $ORIGIN $USER@$SERVER:~/$DEST
https://snipt.net/embed/93186811decde1b8c3660cf677f2e4b0/
/raw/93186811decde1b8c3660cf677f2e4b0/
93186811decde1b8c3660cf677f2e4b0
bash
Bash
1
2019-06-15T13:49:45
True
False
False
/api/public/snipt/27840/
my-rsync-command
<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>rsync -rtv --delete --size-only --progress -e ssh <span class="nv">$ORIGIN</span> <span class="nv">$USER</span>@<span class="nv">$SERVER</span>:~/<span class="nv">$DEST</span> </span></pre></div> </td></tr></table>
rsync, sftp, ssh

Bash

Find SMTP server

dig +nocmd $DOMAIN MX +noall +answer | awk '{print $5 " " $6}' | sort  -n | awk '{print substr($2,1,length($2)-1) " " $1 }'
https://snipt.net/embed/34e75d3e86034660caa8f3dcd4c20963/
/raw/34e75d3e86034660caa8f3dcd4c20963/
34e75d3e86034660caa8f3dcd4c20963
bash
Bash
1
2019-06-06T18:22:31
True
False
False
/api/public/snipt/26901/
find-smtp-server
<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>dig +nocmd <span class="nv">$DOMAIN</span> MX +noall +answer <span class="p">|</span> awk <span class="s1">&#39;{print $5 &quot; &quot; $6}&#39;</span> <span class="p">|</span> sort -n <span class="p">|</span> awk <span class="s1">&#39;{print substr($2,1,length($2)-1) &quot; &quot; $1 }&#39;</span> </span></pre></div> </td></tr></table>
dig, dns, mail, smtp