Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

PHP

Get terms on a archive page

1
2
3
4
5
6
7
<?php
    $queried_object = get_queried_object();
    $term_slug = $queried_object->slug;
    
    echo $term_slug;
    
?>
https://snipt.net/embed/ad8e4eb6eb6f5cd505ca91754ba95051/
https://snipt.net/raw/ad8e4eb6eb6f5cd505ca91754ba95051/
ad8e4eb6eb6f5cd505ca91754ba95051
php
PHP
7
2016-12-08T15:29:07
True
False
False
Nov 22, 2013 at 07:31 AM
/api/public/snipt/95975/
get-terms-on-a-archive-page
<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="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a> <span class="nv">$queried_object</span> <span class="o">=</span> <span class="nx">get_queried_object</span><span class="p">();</span> </span><span id="L-3"><a name="L-3"></a> <span class="nv">$term_slug</span> <span class="o">=</span> <span class="nv">$queried_object</span><span class="o">-&gt;</span><span class="na">slug</span><span class="p">;</span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a> <span class="k">echo</span> <span class="nv">$term_slug</span><span class="p">;</span> </span><span id="L-6"><a name="L-6"></a> </span><span id="L-7"><a name="L-7"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
archive, query, taxonomy, terms, wordpress

Bash

Extracting an Entire tar.gz Archive

tar -xvf [filename].tar.gz
https://snipt.net/embed/513f65aa5c3f3e3f7782b6859d26eecc/
https://snipt.net/raw/513f65aa5c3f3e3f7782b6859d26eecc/
513f65aa5c3f3e3f7782b6859d26eecc
bash
Bash
1
2016-12-09T06:29:22
True
False
False
/api/public/snipt/36516/
extracting-an-entire-targz-archive
<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>tar -xvf <span class="o">[</span>filename<span class="o">]</span>.tar.gz </span></pre></div> </td></tr></table>
archive, extract, gz, tar

Bash

tar but exclude files listed in text file

$ tar cfvzp myfile.tgz -X exclude.txt ../public_html/
https://snipt.net/embed/d9696763b4f3d445a00fa99c06dff02b/
https://snipt.net/raw/d9696763b4f3d445a00fa99c06dff02b/
d9696763b4f3d445a00fa99c06dff02b
bash
Bash
1
2016-12-04T05:26:01
True
False
False
/api/public/snipt/20282/
tar-but-exclude-files-listed-in-text-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>$ tar cfvzp myfile.tgz -X exclude.txt ../public_html/ </span></pre></div> </td></tr></table>
archive, backup, tar

Bash

Archive mail with archivemail into mbox format

archivemail --date=2010-01-15 --dont-mangle --include-flagged -n -v --output-dir=archived imaps://"[email protected]":"password"@mail.domain.com/INBOX.Sent
https://snipt.net/embed/5a2a732eb7e603ba151c4ce70dd869ba/
https://snipt.net/raw/5a2a732eb7e603ba151c4ce70dd869ba/
5a2a732eb7e603ba151c4ce70dd869ba
bash
Bash
1
2016-12-11T05:39:31
True
False
False
/api/public/snipt/11763/
archive-mail-with-archivemail-into-mbox-format
<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>archivemail --date<span class="o">=</span>2010-01-15 --dont-mangle --include-flagged -n -v --output-dir<span class="o">=</span>archived imaps://<span class="s2">&quot;[email protected]&quot;</span>:<span class="s2">&quot;password&quot;</span>@mail.domain.com/INBOX.Sent </span></pre></div> </td></tr></table>
archive, archivemail, backup, email

Bash

Restore and Import MySQL dump

mysql -u username -ppassword database_name < dump.sql
https://snipt.net/embed/db660354aadf4edae6b81839c8a29ff4/
https://snipt.net/raw/db660354aadf4edae6b81839c8a29ff4/
db660354aadf4edae6b81839c8a29ff4
bash
Bash
1
2016-12-11T03:29:19
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
Copyrighted, illegal, or inappropriate content? Email [email protected].