snipt

Ctrl+h for KB shortcuts

Bash

merge multiple PDFs

gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=merged.pdf source1.pdf source2.pdf source3.pdf etc.pdf
https://snipt.net/embed/74c2593c390f1b3d9789a70b118208d8/
/raw/74c2593c390f1b3d9789a70b118208d8/
74c2593c390f1b3d9789a70b118208d8
bash
Bash
1
2019-06-15T17:18:16
True
False
False
/api/public/snipt/37531/
merge-multiple-pdfs
<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>gs -q -dNOPAUSE -dBATCH -sDEVICE<span class="o">=</span>pdfwrite -sOutputFile<span class="o">=</span>merged.pdf source1.pdf source2.pdf source3.pdf etc.pdf </span></pre></div> </td></tr></table>
pdf

Bash

Remove all deleted files from svn

svn status | grep ! | cut -d " " -f 8 | xargs -n 1 svn rm --force
https://snipt.net/embed/0c8f5b88be56994040bac6e8682ffb79/
/raw/0c8f5b88be56994040bac6e8682ffb79/
0c8f5b88be56994040bac6e8682ffb79
bash
Bash
1
2019-06-14T12:31:55
True
False
False
/api/public/snipt/25517/
remove-all-deleted-files-from-svn
<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 status <span class="p">|</span> grep ! <span class="p">|</span> cut -d <span class="s2">&quot; &quot;</span> -f <span class="m">8</span> <span class="p">|</span> xargs -n <span class="m">1</span> svn rm --force </span></pre></div> </td></tr></table>
svn, xargs

Ruby

ssh port forwarding

#This forwards all localhost:1234 connections to google.com:80 through gimli
ssh -L 1234:google.com:80 gimli.cs.berkeley.edu
https://snipt.net/embed/554defb67545e7a2885fa8560c668925/
/raw/554defb67545e7a2885fa8560c668925/
554defb67545e7a2885fa8560c668925
rb
Ruby
2
2019-06-10T04:39:37
True
False
False
/api/public/snipt/8832/
ssh-port-forwarding
<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><span class="c1">#This forwards all localhost:1234 connections to google.com:80 through gimli</span> </span><span id="L-2"><a name="L-2"></a><span class="n">ssh</span> <span class="o">-</span><span class="n">L</span> <span class="mi">1234</span><span class="ss">:google</span><span class="o">.</span><span class="n">com</span><span class="p">:</span><span class="mi">80</span> <span class="n">gimli</span><span class="o">.</span><span class="n">cs</span><span class="o">.</span><span class="n">berkeley</span><span class="o">.</span><span class="n">edu</span> </span></pre></div> </td></tr></table>
forwarding, mysql, server, shell, ssh

Bash

Generate SSH keypairs

ssh-keygen -t rsa
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
https://snipt.net/embed/23674ab97c9298374947d9484e10ccee/
/raw/23674ab97c9298374947d9484e10ccee/
23674ab97c9298374947d9484e10ccee
bash
Bash
3
2019-06-13T16:07:04
True
False
False
/api/public/snipt/6975/
generate-ssh-keypairs
<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>ssh-keygen -t rsa </span><span id="L-2"><a name="L-2"></a>cat ~/.ssh/id_rsa.pub &gt;&gt; ~/.ssh/authorized_keys </span></pre></div> </td></tr></table>
login, security, shell, ssh

Bash

Restore and Import MySQL dump

mysql -u username -ppassword database_name < dump.sql
https://snipt.net/embed/db660354aadf4edae6b81839c8a29ff4/
/raw/db660354aadf4edae6b81839c8a29ff4/
db660354aadf4edae6b81839c8a29ff4
bash
Bash
1
2019-06-13T19:38:34
True
False
False
/api/public/snipt/6904/
restore-and-import-mysql-dump
<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>mysql -u username -ppassword database_name &lt; dump.sql </span></pre></div> </td></tr></table>
archive, backup, mysql, shell

Bash

Backup ALL MySQL DBs

mysqldump -u username -ppassword –all-databases > dump.sql
https://snipt.net/embed/a427e3c7f3e7597add52df495bb61454/
/raw/a427e3c7f3e7597add52df495bb61454/
a427e3c7f3e7597add52df495bb61454
bash
Bash
1
2019-06-15T05:52:15
True
False
False
/api/public/snipt/6903/
backup-all-mysql-dbs
<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 -u username -ppassword –all-databases &gt; dump.sql </span></pre></div> </td></tr></table>
archive, backup, mysql, shell

Bash

SSH Streaming tar

ssh $SERVER tar -czf - $FILEDIR > $LOCALFILE.tgz
https://snipt.net/embed/7586d5131571a483fd351a6ad3d17f4a/
/raw/7586d5131571a483fd351a6ad3d17f4a/
7586d5131571a483fd351a6ad3d17f4a
bash
Bash
1
2019-06-09T12:34:34
True
False
False
/api/public/snipt/6901/
ssh-streaming-tar
<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>ssh <span class="nv">$SERVER</span> tar -czf - <span class="nv">$FILEDIR</span> &gt; <span class="nv">$LOCALFILE</span>.tgz </span></pre></div> </td></tr></table>
archive, shell, ssh, tar

Bash

Backup and compress a MySQL DB

mysqldump $DB_NAME -R -q --user=$USER --password=$PASSWORD --lock-tables | gzip > $BACKUPDIR/$BACKUPNAME
https://snipt.net/embed/ded50795e42c5309713131ffdceee243/
/raw/ded50795e42c5309713131ffdceee243/
ded50795e42c5309713131ffdceee243
bash
Bash
2
2019-06-15T10:16:24
True
False
False
/api/public/snipt/6900/
backup-and-compress-a-mysql-db
<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 <span class="nv">$DB_NAME</span> -R -q --user<span class="o">=</span><span class="nv">$USER</span> --password<span class="o">=</span><span class="nv">$PASSWORD</span> --lock-tables <span class="p">|</span> gzip &gt; <span class="nv">$BACKUPDIR</span>/<span class="nv">$BACKUPNAME</span> </span></pre></div> </td></tr></table>
archive, backup, mysql, shell