snipt

Ctrl+h for KB shortcuts

Bash

SVN add all new files (not fully tested)

svn status | grep "?" | sed s/'\?\s*'// > to-add
svn add --targets to-add
https://snipt.net/embed/a5ccd3986857401b76b6222272b1492b/
/raw/a5ccd3986857401b76b6222272b1492b/
a5ccd3986857401b76b6222272b1492b
bash
Bash
2
2019-08-23T00:43:01
True
False
False
/api/public/snipt/10364/
svn-add-new-all-new-files-not-fully-tested
<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>svn status <span class="p">|</span> grep <span class="s2">&quot;?&quot;</span> <span class="p">|</span> sed s/<span class="s1">&#39;\?\s*&#39;</span>// &gt; to-add </span><span id="L-2"><a name="L-2"></a>svn add --targets to-add </span></pre></div> </td></tr></table>
bash, svn

Bash

Get packages names from /var/log/yum.log

sed s/'^.*Installed: \([0-9]:\)\?\([a-z0-9_-]*\?\)-.*'/'\2'/gi | sed s/'-[0-9]\+$'//gi
https://snipt.net/embed/e4c8c979199d1c9490a3a3817d16ff9d/
/raw/e4c8c979199d1c9490a3a3817d16ff9d/
e4c8c979199d1c9490a3a3817d16ff9d
bash
Bash
1
2019-08-24T10:51:07
True
False
False
/api/public/snipt/8895/
get-packages-names-from-varlogyumlog
<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>sed s/<span class="s1">&#39;^.*Installed: \([0-9]:\)\?\([a-z0-9_-]*\?\)-.*&#39;</span>/<span class="s1">&#39;\2&#39;</span>/gi <span class="p">|</span> sed s/<span class="s1">&#39;-[0-9]\+$&#39;</span>//gi </span></pre></div> </td></tr></table>
bash, linux, yum

Python

PowerStrings problem solved in one line

