snipt

Ctrl+h for KB shortcuts

Bash

formatting for scp command

scp [options] [[[email protected]]host1:]filename1 ... [[[email protected]]host2:]filename2
https://snipt.net/embed/3b24dd09a44d09ff4721c74e1c1f4282/
/raw/3b24dd09a44d09ff4721c74e1c1f4282/
3b24dd09a44d09ff4721c74e1c1f4282
bash
Bash
1
2019-06-18T14:42:52
True
False
False
/api/public/snipt/1866/
formatting-for-scp-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>scp <span class="o">[</span>options<span class="o">]</span> <span class="o">[[</span>[email protected]<span class="o">]</span>host1:<span class="o">]</span>filename1 ... <span class="o">[[</span>[email protected]<span class="o">]</span>host2:<span class="o">]</span>filename2 </span></pre></div> </td></tr></table>
scp

Bash

process a bunch of XML files w/this python script

find . -name '*.xml' -print | xargs python my-python-script.py
https://snipt.net/embed/d43c22f54e66976a68e152388c3939b3/
/raw/d43c22f54e66976a68e152388c3939b3/
d43c22f54e66976a68e152388c3939b3
bash
Bash
1
2019-06-04T06:31:07
True
False
False
/api/public/snipt/1655/
process-a-bunch-of-xml-files-wthis-python-script
<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 . -name <span class="s1">&#39;*.xml&#39;</span> -print <span class="p">|</span> xargs python my-python-script.py </span></pre></div> </td></tr></table>
bash, find, xargs

MySQL

show state & thread ID's of MySQL processes

SHOW PROCESSLIST;
https://snipt.net/embed/48249b7e42ff1283a6efb0212f0f78df/
/raw/48249b7e42ff1283a6efb0212f0f78df/
48249b7e42ff1283a6efb0212f0f78df
mysql
MySQL
1
2019-06-23T09:49:48
True
False
False
/api/public/snipt/1349/
show-state-thread-ids-of-mysql-processes
<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="k">SHOW</span> <span class="n">PROCESSLIST</span><span class="p">;</span> </span></pre></div> </td></tr></table>
mysql, optimization

Bash

List all users

1
2
3
4
$ cat /etc/passwd 

$ cat /etc/passwd | cut -d: -f1 
# only show names
https://snipt.net/embed/e7fbbbaa438dd5473d8734dc8f639374/
/raw/e7fbbbaa438dd5473d8734dc8f639374/
e7fbbbaa438dd5473d8734dc8f639374
bash
Bash
4
2019-05-27T16:06:43
True
False
False
/api/public/snipt/1177/
list-all-users
<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>$ cat /etc/passwd </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>$ cat /etc/passwd <span class="p">|</span> cut -d: -f1 </span><span id="L-4"><a name="L-4"></a><span class="c1"># only show names</span> </span></pre></div> </td></tr></table>
bash

Python

return a string starting w/the last occurrence of '/'

mystring = "http://some.domain/foo/bar/returnedstring"
mystring[-(mystring[::-1].find('/')):]
https://snipt.net/embed/06f35208aac725e4436748e89da6b996/
/raw/06f35208aac725e4436748e89da6b996/
06f35208aac725e4436748e89da6b996
python
Python
3
2019-06-26T03:24:57
True
False
False
/api/public/snipt/690/
return-a-string-starting-wthe-last-occurrence-of
<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="n">mystring</span> <span class="o">=</span> <span class="s2">&quot;http://some.domain/foo/bar/returnedstring&quot;</span> </span><span id="L-2"><a name="L-2"></a><span class="n">mystring</span><span class="p">[</span><span class="o">-</span><span class="p">(</span><span class="n">mystring</span><span class="p">[::</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">)):]</span> </span></pre></div> </td></tr></table>
python, string-manip

ApacheConf

mod_rewrite 301 redirect

RewriteRule ^whatever/(.*)$ http://www.domain.com/$1/ [R=301,L]
https://snipt.net/embed/e4754a4e77c65133b1c9404bb821e45a/
/raw/e4754a4e77c65133b1c9404bb821e45a/
e4754a4e77c65133b1c9404bb821e45a
apacheconf
ApacheConf
1
2019-06-25T14:05:16
True
False
False
/api/public/snipt/438/
mod_rewrite-301-redirect
<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="nb">RewriteRule</span> ^whatever/(.*)$ http://www.domain.com/$1/ [R=301,L] </span></pre></div> </td></tr></table>
apache, mod_rewrite

Bash

mysql dump into file

mysqldump -u USER -p DATABASE > filename.sql
https://snipt.net/embed/4ab6543aeaabfd991684f9a173a932cf/
/raw/4ab6543aeaabfd991684f9a173a932cf/
4ab6543aeaabfd991684f9a173a932cf
bash
Bash
1
2019-06-17T21:18:17
True
False
False
/api/public/snipt/292/
mysql-dump-into-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>mysqldump -u USER -p DATABASE &gt; filename.sql </span></pre></div> </td></tr></table>
backup, mysql

Text only

Drupal CVS checkout for modules

cvs -d:pserver:anonymous:[email protected]:/cvs/drupal-contrib checkout -d views -r HEAD contributions/modules/views
https://snipt.net/embed/d2a6c2ea90831549569bbba30d88efcb/
/raw/d2a6c2ea90831549569bbba30d88efcb/
d2a6c2ea90831549569bbba30d88efcb
text
Text only
1
2019-06-21T23:46:11
True
False
False
/api/public/snipt/9/
drupal-cvs-checkout-for-modules
<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>cvs -d:pserver:anonymous:[email protected]:/cvs/drupal-contrib checkout -d views -r HEAD contributions/modules/views </span></pre></div> </td></tr></table>
cvs, drupal