snipt

Ctrl+h for KB shortcuts

Bash

backup all databases mysql

mysqldump --opt --extended-insert --single-transaction --create-options --default-character-set=utf8 --all-databases --user=<user> --password=<password> > all.sql
https://snipt.net/embed/2b620a12190a51ef2778c379b44721d1/
/raw/2b620a12190a51ef2778c379b44721d1/
2b620a12190a51ef2778c379b44721d1
bash
Bash
1
2019-07-15T17:40:14
True
False
False
/api/public/snipt/4914/
backup-all-databases-mysql
<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>mysqldump --opt --extended-insert --single-transaction --create-options --default-character-set<span class="o">=</span>utf8 --all-databases --user<span class="o">=</span>&lt;user&gt; --password<span class="o">=</span>&lt;password&gt; &gt; all.sql </span></pre></div> </td></tr></table>
backup, mysql, sysadmin

Bash

recursive find in the current directory for a given string

find . -regex ".*.p.*" -and -not -regex ".*\.svn/.*"  -type f -exec grep -H someText {} \; | grep -v ignoreText
https://snipt.net/embed/ae227146d939666568ac48938c150bee/
/raw/ae227146d939666568ac48938c150bee/
ae227146d939666568ac48938c150bee
bash
Bash
1
2019-07-10T07:49:59
True
False
False
/api/public/snipt/4661/
recursive-find-in-the-current-directory-for-a-given-string
<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 . -regex <span class="s2">&quot;.*.p.*&quot;</span> -and -not -regex <span class="s2">&quot;.*\.svn/.*&quot;</span> -type f -exec grep -H someText <span class="o">{}</span> <span class="se">\;</span> <span class="p">|</span> grep -v ignoreText </span></pre></div> </td></tr></table>
find, osx

Bash

simple packet filtering on local host

tcpdump -A -i lo0 port 8080
https://snipt.net/embed/391e44ef7303505434c875f8dce9e54b/
/raw/391e44ef7303505434c875f8dce9e54b/
391e44ef7303505434c875f8dce9e54b
bash
Bash
1
2019-07-19T16:26:28
True
False
False
/api/public/snipt/4102/
simple-packet-filtering-on-local-host
<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>tcpdump -A -i lo0 port 8080 </span></pre></div> </td></tr></table>
sysadmin, tcpdump

Bash

dump a database on one server and load it on another

1
2
3
4
# server
mysqldump -u<user> -p<pass> database | nc -l -p <port>
# client
nc <server> <port> | mysql -u<user> -p<pass> database
https://snipt.net/embed/c4801dc7574c2138cf8c0d8ccbac5042/
/raw/c4801dc7574c2138cf8c0d8ccbac5042/
c4801dc7574c2138cf8c0d8ccbac5042
bash
Bash
4
2019-07-18T15:18:35
True
False
False
/api/public/snipt/3695/
dump-a-database-on-one-server-and-load-it-on-another
<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="c1"># server</span> </span><span id="L-2"><a name="L-2"></a>mysqldump -u&lt;user&gt; -p&lt;pass&gt; database <span class="p">|</span> nc -l -p &lt;port&gt; </span><span id="L-3"><a name="L-3"></a><span class="c1"># client</span> </span><span id="L-4"><a name="L-4"></a>nc &lt;server&gt; &lt;port&gt; <span class="p">|</span> mysql -u&lt;user&gt; -p&lt;pass&gt; database </span></pre></div> </td></tr></table>
mysql, netcat

Bash

merge changes from a branch into the main trunk

svn merge -r30:HEAD <svn branch path>
https://snipt.net/embed/6ac61a8d14d87fd481a588272b82a824/
/raw/6ac61a8d14d87fd481a588272b82a824/
6ac61a8d14d87fd481a588272b82a824
bash
Bash
1
2019-07-09T14:23:48
True
False
False
/api/public/snipt/3244/
merge-changes-from-a-branch-into-the-main-trunk
<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>svn merge -r30:HEAD &lt;svn branch path&gt; </span></pre></div> </td></tr></table>
svn

Bash

find the revision from which a branch was copied

svn log --verbose --stop-on-copy <svn repository path>
https://snipt.net/embed/b083c7e09966ba3d1ec64439f0ba44f8/
/raw/b083c7e09966ba3d1ec64439f0ba44f8/
b083c7e09966ba3d1ec64439f0ba44f8
bash
Bash
1
2019-07-10T00:00:06
True
False
False
/api/public/snipt/3243/
find-the-revision-from-which-a-branch-was-copied
<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>svn log --verbose --stop-on-copy &lt;svn repository path&gt; </span></pre></div> </td></tr></table>
svn

Bash

run file through command

:% ! <command>
https://snipt.net/embed/99ed68c40509dd886716cd3c3e4c63ee/
/raw/99ed68c40509dd886716cd3c3e4c63ee/
99ed68c40509dd886716cd3c3e4c63ee
bash
Bash
1
2019-07-12T06:48:34
True
False
False
/api/public/snipt/2448/
run-file-through-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>:% ! &lt;command&gt; </span></pre></div> </td></tr></table>
vim

Bash

insert output from command into current file

:r!<command>
https://snipt.net/embed/5826234529f090701d12ee5eefec7b9e/
/raw/5826234529f090701d12ee5eefec7b9e/
5826234529f090701d12ee5eefec7b9e
bash
Bash
1
2019-07-09T14:51:09
True
False
False
/api/public/snipt/2447/
insert-output-from-command-into-current-file
<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>:r!&lt;command&gt; </span></pre></div> </td></tr></table>
vim

Bash

mysql: check all tables in all databases

mysqlcheck -u root -p --auto-repair --check --optimize --all-databases
https://snipt.net/embed/6d4279ae5b219885f32e6eee51071999/
/raw/6d4279ae5b219885f32e6eee51071999/
6d4279ae5b219885f32e6eee51071999
bash
Bash
1
2019-07-19T14:20:48
True
False
False
/api/public/snipt/2043/
mysql-check-all-tables-in-all-databases
<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>mysqlcheck -u root -p --auto-repair --check --optimize --all-databases </span></pre></div> </td></tr></table>
dba, mysql, sysadmin

Text only

Indent enclosed code region vim

# position on '{'
=vi{
https://snipt.net/embed/188b81d3f3dfe5e984ae8db2fe8e269f/
/raw/188b81d3f3dfe5e984ae8db2fe8e269f/
188b81d3f3dfe5e984ae8db2fe8e269f
text
Text only
2
2019-07-15T19:46:32
True
False
False
/api/public/snipt/1658/
indent-enclosed-code-region-vim
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a># position on &#39;{&#39; </span><span id="L-2"><a name="L-2"></a>=vi{ </span></pre></div> </td></tr></table>
vim