Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

JavaScript

Limit string length/trim text with jQuery

1
2
3
4
5
6
7
8
jQuery(document).ready(function($){
	$("h3").each(function(){
	        if ($(this).text().length > 30) {
	            $(this).text($(this).text().substr(0, 27)); 
	            $(this).append('...');
	        }
	    });
});
https://snipt.net/embed/cff52cef5e9cd507cea011f043282c54/
https://snipt.net/raw/cff52cef5e9cd507cea011f043282c54/
cff52cef5e9cd507cea011f043282c54
js
JavaScript
8
2016-12-10T07:42:47
True
False
False
/api/public/snipt/43488/
limit-string-lengthtrim-text-with-jquery
<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="nx">jQuery</span><span class="p">(</span><span class="nb">document</span><span class="p">).</span><span class="nx">ready</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">$</span><span class="p">){</span> </span><span id="L-2"><a name="L-2"></a> <span class="nx">$</span><span class="p">(</span><span class="s2">&quot;h3&quot;</span><span class="p">).</span><span class="nx">each</span><span class="p">(</span><span class="kd">function</span><span class="p">(){</span> </span><span id="L-3"><a name="L-3"></a> <span class="k">if</span> <span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">text</span><span class="p">().</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="mi">30</span><span class="p">)</span> <span class="p">{</span> </span><span id="L-4"><a name="L-4"></a> <span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">text</span><span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">text</span><span class="p">().</span><span class="nx">substr</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">27</span><span class="p">));</span> </span><span id="L-5"><a name="L-5"></a> <span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">append</span><span class="p">(</span><span class="s1">&#39;...&#39;</span><span class="p">);</span> </span><span id="L-6"><a name="L-6"></a> <span class="p">}</span> </span><span id="L-7"><a name="L-7"></a> <span class="p">});</span> </span><span id="L-8"><a name="L-8"></a><span class="p">});</span> </span></pre></div> </td></tr></table>
javascript, jquery, length, limit, trim

Text only

restrict users in Linux to their home directory

1
2
3
4
# Restrict users in Linux to their home directory
# Edit /etc/vsftpd/vsftpd.conf
chroot_local_user=YES
# Then: service vsftpd restart
https://snipt.net/embed/065cb36facb1158cae2f5eaec671327e/
https://snipt.net/raw/065cb36facb1158cae2f5eaec671327e/
065cb36facb1158cae2f5eaec671327e
text
Text only
4
2016-12-07T18:22:30
True
False
False
/api/public/snipt/27213/
restrict-users-in-linux-to-their-home-directory
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a># Restrict users in Linux to their home directory </span><span id="L-2"><a name="L-2"></a># Edit /etc/vsftpd/vsftpd.conf </span><span id="L-3"><a name="L-3"></a>chroot_local_user=YES </span><span id="L-4"><a name="L-4"></a># Then: service vsftpd restart </span></pre></div> </td></tr></table>
directory, ftp, home, limit, restrict

MySQL

Méthode pour compter les résultats depuis un SELECT utilisant une clause LIMIT

1
2
3
SELECT SQL_CALC_FOUND_ROWS * FROM tbl_name
WHERE id > 100 LIMIT 10;
SELECT FOUND_ROWS();
https://snipt.net/embed/80961c8e6bfdcdd44503bb9a5ac20f4e/
https://snipt.net/raw/80961c8e6bfdcdd44503bb9a5ac20f4e/
80961c8e6bfdcdd44503bb9a5ac20f4e
mysql
MySQL
4
2016-12-10T06:13:29
True
False
False
/api/public/snipt/4984/
methode-pour-compter-les-resultats-depuis-un-select-utilisant-une-clause-limit
<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></span><span id="L-1"><a name="L-1"></a><span class="k">SELECT</span> <span class="k">SQL_CALC_FOUND_ROWS</span> <span class="o">*</span> <span class="k">FROM</span> <span class="n">tbl_name</span> </span><span id="L-2"><a name="L-2"></a><span class="k">WHERE</span> <span class="n">id</span> <span class="o">&gt;</span> <span class="mi">100</span> <span class="k">LIMIT</span> <span class="mi">10</span><span class="p">;</span> </span><span id="L-3"><a name="L-3"></a><span class="k">SELECT</span> <span class="nf">FOUND_ROWS</span><span class="p">();</span> </span></pre></div> </td></tr></table>
count, couting, found_rows, limit, mysql, select, sql, sql_calc_found_rows
Copyrighted, illegal, or inappropriate content? Email [email protected].