Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

Bash

Tar ball tar.gz compress quick

#!/bin/bash
tar -cvzf $1.tar.gz $1
https://snipt.net/embed/55ef009ae34e3468eecef57053db1179/
https://snipt.net/raw/55ef009ae34e3468eecef57053db1179/
55ef009ae34e3468eecef57053db1179
bash
Bash
2
2016-12-04T22:03:07
True
False
False
/api/public/snipt/95069/
tar-ball-targz-compress-quick
<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="ch">#!/bin/bash</span> </span><span id="L-2"><a name="L-2"></a>tar -cvzf <span class="nv">$1</span>.tar.gz <span class="nv">$1</span> </span></pre></div> </td></tr></table>
compress, gz, tar, zip

Bash

Compress an entire folder

tar -cvf [filename].tar.gz [folder path]
https://snipt.net/embed/fcdf41273abb586a4ab641097ebf3798/
https://snipt.net/raw/fcdf41273abb586a4ab641097ebf3798/
fcdf41273abb586a4ab641097ebf3798
bash
Bash
1
2016-12-03T11:13:13
True
False
False
/api/public/snipt/35963/
compress-an-entire-folder
<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 -cvf <span class="o">[</span>filename<span class="o">]</span>.tar.gz <span class="o">[</span>folder path<span class="o">]</span> </span></pre></div> </td></tr></table>
compress, folder, gz, linux, tar, zip

Text only

code added to .htaccess to enable compression of certain served content using Apache mod_deflate

# compress all text & html
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/x-js text/css application/x-javascript application/javascript
https://snipt.net/embed/00eeb47352ae3f9782f4de7d88b1406c/
https://snipt.net/raw/00eeb47352ae3f9782f4de7d88b1406c/
00eeb47352ae3f9782f4de7d88b1406c
text
Text only
2
2016-12-05T06:41:08
True
False
False
/api/public/snipt/14175/
code-added-to-htaccess-to-enable-compression-of-certain-served-content-using-apache-mod_deflate
<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># compress all text &amp; html </span><span id="L-2"><a name="L-2"></a>AddOutputFilterByType DEFLATE text/html text/plain text/xml text/x-js text/css application/x-javascript application/javascript </span></pre></div> </td></tr></table>
apache, compress, compression, htaccess, mod_deflate

ApacheConf

.htaccess for serving .js files as gzipped

1
2
3
4
5
6
7
RewriteEngine on
RewriteCond %{HTTP:Accept-Encoding} gzip
#RewriteCond %{HTTP_USER_AGENT} !Safari
RewriteCond %{REQUEST_FILENAME}.jgz -f
RewriteRule (.*)\.js$ $1\.js.jgz [L]
AddType "text/javascript" .js.jgz
AddEncoding gzip .jgz
https://snipt.net/embed/75606e4eafd8610ad7d2f6a036041799/
https://snipt.net/raw/75606e4eafd8610ad7d2f6a036041799/
75606e4eafd8610ad7d2f6a036041799
apacheconf
ApacheConf
7
2016-12-05T06:33:13
True
False
False
/api/public/snipt/9920/
htaccess-for-serving-js-files-as-gzipped
<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="nb">RewriteEngine</span> <span class="k">on</span> </span><span id="L-2"><a name="L-2"></a><span class="nb">RewriteCond</span> %{HTTP:Accept-Encoding} gzip </span><span id="L-3"><a name="L-3"></a><span class="c">#RewriteCond %{HTTP_USER_AGENT} !Safari</span> </span><span id="L-4"><a name="L-4"></a><span class="nb">RewriteCond</span> %{REQUEST_FILENAME}.jgz -f </span><span id="L-5"><a name="L-5"></a><span class="nb">RewriteRule</span> (.*)\.js$ $1\.js.jgz [L] </span><span id="L-6"><a name="L-6"></a><span class="nb">AddType</span> <span class="s2">&quot;text/javascript&quot;</span> .js.jgz </span><span id="L-7"><a name="L-7"></a><span class="nb">AddEncoding</span> gzip .jgz </span></pre></div> </td></tr></table>
.htccess, compress, gzip, javascript

Bash

Compress font files for use with @font-face

1
2
3
4
5
6
# Compress font files for use with @font-face
Addtype font/opentype .otf
Addtype font/truetype .ttf
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css font/opentype font/truetype

# Comments: Both these declarations require their appropriate modules to be active: mod_mime and mod_deflate. And for best practice, the AddType declaration should be in the mime.conf file, and the AddOutputFilterByType declaration should be in the deflate.conf file. See your particular distribution's help files for enabling and configuring Apache modules.
https://snipt.net/embed/c84599fafe2526ca8e7e05460b94827d/
https://snipt.net/raw/c84599fafe2526ca8e7e05460b94827d/
c84599fafe2526ca8e7e05460b94827d
bash
Bash
6
2016-12-05T04:14:58
True
False
False
/api/public/snipt/9204/
compress-font-files-for-use-with-font-face
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c1"># Compress font files for use with @font-face</span> </span><span id="L-2"><a name="L-2"></a>Addtype font/opentype .otf </span><span id="L-3"><a name="L-3"></a>Addtype font/truetype .ttf </span><span id="L-4"><a name="L-4"></a>AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css font/opentype font/truetype </span><span id="L-5"><a name="L-5"></a> </span><span id="L-6"><a name="L-6"></a><span class="c1"># Comments: Both these declarations require their appropriate modules to be active: mod_mime and mod_deflate. And for best practice, the AddType declaration should be in the mime.conf file, and the AddOutputFilterByType declaration should be in the deflate.conf file. See your particular distribution&#39;s help files for enabling and configuring Apache modules.</span> </span></pre></div> </td></tr></table>
@font-face, compress, fonts, gzip, htaccess

Bash

Tar to a pipe, doesnt use diskspace

tar -cf - ./filename | (cd other-directory; tar -xf -)
https://snipt.net/embed/f400281d56a70cd05b1e5f06a2b9b346/
https://snipt.net/raw/f400281d56a70cd05b1e5f06a2b9b346/
f400281d56a70cd05b1e5f06a2b9b346
bash
Bash
1
2016-12-02T17:18:30
True
False
False
/api/public/snipt/6899/
tar-to-a-pipe-doesnt-use-diskspace
<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 -cf - ./filename <span class="p">|</span> <span class="o">(</span><span class="nb">cd</span> other-directory<span class="p">;</span> tar -xf -<span class="o">)</span> </span></pre></div> </td></tr></table>
compress, shell, ssh, tar
Copyrighted, illegal, or inappropriate content? Email [email protected].