Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

Bash

add user to group

usermod -a -G ftp tony
https://snipt.net/embed/7551b66e6f5b9673c97eca7e31fb0a5e/
https://snipt.net/raw/7551b66e6f5b9673c97eca7e31fb0a5e/
7551b66e6f5b9673c97eca7e31fb0a5e
bash
Bash
1
2016-12-10T12:15:04
True
False
False
/api/public/snipt/25923/
add-user-to-group-1
<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>usermod -a -G ftp tony </span></pre></div> </td></tr></table>
admin, group, server, user

MySQL

Finding duplicate records in mysql

1
2
3
4
5
SELECT title, COUNT(title) AS num_found
FROM articles
GROUP BY title
HAVING num_found > 1
ORDER BY num_found DESC;
https://snipt.net/embed/fda42d21d2b6ec448a154963753734d3/
https://snipt.net/raw/fda42d21d2b6ec448a154963753734d3/
fda42d21d2b6ec448a154963753734d3
mysql
MySQL
5
2016-12-06T13:49:50
True
False
False
/api/public/snipt/22053/
finding-duplicate-records-in-mysql
<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></span><span id="L-1"><a name="L-1"></a><span class="k">SELECT</span> <span class="n">title</span><span class="p">,</span> <span class="nf">COUNT</span><span class="p">(</span><span class="n">title</span><span class="p">)</span> <span class="k">AS</span> <span class="n">num_found</span> </span><span id="L-2"><a name="L-2"></a><span class="k">FROM</span> <span class="n">articles</span> </span><span id="L-3"><a name="L-3"></a><span class="k">GROUP</span> <span class="k">BY</span> <span class="n">title</span> </span><span id="L-4"><a name="L-4"></a><span class="k">HAVING</span> <span class="n">num_found</span> <span class="o">&gt;</span> <span class="mi">1</span> </span><span id="L-5"><a name="L-5"></a><span class="k">ORDER</span> <span class="k">BY</span> <span class="n">num_found</span> <span class="k">DESC</span><span class="p">;</span> </span></pre></div> </td></tr></table>
count, group, mysql, select

HTML+PHP

Duplicate groups (Magic Fields)

1
2
3
4
5
6
7
8
<?php 
        $fields = get_group('event_faq'); 
        foreach($fields as $field){ ?>
<h4>
        <?php echo $field['faq_title'][1]; ?> </h4>
<?php echo $field['faq_text'][1]; ?>
<div class="separator"></div>
<?php } ?>
https://snipt.net/embed/da41d37f6c107ee59f2fa8a2cb0b14ac/
https://snipt.net/raw/da41d37f6c107ee59f2fa8a2cb0b14ac/
da41d37f6c107ee59f2fa8a2cb0b14ac
html+php
HTML+PHP
8
2016-12-10T07:49:48
True
False
False
/api/public/snipt/14291/
duplicate-groups-magic-fields
<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> <a href="#L-8">8</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">$fields</span> <span class="o">=</span> <span class="nx">get_group</span><span class="p">(</span><span class="s1">&#39;event_faq&#39;</span><span class="p">);</span> </span><span id="L-3"><a name="L-3"></a> <span class="k">foreach</span><span class="p">(</span><span class="nv">$fields</span> <span class="k">as</span> <span class="nv">$field</span><span class="p">){</span> <span class="cp">?&gt;</span> </span><span id="L-4"><a name="L-4"></a><span class="p">&lt;</span><span class="nt">h4</span><span class="p">&gt;</span> </span><span id="L-5"><a name="L-5"></a> <span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nv">$field</span><span class="p">[</span><span class="s1">&#39;faq_title&#39;</span><span class="p">][</span><span class="mi">1</span><span class="p">];</span> <span class="cp">?&gt;</span> <span class="p">&lt;/</span><span class="nt">h4</span><span class="p">&gt;</span> </span><span id="L-6"><a name="L-6"></a><span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nv">$field</span><span class="p">[</span><span class="s1">&#39;faq_text&#39;</span><span class="p">][</span><span class="mi">1</span><span class="p">];</span> <span class="cp">?&gt;</span> </span><span id="L-7"><a name="L-7"></a><span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;separator&quot;</span><span class="p">&gt;&lt;/</span><span class="nt">div</span><span class="p">&gt;</span> </span><span id="L-8"><a name="L-8"></a><span class="cp">&lt;?php</span> <span class="p">}</span> <span class="cp">?&gt;</span> </span></pre></div> </td></tr></table>
group, magicfields, wordpress

Bash

useradd

useradd -d /DIRECTORY/USER_FOLDER -g MAIN_USER_GID_(or group name) -G OTHER,USER,GROUPS -s /sbin/nologin USERNAME
https://snipt.net/embed/2fff73ee83a2bd3ee6e95350b9607eb9/
https://snipt.net/raw/2fff73ee83a2bd3ee6e95350b9607eb9/
2fff73ee83a2bd3ee6e95350b9607eb9
bash
Bash
2
2016-12-10T03:21:02
True
False
False
/api/public/snipt/3019/
useradd
<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>useradd -d /DIRECTORY/USER_FOLDER -g MAIN_USER_GID_<span class="o">(</span>or group name<span class="o">)</span> -G OTHER,USER,GROUPS -s /sbin/nologin USERNAME </span></pre></div> </td></tr></table>
add, bash, group, user
Copyrighted, illegal, or inappropriate content? Email [email protected].