snipt

Ctrl+h for KB shortcuts

Shell Session

wp.sh

1
2
3
4
5
6
# Finds out in which partition (wp) a given file/dir resides.
# Defaults to working directory.
# -----------------------------------------------------------
# http://snipt.net/metalcoder/wpsh
file=${1-.}
df -P $file | tail -1 | cut -d' ' -f 1
https://snipt.net/embed/e2057f158fa6f571e2f799aace9f8489/
https://snipt.net/raw/e2057f158fa6f571e2f799aace9f8489/
e2057f158fa6f571e2f799aace9f8489
shell-session
Shell Session
7
2016-09-21T17:41:18
True
False
False
/api/public/snipt/66239/
wpsh
<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 id="L-1"><a name="L-1"></a><span class="go"># Finds out in which partition (wp) a given file/dir resides.</span> </span><span id="L-2"><a name="L-2"></a><span class="go"># Defaults to working directory.</span> </span><span id="L-3"><a name="L-3"></a><span class="go"># -----------------------------------------------------------</span> </span><span id="L-4"><a name="L-4"></a><span class="go"># http://snipt.net/metalcoder/wpsh</span> </span><span id="L-5"><a name="L-5"></a><span class="go">file=${1-.}</span> </span><span id="L-6"><a name="L-6"></a><span class="go">df -P $file | tail -1 | cut -d&#39; &#39; -f 1</span> </span></pre></div> </td></tr></table>
file-system, linux, shellscript, sysadmin, unix

Nginx configuration file

Redirect 50% of users in nginx

1
2
3
if ($remote_addr ~ "[02468]$") {
    rewrite ^(.*) http://somewhereelse.com/$1;
}
https://snipt.net/embed/974ec8288ef16a88b3bbff8434b8b71e/
https://snipt.net/raw/974ec8288ef16a88b3bbff8434b8b71e/
974ec8288ef16a88b3bbff8434b8b71e
nginx
Nginx configuration file
3
2016-09-23T11:34:02
True
False
False
/api/public/snipt/42258/
redirect-50-of-users-in-nginx
<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></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="k">if</span> <span class="s">(</span><span class="nv">$remote_addr</span> <span class="p">~</span> <span class="sr">&quot;[02468]$&quot;)</span> <span class="p">{</span> </span><span id="L-2"><a name="L-2"></a> <span class="kn">rewrite</span> <span class="s">^(.*)</span> <span class="s">http://somewhereelse.com/</span><span class="nv">$1</span><span class="p">;</span> </span><span id="L-3"><a name="L-3"></a><span class="p">}</span> </span></pre></div> </td></tr></table>
nginx, sysadmin

Text only

Adding PPA repositories

1
2
3
4
5
#get the gpg keys
sudo add-apt-repository ppa:duplicity-team/ppa

# Now edit /etc/apt/sources.list
deb http://ppa.launchpad.net/duplicity-team/ppa/ubuntu YOUR_UBUNTU_VERSION_HERE main 
https://snipt.net/embed/9ea29ba1d7e17d47f0be433eaa4d1caa/
https://snipt.net/raw/9ea29ba1d7e17d47f0be433eaa4d1caa/
9ea29ba1d7e17d47f0be433eaa4d1caa
text
Text only
5
2016-09-22T10:25:47
True
False
False
/api/public/snipt/30232/
adding-ppa-repositories
<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>#get the gpg keys </span><span id="L-2"><a name="L-2"></a>sudo add-apt-repository ppa:duplicity-team/ppa </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a># Now edit /etc/apt/sources.list </span><span id="L-5"><a name="L-5"></a>deb http://ppa.launchpad.net/duplicity-team/ppa/ubuntu YOUR_UBUNTU_VERSION_HERE main </span></pre></div> </td></tr></table>
sysadmin, ubuntu
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.