power = lambda s : re.match('^(\w+?)\\1+$', s) and (len(s) / len(re.match('^(\w+?)\\1+$', s).group(1))) or 1
https://snipt.net/embed/ef12a091faf3f4403074eff1ac87e548/
/raw/ef12a091faf3f4403074eff1ac87e548/
ef12a091faf3f4403074eff1ac87e548
python
Python
1
2019-08-23T16:39:18
True
False
False
/api/public/snipt/8567/
powerstrings-problem-solved-in-one-line
<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><span class="n">power</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">s</span> <span class="p">:</span> <span class="n">re</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="s1">&#39;^(\w+?)</span><span class="se">\\</span><span class="s1">1+$&#39;</span><span class="p">,</span> <span class="n">s</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">s</span><span class="p">)</span> <span class="o">/</span> <span class="nb">len</span><span class="p">(</span><span class="n">re</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="s1">&#39;^(\w+?)</span><span class="se">\\</span><span class="s1">1+$&#39;</span><span class="p">,</span> <span class="n">s</span><span class="p">)</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">)))</span> <span class="ow">or</span> <span class="mi">1</span> </span></pre></div> </td></tr></table>
acm, power, strings

Bash

Remove .svn directories recursively

find -name .svn -delete
https://snipt.net/embed/12d182d2adecb7887be0fc79ea4cb505/
/raw/12d182d2adecb7887be0fc79ea4cb505/
12d182d2adecb7887be0fc79ea4cb505
bash
Bash
1
2019-08-24T10:24:43
True
False
False
/api/public/snipt/5048/
remove-svn-directories-recursively
<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>find -name .svn -delete </span></pre></div> </td></tr></table>
bash, find, linux, rm, svn

Bash

Get max gidNumber from LDAP Directory

ldapsearch -D cn=Manager,dc=example,dc=com -xW -b ou=People,dc=example,dc=com | grep gidNumber | sed s/'gidNumber: '/''/ | sort -r | head -n1
https://snipt.net/embed/73ec627d170762e6ffdc07a0c6b11e7d/
/raw/73ec627d170762e6ffdc07a0c6b11e7d/
73ec627d170762e6ffdc07a0c6b11e7d
bash
Bash
1
2019-08-21T13:48:09
True
False
False
/api/public/snipt/4665/
get-max-gidnumber-from-ldap-directory
<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>ldapsearch -D <span class="nv">cn</span><span class="o">=</span>Manager,dc<span class="o">=</span>example,dc<span class="o">=</span>com -xW -b <span class="nv">ou</span><span class="o">=</span>People,dc<span class="o">=</span>example,dc<span class="o">=</span>com <span class="p">|</span> grep gidNumber <span class="p">|</span> sed s/<span class="s1">&#39;gidNumber: &#39;</span>/<span class="s1">&#39;&#39;</span>/ <span class="p">|</span> sort -r <span class="p">|</span> head -n1 </span></pre></div> </td></tr></table>
bash, ldap, user

MySQL

Create UTF8 MySQL DataBase

CREATE DATABASE dbname DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci
https://snipt.net/embed/26646f97e04edafa4f7523b725532741/
/raw/26646f97e04edafa4f7523b725532741/
26646f97e04edafa4f7523b725532741
mysql
MySQL
1
2019-08-13T02:57:56
True
False
False
/api/public/snipt/3519/
create-utf8-mysql-database
<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><span class="k">CREATE</span> <span class="k">DATABASE</span> <span class="n">dbname</span> <span class="k">DEFAULT</span> <span class="k">CHARACTER</span> <span class="kt">SET</span> <span class="n">utf8</span> <span class="k">COLLATE</span> <span class="n">utf8_general_ci</span> </span></pre></div> </td></tr></table>
mysql, utf8

Bash

Add a LDAP Entry using a LDIF file

ldapadd -D cn=Manager,dc=example,dc=com -xW -f user.ldif
https://snipt.net/embed/4d08ca43ac8438f8e00a3d0c494b7ca4/
/raw/4d08ca43ac8438f8e00a3d0c494b7ca4/
4d08ca43ac8438f8e00a3d0c494b7ca4
bash
Bash
1
2019-08-11T12:58:39
True
False
False
/api/public/snipt/3320/
add-a-ldap-entry-using-a-ldif-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></span><span id="L-1"><a name="L-1"></a>ldapadd -D <span class="nv">cn</span><span class="o">=</span>Manager,dc<span class="o">=</span>example,dc<span class="o">=</span>com -xW -f user.ldif </span></pre></div> </td></tr></table>
ldap, linux

HTML

Add a class to the body with JavaScript

<script type="text/javascript">document.getElementsByTagName('body')[0].className+=' js'</script>
https://snipt.net/embed/6322b8873ff8524160691103fd67bfb4/
/raw/6322b8873ff8524160691103fd67bfb4/
6322b8873ff8524160691103fd67bfb4
html
HTML
1
2019-08-22T10:07:58
True
False
False
/api/public/snipt/2827/
add-a-class-to-the-body-with-javascript
<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><span class="p">&lt;</span><span class="nt">script</span> <span class="na">type</span><span class="o">=</span><span class="s">&quot;text/javascript&quot;</span><span class="p">&gt;</span><span class="nb">document</span><span class="p">.</span><span class="nx">getElementsByTagName</span><span class="p">(</span><span class="s1">&#39;body&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">].</span><span class="nx">className</span><span class="o">+=</span><span class="s1">&#39; js&#39;</span><span class="p">&lt;/</span><span class="nt">script</span><span class="p">&gt;</span> </span></pre></div> </td></tr></table>
body, html, javascript

HTML

get jQuery from Google

1
2
3
4
5
6
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">google.load('jquery', '1.3.1')</script>

or

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
https://snipt.net/embed/98ccbde3fdb59f7061a65951bd47f07d/
/raw/98ccbde3fdb59f7061a65951bd47f07d/
98ccbde3fdb59f7061a65951bd47f07d
html
HTML
6
2019-08-22T11:49:28
True
False
False
/api/public/snipt/2826/
get-jquery-from-google
<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="p">&lt;</span><span class="nt">script</span> <span class="na">src</span><span class="o">=</span><span class="s">&quot;http://www.google.com/jsapi&quot;</span> <span class="na">type</span><span class="o">=</span><span class="s">&quot;text/javascript&quot;</span><span class="p">&gt;&lt;/</span><span class="nt">script</span><span class="p">&gt;</span> </span><span id="L-2"><a name="L-2"></a><span class="p">&lt;</span><span class="nt">script</span> <span class="na">type</span><span class="o">=</span><span class="s">&quot;text/javascript&quot;</span><span class="p">&gt;</span><span class="nx">google</span><span class="p">.</span><span class="nx">load</span><span class="p">(</span><span class="s1">&#39;jquery&#39;</span><span class="p">,</span> <span class="s1">&#39;1.3.1&#39;</span><span class="p">)&lt;/</span><span class="nt">script</span><span class="p">&gt;</span> </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a>or </span><span id="L-5"><a name="L-5"></a> </span><span id="L-6"><a name="L-6"></a><span class="p">&lt;</span><span class="nt">script</span> <span class="na">type</span><span class="o">=</span><span class="s">&quot;text/javascript&quot;</span> <span class="na">src</span><span class="o">=</span><span class="s">&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js&quot;</span><span class="p">&gt;&lt;/</span><span class="nt">script</span><span class="p">&gt;</span> </span></pre></div> </td></tr></table>
google, jquery