snipt

Ctrl+h for KB shortcuts

Bash

Retirer un package des mises à jour apt-get sous Debian

apt-get install wajig
wajig hold <package_name>
https://snipt.net/embed/ee48f3dcee921701c3b6eb703f9fb31e/
/raw/ee48f3dcee921701c3b6eb703f9fb31e/
ee48f3dcee921701c3b6eb703f9fb31e
bash
Bash
2
2019-08-23T07:11:24
True
False
False
/api/public/snipt/5688/
retirer-un-package-des-mises-a-jour-apt-get-sous-debian
<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>apt-get install wajig </span><span id="L-2"><a name="L-2"></a>wajig hold &lt;package_name&gt; </span></pre></div> </td></tr></table>
apt-get, debian, dpkg, linux, update, upgrade

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/
/raw/80961c8e6bfdcdd44503bb9a5ac20f4e/
80961c8e6bfdcdd44503bb9a5ac20f4e
mysql
MySQL
4
2019-08-21T15:49:07
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

JavaScript

Vérifie si le navigateur est Internet Explorer

1
2
3
function isIE() {
	return (navigator.userAgent.indexOf('MSIE') != -1);
}
https://snipt.net/embed/2d1b7424355d8fb27e2f9c2556b83d06/
/raw/2d1b7424355d8fb27e2f9c2556b83d06/
2d1b7424355d8fb27e2f9c2556b83d06
js
JavaScript
3
2019-08-21T15:50:25
True
False
False
/api/public/snipt/4839/
verifie-si-le-navigateur-est-internet-explorer
<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="kd">function</span> <span class="nx">isIE</span><span class="p">()</span> <span class="p">{</span> </span><span id="L-2"><a name="L-2"></a> <span class="k">return</span> <span class="p">(</span><span class="nx">navigator</span><span class="p">.</span><span class="nx">userAgent</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="s1">&#39;MSIE&#39;</span><span class="p">)</span> <span class="o">!=</span> <span class="o">-</span><span class="mi">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>
ie, internetexplorer, javascript, js

Bash

Création d'un certificat SSL autosigné

1
2
3
openssl genrsa -out server.key 1024
openssl req -new -x509 -days 365 -key server.key -out server.crt
openssl x509 -in server.crt -text -noout
https://snipt.net/embed/df70fc641c68772f9d6ec125e8c485d7/
/raw/df70fc641c68772f9d6ec125e8c485d7/
df70fc641c68772f9d6ec125e8c485d7
bash
Bash
3
2019-08-26T01:07:43
True
False
False
/api/public/snipt/4296/
creation-dun-certificat-ssl-autosigne
<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>openssl genrsa -out server.key 1024 </span><span id="L-2"><a name="L-2"></a>openssl req -new -x509 -days <span class="m">365</span> -key server.key -out server.crt </span><span id="L-3"><a name="L-3"></a>openssl x509 -in server.crt -text -noout </span></pre></div> </td></tr></table>
cert, certificat, https, openssl, ssl

PHP

Date au format UTC (RFC 822)

1
2
3
4
<?
date_default_timezone_set('UTC');
date(DATE_RFC822);
?>
https://snipt.net/embed/6407b574c86612ddcf19e23eb35539fb/
/raw/6407b574c86612ddcf19e23eb35539fb/
6407b574c86612ddcf19e23eb35539fb
php
PHP
4
2019-08-21T08:30:28
True
False
False
/api/public/snipt/4267/
date-au-format-utc-rfc-822
<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><span class="cp">&lt;?</span> </span><span id="L-2"><a name="L-2"></a><span class="nb">date_default_timezone_set</span><span class="p">(</span><span class="s1">&#39;UTC&#39;</span><span class="p">);</span> </span><span id="L-3"><a name="L-3"></a><span class="nb">date</span><span class="p">(</span><span class="nx">DATE_RFC822</span><span class="p">);</span> </span><span id="L-4"><a name="L-4"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
date, php, rfc822, utc

PHP

Retourne le type mime d'un fichier

1
2
3
<?
$fileType = mime_content_type($pathToFile);
?>
https://snipt.net/embed/b9c32076c0fdf10d4eb53354059730e3/
/raw/b9c32076c0fdf10d4eb53354059730e3/
b9c32076c0fdf10d4eb53354059730e3
php
PHP
3
2019-08-25T12:20:50
True
False
False
/api/public/snipt/4262/
retourne-le-type-mime-dun-fichier
<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="cp">&lt;?</span> </span><span id="L-2"><a name="L-2"></a><span class="nv">$fileType</span> <span class="o">=</span> <span class="nb">mime_content_type</span><span class="p">(</span><span class="nv">$pathToFile</span><span class="p">);</span> </span><span id="L-3"><a name="L-3"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
fichier, file, mime, type

Bash

Remplacer "de force" le mot de passe de l'utilisateur root de MySQL

1
2
3
4
5
6
7
/etc/init.d/mysql stop
mysqld_safe --skip-grant-tables &
mysql -u root
mysql> use mysql;
mysql> update user set password=PASSWORD("newrootpassword") where user = 'root';
mysql> flush privileges;
mysql> quit
https://snipt.net/embed/365fbc0efc292f94c44ad75430338270/
/raw/365fbc0efc292f94c44ad75430338270/
365fbc0efc292f94c44ad75430338270
bash
Bash
7
2019-08-21T15:51:05
True
False
False
/api/public/snipt/4261/
remplacer-de-force-le-mot-de-passe-de-lutilisateur-root-de-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> <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>/etc/init.d/mysql stop </span><span id="L-2"><a name="L-2"></a>mysqld_safe --skip-grant-tables <span class="p">&amp;</span> </span><span id="L-3"><a name="L-3"></a>mysql -u root </span><span id="L-4"><a name="L-4"></a>mysql&gt; use mysql<span class="p">;</span> </span><span id="L-5"><a name="L-5"></a>mysql&gt; update user <span class="nb">set</span> <span class="nv">password</span><span class="o">=</span>PASSWORD<span class="o">(</span><span class="s2">&quot;newrootpassword&quot;</span><span class="o">)</span> where <span class="nv">user</span> <span class="o">=</span> <span class="s1">&#39;root&#39;</span><span class="p">;</span> </span><span id="L-6"><a name="L-6"></a>mysql&gt; flush privileges<span class="p">;</span> </span><span id="L-7"><a name="L-7"></a>mysql&gt; quit </span></pre></div> </td></tr></table>
admin, motdepasse, mysql, root, serveur

Bash

Tuer Webmin

killall miniserv.pl
https://snipt.net/embed/213e53ea3ce712146dadb7c00b4d5ad5/
/raw/213e53ea3ce712146dadb7c00b4d5ad5/
213e53ea3ce712146dadb7c00b4d5ad5
bash
Bash
1
2019-08-23T18:22:16
True
False
False
/api/public/snipt/4260/
tuer-webmin
<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>killall miniserv.pl </span></pre></div> </td></tr></table>
admin, serveur, webmin

Bash

Déprotège un certificat SSL

openssl rsa -in protected.key > deprotected.key
https://snipt.net/embed/34da4372192e57b393fac9d0e788020d/
/raw/34da4372192e57b393fac9d0e788020d/
34da4372192e57b393fac9d0e788020d
bash
Bash
1
2019-08-25T18:20:10
True
False
False
/api/public/snipt/4259/
deprotege-un-certificat-ssl
<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>openssl rsa -in protected.key &gt; deprotected.key </span></pre></div> </td></tr></table>
admin, key, serveur, ssl