snipt

Ctrl+h for KB shortcuts

PostgreSQL console (psql)

Dump data from postgreSQL and compress it via gzip

psql -d news -c "\copy (select * from cnyes where newstime between '2015-1-1' and '2016-3-31') to stdout WITH (FORMAT CSV, HEADER TRUE, FORCE_QUOTE *)"  | gzip > /home/aha/cnyes.csv.gz
https://snipt.net/embed/7ecf3e734986d2ffd64027234dc64bac/
https://snipt.net/raw/7ecf3e734986d2ffd64027234dc64bac/
7ecf3e734986d2ffd64027234dc64bac
psql
PostgreSQL console (psql)
1
2016-09-30T15:50:43
True
False
False
Apr 09, 2016 at 08:30 AM
/api/public/snipt/145288/
dump-data-from-postgresql-and-compress-it-via-gzip
<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 id="L-1"><a name="L-1"></a><span class="n">psql</span> <span class="o">-</span><span class="n">d</span> <span class="n">news</span> <span class="o">-</span><span class="n">c</span> <span class="s-Name">&quot;\copy (select * from cnyes where newstime between &#39;2015-1-1&#39; and &#39;2016-3-31&#39;) to stdout WITH (FORMAT CSV, HEADER TRUE, FORCE_QUOTE *)&quot;</span> <span class="o">|</span> <span class="n">gzip</span> <span class="o">&gt;</span> <span class="o">/</span><span class="n">home</span><span class="o">/</span><span class="n">aha</span><span class="o">/</span><span class="n">cnyes</span><span class="mf">.</span><span class="k">csv</span><span class="mf">.</span><span class="n">gz</span> </span></pre></div> </td></tr></table>
csv, gzip, postgresql, sql

Text only

.htaccess Gzip Compression

1
2
3
4
5
# BEGIN GZIP
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
</ifmodule>
# END GZIP
https://snipt.net/embed/31208984d23e86248954e9a43d8214b9/
https://snipt.net/raw/31208984d23e86248954e9a43d8214b9/
31208984d23e86248954e9a43d8214b9
text
Text only
5
2016-09-30T14:03:50
True
False
False
/api/public/snipt/122411/
htaccess-gzip-compression-1
<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 id="L-1"><a name="L-1"></a># BEGIN GZIP </span><span id="L-2"><a name="L-2"></a>&lt;ifmodule mod_deflate.c&gt; </span><span id="L-3"><a name="L-3"></a>AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript </span><span id="L-4"><a name="L-4"></a>&lt;/ifmodule&gt; </span><span id="L-5"><a name="L-5"></a># END GZIP </span></pre></div> </td></tr></table>
gzip, htaccess

ApacheConf

GZIP site

1
2
3
4
5
6
7
# Paste this into your .htaccess file
# If server and browser support GZIP
# BEGIN GZIP
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
</ifmodule>
# END GZIP
https://snipt.net/embed/f8d14dd3f2f250f7dcc8384b46c3faf7/
https://snipt.net/raw/f8d14dd3f2f250f7dcc8384b46c3faf7/
f8d14dd3f2f250f7dcc8384b46c3faf7
apacheconf
ApacheConf
7
2016-09-26T01:09:32
True
False
False
/api/public/snipt/40749/
gzip-site
<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 id="L-1"><a name="L-1"></a><span class="c"># Paste this into your .htaccess file</span> </span><span id="L-2"><a name="L-2"></a><span class="c"># If server and browser support GZIP</span> </span><span id="L-3"><a name="L-3"></a><span class="c"># BEGIN GZIP</span> </span><span id="L-4"><a name="L-4"></a><span class="nt">&lt;ifmodule</span> <span class="s">mod_deflate.c</span><span class="nt">&gt;</span> </span><span id="L-5"><a name="L-5"></a><span class="nb">AddOutputFilterByType</span> DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript </span><span id="L-6"><a name="L-6"></a><span class="nt">&lt;/ifmodule&gt;</span> </span><span id="L-7"><a name="L-7"></a><span class="c"># END GZIP</span> </span></pre></div> </td></tr></table>
browser, gzip, htaccess, server

Bash

compress a file

tar -czvf archive.tgz files
https://snipt.net/embed/19b7759abc360f157f9fe4f99477320b/
https://snipt.net/raw/19b7759abc360f157f9fe4f99477320b/
19b7759abc360f157f9fe4f99477320b
bash
Bash
1
2016-09-30T14:22:15
True
False
False
/api/public/snipt/39160/
compress-a-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 id="L-1"><a name="L-1"></a>tar -czvf archive.tgz files </span></pre></div> </td></tr></table>
gzip, tar

PHP

gzip compression

// add to top of php page for compression
<? ob_start("ob_gzhandler"); ?>
https://snipt.net/embed/f9a1510920d667b45e1259107b5f9ee5/
https://snipt.net/raw/f9a1510920d667b45e1259107b5f9ee5/
f9a1510920d667b45e1259107b5f9ee5
php
PHP
2
2016-09-29T07:26:59
True
False
False
/api/public/snipt/29114/
gzip-compression-1
<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 id="L-1"><a name="L-1"></a><span class="x">// add to top of php page for compression</span> </span><span id="L-2"><a name="L-2"></a><span class="cp">&lt;?</span> <span class="nb">ob_start</span><span class="p">(</span><span class="s2">&quot;ob_gzhandler&quot;</span><span class="p">);</span> <span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
gzip, php
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.