<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
 xmlns:dc="http://purl.org/dc/elements/1.1/"
 xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title><![CDATA[Godefroy de Compreignac]]></title>
	<description><![CDATA[Flux RSS des articles]]></description>
	<pubDate>Thu, 02 Sep 2010 15:42:40 +0200</pubDate>
	<link>http://www.skreo.net</link>
	<language>fr</language>
	<generator>http://www.eklablog.com</generator>
	
	<item>
		<title><![CDATA[[Linux] Switcher entre Dual Screen et Mono Screen sans redémarrer le serveur X]]></title>
		<link>http://www.skreo.net/linux-switcher-entre-dual-screen-et-mono-screen-sans-redemarrer-le-ser-a1442268</link>
		<description><![CDATA[Depuis un an, j'utilise un portable Dell XPS Studio avec un deuxi&egrave;me &eacute;cran (Asus 26&quot;). Ma carte graphique est une Nvidia &nbsp;GeForce 9400M G. Mon probl&egrave;me, c'est que j'emporte souvent mon laptop en dehors de chez moi, et j'ai donc besoin de pouvoir passer facilement entre une configuration &agrave; 2...]]></description>
		<content:encoded><![CDATA[<p>Depuis un an, j'utilise un portable Dell XPS Studio avec un <strong>deuxi&egrave;me &eacute;cran</strong> (Asus 26"). Ma carte graphique est une <strong>Nvidia</strong>&nbsp;GeForce 9400M G.</p>
<p>Mon probl&egrave;me, c'est que j'emporte souvent mon laptop en dehors de chez moi, et j'ai donc besoin de pouvoir <strong>passer facilement entre une configuration &agrave; 2 &eacute;crans (dual screen) et une configuration &agrave; 1 &eacute;cran</strong>. Jusqu'&agrave; maintenant, j'avais deux fichiers <em>/etc/X11/xorg.conf</em>, et je m'&eacute;tais fait un raccourci pour switcher entre les deux et red&eacute;marrer le serveur X. Mais ce n'est vraiment pas pratique, car red&eacute;marrer le serveur X signifie tuer tous les programmes ouverts et recommencer une nouvelle session, ce qui en plus prend du temps...</p>
<p>Aujourd'hui, je suis pass&eacute; &agrave; la derni&egrave;re version d'Ubuntu Lucid Lynx en r&eacute;installant tout (sauf ma partition <em>/home</em>), et pour partir sur de bonnes bases, j'ai enfin d&eacute;cid&eacute; de prendre le temps de trouver une solution &agrave; mon probl&egrave;me de dual screen.<br/><br/>Et au bout de plusieurs heures de recherche (-_-), j'en enfin trouv&eacute; une solution tr&egrave;s simple.<br/><strong>Attention ! </strong>Je ne sais pas si elle fonctionne avec autre chose qu'une carte Nvidia et son driver propri&eacute;taire.<br/><br/>R&eacute;glez votre <em>/etc/X11/xorg.conf</em> pour le dual screen, puis trouvez la ligne du <strong>Option "metamodes"</strong>. Cette ligne contient le positionnement des deux &eacute;crans. Au lieu de n'y mettre que la configuration du positionnement pour deux &eacute;crans, mettez &eacute;galement celle pour un seul &eacute;cran, en s&eacute;parant les deux par un point-virgule (;).<br/><br/>Un exemple vaut mieux qu'un long discours, donc dans mon cas, c'&eacute;tait comme &ccedil;a :<br/>La ligne &agrave; modifier dans le&nbsp;<em>/etc/X11/xorg.conf</em> en dual screen :<br/><div class="code"><span style="color: #990000;">Option</span> <span style="color: #0000ff;">&quot;metamodes&quot;</span> <span style="color: #0000ff;">&quot;DFP-0: nvidia-auto-select +0+507, DFP-1: nvidia-auto-select +1280+0&quot;</span><div style="display:none;">[code=xorg_conf]Option "metamodes" "DFP-0: nvidia-auto-select +0+507, DFP-1: nvidia-auto-select +1280+0"[/code]</div></div>&nbsp;<br/><br/>La ligne correspondante dans le&nbsp;<em>xorg.conf</em>&nbsp;pour un seul &eacute;cran :<br/><div class="code"><span style="color: #990000;">Option</span> <span style="color: #0000ff;">&quot;metamodes&quot;</span> <span style="color: #0000ff;">&quot;DFP-0: nvidia-auto-select +0+0, DFP-1: NULL&quot;</span><div style="display:none;">[code=xorg_conf]Option "metamodes" "DFP-0: nvidia-auto-select +0+0, DFP-1: NULL"[/code]</div></div>&nbsp;<br/><br/>Et &agrave; la fin, on veut &ccedil;a :<br/><div class="code"><span style="color: #990000;">Option</span> <span style="color: #0000ff;">&quot;metamodes&quot;</span> <span style="color: #0000ff;">&quot;DFP-0: nvidia-auto-select +0+0, DFP-1: NULL; DFP-0: nvidia-auto-select +0+507, DFP-1: nvidia-auto-select +1280+0&quot;</span><div style="display:none;">[code=xorg_conf]Option "metamodes" "DFP-0: nvidia-auto-select +0+0, DFP-1: NULL;&nbsp;DFP-0: nvidia-auto-select +0+507, DFP-1: nvidia-auto-select +1280+0"[/code]</div></div><br/><br/>Red&eacute;marrez ensuite le serveur X (c'est la derni&egrave;re fois que vous aurez &agrave; le faire), en appuyant sur AltGr+Impr+K.<br/><br/>Puis installez le paquet "xrandr" s'il n'est pas encore install&eacute; :<br/><div class="code"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span> xrandr<div style="display:none;">[code=bash]sudo aptitude install xrandr[/code]</div></div><br/><br/>Et maintenant, pour passer d'une configuration &agrave; une autre :<br/><div class="code"><span style="color: #666666; font-style: italic;"># Mode 1 écran</span><br />
xrandr <span style="color: #660033;">-s</span> <span style="color: #000000;">0</span><br />
<span style="color: #666666; font-style: italic;"># Mode 2 écrans</span><br />
xrandr <span style="color: #660033;">-s</span> <span style="color: #000000;">1</span><div style="display:none;">[code=bash]# Mode 1 &eacute;cran<br/>xrandr -s 0<br/># Mode 2 &eacute;crans<br/>xrandr -s 1[/code]</div></div><br/><br/>Vous pouvez ensuite vous cr&eacute;er des raccourcis pour ces deux commandes, les scripter...etc.<br/><br/>Si vous avez une remarque, une astuce diff&eacute;rente ou si vous savez comme faire la m&ecirc;me chose avec une autre carte graphique, n'h&eacute;sitez pas &agrave; commenter cet article ;-)</p><br /><br /><strong>Partager cet article :</strong> <a href="javascript:;" onclick="window.open('http://ek.la/twitter?blog=1535&amp;path=linux-switcher-entre-dual-screen-et-mono-screen-sans-redemarrer-le-ser-a1442268&amp;title=%5BLinux%5D+Switcher+entre+Dual+Screen+et+Mono+Screen+sans+red%C3%A9marrer+le+serveur+X');" onmouseover="if(Help.bubble) Help.bubble(this, &quot;Diffuser sur Twitter&quot;);"><img src="http://www.skreo.net//images/bookmarks/retweet.png" alt="Retweet" class="icon" /></a> <a href="http://www.wikio.fr/vote?url=http%3A%2F%2Fwww.skreo.net%2Flinux-switcher-entre-dual-screen-et-mono-screen-sans-redemarrer-le-ser-a1442268" onmouseover="if(Help.bubble) Help.bubble(this, &quot;Voter sur wikio&quot;);"><img src="http://www.skreo.net//images/bookmarks/wikio.gif" alt="Wikio" class="icon" /></a> <iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.skreo.net%2Flinux-switcher-entre-dual-screen-et-mono-screen-sans-redemarrer-le-ser-a1442268&amp;layout=button_count&amp;show_faces=false&amp;width=110&amp;action=like&amp;colorscheme=light&amp;height=20" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:110px; height:20px;" class="icon" allowTransparency="true"></iframe><br /><br /><hr />Article original rédigé par Skreo et publié sur <a href="http://skreo.eklablog.com">Godefroy de Compreignac</a> <br /> Reproduction interdite sans autorisation]]></content:encoded>
		<pubDate>Fri, 16 Jul 2010 18:27:52 +0200</pubDate>
		<guid isPermaLink="true">http://www.skreo.net/linux-switcher-entre-dual-screen-et-mono-screen-sans-redemarrer-le-ser-a1442268</guid>
		<dc:creator>Skreo</dc:creator>
		<dc:date>2010-07-16T18:27:52+02:00</dc:date>
	</item>
	<item>
		<title><![CDATA[[SVN] Être averti en temps réel des commits envoyés]]></title>
		<link>http://www.skreo.net/svn-etre-averti-en-temps-reel-des-commits-envoyes-a890030</link>
		<description><![CDATA[Quand on travaille sur un projet avec plusieurs personnes et qu'on utilise SVN , il peut &ecirc;tre utile d'&ecirc;tre averti en temps r&eacute;el des commits qu'envoient les autres collaborateurs. Je me suis inspir&eacute; de l'id&eacute;e de Metrokid et du script de Christophe-Marie pour faire un petit script de...]]></description>
		<content:encoded><![CDATA[<p>Quand on travaille sur un projet avec plusieurs personnes et qu'on utilise <a href="http://subversion.tigris.org/">SVN</a>, il peut &ecirc;tre utile d'&ecirc;tre <strong>averti en temps r&eacute;el des commits</strong> qu'envoient les autres collaborateurs.</p>
<p>Je me suis inspir&eacute; de l'id&eacute;e de <a href="http://metrokid.fr/2009/08/petit-outil-pour-se-tenir-au-courant-en-temps-reel-des-changements-sur-un-svn/">Metrokid</a> et du script de <a href="http://chm.duquesne.free.fr/blog/?p=116">Christophe-Marie</a> pour faire un petit script de notification&nbsp;par <a href="http://en.wikipedia.org/wiki/Cron">Cron</a>.</p>
<p>Nous aurons besoin de la commande <em>notify-send</em> disponible dans le paquet <em>libnotify-bin</em>. Si vous ne l'avez pas, installez le :<br /><div class="code">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">aptitude</span>  <span style="color: #c20cb9; font-weight: bold;">install</span> libnotify-bin<div style="display:none;">[code=bash]$ sudo aptitude &nbsp;install libnotify-bin[/code]</div></div></p>
<p>Et voil&agrave; notre petit script, que nous nommerons <em>.svn-monitor.sh</em> et que nous placerons dans le dossier home de l'utilisateur courant ($HOME) :</p>
<p><div class="code"><span style="color: #666666; font-style: italic;">#!/bin/bash</span><br />
&nbsp;<br />
&nbsp;<span style="color: #666666; font-style: italic;"># Pour que cron sache sur quel moniteur afficher la notification</span><br />
&nbsp;<span style="color: #007800;">DISPLAY</span>=:<span style="color: #000000;">0.0</span><br />
&nbsp;<br />
&nbsp;<span style="color: #666666; font-style: italic;"># Fichier dans lequel on stocke la date de dernière révision testée</span><br />
&nbsp;<span style="color: #007800;">LOGFILE</span>=<span style="color: #007800;">$HOME</span><span style="color: #000000; font-weight: bold;">/</span>.svn-monitor<br />
&nbsp;<span style="color: #666666; font-style: italic;"># URL du dépôt SVN</span><br />
&nbsp;<span style="color: #007800;">SVNPATH</span>=http:<span style="color: #000000; font-weight: bold;">//</span>url-du-depot<br />
&nbsp;<span style="color: #666666; font-style: italic;"># Nom d'utilisateur dont les révisions ne seront pas affichées</span><br />
&nbsp;<span style="color: #007800;">USERNAME</span>=Skreo<br />
&nbsp;<span style="color: #666666; font-style: italic;"># Icône utilisée dans la fenêtre de notification</span><br />
&nbsp;<span style="color: #007800;">ICON</span>=<span style="color: #ff0000;">'/usr/share/icons/gnome/32x32/status/dialog-information.png'</span><br />
&nbsp;<span style="color: #666666; font-style: italic;"># Durée d'affichage de la fenêtre de notification</span><br />
&nbsp;<span style="color: #007800;">DURATION</span>=<span style="color: #000000;">5000</span><br />
&nbsp;<br />
&nbsp;<span style="color: #666666; font-style: italic;"># Révision à vérifier</span><br />
&nbsp;<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$LOGFILE</span> ; <span style="color: #000000; font-weight: bold;">then</span><br />
    <span style="color: #007800;">REV</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$LOGFILE</span><span style="color: #000000; font-weight: bold;">`</span> +<span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
&nbsp;<span style="color: #000000; font-weight: bold;">else</span><br />
    <span style="color: #007800;">REV</span>=HEAD<br />
&nbsp;<span style="color: #000000; font-weight: bold;">fi</span><br />
&nbsp;<br />
&nbsp;<span style="color: #666666; font-style: italic;"># Récupération du log de la dernière révision</span><br />
&nbsp;<span style="color: #007800;">TEXT</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">svn</span> log <span style="color: #007800;">$SVNPATH</span> <span style="color: #660033;">-r</span> <span style="color: #007800;">$REV</span>:HEAD <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-r</span> <span style="color: #ff0000;">&quot;s/^-+$/---/&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-r</span> <span style="color: #ff0000;">&quot;s/^r([0-9]+) \| ([^ ]+) \| [^(]*\(([^)]+)\).*$/rév \1 par \2 le \3/&quot;</span><span style="color: #000000; font-weight: bold;">`</span><br />
&nbsp;<br />
&nbsp;<span style="color: #666666; font-style: italic;"># Si on obtient un résultat, on l'affiche</span><br />
&nbsp;<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$TEXT</span>&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;&quot;</span> ; <span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp;<br />
    <span style="color: #666666; font-style: italic;"># Détermination de la dernière révision</span><br />
    <span style="color: #007800;">LASTREV</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$TEXT</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-r</span> <span style="color: #ff0000;">&quot;s/^(.*rév ([0-9]+) .*|.*)$/\2/&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> NF <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #660033;">-nr</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">head</span> -<span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">`</span><br />
&nbsp;<br />
    <span style="color: #666666; font-style: italic;"># Suppression de l'affichage des révisions faîtes par $USERNAME</span><br />
    <span style="color: #007800;">TEXT</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$TEXT</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-r</span> <span style="color: #ff0000;">&quot;s/<span style="color: #007800;">$USERNAME</span>/-/g&quot;</span><span style="color: #000000; font-weight: bold;">`</span><br />
    <span style="color: #007800;">TEXT</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$TEXT</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-r</span> <span style="color: #ff0000;">':a;N;$!ba;s/---\nrév [0-9]+ par - .*\n---/---/g'</span><span style="color: #000000; font-weight: bold;">`</span><br />
&nbsp;<br />
    <span style="color: #666666; font-style: italic;"># Suppression de la première et de la dernière ligne, et suppression des lignes vides</span><br />
    <span style="color: #007800;">TEXT</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$TEXT</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'1d'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'$d'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> NF<span style="color: #000000; font-weight: bold;">`</span><br />
&nbsp;<br />
    <span style="color: #666666; font-style: italic;"># Affichage de la notification</span><br />
    notify-send <span style="color: #660033;">-t</span> <span style="color: #007800;">$DURATION</span> <span style="color: #660033;">-i</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$ICON</span>&quot;</span> <span style="color: #ff0000;">&quot;SVN&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$TEXT</span>&quot;</span><br />
&nbsp;<br />
    <span style="color: #666666; font-style: italic;"># Et on l'enregistre dans le fichier</span><br />
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$LASTREV</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$LOGFILE</span><br />
&nbsp;<span style="color: #000000; font-weight: bold;">fi</span><div style="display:none;">[code=bash]#!/bin/bash<br /> <br /> # Pour que cron sache sur quel moniteur afficher la notification<br /> DISPLAY=:0.0<br /> <br /> # Fichier dans lequel on stocke la date de derni&egrave;re r&eacute;vision test&eacute;e<br /> LOGFILE=$HOME/.svn-monitor<br /> # URL du d&eacute;p&ocirc;t SVN<br /> SVNPATH=http://url-du-depot<br /> # Nom d'utilisateur dont les r&eacute;visions ne seront pas affich&eacute;es<br /> USERNAME=Skreo<br /> # Ic&ocirc;ne utilis&eacute;e dans la fen&ecirc;tre de notification<br /> ICON='/usr/share/icons/gnome/32x32/status/dialog-information.png'<br /> # Dur&eacute;e d'affichage de la fen&ecirc;tre de notification<br /> DURATION=5000<br /> <br /> # R&eacute;vision &agrave; v&eacute;rifier<br /> if test -f $LOGFILE ; then<br />&nbsp;&nbsp; &nbsp;REV=$(( `cat $LOGFILE` +1 ))<br /> else<br />&nbsp;&nbsp; &nbsp;REV=HEAD<br /> fi<br /> <br /> # R&eacute;cup&eacute;ration du log de la derni&egrave;re r&eacute;vision<br /> TEXT=`svn log $SVNPATH -r $REV:HEAD | sed -r "s/^-+$/---/" | sed -r "s/^r([0-9]+) \| ([^ ]+) \| [^(]*\(([^)]+)\).*$/r&eacute;v \1 par \2 le \3/"`<br /> <br /> # Si on obtient un r&eacute;sultat, on l'affiche<br /> if test "$TEXT" != "" ; then<br /> <br />&nbsp;&nbsp; &nbsp;# D&eacute;termination de la derni&egrave;re r&eacute;vision<br />&nbsp;&nbsp; &nbsp;LASTREV=`echo -e "$TEXT" | sed -r "s/^(.*r&eacute;v ([0-9]+) .*|.*)$/\2/" | awk NF | sort -nr | head -1`<br /> <br />&nbsp;&nbsp; &nbsp;# Suppression de l'affichage des r&eacute;visions fa&icirc;tes par $USERNAME<br />&nbsp;&nbsp; &nbsp;TEXT=`echo "$TEXT" | sed -r "s/$USERNAME/-/g"`<br />&nbsp;&nbsp; &nbsp;TEXT=`echo "$TEXT" | sed -r ':a;N;$!ba;s/---\nr&eacute;v [0-9]+ par - .*\n---/---/g'`<br /> <br />&nbsp;&nbsp; &nbsp;# Suppression de la premi&egrave;re et de la derni&egrave;re ligne, et suppression des lignes vides<br />&nbsp;&nbsp; &nbsp;TEXT=`echo "$TEXT" | sed '1d' | sed '$d' | awk NF`<br /> <br />&nbsp;&nbsp; &nbsp;# Affichage de la notification<br />&nbsp;&nbsp; &nbsp;notify-send -t $DURATION -i "$ICON" "SVN" "$TEXT"<br /> <br />&nbsp;&nbsp; &nbsp;# Et on l'enregistre dans le fichier<br />&nbsp;&nbsp; &nbsp;echo $LASTREV &gt; $LOGFILE<br /> fi[/code]</div></div></p>
<p>Il ne reste ensuite plus qu'&agrave; l'ex&eacute;cuter par cron toutes les 5 minutes par exemple.<br />Pour modifier les t&acirc;ches cron :<br /><div class="code">$ crontab <span style="color: #660033;">-e</span><div style="display:none;">[code=bash]$ crontab -e[/code]</div></div></p>
<p>Lignes &agrave; ajouter dans le cron :<br /><div class="code"><span style="color: #007800;">DISPLAY</span>=:<span style="color: #000000;">0.0</span><br />
<span style="color: #007800;">LANG</span>=fr_FR.UTF-<span style="color: #000000;">8</span><br />
<span style="color: #000000; font-weight: bold;">*/</span><span style="color: #000000;">5</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span>     <span style="color: #c20cb9; font-weight: bold;">sh</span> <span style="color: #007800;">$HOME</span><span style="color: #000000; font-weight: bold;">/</span>.svn-monitor.sh<div style="display:none;">[code=bash]<br />DISPLAY=:0.0<br />LANG=fr_FR.UTF-8<br />*/5 * * * * &nbsp; &nbsp; sh $HOME/.svn-monitor.sh<br />[/code]</div></div></p><br /><br /><strong>Partager cet article :</strong> <a href="javascript:;" onclick="window.open('http://ek.la/twitter?blog=1535&amp;path=svn-etre-averti-en-temps-reel-des-commits-envoyes-a890030&amp;title=%5BSVN%5D+%C3%8Atre+averti+en+temps+r%C3%A9el+des+commits+envoy%C3%A9s');" onmouseover="if(Help.bubble) Help.bubble(this, &quot;Diffuser sur Twitter&quot;);"><img src="http://www.skreo.net//images/bookmarks/retweet.png" alt="Retweet" class="icon" /></a> <a href="http://www.wikio.fr/vote?url=http%3A%2F%2Fwww.skreo.net%2Fsvn-etre-averti-en-temps-reel-des-commits-envoyes-a890030" onmouseover="if(Help.bubble) Help.bubble(this, &quot;Voter sur wikio&quot;);"><img src="http://www.skreo.net//images/bookmarks/wikio.gif" alt="Wikio" class="icon" /></a> <iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.skreo.net%2Fsvn-etre-averti-en-temps-reel-des-commits-envoyes-a890030&amp;layout=button_count&amp;show_faces=false&amp;width=110&amp;action=like&amp;colorscheme=light&amp;height=20" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:110px; height:20px;" class="icon" allowTransparency="true"></iframe><br /><br /><hr />Article original rédigé par Skreo et publié sur <a href="http://skreo.eklablog.com">Godefroy de Compreignac</a> <br /> Reproduction interdite sans autorisation]]></content:encoded>
		<pubDate>Wed, 23 Dec 2009 15:18:12 +0100</pubDate>
		<guid isPermaLink="true">http://www.skreo.net/svn-etre-averti-en-temps-reel-des-commits-envoyes-a890030</guid>
		<dc:creator>Skreo</dc:creator>
		<dc:date>2009-12-23T15:18:12+01:00</dc:date>
	</item>
	<item>
		<title><![CDATA[[MySQL] Optimisation d'une recherche avec multiples jointures]]></title>
		<link>http://www.skreo.net/mysql-optimisation-d-une-recherche-avec-multiples-jointures-a860197</link>
		<description><![CDATA[J'ai &eacute;t&eacute; confront&eacute; &agrave; un probl&egrave;me de ralentissements sur EklaBlog d&ucirc;s &agrave; une requ&ecirc;te SELECT utilisant de multiples jointures . Nous allons voir dans cet article comment optimiser cela. La requ&ecirc;te en elle-m&ecirc;me n'est pas tr&egrave;s complexe et utilise uniquement des cl&eacute;s (primary et indexes),...]]></description>
		<content:encoded><![CDATA[<p>J'ai &eacute;t&eacute; confront&eacute; &agrave; un probl&egrave;me de <strong>ralentissements</strong> sur EklaBlog d&ucirc;s &agrave; une requ&ecirc;te SELECT utilisant de <strong>multiples jointures</strong>. Nous allons voir dans cet article comment <strong>optimiser</strong> cela.</p>
<p>La requ&ecirc;te en elle-m&ecirc;me n'est pas tr&egrave;s complexe et utilise uniquement des cl&eacute;s (primary et indexes), mais elle est tr&egrave;s lente pour plusieurs raisons :</p>
<ul>
<li>Jointure sur 5 tables</li>
<li>Recherche sur 4 champs chacun dans une table diff&eacute;rente</li>
<li>Tri par ORDER BY</li>
</ul>
<p>Elle ressemble en gros &agrave; ceci :</p>
<p><div class="code"><a href="http://search.mysql.com/search?site=refman-51&amp;q=SELECT&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">SELECT</span></a> a.id<span style="color: #000033;">,</span> a.blog<span style="color: #000033;">,</span> a.category_id<span style="color: #000033;">,</span> a.title<span style="color: #000033;">,</span> a.content<span style="color: #000033;">,</span> a.author<span style="color: #000033;">,</span> a.creadt<span style="color: #000033;">,</span> c.url<br />
    <a href="http://search.mysql.com/search?site=refman-51&amp;q=FROM&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">FROM</span></a> mod_article a  <br />
    <a href="http://search.mysql.com/search?site=refman-51&amp;q=INNER&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">INNER</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=JOIN&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">JOIN</span></a> categories b <a href="http://search.mysql.com/search?site=refman-51&amp;q=ON&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">ON</span></a> b.id<span style="color: #CC0099;">=</span>a.category_id  <br />
    <a href="http://search.mysql.com/search?site=refman-51&amp;q=INNER&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">INNER</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=JOIN&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">JOIN</span></a> blogs c <a href="http://search.mysql.com/search?site=refman-51&amp;q=ON&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">ON</span></a> c.id<span style="color: #CC0099;">=</span>b.blog_id  <br />
    <a href="http://search.mysql.com/search?site=refman-51&amp;q=INNER&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">INNER</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=JOIN&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">JOIN</span></a> articles_tags at <a href="http://search.mysql.com/search?site=refman-51&amp;q=ON&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">ON</span></a> at.article_id<span style="color: #CC0099;">=</span>a.id <br />
    <a href="http://search.mysql.com/search?site=refman-51&amp;q=INNER&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">INNER</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=JOIN&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">JOIN</span></a> tags t <a href="http://search.mysql.com/search?site=refman-51&amp;q=ON&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">ON</span></a> t.id<span style="color: #CC0099;">=</span>at.tag_id <br />
    <a href="http://search.mysql.com/search?site=refman-51&amp;q=WHERE&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">WHERE</span></a> t.name<span style="color: #CC0099;">=</span><span style="color: #008000;">&quot;skreo&quot;</span> <a href="http://dev.mysql.com/doc/refman/5.1/en/non-typed-operators.html"><span style="color: #CC0099; font-weight: bold;">AND</span></a> a.online<span style="color: #CC0099;">=</span><span style="color: #008000;">&quot;1&quot;</span> <a href="http://dev.mysql.com/doc/refman/5.1/en/non-typed-operators.html"><span style="color: #CC0099; font-weight: bold;">AND</span></a> b.protect<span style="color: #CC0099;">=</span><span style="color: #008000;">&quot;&quot;</span> <a href="http://dev.mysql.com/doc/refman/5.1/en/non-typed-operators.html"><span style="color: #CC0099; font-weight: bold;">AND</span></a> c.protect<span style="color: #CC0099;">=</span><span style="color: #008000;">&quot;&quot;</span>  <br />
    <a href="http://search.mysql.com/search?site=refman-51&amp;q=ORDER%20BY&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">ORDER BY</span></a> a.creadt <a href="http://search.mysql.com/search?site=refman-51&amp;q=DESC&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">DESC</span></a> <br />
    <a href="http://search.mysql.com/search?site=refman-51&amp;q=LIMIT&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">LIMIT</span></a> <span style="color: #008080;">10</span><div style="display:none;">[code=mysql]SELECT a.id, a.blog, a.category_id, a.title, a.content, a.author, a.creadt, c.url<br />&nbsp;&nbsp;&nbsp; FROM mod_article a&nbsp; <br />&nbsp;&nbsp;&nbsp; INNER JOIN categories b ON b.id=a.category_id&nbsp; <br />&nbsp;&nbsp;&nbsp; INNER JOIN blogs c ON c.id=b.blog_id&nbsp; <br />&nbsp;&nbsp;&nbsp; INNER JOIN articles_tags at ON at.article_id=a.id <br />&nbsp;&nbsp;&nbsp; INNER JOIN tags t ON t.id=at.tag_id <br />&nbsp;&nbsp;&nbsp; WHERE t.name="skreo" AND a.online="1" AND b.protect="" AND c.protect=""&nbsp; <br />&nbsp;&nbsp;&nbsp; ORDER BY a.creadt DESC <br />&nbsp;&nbsp;&nbsp; LIMIT 10[/code]</div></div></p>
<p>Les tables concern&eacute;es sont relativement grosses :</p>
<ul>
<li>130 000 entr&eacute;es dans <em>tags</em></li>
<li>1 400 000 entr&eacute;es dans <em>articles_tags</em></li>
<li>400 000 entr&eacute;es dans <em>articles</em></li>
<li>70 000 entr&eacute;es dans <em>categories</em></li>
<li>130 000 entr&eacute;es dans <em>tags</em></li>
<li>19 000 entr&eacute;es dans <em>blogs</em></li>
</ul>
<p>D'o&ugrave; un temps d'ex&eacute;cution de la requ&ecirc;te pouvant atteindre 30 secondes...</p>
<p>Lors d'un test en local, que je r&eacute;p&egrave;terai dans la suite de l'article, j'obtiens une ex&eacute;cution en 0.24s en moyenne quand le pc ne fait rien d'autre.</p>
<p>&nbsp;</p>
<h3>Solution possible</h3>
<p>Une solution possible que m'a indiqu&eacute; mon ami <a href="http://twitter.com/swing_arcus77">Guilhem</a> est de stocker un r&eacute;sultat interm&eacute;diaire de la requ&ecirc;te dans une table de type MEMORY (en RAM) :</p>
<p><div class="code"><a href="http://search.mysql.com/search?site=refman-51&amp;q=CREATE&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">CREATE</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=TABLE&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">TABLE</span></a> tags_lookup <span style="color: #FF00FF;">&#40;</span><br />
    article_id <a href="http://search.mysql.com/search?site=refman-51&amp;q=INT&amp;lr=lang_en"><span style="color: #999900; font-weight: bold;">int</span></a><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">10</span><span style="color: #FF00FF;">&#41;</span> <a href="http://search.mysql.com/search?site=refman-51&amp;q=UNSIGNED&amp;lr=lang_en"><span style="color: #FF9900; font-weight: bold;">unsigned</span></a> <a href="http://dev.mysql.com/doc/refman/5.1/en/non-typed-operators.html"><span style="color: #CC0099; font-weight: bold;">NOT</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=NULL&amp;lr=lang_en"><span style="color: #9900FF; font-weight: bold;">NULL</span></a><span style="color: #000033;">,</span><br />
    tag_id <a href="http://search.mysql.com/search?site=refman-51&amp;q=INT&amp;lr=lang_en"><span style="color: #999900; font-weight: bold;">int</span></a><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">10</span><span style="color: #FF00FF;">&#41;</span> <a href="http://search.mysql.com/search?site=refman-51&amp;q=UNSIGNED&amp;lr=lang_en"><span style="color: #FF9900; font-weight: bold;">unsigned</span></a> <a href="http://dev.mysql.com/doc/refman/5.1/en/non-typed-operators.html"><span style="color: #CC0099; font-weight: bold;">NOT</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=NULL&amp;lr=lang_en"><span style="color: #9900FF; font-weight: bold;">NULL</span></a><span style="color: #000033;">,</span><br />
    creadt <a href="http://search.mysql.com/search?site=refman-51&amp;q=INT&amp;lr=lang_en"><span style="color: #999900; font-weight: bold;">int</span></a><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">10</span><span style="color: #FF00FF;">&#41;</span> <a href="http://search.mysql.com/search?site=refman-51&amp;q=UNSIGNED&amp;lr=lang_en"><span style="color: #FF9900; font-weight: bold;">unsigned</span></a> <a href="http://dev.mysql.com/doc/refman/5.1/en/non-typed-operators.html"><span style="color: #CC0099; font-weight: bold;">NOT</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=NULL&amp;lr=lang_en"><span style="color: #9900FF; font-weight: bold;">NULL</span></a><span style="color: #000033;">,</span><br />
    blog_id <a href="http://search.mysql.com/search?site=refman-51&amp;q=INT&amp;lr=lang_en"><span style="color: #999900; font-weight: bold;">int</span></a><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">10</span><span style="color: #FF00FF;">&#41;</span> <a href="http://search.mysql.com/search?site=refman-51&amp;q=UNSIGNED&amp;lr=lang_en"><span style="color: #FF9900; font-weight: bold;">unsigned</span></a> <a href="http://dev.mysql.com/doc/refman/5.1/en/non-typed-operators.html"><span style="color: #CC0099; font-weight: bold;">NOT</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=NULL&amp;lr=lang_en"><span style="color: #9900FF; font-weight: bold;">NULL</span></a><span style="color: #000033;">,</span><br />
    <a href="http://search.mysql.com/search?site=refman-51&amp;q=KEY&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">KEY</span></a> tag_id <span style="color: #FF00FF;">&#40;</span>tag_id<span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span><br />
    <a href="http://search.mysql.com/search?site=refman-51&amp;q=KEY&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">KEY</span></a> creadt <span style="color: #FF00FF;">&#40;</span>creadt<span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span><br />
    <a href="http://search.mysql.com/search?site=refman-51&amp;q=KEY&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">KEY</span></a> blog_id <span style="color: #FF00FF;">&#40;</span>blog_id<span style="color: #FF00FF;">&#41;</span><br />
<span style="color: #FF00FF;">&#41;</span> <a href="http://search.mysql.com/search?site=refman-51&amp;q=ENGINE&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">ENGINE</span></a><span style="color: #CC0099;">=</span>MEMORY<div style="display:none;">[code=mysql]CREATE TABLE tags_lookup (<br />&nbsp;&nbsp;&nbsp; article_id int(10) unsigned NOT NULL,<br />&nbsp;&nbsp;&nbsp; tag_id int(10) unsigned NOT NULL,<br />&nbsp;&nbsp;&nbsp; creadt int(10) unsigned NOT NULL,<br />&nbsp;&nbsp;&nbsp; blog_id int(10) unsigned NOT NULL,<br />&nbsp;&nbsp;&nbsp; KEY tag_id (tag_id),<br />&nbsp;&nbsp;&nbsp; KEY creadt (creadt),<br />&nbsp;&nbsp;&nbsp; KEY blog_id (blog_id)<br />) ENGINE=MEMORY[/code]</div></div></p>
<p>Il faut ensuite remplir la remplir :</p>
<p><div class="code"><span style="color: #808080; font-style: italic;"># On vide la table</span><br />
<a href="http://search.mysql.com/search?site=refman-51&amp;q=TRUNCATE&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">TRUNCATE</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=TABLE&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">TABLE</span></a> tags_lookup<span style="color: #000033;">;</span><br />
<span style="color: #808080; font-style: italic;"># Puis on la remplit entièrement</span><br />
<a href="http://search.mysql.com/search?site=refman-51&amp;q=INSERT&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">INSERT</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=INTO&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">INTO</span></a> tags_lookup<br />
    <a href="http://search.mysql.com/search?site=refman-51&amp;q=SELECT&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">SELECT</span></a> a.id <a href="http://search.mysql.com/search?site=refman-51&amp;q=AS&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">AS</span></a> article_id<span style="color: #000033;">,</span> at.tag_id<span style="color: #000033;">,</span> a.creadt<span style="color: #000033;">,</span> c.id <a href="http://search.mysql.com/search?site=refman-51&amp;q=AS&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">AS</span></a> blog_id<br />
    <a href="http://search.mysql.com/search?site=refman-51&amp;q=FROM&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">FROM</span></a> articles a<span style="color: #000033;">,</span> categories b<span style="color: #000033;">,</span> blogs c<span style="color: #000033;">,</span> articles_tags at<br />
    <a href="http://search.mysql.com/search?site=refman-51&amp;q=WHERE&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">WHERE</span></a> a.online<span style="color: #CC0099;">=</span><span style="color: #008000;">&quot;1&quot;</span> <a href="http://dev.mysql.com/doc/refman/5.1/en/non-typed-operators.html"><span style="color: #CC0099; font-weight: bold;">AND</span></a> b.protect<span style="color: #CC0099;">=</span><span style="color: #008000;">&quot;&quot;</span> <a href="http://dev.mysql.com/doc/refman/5.1/en/non-typed-operators.html"><span style="color: #CC0099; font-weight: bold;">AND</span></a> c.protect<span style="color: #CC0099;">=</span><span style="color: #008000;">&quot;&quot;</span><br />
    <a href="http://dev.mysql.com/doc/refman/5.1/en/non-typed-operators.html"><span style="color: #CC0099; font-weight: bold;">AND</span></a> b.id<span style="color: #CC0099;">=</span>a.category_id <a href="http://dev.mysql.com/doc/refman/5.1/en/non-typed-operators.html"><span style="color: #CC0099; font-weight: bold;">AND</span></a> c.id<span style="color: #CC0099;">=</span>a.blog_id <a href="http://dev.mysql.com/doc/refman/5.1/en/non-typed-operators.html"><span style="color: #CC0099; font-weight: bold;">AND</span></a> at.article_id<span style="color: #CC0099;">=</span>a.id<span style="color: #000033;">;</span><div style="display:none;">[code=mysql]# On vide la table<br />TRUNCATE TABLE tags_lookup;<br /># Puis on la remplit enti&egrave;rement<br />INSERT INTO tags_lookup<br />&nbsp;&nbsp;&nbsp; SELECT a.id AS article_id, at.tag_id, a.creadt, c.id AS blog_id<br />&nbsp;&nbsp;&nbsp; FROM articles a, categories b, blogs c, articles_tags at<br />&nbsp;&nbsp;&nbsp; WHERE a.online="1" AND b.protect="" AND c.protect=""<br />&nbsp;&nbsp;&nbsp; AND b.id=a.category_id AND c.id=a.blog_id AND at.article_id=a.id;[/code]</div></div></p>
<p>Il faudra ex&eacute;cuter les requ&ecirc;tes ci-dessus r&eacute;guli&egrave;rement pour mettre &agrave; jour le contenu de la table, &agrave; l'aide d'un bash par exemple.</p>
<p>Pour obtenir les informations qu'on voulait au d&eacute;but, on peut alors ex&eacute;cuter cette requ&ecirc;te :</p>
<p><div class="code"><a href="http://search.mysql.com/search?site=refman-51&amp;q=SELECT&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">SELECT</span></a> a.id<span style="color: #000033;">,</span> a.blog<span style="color: #000033;">,</span> a.category_id<span style="color: #000033;">,</span> a.title<span style="color: #000033;">,</span> a.content<span style="color: #000033;">,</span> a.author<span style="color: #000033;">,</span> a.creadt<span style="color: #000033;">,</span> c.url<br />
    <a href="http://search.mysql.com/search?site=refman-51&amp;q=FROM&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">FROM</span></a> tags t <br />
    <a href="http://search.mysql.com/search?site=refman-51&amp;q=INNER&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">INNER</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=JOIN&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">JOIN</span></a> tags_lookup s <a href="http://search.mysql.com/search?site=refman-51&amp;q=ON&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">ON</span></a> s.tag_id<span style="color: #CC0099;">=</span>t.id <br />
    <a href="http://search.mysql.com/search?site=refman-51&amp;q=INNER&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">INNER</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=JOIN&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">JOIN</span></a> articles a <a href="http://search.mysql.com/search?site=refman-51&amp;q=ON&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">ON</span></a> a.id<span style="color: #CC0099;">=</span>s.article_id <br />
    <a href="http://search.mysql.com/search?site=refman-51&amp;q=INNER&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">INNER</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=JOIN&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">JOIN</span></a> categories b <a href="http://search.mysql.com/search?site=refman-51&amp;q=ON&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">ON</span></a> b.id<span style="color: #CC0099;">=</span>a.category_id  <br />
    <a href="http://search.mysql.com/search?site=refman-51&amp;q=INNER&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">INNER</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=JOIN&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">JOIN</span></a> blogs c <a href="http://search.mysql.com/search?site=refman-51&amp;q=ON&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">ON</span></a> c.id<span style="color: #CC0099;">=</span>a.blog _id<br />
    <a href="http://search.mysql.com/search?site=refman-51&amp;q=WHERE&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">WHERE</span></a> t.name<span style="color: #CC0099;">=</span><span style="color: #008000;">&quot;skreo&quot;</span> <br />
    <a href="http://search.mysql.com/search?site=refman-51&amp;q=ORDER%20BY&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">ORDER BY</span></a> s.creadt <a href="http://search.mysql.com/search?site=refman-51&amp;q=DESC&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">DESC</span></a> <br />
    <a href="http://search.mysql.com/search?site=refman-51&amp;q=LIMIT&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">LIMIT</span></a> <span style="color: #008080;">10</span><div style="display:none;">[code=mysql]SELECT a.id, a.blog, a.category_id, a.title, a.content, a.author, a.creadt, c.url<br />&nbsp;&nbsp;&nbsp; FROM tags t <br />&nbsp;&nbsp;&nbsp; INNER JOIN tags_lookup s ON s.tag_id=t.id <br />&nbsp;&nbsp;&nbsp; INNER JOIN articles a ON a.id=s.article_id <br />&nbsp;&nbsp;&nbsp; INNER JOIN categories b ON b.id=a.category_id&nbsp; <br />&nbsp;&nbsp;&nbsp; INNER JOIN blogs c ON c.id=a.blog _id<br />&nbsp;&nbsp;&nbsp; WHERE t.name="skreo" <br />&nbsp;&nbsp;&nbsp; ORDER BY s.creadt DESC <br />&nbsp;&nbsp;&nbsp; LIMIT 10[/code]</div></div></p>
<p>Lors de mon test, j'obtiens cette fois-ci 0.15s d'ex&eacute;cution en moyenne, ce qui est d&eacute;j&agrave; mieux.</p>
<p>Mais le gros avantage d'une telle structure, c'est qu'on va pouvoir faire une recherche beaucoup <strong>plus facile &agrave; comprendre pour le serveur MySQL</strong>, gr&acirc;ce &agrave; des requ&ecirc;tes imbriqu&eacute;es :</p>
<p><div class="code"><a href="http://search.mysql.com/search?site=refman-51&amp;q=SELECT&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">SELECT</span></a> a.id<span style="color: #000033;">,</span> a.blog<span style="color: #000033;">,</span> a.category_id<span style="color: #000033;">,</span> a.title<span style="color: #000033;">,</span> a.content<span style="color: #000033;">,</span> a.author<span style="color: #000033;">,</span> a.creadt<span style="color: #000033;">,</span> c.url<br />
    <a href="http://search.mysql.com/search?site=refman-51&amp;q=FROM&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">FROM</span></a> <span style="color: #FF00FF;">&#40;</span><br />
        <a href="http://search.mysql.com/search?site=refman-51&amp;q=SELECT&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">SELECT</span></a> article_id<br />
        <a href="http://search.mysql.com/search?site=refman-51&amp;q=FROM&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">FROM</span></a> tags_lookup<br />
        <a href="http://search.mysql.com/search?site=refman-51&amp;q=WHERE&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">WHERE</span></a> tag_id<span style="color: #CC0099;">=</span><span style="color: #FF00FF;">&#40;</span><br />
            <a href="http://search.mysql.com/search?site=refman-51&amp;q=SELECT&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">SELECT</span></a> id<br />
            <a href="http://search.mysql.com/search?site=refman-51&amp;q=FROM&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">FROM</span></a> tags<br />
            <a href="http://search.mysql.com/search?site=refman-51&amp;q=WHERE&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">WHERE</span></a> name<span style="color: #CC0099;">=</span><span style="color: #008000;">&quot;skreo&quot;</span><br />
            <a href="http://search.mysql.com/search?site=refman-51&amp;q=LIMIT&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">LIMIT</span></a> <span style="color: #008080;">1</span><br />
        <span style="color: #FF00FF;">&#41;</span><br />
        <a href="http://search.mysql.com/search?site=refman-51&amp;q=ORDER%20BY&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">ORDER BY</span></a> creadt <a href="http://search.mysql.com/search?site=refman-51&amp;q=DESC&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">DESC</span></a><br />
        <a href="http://search.mysql.com/search?site=refman-51&amp;q=LIMIT&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">LIMIT</span></a> <span style="color: #008080;">10</span><br />
    <span style="color: #FF00FF;">&#41;</span> s<br />
    <a href="http://search.mysql.com/search?site=refman-51&amp;q=INNER&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">INNER</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=JOIN&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">JOIN</span></a> articles a <a href="http://search.mysql.com/search?site=refman-51&amp;q=ON&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">ON</span></a> a.id<span style="color: #CC0099;">=</span>s.article_id<br />
    <a href="http://search.mysql.com/search?site=refman-51&amp;q=INNER&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">INNER</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=JOIN&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">JOIN</span></a> categories b <a href="http://search.mysql.com/search?site=refman-51&amp;q=ON&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">ON</span></a> b.id<span style="color: #CC0099;">=</span>a.category_id<br />
    <a href="http://search.mysql.com/search?site=refman-51&amp;q=INNER&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">INNER</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=JOIN&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">JOIN</span></a> blogs c <a href="http://search.mysql.com/search?site=refman-51&amp;q=ON&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">ON</span></a> c.id<span style="color: #CC0099;">=</span>a.blog_id<br />
    <a href="http://search.mysql.com/search?site=refman-51&amp;q=ORDER%20BY&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">ORDER BY</span></a> a.creadt <a href="http://search.mysql.com/search?site=refman-51&amp;q=DESC&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">DESC</span></a><br />
    <a href="http://search.mysql.com/search?site=refman-51&amp;q=LIMIT&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">LIMIT</span></a> <span style="color: #008080;">10</span><span style="color: #000033;">;</span><div style="display:none;">[code=mysql]SELECT a.id, a.blog, a.category_id, a.title, a.content, a.author, a.creadt, c.url<br />&nbsp;&nbsp;&nbsp; FROM (<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; SELECT article_id<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; FROM tags_lookup<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; WHERE tag_id=(<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; SELECT id<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; FROM tags<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; WHERE name="skreo"<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; LIMIT 1<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; )<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ORDER BY creadt DESC<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; LIMIT 10<br />&nbsp;&nbsp;&nbsp; ) s<br />&nbsp;&nbsp;&nbsp; INNER JOIN articles a ON a.id=s.article_id<br />&nbsp;&nbsp;&nbsp; INNER JOIN categories b ON b.id=a.category_id<br />&nbsp;&nbsp;&nbsp; INNER JOIN blogs c ON c.id=a.blog_id<br />&nbsp;&nbsp;&nbsp; ORDER BY a.creadt DESC<br />&nbsp;&nbsp;&nbsp; LIMIT 10;[/code]</div></div></p>
<p>Toujours avec la m&ecirc;me base de donn&eacute;es, j'obtiens cette fois-ci une <strong>ex&eacute;cution presque instantan&eacute;e</strong> : entre 0 et 0.02 secondes !</p>
<p>&nbsp;</p>
<h3>Conclusion</h3>
<p>En mettant en place une table en m&eacute;moire vive rassemblant des donn&eacute;es correspondant &agrave; une partie du traitement d'une grosse requ&ecirc;te, on peut donc &eacute;viter des jointures tr&egrave;s lourdes.</p>
<p>Cette m&eacute;thode a bien &eacute;videmment comme inconv&eacute;nient d'avoir des donn&eacute;es pas toujours ultra fraiches en m&eacute;moire, mais &ccedil;a peut &ecirc;tre un bon compromis quand on voit la rapidit&eacute; des requ&ecirc;tes qui en r&eacute;sultent.</p>
<p><em>Vous avez d'autres solutions int&eacute;ressantes ? une meilleure id&eacute;e ?</em></p><br /><br /><strong>Partager cet article :</strong> <a href="javascript:;" onclick="window.open('http://ek.la/twitter?blog=1535&amp;path=mysql-optimisation-d-une-recherche-avec-multiples-jointures-a860197&amp;title=%5BMySQL%5D+Optimisation+d%27une+recherche+avec+multiples+jointures');" onmouseover="if(Help.bubble) Help.bubble(this, &quot;Diffuser sur Twitter&quot;);"><img src="http://www.skreo.net//images/bookmarks/retweet.png" alt="Retweet" class="icon" /></a> <a href="http://www.wikio.fr/vote?url=http%3A%2F%2Fwww.skreo.net%2Fmysql-optimisation-d-une-recherche-avec-multiples-jointures-a860197" onmouseover="if(Help.bubble) Help.bubble(this, &quot;Voter sur wikio&quot;);"><img src="http://www.skreo.net//images/bookmarks/wikio.gif" alt="Wikio" class="icon" /></a> <iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.skreo.net%2Fmysql-optimisation-d-une-recherche-avec-multiples-jointures-a860197&amp;layout=button_count&amp;show_faces=false&amp;width=110&amp;action=like&amp;colorscheme=light&amp;height=20" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:110px; height:20px;" class="icon" allowTransparency="true"></iframe><br /><br /><hr />Article original rédigé par Skreo et publié sur <a href="http://skreo.eklablog.com">Godefroy de Compreignac</a> <br /> Reproduction interdite sans autorisation]]></content:encoded>
		<pubDate>Thu, 10 Dec 2009 16:42:07 +0100</pubDate>
		<guid isPermaLink="true">http://www.skreo.net/mysql-optimisation-d-une-recherche-avec-multiples-jointures-a860197</guid>
		<dc:creator>Skreo</dc:creator>
		<dc:date>2009-12-10T16:42:07+01:00</dc:date>
	</item>
	<item>
		<title><![CDATA[[Ubuntu] Mes nouveaux choix de logiciels]]></title>
		<link>http://www.skreo.net/ubuntu-mes-nouveaux-choix-de-logiciels-a610241</link>
		<description><![CDATA[Ayant fait l'acquisition d'un magnifique joujou, un Dell XPS Studio , j'ai d&eacute;cid&eacute; de ne pas migrer mon ancienne partition /home, mais plut&ocirc;t de refaire une installation propre de Ubuntu Jaunty Jackalope , et de changer certaine habitudes dans les logiciels que j'utilise. Ainsi j'ai commenc&eacute; par...]]></description>
		<content:encoded><![CDATA[<p style="text-align: justify;">Ayant fait l'acquisition d'un magnifique joujou, un <strong>Dell XPS Studio</strong>, j'ai d&eacute;cid&eacute; de ne pas migrer mon ancienne partition /home, mais plut&ocirc;t de refaire une installation propre de <a href="http://doc.ubuntu-fr.org/jaunty"><strong>Ubuntu Jaunty Jackalope</strong></a>, et de changer certaine habitudes dans les logiciels que j'utilise.</p>
<p style="text-align: justify;"><img style="float: right; padding-left: 5px;" src="http://data0.eklablog.com/skreo/mod_article610241_1.png" alt="Pidgin, messagerie instantan&eacute;e"/>Ainsi j'ai commenc&eacute; par abandonner <a href="http://kopete.kde.org/">Kopete</a> (Instant Messenger) et <a href="http://amarok.kde.org/">Amarok</a> (Music player) qui sont devenus lourds et peu ergonomiques avec l'arriv&eacute;e de la nouvelle version de <a href="http://fr.kde.org/">KDE</a>, du moins c'est mon avis. Comme quoi, il n'y a que les cons qui ne changent pas d'avis ! (Cf. <a href="http://www.skreo.net//article-2906-119192-marre-des-plantages-passage-a-ubuntu.html#comment-154697">un de mes commentaires</a> sur un article pr&eacute;c&eacute;dent)</p>
<p style="text-align: justify;">J'ai donc remplac&eacute; Kopete par <strong><a href="http://www.pidgin.im/">Pidgin</a></strong> qui est parfaitement int&eacute;gr&eacute; &agrave; Gnome, complet, et qui supporte un tr&egrave;s grand nombre de protocoles. Je l'utilise donc avec mes comptes MSN, <a href="http://fr.wikipedia.org/wiki/Jabber">Jabber</a>, et Facebook. Car Pidgin supporte m&ecirc;me Facebook, avec un <a href="http://code.google.com/p/pidgin-facebookchat/">plugin disponible ici</a> !</p>
<p style="text-align: justify;"><img style="float: left; padding-right: 5px;" src="http://data0.eklablog.com/skreo/mod_article610241_2.png" alt="Exaile, lecteur de musique"/>A la place d'Amarok, j'ai install&eacute; <strong><a href="http://www.exaile.org/">Exaile</a></strong>, son &eacute;quivalent pour Gnome, certes un peu moins ergonomique que la version 1.4 d'Amarok, mais aussi efficace et avec s&ucirc;rement autant de fonctionnalit&eacute;s.</p>
<p style="text-align: justify;"><img style="float: right; padding-left: 5px;" src="http://data0.eklablog.com/skreo/mod_article610241_3.png" alt="Deluge, client torrent"/>Ensuite, je n'ai cette fois pas install&eacute; <a href="http://azureus.sourceforge.net/">Azureus</a> (Client Torrent), tr&egrave;s efficace mais aussi tr&egrave;s lourd (s&ucirc;rement car c'est une application Java). &Agrave; la place, j'ai pr&eacute;f&eacute;r&eacute; <strong><a href="http://deluge-torrent.org/">Deluge</a></strong>, un client l&eacute;ger, parfaitement int&eacute;gr&eacute; &agrave; Gnome, et offrant une rapidit&eacute; impressionnante.</p>
<p style="text-align: justify;">Les logiciels que j'utilise maintenant principalement et qui me conviennent parfaitement sont donc :</p>
<div style="text-align: justify;">
<ul>
<li><a href="http://www.exaile.org/">Exaile</a> : Lecteur de musique</li>
<li><a href="http://www.pidgin.im/">Pidgin</a> : Messagerie instantan&eacute;e</li>
<li><a href="http://deluge-torrent.org/">Deluge</a> : Client Torrent</li>
<li><a href="http://www.geany.org/">Geany</a> : Editeur de code</li>
<li><a href="http://www.mozilla-europe.org/fr/firefox/">Firefox 3.5</a> : Navigateur web peu connu</li>
<li><a href="http://www.skreo.net//article-2906-417068-zim-gerez-vos-notes-et-todo-lists-super-facilement.html">Zim</a> : Gestionnaire de notes</li>
<li><a href="http://live.gnome.org/Nautilus">Nautilus</a> : Gestionnaire de fichiers par d&eacute;faut de Gnome</li>
<li><a href="http://www.videolan.org/vlc/">VLC</a> : Lecteur vid&eacute;o</li>
</ul>
</div><br /><br /><strong>Partager cet article :</strong> <a href="javascript:;" onclick="window.open('http://ek.la/twitter?blog=1535&amp;path=ubuntu-mes-nouveaux-choix-de-logiciels-a610241&amp;title=%5BUbuntu%5D+Mes+nouveaux+choix+de+logiciels');" onmouseover="if(Help.bubble) Help.bubble(this, &quot;Diffuser sur Twitter&quot;);"><img src="http://www.skreo.net//images/bookmarks/retweet.png" alt="Retweet" class="icon" /></a> <a href="http://www.wikio.fr/vote?url=http%3A%2F%2Fwww.skreo.net%2Fubuntu-mes-nouveaux-choix-de-logiciels-a610241" onmouseover="if(Help.bubble) Help.bubble(this, &quot;Voter sur wikio&quot;);"><img src="http://www.skreo.net//images/bookmarks/wikio.gif" alt="Wikio" class="icon" /></a> <iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.skreo.net%2Fubuntu-mes-nouveaux-choix-de-logiciels-a610241&amp;layout=button_count&amp;show_faces=false&amp;width=110&amp;action=like&amp;colorscheme=light&amp;height=20" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:110px; height:20px;" class="icon" allowTransparency="true"></iframe><br /><br /><hr />Article original rédigé par Skreo et publié sur <a href="http://skreo.eklablog.com">Godefroy de Compreignac</a> <br /> Reproduction interdite sans autorisation]]></content:encoded>
		<pubDate>Sun, 02 Aug 2009 13:37:52 +0200</pubDate>
		<guid isPermaLink="true">http://www.skreo.net/ubuntu-mes-nouveaux-choix-de-logiciels-a610241</guid>
		<dc:creator>Skreo</dc:creator>
		<dc:date>2009-08-02T13:37:52+02:00</dc:date>
	</item>
	<item>
		<title><![CDATA[[LaTeX] Comment faire rapidement une facture super classe]]></title>
		<link>http://www.skreo.net/latex-comment-faire-rapidement-une-facture-super-classe-a530591</link>
		<description><![CDATA[J'ai fait mes premi&egrave;res factures r&eacute;cemment, et j'ai &eacute;t&eacute; compl&egrave;tement incapable de trouver la moindre application gratuite/libre permettant d'&eacute;diter facilement et rapidement une belle facture. Donc comme je suis un peu kamikaze, j'ai pass&eacute; des heures &agrave; m'am&eacute;liorer en LaTeX en mettant au...]]></description>
		<content:encoded><![CDATA[<p>J'ai fait mes premi&egrave;res factures r&eacute;cemment, et j'ai &eacute;t&eacute; compl&egrave;tement incapable de trouver la moindre application gratuite/libre permettant d'&eacute;diter facilement et rapidement une belle facture.</p>
<p>Donc comme je suis un peu kamikaze, j'ai pass&eacute; des heures &agrave; m'am&eacute;liorer en LaTeX en mettant au point un petit syst&egrave;me pour &eacute;diter des jolies factures.</p>
<p>Pour ceux qui ne connaissent pas ou peu LaTeX, il existe de tr&egrave;s bonnes <acronym title="Foire Aux Questions">FAQ</acronym>, notamment :</p>
<ul>
<li><a href="http://latex.developpez.com/faq/">http://latex.developpez.com/faq/</a></li>
<li><a href="http://www.grappa.univ-lille3.fr/FAQ-LaTeX/">http://www.grappa.univ-lille3.fr/FAQ-LaTeX/</a></li>
</ul>
<p><br />Voici le code LaTeX de ma facture :</p>
<p><div class="code"><span style="color: #800000; font-weight: normal;">\documentclass</span><span style="color: #0000D0; ">[</span><span style="color: #C08020; font-weight: normal;">french,11pt</span><span style="color: #0000D0; ">]{</span><span style="color: #2020C0; font-weight: normal;">article</span><span style="color: #0000D0; ">}</span><br />
<span style="color: #800000; font-weight: normal;">\usepackage</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">babel</span><span style="color: #0000D0; ">}</span><br />
<span style="color: #800000; font-weight: normal;">\usepackage</span><span style="color: #0000D0; ">[</span><span style="color: #C08020; font-weight: normal;">T1</span><span style="color: #0000D0; ">]{</span><span style="color: #2020C0; font-weight: normal;">fontenc</span><span style="color: #0000D0; ">}</span><br />
<span style="color: #800000; font-weight: normal;">\usepackage</span><span style="color: #0000D0; ">[</span><span style="color: #C08020; font-weight: normal;">utf8</span><span style="color: #0000D0; ">]{</span><span style="color: #2020C0; font-weight: normal;">inputenc</span><span style="color: #0000D0; ">}</span><br />
<span style="color: #800000; font-weight: normal;">\usepackage</span><span style="color: #0000D0; ">[</span><span style="color: #C08020; font-weight: normal;">a4paper</span><span style="color: #0000D0; ">]{</span><span style="color: #2020C0; font-weight: normal;">geometry</span><span style="color: #0000D0; ">}</span><br />
<span style="color: #800000; font-weight: normal;">\usepackage</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">units</span><span style="color: #0000D0; ">}</span><br />
<span style="color: #800000; font-weight: normal;">\usepackage</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">bera</span><span style="color: #0000D0; ">}</span><br />
<span style="color: #800000; font-weight: normal;">\usepackage</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">graphicx</span><span style="color: #0000D0; ">}</span><br />
<span style="color: #800000; font-weight: normal;">\usepackage</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">fancyhdr</span><span style="color: #0000D0; ">}</span><br />
<span style="color: #800000; font-weight: normal;">\usepackage</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">fp</span><span style="color: #0000D0; ">}</span><br />
<br />
<span style="color: #800000; font-weight: normal;">\def</span><span style="color: #800000; font-weight: normal;">\TVA</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">19.6</span><span style="color: #0000D0; ">}</span>    <span style="color: #2C922C; font-style: italic;">% Taux de la TVA</span><br />
<br />
<span style="color: #800000; font-weight: normal;">\def</span><span style="color: #800000; font-weight: normal;">\TotalHT</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">0</span><span style="color: #0000D0; ">}</span><br />
<span style="color: #800000; font-weight: normal;">\def</span><span style="color: #800000; font-weight: normal;">\TotalTVA</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">0</span><span style="color: #0000D0; ">}</span><br />
<br />
<span style="color: #800000; font-weight: normal;">\newcommand</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\AjouterProduit</span></span><span style="color: #0000D0; ">}[</span><span style="color: #C08020; font-weight: normal;">3</span><span style="color: #0000D0; ">]{</span><span style="color: #2C922C; font-style: italic;">%    Arguments : Désignation, quantité, prix unitaire HT</span><br />
    <span style="color: #800000; font-weight: normal;">\FPround</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\prix</span></span><span style="color: #0000D0; ">}{</span><span style="color: #2020C0; font-weight: normal;">#3</span><span style="color: #0000D0; ">}{</span><span style="color: #2020C0; font-weight: normal;">2</span><span style="color: #0000D0; ">}</span><br />
    <span style="color: #800000; font-weight: normal;">\FPeval</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\montant</span></span><span style="color: #0000D0; ">}{</span><span style="color: #2020C0; font-weight: normal;">#2 * #3</span><span style="color: #0000D0; ">}</span><br />
    <span style="color: #800000; font-weight: normal;">\FPround</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\montant</span></span><span style="color: #0000D0; ">}{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\montant</span></span><span style="color: #0000D0; ">}{</span><span style="color: #2020C0; font-weight: normal;">2</span><span style="color: #0000D0; ">}</span><br />
    <span style="color: #800000; font-weight: normal;">\FPadd</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\TotalHT</span></span><span style="color: #0000D0; ">}{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\TotalHT</span></span><span style="color: #0000D0; ">}{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\montant</span></span><span style="color: #0000D0; ">}</span><br />
    <br />
    <span style="color: #800000; font-weight: normal;">\eaddto</span><span style="color: #800000; font-weight: normal;">\ListeProduits</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">#1    &amp;    <span style="color: #800000; font-weight: normal;">\prix</span>    <span style="color: #0000D0; ">&amp;</span>    #2    <span style="color: #0000D0; ">&amp;</span>    <span style="color: #800000; font-weight: normal;">\montant</span>    <span style="color: #800000; font-weight: normal;">\cr</span></span><span style="color: #0000D0; ">}</span><br />
<span style="color: #0000D0; ">}</span><br />
<br />
<span style="color: #800000; font-weight: normal;">\newcommand</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\AfficheResultat</span></span><span style="color: #0000D0; ">}{</span><span style="color: #2C922C; font-style: italic;">%</span><br />
    <span style="color: #800000; font-weight: normal;">\ListeProduits</span><br />
    <br />
    <span style="color: #800000; font-weight: normal;">\FPeval</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\TotalTVA</span></span><span style="color: #0000D0; ">}{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\TotalHT</span> * <span style="color: #800000; font-weight: normal;">\TVA</span> / 100</span><span style="color: #0000D0; ">}</span><br />
    <span style="color: #800000; font-weight: normal;">\FPadd</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\TotalTTC</span></span><span style="color: #0000D0; ">}{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\TotalHT</span></span><span style="color: #0000D0; ">}{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\TotalTVA</span></span><span style="color: #0000D0; ">}</span><br />
    <span style="color: #800000; font-weight: normal;">\FPround</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\TotalHT</span></span><span style="color: #0000D0; ">}{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\TotalHT</span></span><span style="color: #0000D0; ">}{</span><span style="color: #2020C0; font-weight: normal;">2</span><span style="color: #0000D0; ">}</span><br />
    <span style="color: #800000; font-weight: normal;">\FPround</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\TotalTVA</span></span><span style="color: #0000D0; ">}{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\TotalTVA</span></span><span style="color: #0000D0; ">}{</span><span style="color: #2020C0; font-weight: normal;">2</span><span style="color: #0000D0; ">}</span><br />
    <span style="color: #800000; font-weight: normal;">\FPround</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\TotalTTC</span></span><span style="color: #0000D0; ">}{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\TotalTTC</span></span><span style="color: #0000D0; ">}{</span><span style="color: #2020C0; font-weight: normal;">2</span><span style="color: #0000D0; ">}</span><br />
    <span style="color: #800000; font-weight: normal;">\global</span><span style="color: #800000; font-weight: normal;">\let</span><span style="color: #800000; font-weight: normal;">\TotalHT</span><span style="color: #800000; font-weight: normal;">\TotalHT</span><br />
    <span style="color: #800000; font-weight: normal;">\global</span><span style="color: #800000; font-weight: normal;">\let</span><span style="color: #800000; font-weight: normal;">\TotalTVA</span><span style="color: #800000; font-weight: normal;">\TotalTVA</span><br />
    <span style="color: #800000; font-weight: normal;">\global</span><span style="color: #800000; font-weight: normal;">\let</span><span style="color: #800000; font-weight: normal;">\TotalTTC</span><span style="color: #800000; font-weight: normal;">\TotalTTC</span><br />
    <br />
    <span style="color: #800000; font-weight: normal;">\cr</span> <span style="color: #800000; font-weight: normal;">\hline</span><br />
    Total HT            <span style="color: #0000D0; ">&amp;</span> <span style="color: #0000D0; ">&amp;</span> <span style="color: #0000D0; ">&amp;</span>    <span style="color: #800000; font-weight: normal;">\TotalHT</span>    <span style="color: #800000; font-weight: normal;">\cr</span><br />
    TVA <span style="color: #800000; font-weight: normal;">\TVA</span>~<span style="color: #800000; font-weight: normal;">\%</span>         <span style="color: #0000D0; ">&amp;</span> <span style="color: #0000D0; ">&amp;</span> <span style="color: #0000D0; ">&amp;</span>    <span style="color: #800000; font-weight: normal;">\TotalTVA</span>    <span style="color: #800000; font-weight: normal;">\cr</span><br />
    <span style="color: #800000; font-weight: normal;">\hline</span> <span style="color: #800000; font-weight: normal;">\hline</span><br />
    <span style="color: #800000; font-weight: normal;">\textbf</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">Total TTC</span><span style="color: #0000D0; ">}</span>    <span style="color: #0000D0; ">&amp;</span> <span style="color: #0000D0; ">&amp;</span> <span style="color: #0000D0; ">&amp;</span>    <span style="color: #800000; font-weight: normal;">\TotalTTC</span><br />
<span style="color: #0000D0; ">}</span><br />
<br />
<span style="color: #800000; font-weight: normal;">\newcommand*</span><span style="color: #800000; font-weight: normal;">\eaddto</span><span style="color: #0000D0; ">[</span><span style="color: #C08020; font-weight: normal;">2</span><span style="color: #0000D0; ">]{</span><span style="color: #2C922C; font-style: italic;">% version développée de \addto</span><br />
   <span style="color: #800000; font-weight: normal;">\edef</span><span style="color: #800000; font-weight: normal;">\tmp</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">#2</span><span style="color: #0000D0; ">}</span><span style="color: #2C922C; font-style: italic;">%</span><br />
   <span style="color: #800000; font-weight: normal;">\expandafter</span><span style="color: #800000; font-weight: normal;">\addto</span><br />
   <span style="color: #800000; font-weight: normal;">\expandafter</span>#1<span style="color: #2C922C; font-style: italic;">%</span><br />
   <span style="color: #800000; font-weight: normal;">\expandafter</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\tmp</span></span><span style="color: #0000D0; ">}</span><span style="color: #2C922C; font-style: italic;">%</span><br />
<span style="color: #0000D0; ">}</span> <br />
<br />
<span style="color: #800000; font-weight: normal;">\newcommand</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\ListeProduits</span></span><span style="color: #0000D0; ">}{</span><span style="color: #0000D0; ">}</span><br />
<br />
<br />
<br />
<br />
<span style="color: #2C922C; font-style: italic;">%%%%%%%%%%%%%%%%%%%%% A MODIFIER DANS LA FACTURE %%%%%%%%%%%%%%%%%%%%%</span><br />
<br />
<span style="color: #800000; font-weight: normal;">\def</span><span style="color: #800000; font-weight: normal;">\FactureNum</span>            <span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">1</span><span style="color: #0000D0; ">}</span>    <span style="color: #2C922C; font-style: italic;">% Numéro de facture</span><br />
<span style="color: #800000; font-weight: normal;">\def</span><span style="color: #800000; font-weight: normal;">\FactureAcquittee</span>    <span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">non</span><span style="color: #0000D0; ">}</span>        <span style="color: #2C922C; font-style: italic;">% Facture acquittée : oui/non</span><br />
<span style="color: #800000; font-weight: normal;">\def</span><span style="color: #800000; font-weight: normal;">\FactureLieu</span>    <span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">Paris</span><span style="color: #0000D0; ">}</span>    <span style="color: #2C922C; font-style: italic;">% Lieu de l'édition de la facture</span><br />
<span style="color: #800000; font-weight: normal;">\def</span><span style="color: #800000; font-weight: normal;">\FactureObjet</span>    <span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">facture pour te faire payer</span><span style="color: #0000D0; ">}</span>    <span style="color: #2C922C; font-style: italic;">% Objet du document</span><br />
<span style="color: #2C922C; font-style: italic;">% Description de la facture</span><br />
<span style="color: #800000; font-weight: normal;">\def</span><span style="color: #800000; font-weight: normal;">\FactureDescr</span>    <span style="color: #0000D0; ">{</span><span style="color: #2C922C; font-style: italic;">%</span><br />
Cette facture concerne la réalisation du site web machin-truc.com, son hébergement, et la location du nom de domaine<br />
<span style="color: #0000D0; ">}</span><br />
<br />
<span style="color: #2C922C; font-style: italic;">% Infos Client</span><br />
<span style="color: #800000; font-weight: normal;">\def</span><span style="color: #800000; font-weight: normal;">\ClientNom</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">M. Dupont</span><span style="color: #0000D0; ">}</span>    <span style="color: #2C922C; font-style: italic;">% Nom du client</span><br />
<span style="color: #800000; font-weight: normal;">\def</span><span style="color: #800000; font-weight: normal;">\ClientAdresse</span><span style="color: #0000D0; ">{</span><span style="color: #2C922C; font-style: italic;">%                    % Adresse du client</span><br />
    12, rue de la Geekerie <span style="color: #0000D0; ">\\</span><br />
    75000 Paris<br />
<span style="color: #0000D0; ">}</span><br />
<br />
<span style="color: #2C922C; font-style: italic;">% Liste des produits facturés : Désignation, quantité, prix unitaire HT</span><br />
<span style="color: #800000; font-weight: normal;">\AjouterProduit</span>    <span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">Réalisation du site</span><span style="color: #0000D0; ">}</span>        <span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">1</span><span style="color: #0000D0; ">}</span>        <span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">1600</span><span style="color: #0000D0; ">}</span><br />
<span style="color: #800000; font-weight: normal;">\AjouterProduit</span>    <span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">Hébergement -- 1 mois</span><span style="color: #0000D0; ">}</span>        <span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">3</span><span style="color: #0000D0; ">}</span>        <span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">10</span><span style="color: #0000D0; ">}</span><br />
<span style="color: #800000; font-weight: normal;">\AjouterProduit</span>    <span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">Nom de domaine -- 1 an</span><span style="color: #0000D0; ">}</span>    <span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">1</span><span style="color: #0000D0; ">}</span>        <span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">8</span><span style="color: #0000D0; ">}</span><br />
<br />
<span style="color: #2C922C; font-style: italic;">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</span><br />
<br />
<br />
<br />
<br />
<span style="color: #800000; font-weight: normal;">\geometry</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">verbose,tmargin=4em,bmargin=8em,lmargin=6em,rmargin=6em</span><span style="color: #0000D0; ">}</span><br />
<span style="color: #800000; font-weight: normal;">\setlength</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\parindent</span></span><span style="color: #0000D0; ">}{</span><span style="color: #2020C0; font-weight: normal;">0pt</span><span style="color: #0000D0; ">}</span><br />
<span style="color: #800000; font-weight: normal;">\setlength</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\parskip</span></span><span style="color: #0000D0; ">}{</span><span style="color: #2020C0; font-weight: normal;">1ex plus 0.5ex minus 0.2ex</span><span style="color: #0000D0; ">}</span><br />
<br />
<span style="color: #800000; font-weight: normal;">\thispagestyle</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">fancy</span><span style="color: #0000D0; ">}</span><br />
<span style="color: #800000; font-weight: normal;">\pagestyle</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">fancy</span><span style="color: #0000D0; ">}</span><br />
<span style="color: #800000; font-weight: normal;">\setlength</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\parindent</span></span><span style="color: #0000D0; ">}{</span><span style="color: #2020C0; font-weight: normal;">0pt</span><span style="color: #0000D0; ">}</span><br />
<br />
<span style="color: #800000; font-weight: normal;">\renewcommand</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\headrulewidth</span></span><span style="color: #0000D0; ">}{</span><span style="color: #2020C0; font-weight: normal;">0pt</span><span style="color: #0000D0; ">}</span><br />
<span style="color: #800000; font-weight: normal;">\cfoot</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;"><br />
    Ma Société SARL au capital de 3000 € ~--~ 34, rue du Brainfuck - 75000 Paris<span style="color: #800000; font-weight: normal;">\newline</span><br />
    <span style="color: #800000; font-weight: normal;">\small</span><span style="color: #0000D0; ">{</span><br />
        Telephone : +33(0)6 12 34 56 78 ~--~ Site web : www.ma-societe.com ~--~ E-mail : contact@ma-societe.com<span style="color: #800000; font-weight: normal;">\newline</span><br />
        RCS Paris 512 569 485 ~--~ Code APE 6201Z ~--~ Numéro TVA : FR 56-512-569-485<br />
    </span><span style="color: #0000D0; ">}</span><br />
<span style="color: #0000D0; ">}</span><br />
<br />
<br />
<br />
<span style="color: #C00000; font-weight: normal;">\begin</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #0000D0; font-weight: normal;">document</span></span><span style="color: #0000D0; ">}</span><br />
<br />
<span style="color: #2C922C; font-style: italic;">% Logo de la société</span><br />
<span style="color: #800000; font-weight: normal;">\includegraphics</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">logo.jpg</span><span style="color: #0000D0; ">}</span><br />
<br />
<span style="color: #2C922C; font-style: italic;">% Nom et adresse de la société</span><br />
Ma Société SARL <span style="color: #0000D0; ">\\</span><br />
34, rue du Brainfuck <span style="color: #0000D0; ">\\</span><br />
75000 Paris<br />
<br />
Facture n°<span style="color: #800000; font-weight: normal;">\FactureNum</span><br />
<br />
<br />
<span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\addtolength</span><span style="color: #0000D0; ">{</span><span style="color: #800000; font-weight: normal;">\leftskip</span></span><span style="color: #0000D0; ">}{</span><span style="color: #2020C0; font-weight: normal;">10.5cm</span><span style="color: #0000D0; ">}</span> <span style="color: #2C922C; font-style: italic;">%in ERT</span><br />
    <span style="color: #800000; font-weight: normal;">\textbf</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\ClientNom</span></span><span style="color: #0000D0; ">}</span>    <span style="color: #0000D0; ">\\</span><br />
    <span style="color: #800000; font-weight: normal;">\ClientAdresse</span>        <span style="color: #0000D0; ">\\</span><br />
<br />
<span style="color: #0000D0; ">}</span> <span style="color: #2C922C; font-style: italic;">%in ERT</span><br />
<br />
<br />
<span style="color: #800000; font-weight: normal;">\hspace*</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">10.5cm</span><span style="color: #0000D0; ">}</span><br />
<span style="color: #800000; font-weight: normal;">\FactureLieu</span>, le <span style="color: #800000; font-weight: normal;">\today</span><br />
<br />
~<span style="color: #0000D0; ">\\</span>~<span style="color: #0000D0; ">\\</span><br />
<br />
<span style="color: #800000; font-weight: normal;">\textbf</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">Objet : <span style="color: #800000; font-weight: normal;">\FactureObjet</span> <span style="color: #0000D0; ">\\</span></span><span style="color: #0000D0; ">}</span><br />
<br />
<span style="color: #800000; font-weight: normal;">\textnormal</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\FactureDescr</span></span><span style="color: #0000D0; ">}</span><br />
<br />
~<span style="color: #0000D0; ">\\</span><br />
<br />
<span style="color: #C00000; font-weight: normal;">\begin</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #0000D0; font-weight: normal;">center</span></span><span style="color: #0000D0; ">}</span><br />
    <span style="color: #C00000; font-weight: normal;">\begin</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #0000D0; font-weight: normal;">tabular</span></span><span style="color: #0000D0; ">}{</span><span style="color: #2020C0; font-weight: normal;">lrrr</span><span style="color: #0000D0; ">}</span><br />
        <span style="color: #800000; font-weight: normal;">\textbf</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">Désignation ~~~~~~</span><span style="color: #0000D0; ">}</span>    <span style="color: #0000D0; ">&amp;</span> <span style="color: #800000; font-weight: normal;">\textbf</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">Prix unitaire</span><span style="color: #0000D0; ">}</span>    <span style="color: #0000D0; ">&amp;</span> <span style="color: #800000; font-weight: normal;">\textbf</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">Quantité</span><span style="color: #0000D0; ">}</span>    <span style="color: #0000D0; ">&amp;</span> <span style="color: #800000; font-weight: normal;">\textbf</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">Montant (EUR)</span><span style="color: #0000D0; ">}</span>    <span style="color: #0000D0; ">\\</span><br />
        <span style="color: #800000; font-weight: normal;">\hline</span><br />
        <span style="color: #800000; font-weight: normal;">\AfficheResultat</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #0000D0; ">}</span><br />
    <span style="color: #C00000; font-weight: normal;">\end</span><span style="color: #0000D0; ">{</span><span style="color: #0000D0; font-weight: normal;">tabular</span></span><span style="color: #0000D0; ">}</span><br />
<span style="color: #C00000; font-weight: normal;">\end</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #0000D0; font-weight: normal;">center</span></span><span style="color: #0000D0; ">}</span><br />
<br />
~<span style="color: #0000D0; ">\\</span><br />
<br />
<span style="color: #800000; font-weight: normal;">\ifthenelse</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\equal</span><span style="color: #0000D0; ">{</span><span style="color: #800000; font-weight: normal;">\FactureAcquittee</span></span><span style="color: #0000D0; ">}{</span><span style="color: #2020C0; font-weight: normal;">oui</span><span style="color: #0000D0; ">}}{</span><span style="color: #2020C0; font-weight: normal;"><br />
    Facture acquittée.<br />
</span><span style="color: #0000D0; ">}{</span><span style="color: #2020C0; font-weight: normal;"><br />
<br />
    À régler par chèque ou par virement bancaire :<br />
<br />
    <span style="color: #C00000; font-weight: normal;">\begin</span><span style="color: #0000D0; ">{</span><span style="color: #0000D0; font-weight: normal;">center</span></span><span style="color: #0000D0; ">}</span><br />
        <span style="color: #C00000; font-weight: normal;">\begin</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #0000D0; font-weight: normal;">tabular</span></span><span style="color: #0000D0; ">}{</span><span style="color: #0000D0; "><span style="color: #2020C0; font-weight: normal;">|c c c c|</span></span><span style="color: #0000D0; ">}</span><br />
            <span style="color: #800000; font-weight: normal;">\hline</span>     <span style="color: #800000; font-weight: normal;">\textbf</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">Code banque</span><span style="color: #0000D0; ">}</span>    <span style="color: #0000D0; ">&amp;</span> <span style="color: #800000; font-weight: normal;">\textbf</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">Code guichet</span><span style="color: #0000D0; ">}</span>    <span style="color: #0000D0; ">&amp;</span> <span style="color: #800000; font-weight: normal;">\textbf</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">N° de Compte</span><span style="color: #0000D0; ">}</span>        <span style="color: #0000D0; ">&amp;</span> <span style="color: #800000; font-weight: normal;">\textbf</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">Clé RIB</span><span style="color: #0000D0; ">}</span>    <span style="color: #0000D0; ">\\</span><br />
                    59763                    <span style="color: #0000D0; ">&amp;</span> 00726                     <span style="color: #0000D0; ">&amp;</span> 41652387462                <span style="color: #0000D0; ">&amp;</span> 98                <span style="color: #0000D0; ">\\</span><br />
            <span style="color: #800000; font-weight: normal;">\hline</span>     <span style="color: #800000; font-weight: normal;">\textbf</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">IBAN N°</span><span style="color: #0000D0; ">}</span>        <span style="color: #0000D0; ">&amp;</span> <span style="color: #800000; font-weight: normal;">\multicolumn</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">3</span><span style="color: #0000D0; ">}{</span><span style="color: #0000D0; "><span style="color: #2020C0; font-weight: normal;">|l|</span></span><span style="color: #0000D0; ">}{</span><span style="color: #2020C0; font-weight: normal;"> FR59 4859 4628 7921 0289 8106 846 </span><span style="color: #0000D0; ">}</span>         <span style="color: #0000D0; ">\\</span><br />
            <span style="color: #800000; font-weight: normal;">\hline</span>     <span style="color: #800000; font-weight: normal;">\textbf</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">Code BIC</span><span style="color: #0000D0; ">}</span>        <span style="color: #0000D0; ">&amp;</span> <span style="color: #800000; font-weight: normal;">\multicolumn</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;">3</span><span style="color: #0000D0; ">}{</span><span style="color: #0000D0; "><span style="color: #2020C0; font-weight: normal;">|l|</span></span><span style="color: #0000D0; ">}{</span><span style="color: #2020C0; font-weight: normal;"> AGRIFPRP792 </span><span style="color: #0000D0; ">}</span>         <span style="color: #0000D0; ">\\</span><br />
            <span style="color: #800000; font-weight: normal;">\hline</span><br />
        <span style="color: #C00000; font-weight: normal;">\end</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #0000D0; font-weight: normal;">tabular</span></span><span style="color: #0000D0; ">}</span><br />
    <span style="color: #C00000; font-weight: normal;">\end</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #0000D0; font-weight: normal;">center</span></span><span style="color: #0000D0; ">}</span><br />
<br />
<span style="color: #0000D0; ">}</span><br />
<br />
<span style="color: #C00000; font-weight: normal;">\end</span><span style="color: #0000D0; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #0000D0; font-weight: normal;">document</span></span><span style="color: #0000D0; ">}</span><div style="display:none;">[code=latex]\documentclass[french,11pt]{article}<br />\usepackage{babel}<br />\usepackage[T1]{fontenc}<br />\usepackage[utf8]{inputenc}<br />\usepackage[a4paper]{geometry}<br />\usepackage{units}<br />\usepackage{bera}<br />\usepackage{graphicx}<br />\usepackage{fancyhdr}<br />\usepackage{fp}<br /><br />\def\TVA{19.6}&nbsp;&nbsp;&nbsp; % Taux de la TVA<br /><br />\def\TotalHT{0}<br />\def\TotalTVA{0}<br /><br />\newcommand{\AjouterProduit}[3]{%&nbsp;&nbsp;&nbsp; Arguments : D&eacute;signation, quantit&eacute;, prix unitaire HT<br />&nbsp;&nbsp;&nbsp; \FPround{\prix}{#3}{2}<br />&nbsp;&nbsp;&nbsp; \FPeval{\montant}{#2 * #3}<br />&nbsp;&nbsp;&nbsp; \FPround{\montant}{\montant}{2}<br />&nbsp;&nbsp;&nbsp; \FPadd{\TotalHT}{\TotalHT}{\montant}<br />&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; \eaddto\ListeProduits{#1&nbsp;&nbsp;&nbsp; &amp;&nbsp;&nbsp;&nbsp; \prix&nbsp;&nbsp;&nbsp; &amp;&nbsp;&nbsp;&nbsp; #2&nbsp;&nbsp;&nbsp; &amp;&nbsp;&nbsp;&nbsp; \montant&nbsp;&nbsp;&nbsp; \cr}<br />}<br /><br />\newcommand{\AfficheResultat}{%<br />&nbsp;&nbsp;&nbsp; \ListeProduits<br />&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; \FPeval{\TotalTVA}{\TotalHT * \TVA / 100}<br />&nbsp;&nbsp;&nbsp; \FPadd{\TotalTTC}{\TotalHT}{\TotalTVA}<br />&nbsp;&nbsp;&nbsp; \FPround{\TotalHT}{\TotalHT}{2}<br />&nbsp;&nbsp;&nbsp; \FPround{\TotalTVA}{\TotalTVA}{2}<br />&nbsp;&nbsp;&nbsp; \FPround{\TotalTTC}{\TotalTTC}{2}<br />&nbsp;&nbsp;&nbsp; \global\let\TotalHT\TotalHT<br />&nbsp;&nbsp;&nbsp; \global\let\TotalTVA\TotalTVA<br />&nbsp;&nbsp;&nbsp; \global\let\TotalTTC\TotalTTC<br />&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; \cr \hline<br />&nbsp;&nbsp;&nbsp; Total HT&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &amp; &amp; &amp;&nbsp;&nbsp;&nbsp; \TotalHT&nbsp;&nbsp;&nbsp; \cr<br />&nbsp;&nbsp;&nbsp; TVA \TVA~\% &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &amp; &amp; &amp;&nbsp;&nbsp;&nbsp; \TotalTVA&nbsp;&nbsp;&nbsp; \cr<br />&nbsp;&nbsp;&nbsp; \hline \hline<br />&nbsp;&nbsp;&nbsp; \textbf{Total TTC}&nbsp;&nbsp;&nbsp; &amp; &amp; &amp;&nbsp;&nbsp;&nbsp; \TotalTTC<br />}<br /><br />\newcommand*\eaddto[2]{% version d&eacute;velopp&eacute;e de \addto<br />&nbsp;&nbsp; \edef\tmp{#2}%<br />&nbsp;&nbsp; \expandafter\addto<br />&nbsp;&nbsp; \expandafter#1%<br />&nbsp;&nbsp; \expandafter{\tmp}%<br />} <br /><br />\newcommand{\ListeProduits}{}<br /><br /><br /><br /><br />%%%%%%%%%%%%%%%%%%%%% A MODIFIER DANS LA FACTURE %%%%%%%%%%%%%%%%%%%%%<br /><br />\def\FactureNum&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {1}&nbsp;&nbsp;&nbsp; % Num&eacute;ro de facture<br />\def\FactureAcquittee&nbsp;&nbsp;&nbsp; {non}&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; % Facture acquitt&eacute;e : oui/non<br />\def\FactureLieu&nbsp;&nbsp;&nbsp; {Paris}&nbsp;&nbsp;&nbsp; % Lieu de l'&eacute;dition de la facture<br />\def\FactureObjet&nbsp;&nbsp;&nbsp; {facture pour te faire payer}&nbsp;&nbsp;&nbsp; % Objet du document<br />% Description de la facture<br />\def\FactureDescr&nbsp;&nbsp;&nbsp; {%<br />Cette facture concerne la r&eacute;alisation du site web machin-truc.com, son h&eacute;bergement, et la location du nom de domaine<br />}<br /><br />% Infos Client<br />\def\ClientNom{M. Dupont}&nbsp;&nbsp;&nbsp; % Nom du client<br />\def\ClientAdresse{%&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; % Adresse du client<br />&nbsp;&nbsp;&nbsp; 12, rue de la Geekerie \\<br />&nbsp;&nbsp;&nbsp; 75000 Paris<br />}<br /><br />% Liste des produits factur&eacute;s : D&eacute;signation, quantit&eacute;, prix unitaire HT<br />\AjouterProduit&nbsp;&nbsp;&nbsp; {R&eacute;alisation du site}&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {1}&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {1600}<br />\AjouterProduit&nbsp;&nbsp;&nbsp; {H&eacute;bergement -- 1 mois}&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {3}&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {10}<br />\AjouterProduit&nbsp;&nbsp;&nbsp; {Nom de domaine -- 1 an}&nbsp;&nbsp;&nbsp; {1}&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {8}<br /><br />%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%<br /><br /><br /><br /><br />\geometry{verbose,tmargin=4em,bmargin=8em,lmargin=6em,rmargin=6em}<br />\setlength{\parindent}{0pt}<br />\setlength{\parskip}{1ex plus 0.5ex minus 0.2ex}<br /><br />\thispagestyle{fancy}<br />\pagestyle{fancy}<br />\setlength{\parindent}{0pt}<br /><br />\renewcommand{\headrulewidth}{0pt}<br />\cfoot{<br />&nbsp;&nbsp;&nbsp; Ma Soci&eacute;t&eacute; SARL au capital de 3000 &euro; ~--~ 34, rue du Brainfuck - 75000 Paris\newline<br />&nbsp;&nbsp;&nbsp; \small{<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Telephone : +33(0)6 12 34 56 78 ~--~ Site web : www.ma-societe.com ~--~ E-mail : contact@ma-societe.com\newline<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; RCS Paris 512 569 485 ~--~ Code APE 6201Z ~--~ Num&eacute;ro TVA : FR 56-512-569-485<br />&nbsp;&nbsp;&nbsp; }<br />}<br /><br /><br /><br />\begin{document}<br /><br />% Logo de la soci&eacute;t&eacute;<br />\includegraphics{logo.jpg}<br /><br />% Nom et adresse de la soci&eacute;t&eacute;<br />Ma Soci&eacute;t&eacute; SARL \\<br />34, rue du Brainfuck \\<br />75000 Paris<br /><br />Facture n&deg;\FactureNum<br /><br /><br />{\addtolength{\leftskip}{10.5cm} %in ERT<br />&nbsp;&nbsp;&nbsp; \textbf{\ClientNom}&nbsp;&nbsp;&nbsp; \\<br />&nbsp;&nbsp;&nbsp; \ClientAdresse&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \\<br /><br />} %in ERT<br /><br /><br />\hspace*{10.5cm}<br />\FactureLieu, le \today<br /><br />~\\~\\<br /><br />\textbf{Objet : \FactureObjet \\}<br /><br />\textnormal{\FactureDescr}<br /><br />~\\<br /><br />\begin{center}<br />&nbsp;&nbsp;&nbsp; \begin{tabular}{lrrr}<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \textbf{D&eacute;signation ~~~~~~}&nbsp;&nbsp;&nbsp; &amp; \textbf{Prix unitaire}&nbsp;&nbsp;&nbsp; &amp; \textbf{Quantit&eacute;}&nbsp;&nbsp;&nbsp; &amp; \textbf{Montant (EUR)}&nbsp;&nbsp;&nbsp; \\<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \hline<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \AfficheResultat{}<br />&nbsp;&nbsp;&nbsp; \end{tabular}<br />\end{center}<br /><br />~\\<br /><br />\ifthenelse{\equal{\FactureAcquittee}{oui}}{<br />&nbsp;&nbsp;&nbsp; Facture acquitt&eacute;e.<br />}{<br /><br />&nbsp;&nbsp;&nbsp; &Agrave; r&eacute;gler par ch&egrave;que ou par virement bancaire :<br /><br />&nbsp;&nbsp;&nbsp; \begin{center}<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \begin{tabular}{|c c c c|}<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \hline &nbsp;&nbsp;&nbsp; \textbf{Code banque}&nbsp;&nbsp;&nbsp; &amp; \textbf{Code guichet}&nbsp;&nbsp;&nbsp; &amp; \textbf{N&deg; de Compte}&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &amp; \textbf{Cl&eacute; RIB}&nbsp;&nbsp;&nbsp; \\<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 59763&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &amp; 00726&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &amp; 41652387462&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &amp; 98&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \\<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \hline &nbsp;&nbsp;&nbsp; \textbf{IBAN N&deg;}&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &amp; \multicolumn{3}{|l|}{ FR59 4859 4628 7921 0289 8106 846 } &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \\<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \hline &nbsp;&nbsp;&nbsp; \textbf{Code BIC}&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &amp; \multicolumn{3}{|l|}{ AGRIFPRP792 } &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \\<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \hline<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \end{tabular}<br />&nbsp;&nbsp;&nbsp; \end{center}<br /><br />}<br /><br />\end{document}<br />[/code]</div></div></p>
<p><br />Tout d'abord, la premi&egrave;re fois, il faut modifier le nom de votre soci&eacute;t&eacute;, son adresse, le logo (situ&eacute; dans un fichier <em>logo.jpg</em> qui doit &ecirc;tre dans le m&ecirc;me dossier), les informations de votre soci&eacute;t&eacute; en bas de page, et les informations bancaires pour les virements.</p>
<p>Ensuite, &agrave; chaque fois qu'il faudra faire une facture, il suffira de modifier les lignes dans l'encart "A&nbsp;MODIFIER&nbsp;DANS&nbsp;LA&nbsp;FACTURE" o&ugrave; on d&eacute;finit les infos du clients, la description de la facture, et les produits vendus. Tout est expliqu&eacute; dans les commentaires du code <img src="http://www.skreo.net/images/emoticons/smile.gif" border="0" alt=""/></p>
<p>Les sous-totaux, la TVA, et le total TTC sont calcul&eacute;s automatiquement. C'&eacute;tait bien s&ucirc;r la partie la plus dure &agrave; faire... J'ai utilis&eacute; en particulier le package <a href="http://www.tug.org/tetex/tetex-texmfdist/doc/latex/fp/readme.fp">fp</a> pour les calculs.</p>
<p><br />Vous trouverez dans ce targ&eacute;z&egrave;de la source .tex de cet exemple, ainsi que le pdf compil&eacute; :<br /><a href="http://data0.eklablog.com/skreo/perso/facture.tar.gz"><img class="icon" src="http://data0.eklablog.com/skreo/perso/images/icones/download.gif" width="17" height="17" alt=""/> T&eacute;l&eacute;charger l'exemple</a></p><br /><br /><strong>Partager cet article :</strong> <a href="javascript:;" onclick="window.open('http://ek.la/twitter?blog=1535&amp;path=latex-comment-faire-rapidement-une-facture-super-classe-a530591&amp;title=%5BLaTeX%5D+Comment+faire+rapidement+une+facture+super+classe');" onmouseover="if(Help.bubble) Help.bubble(this, &quot;Diffuser sur Twitter&quot;);"><img src="http://www.skreo.net//images/bookmarks/retweet.png" alt="Retweet" class="icon" /></a> <a href="http://www.wikio.fr/vote?url=http%3A%2F%2Fwww.skreo.net%2Flatex-comment-faire-rapidement-une-facture-super-classe-a530591" onmouseover="if(Help.bubble) Help.bubble(this, &quot;Voter sur wikio&quot;);"><img src="http://www.skreo.net//images/bookmarks/wikio.gif" alt="Wikio" class="icon" /></a> <iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.skreo.net%2Flatex-comment-faire-rapidement-une-facture-super-classe-a530591&amp;layout=button_count&amp;show_faces=false&amp;width=110&amp;action=like&amp;colorscheme=light&amp;height=20" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:110px; height:20px;" class="icon" allowTransparency="true"></iframe><br /><br /><hr />Article original rédigé par Skreo et publié sur <a href="http://skreo.eklablog.com">Godefroy de Compreignac</a> <br /> Reproduction interdite sans autorisation]]></content:encoded>
		<pubDate>Sun, 14 Jun 2009 23:15:39 +0200</pubDate>
		<guid isPermaLink="true">http://www.skreo.net/latex-comment-faire-rapidement-une-facture-super-classe-a530591</guid>
		<dc:creator>Skreo</dc:creator>
		<dc:date>2009-06-14T23:15:39+02:00</dc:date>
	</item>
	<item>
		<title><![CDATA[Zim : Gérez vos notes et todo-lists super facilement]]></title>
		<link>http://www.skreo.net/zim-gerez-vos-notes-et-todo-lists-super-facilement-a417068</link>
		<description><![CDATA[Jusqu'&agrave; pr&eacute;sent j'avais des notes et todo-lists dans tous les sens : fichiers txt &eacute;parpill&eacute;s, mails en draft, Tasks de Gmail, bouts de papier, Basecamp... Et puis j'ai d&eacute;couvert Zim par le Linux Pratique n&deg;15 , un petit logiciel qui vous permet de g&eacute;rer toutes vos notes en WYSIWYG . Il est...]]></description>
		<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://data0.eklablog.com/skreo/mod_article417068_1.png"><img src="http://data0.eklablog.com/skreo/mod_article417068_1.jpg" alt="Zim : G&eacute;rez vos notes et todo-lists super facilement" width="500" height="296"/></a></p>
<p>Jusqu'&agrave; pr&eacute;sent j'avais des notes et todo-lists dans tous les sens : fichiers txt &eacute;parpill&eacute;s, mails en draft, Tasks de Gmail, bouts de papier, Basecamp...</p>
<p>Et puis j'ai d&eacute;couvert <a href="http://zim-wiki.org">Zim</a> par le <a href="http://www.linux-pratique.com/">Linux Pratique n&deg;15</a>, un petit logiciel qui vous permet de g&eacute;rer toutes vos notes en <acronym title="What You See Is What You Get"><a href="http://fr.wikipedia.org/wiki/WYSIWYG">WYSIWYG</a></acronym>. Il est <strong>open source</strong> et compatible avec Linux, Mac OS X, et Windows.</p>
<p>L'avantage par rapport &agrave; un b&ecirc;te notepad ou &agrave; un traitement de texte &eacute;volu&eacute;, c'est qu'il est tr&egrave;s l&eacute;ger, qu'on peut cr&eacute;er diff&eacute;rentes pages li&eacute;es et avec une arborescence, et qu'on peut y ajouter des &eacute;l&eacute;ments du type <strong>todo-list</strong>, images, &eacute;quations LaTeX...etc. Sa particularit&eacute; est aussi d'enregistrer les notes au <strong>format Wiki</strong> dans des fichiers txt. Les notes sont donc tr&egrave;s facilement exportables et modifiables sans Zim au besoin.</p>
<p><strong>Les principales fonctionnalit&eacute;s sont :</strong></p>
<ul>
<li>Arborescence des pages + historique en onglets</li>
<li>Mise en page basique : gras, italique, surlign&eacute;, barr&eacute;, titres, liens</li>
<li>Todo-list : tapez simplement "[]" pour faire apparaitre une case &agrave; cocher</li>
<li>Correcteur orthographique : avec le paquet <em>aspell</em></li>
<li>Diagramme avec le paquet <em>dot</em></li>
<li>LaTeX : avec le paquet <em>latex</em></li>
<li>Insertion d'images (tr&egrave;s peu pratique cependant)</li>
<li>Tri d'une liste en un clic</li>
<li>Export HTML</li>
</ul>
<p>Un truc tr&egrave;s pratique aussi, c'est la possibilit&eacute; de mettre Zim dans le <strong>system tray</strong>, pour avoir toujours le logiciel ouvert avec l'ic&ocirc;ne sous la main sans encombrer la barre des t&acirc;ches.</p>
<p>&Agrave; t&eacute;l&eacute;charger ici : <a href="http://zim-wiki.org/downloads.html">http://zim-wiki.org/downloads.html</a></p><br /><br /><strong>Partager cet article :</strong> <a href="javascript:;" onclick="window.open('http://ek.la/twitter?blog=1535&amp;path=zim-gerez-vos-notes-et-todo-lists-super-facilement-a417068&amp;title=Zim+%3A+G%C3%A9rez+vos+notes+et+todo-lists+super+facilement');" onmouseover="if(Help.bubble) Help.bubble(this, &quot;Diffuser sur Twitter&quot;);"><img src="http://www.skreo.net//images/bookmarks/retweet.png" alt="Retweet" class="icon" /></a> <a href="http://www.wikio.fr/vote?url=http%3A%2F%2Fwww.skreo.net%2Fzim-gerez-vos-notes-et-todo-lists-super-facilement-a417068" onmouseover="if(Help.bubble) Help.bubble(this, &quot;Voter sur wikio&quot;);"><img src="http://www.skreo.net//images/bookmarks/wikio.gif" alt="Wikio" class="icon" /></a> <iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.skreo.net%2Fzim-gerez-vos-notes-et-todo-lists-super-facilement-a417068&amp;layout=button_count&amp;show_faces=false&amp;width=110&amp;action=like&amp;colorscheme=light&amp;height=20" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:110px; height:20px;" class="icon" allowTransparency="true"></iframe><br /><br /><hr />Article original rédigé par Skreo et publié sur <a href="http://skreo.eklablog.com">Godefroy de Compreignac</a> <br /> Reproduction interdite sans autorisation]]></content:encoded>
		<pubDate>Sun, 05 Apr 2009 21:05:40 +0200</pubDate>
		<guid isPermaLink="true">http://www.skreo.net/zim-gerez-vos-notes-et-todo-lists-super-facilement-a417068</guid>
		<dc:creator>Skreo</dc:creator>
		<dc:date>2009-04-05T21:05:40+02:00</dc:date>
	</item>
	<item>
		<title><![CDATA[22,6 Kg de flyers EklaBlog]]></title>
		<link>http://www.skreo.net/-22-6-kg-de-flyers-eklablog-a392723</link>
		<description><![CDATA[Un gros colis est arriv&eacute; chez moi : les 10 000 flyers EklaBlog ! Va falloir qu'on m'aide &agrave; les distribuer ^^ 

 Partager cet article : 

 Article original r&eacute;dig&eacute; par Skreo et publi&eacute; sur Godefroy de Compreignac 
 Reproduction interdite sans autorisation]]></description>
		<content:encoded><![CDATA[<p>Un gros colis est arriv&eacute; chez moi : les 10 000 flyers EklaBlog !</p>
<p>
<p style="text-align: center;"><img src="http://data0.eklablog.com/skreo/mod_article392723_1.jpg" alt="22,6 Kg de flyers EklaBlog"/></p>
Va falloir qu'on m'aide &agrave; les distribuer ^^</p><br /><br /><strong>Partager cet article :</strong> <a href="javascript:;" onclick="window.open('http://ek.la/twitter?blog=1535&amp;path=-22-6-kg-de-flyers-eklablog-a392723&amp;title=22%2C6+Kg+de+flyers+EklaBlog');" onmouseover="if(Help.bubble) Help.bubble(this, &quot;Diffuser sur Twitter&quot;);"><img src="http://www.skreo.net//images/bookmarks/retweet.png" alt="Retweet" class="icon" /></a> <a href="http://www.wikio.fr/vote?url=http%3A%2F%2Fwww.skreo.net%2F-22-6-kg-de-flyers-eklablog-a392723" onmouseover="if(Help.bubble) Help.bubble(this, &quot;Voter sur wikio&quot;);"><img src="http://www.skreo.net//images/bookmarks/wikio.gif" alt="Wikio" class="icon" /></a> <iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.skreo.net%2F-22-6-kg-de-flyers-eklablog-a392723&amp;layout=button_count&amp;show_faces=false&amp;width=110&amp;action=like&amp;colorscheme=light&amp;height=20" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:110px; height:20px;" class="icon" allowTransparency="true"></iframe><br /><br /><hr />Article original rédigé par Skreo et publié sur <a href="http://skreo.eklablog.com">Godefroy de Compreignac</a> <br /> Reproduction interdite sans autorisation]]></content:encoded>
		<pubDate>Mon, 16 Mar 2009 15:54:50 +0100</pubDate>
		<guid isPermaLink="true">http://www.skreo.net/-22-6-kg-de-flyers-eklablog-a392723</guid>
		<dc:creator>Skreo</dc:creator>
		<dc:date>2009-03-16T15:54:50+01:00</dc:date>
	</item>
	<item>
		<title><![CDATA[Un bookmarklet pour consulter les infos Whois d'un site en un clic]]></title>
		<link>http://www.skreo.net/un-bookmarklet-pour-consulter-les-infos-whois-d-un-site-en-un-clic-a381730</link>
		<description><![CDATA[Ayant tr&egrave;s souvent besoin de consulter les informations Whois d'un site pour par exemple contacter le webmaster , v&eacute;rifier l'h&eacute;bergeur, consulter la disponibilit&eacute; ...etc, j'ai eu l'id&eacute;e de faire deux bookmarklets pour faciliter l'usage du Whois.
J'ai choisi ici d'utiliser...]]></description>
		<content:encoded><![CDATA[<p>Ayant tr&egrave;s souvent besoin de consulter les <strong>informations Whois</strong> d'un site pour par exemple <strong>contacter le webmaster</strong>, v&eacute;rifier l'h&eacute;bergeur, <strong>consulter la disponibilit&eacute;</strong>...etc, j'ai eu l'id&eacute;e de faire deux bookmarklets pour faciliter l'usage du Whois.<br />J'ai choisi ici d'utiliser <em>whois.domaintools.com</em>, mais vous pouvez bien s&ucirc;r modifier le code pour en utiliser un autre.</p>
<p>Pour ajouter les bookmarklets &agrave; votre navigateur, glissez-d&eacute;posez les liens dans vos favoris (par exemple dans la barre personnelle de Firefox) :</p>
<p>Le premier sert &agrave; afficher le whois de la page courante :<a style="border: 1px solid #bbbbff; font-weight: bold; display: block; width: 70px; text-align: center;" href="javascript:void(location.href='http://whois.domaintools.com/'+location.host)">Whois ?</a></p>
<p>Le deuxi&egrave;me demande un nom de domaine par une fen&ecirc;tre prompt, et en donne le whois :<a style="border: 1px solid #bbbbff; font-weight: bold; display: block; width: 70px; text-align: center;" href="javascript:a='';if(/^[a-z0-9_-]+\.[a-z0-9_-]+$/.test(a=prompt('URI ?')))location.href='http://whois.domaintools.com/'+a;void(0);">Whois...?</a></p>
<p>D&icirc;tes-moi si &ccedil;a vous sert <img src="http://www.skreo.net/images/emoticons/wink2.gif" border="0" alt=""/></p><br /><br /><strong>Partager cet article :</strong> <a href="javascript:;" onclick="window.open('http://ek.la/twitter?blog=1535&amp;path=un-bookmarklet-pour-consulter-les-infos-whois-d-un-site-en-un-clic-a381730&amp;title=Un+bookmarklet+pour+consulter+les+infos+Whois+d%27un+site+en+un+clic');" onmouseover="if(Help.bubble) Help.bubble(this, &quot;Diffuser sur Twitter&quot;);"><img src="http://www.skreo.net//images/bookmarks/retweet.png" alt="Retweet" class="icon" /></a> <a href="http://www.wikio.fr/vote?url=http%3A%2F%2Fwww.skreo.net%2Fun-bookmarklet-pour-consulter-les-infos-whois-d-un-site-en-un-clic-a381730" onmouseover="if(Help.bubble) Help.bubble(this, &quot;Voter sur wikio&quot;);"><img src="http://www.skreo.net//images/bookmarks/wikio.gif" alt="Wikio" class="icon" /></a> <iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.skreo.net%2Fun-bookmarklet-pour-consulter-les-infos-whois-d-un-site-en-un-clic-a381730&amp;layout=button_count&amp;show_faces=false&amp;width=110&amp;action=like&amp;colorscheme=light&amp;height=20" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:110px; height:20px;" class="icon" allowTransparency="true"></iframe><br /><br /><hr />Article original rédigé par Skreo et publié sur <a href="http://skreo.eklablog.com">Godefroy de Compreignac</a> <br /> Reproduction interdite sans autorisation]]></content:encoded>
		<pubDate>Fri, 06 Mar 2009 20:14:49 +0100</pubDate>
		<guid isPermaLink="true">http://www.skreo.net/un-bookmarklet-pour-consulter-les-infos-whois-d-un-site-en-un-clic-a381730</guid>
		<dc:creator>Skreo</dc:creator>
		<dc:date>2009-03-06T20:14:49+01:00</dc:date>
	</item>
	<item>
		<title><![CDATA[Faire un backup incrémental avec un simple bash]]></title>
		<link>http://www.skreo.net/faire-un-backup-incremental-avec-un-simple-bash-a335207</link>
		<description><![CDATA[J'ai bricol&eacute; un bash pour faire des sauvegardes incr&eacute;mentales quotidiennes de l'ensemble des blogs d'EklaBlog, et j'ai d&eacute;cid&eacute; de vous en faire cadeau Il n'y a rien d'exceptionnel, mais l'astuce n'est pas toujours facile &agrave; trouver sur le net, et cela &eacute;vite d'installer des logiciels comme...]]></description>
		<content:encoded><![CDATA[<p style="text-align: center;"><img src="http://data0.eklablog.com/skreo/mod_article335207_1.jpg" alt="Faire un backup incr&eacute;mental avec un simple bash"/></p>
<p>J'ai bricol&eacute; un bash pour faire des <strong>sauvegardes incr&eacute;mentales quotidiennes</strong> de l'ensemble des blogs d'EklaBlog, et j'ai d&eacute;cid&eacute; de vous en faire cadeau <img src="http://www.skreo.net/images/emoticons/wink2.gif" border="0" alt=""/> Il n'y a rien d'exceptionnel, mais l'astuce n'est pas toujours facile &agrave; trouver sur le net, et cela &eacute;vite d'installer des logiciels comme backup-manager.</p>
<p>J'avais d&eacute;j&agrave; &eacute;crit <a href="http://www.skreo.net//article-2906-91945-mes-solutions-de-backups-et-de-synchronisations-rsync-cron.html">un article au sujet des backups</a>, qui est un peu plus complet sur la description de <a href="http://fr.wikipedia.org/wiki/Rsync">rsync</a> et de <a href="http://fr.wikipedia.org/wiki/Cron">cron</a>, mais il ne traitait pas des sauvegardes incr&eacute;mentales.</p>
<p>L'avantage de ce script par rapport &agrave; certains autres que l'ont peut trouver sur l'intraweb, c'est que ce script cr&eacute;e <strong>un dossier par jour</strong>, et que <strong>chaque dossier de sauvegarde est totalement utilisable seul</strong>. Je dis &ccedil;a car g&eacute;n&eacute;ralement, on utilise la fonction <em>--backup</em> de <em>rsync</em> qui se contente de garder les fichiers modifi&eacute;s dans un autre dossier, ce qui ne permet pas de r&eacute;cup&eacute;rer facilement la sauvegarde totale d'un jour. Au contraire, ce script cr&eacute;e une copie totale de chaque jour, tout en minimisant l'espace disque utilis&eacute; (Un m&ecirc;me fichier pr&eacute;sent dans plusieurs sauvegardes ne sera &eacute;crit qu'une seule fois sur le disque).</p>
<p>Ce script peut fonctionner aussi bien pour la sauvegarde des sites que pour la sauvegarde de fichiers personnels situ&eacute;s sur un ordinateur. Le principal, c'est que le serveur (ordinateur qui contient les donn&eacute;es &agrave; sauvegarder) ait un serveur ssh, et que le client (ordinateur sur lequel vont &ecirc;tre stock&eacute;es les donn&eacute;es) ait la commande <em>rsync</em>. Ca fonctionne sous Linux, et normalement &ccedil;a devrait &ecirc;tre pareil sur Mac.</p>
<p>Pour installer <a href="http://fr.wikipedia.org/wiki/Ssh">ssh</a> sur le serveur (s'il n'est pas install&eacute;) :<br /><div class="code"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> openssh-server<div style="display:none;">[code=bash]sudo apt-get install openssh-server[/code]</div></div><br />Note : "sudo apt-get" fonctionne sur les machines utilisant le gestionnaire de paquets apt. Il se peut que vous ayez &agrave; en utiliser un autre, comme "yum". La commande "sudo" n'est pas n&eacute;cessaire si vous &ecirc;tes d&eacute;j&agrave; en mode administrateur.</p>
<p>Pour installer rsync sur le client :<br /><div class="code"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> rsync<div style="display:none;">[code=bash]sudo apt-get install rsync[/code]</div></div></p>
<p><br />Passons maintenant au script en lui m&ecirc;me :<br /><div class="code"><span style="color: #666666; font-style: italic;"># Source du backup</span><br />
<span style="color: #007800;">SRC</span>=root<span style="color: #000000; font-weight: bold;">@</span>server:<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>dossier<span style="color: #000000; font-weight: bold;">/</span>a<span style="color: #000000; font-weight: bold;">/</span>sauvegarder<br />
<span style="color: #666666; font-style: italic;"># Destination du backup</span><br />
<span style="color: #007800;">DST</span>=<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>dossier<span style="color: #000000; font-weight: bold;">/</span>contenant<span style="color: #000000; font-weight: bold;">/</span>les<span style="color: #000000; font-weight: bold;">/</span>sauvegardes<br />
<span style="color: #666666; font-style: italic;"># Date de la forme année-mois-jour-timestamp</span><br />
<span style="color: #666666; font-style: italic;"># (le timestamp %s sert si on veut faire plusieurs sauvegardes dans la même journée)</span><br />
<span style="color: #007800;">DATE</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>Y-<span style="color: #000000; font-weight: bold;">%</span>m-<span style="color: #000000; font-weight: bold;">%</span>d-<span style="color: #000000; font-weight: bold;">%</span>s<span style="color: #000000; font-weight: bold;">`</span><br />
<br />
<span style="color: #666666; font-style: italic;"># Création du répertoire temporaire</span><br />
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #007800;">$DST</span><span style="color: #000000; font-weight: bold;">/</span>tmp<br />
<br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Backup commencé le &quot;</span><span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> <span style="color: #ff0000;">&quot;+%d/%m/%Y à %T&quot;</span><span style="color: #000000; font-weight: bold;">`</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Starting : &quot;</span><span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> <span style="color: #ff0000;">&quot;+%Y-%m-%d %T&quot;</span><span style="color: #000000; font-weight: bold;">`</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$DST</span><span style="color: #000000; font-weight: bold;">/</span>log<br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Copie de la dernière sauvegarde...&quot;</span><br />
<br />
<span style="color: #666666; font-style: italic;"># Si une sauvegarde a déjà été faite précédemment</span><br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #660033;">-d</span> <span style="color: #007800;">$DST</span><span style="color: #000000; font-weight: bold;">/</span>today ; <span style="color: #000000; font-weight: bold;">then</span><br />
    <span style="color: #666666; font-style: italic;"># Et si le fichier contenant la date de la dernière sauvegarde existe</span><br />
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$DST</span><span style="color: #000000; font-weight: bold;">/</span>last_date ; <span style="color: #000000; font-weight: bold;">then</span><br />
    <br />
        <span style="color: #007800;">LASTDATE</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$DST</span><span style="color: #000000; font-weight: bold;">/</span>last_date<span style="color: #000000; font-weight: bold;">`</span><br />
        <span style="color: #666666; font-style: italic;"># Alors on fait un copie en hardlinks de la sauvegarde d'hier</span><br />
        <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-al</span> <span style="color: #007800;">$DST</span><span style="color: #000000; font-weight: bold;">/</span>today <span style="color: #007800;">$DST</span><span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span><br />
        <span style="color: #666666; font-style: italic;"># Puis on renomme la copie pour qu'elle devienne la sauvegarde d'hier</span><br />
        <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$DST</span><span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>today <span style="color: #007800;">$DST</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$LASTDATE</span><br />
        <br />
    <span style="color: #000000; font-weight: bold;">fi</span><br />
    <br />
<span style="color: #666666; font-style: italic;"># Sinon, on crée le premier dossier</span><br />
<span style="color: #000000; font-weight: bold;">else</span><br />
    <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #007800;">$DST</span><span style="color: #000000; font-weight: bold;">/</span>today<br />
<span style="color: #000000; font-weight: bold;">fi</span><br />
<br />
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> <span style="color: #007800;">$DST</span><span style="color: #000000; font-weight: bold;">/</span>tmp<br />
<span style="color: #666666; font-style: italic;"># On sauvegarde la date actuelle pour le prochain backup</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$DATE</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$DST</span><span style="color: #000000; font-weight: bold;">/</span>last_date<br />
<br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Synchronisation de la sauvegarde du jour...&quot;</span><br />
<br />
<span style="color: #666666; font-style: italic;"># Synchronisation de la source avec le dossier du jour</span><br />
rsync <span style="color: #660033;">-az</span> <span style="color: #660033;">--delete</span> <span style="color: #660033;">--size-only</span> <span style="color: #007800;">$SRC</span><span style="color: #000000; font-weight: bold;">/</span> <span style="color: #007800;">$DST</span><span style="color: #000000; font-weight: bold;">/</span>today<span style="color: #000000; font-weight: bold;">/</span><br />
<br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Backup terminé le &quot;</span><span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> <span style="color: #ff0000;">&quot;+%d/%m/%Y à %T&quot;</span><span style="color: #000000; font-weight: bold;">`</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Done : &quot;</span><span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> <span style="color: #ff0000;">&quot;+%Y-%m-%d %T&quot;</span><span style="color: #000000; font-weight: bold;">`</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$DST</span><span style="color: #000000; font-weight: bold;">/</span>log<div style="display:none;">[code=bash]# Source du backup<br />SRC=root@server:/home/dossier/a/sauvegarder<br /># Destination du backup<br />DST=/home/dossier/contenant/les/sauvegardes<br /># Date de la forme ann&eacute;e-mois-jour-timestamp<br /># (le timestamp %s sert si on veut faire plusieurs sauvegardes dans la m&ecirc;me journ&eacute;e)<br />DATE=`date +%Y-%m-%d-%s`<br /><br /># Cr&eacute;ation du r&eacute;pertoire temporaire<br />mkdir $DST/tmp<br /><br />echo "Backup commenc&eacute; le "`date "+%d/%m/%Y &agrave; %T"`<br />echo "Starting : "`date "+%Y-%m-%d %T"` &gt;&gt; $DST/log<br />echo "Copie de la derni&egrave;re sauvegarde..."<br /><br /># Si une sauvegarde a d&eacute;j&agrave; &eacute;t&eacute; faite pr&eacute;c&eacute;demment<br />if test -d $DST/today ; then<br />&nbsp;&nbsp;&nbsp; # Et si le fichier contenant la date de la derni&egrave;re sauvegarde existe<br />&nbsp;&nbsp;&nbsp; if test -f $DST/last_date ; then<br />&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; LASTDATE=`cat $DST/last_date`<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # Alors on fait un copie en hardlinks de la sauvegarde d'hier<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; cp -al $DST/today $DST/tmp/<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Puis on renomme la copie pour qu'elle devienne la sauvegarde d'hier<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; mv $DST/tmp/today $DST/$LASTDATE<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; fi<br />&nbsp;&nbsp;&nbsp; <br /># Sinon, on cr&eacute;e le premier dossier<br />else<br />&nbsp;&nbsp;&nbsp; mkdir $DST/today<br />fi<br /><br />rm -rf $DST/tmp<br /># On sauvegarde la date actuelle pour le prochain backup<br />echo $DATE &gt; $DST/last_date<br /><br />echo "Synchronisation de la sauvegarde du jour..."<br /><br /># Synchronisation de la source avec le dossier du jour<br />rsync -az --delete --size-only $SRC/ $DST/today/<br /><br />echo "Backup termin&eacute; le "`date "+%d/%m/%Y &agrave; %T"`<br />echo "Done : "`date "+%Y-%m-%d %T"` &gt;&gt; $DST/log[/code]</div></div></p>
<p><br />Et voil&agrave;, avec un fichier log en prime !<br />Pour ceux qui ne comprennent pas trop le fonctionnement du script, c'est en fait assez simple :<br />"<em>cp -al ...</em>" permet de faire une copie conforme d'un dossier mais en hardlinks, c'est-&agrave;-dire en dupliquant juste les noms des fichiers sur le disque dur. Un m&ecirc;me fichier devient alors accessible depuis deux endroits diff&eacute;rents (ou plus si on a plus d'une sauvegarde du fichier). Ensuite le <em>rsync</em> synchronise la source en ajoutant les nouveaux fichiers dans le dossier du jour, et en supprimant et modifiant les fichiers supprim&eacute;s ou modifi&eacute;s depuis la derni&egrave;re sauvegarde. L'astuce, c'est que lorsque <em>rsync</em> modifie un fichier, il est d'abord supprim&eacute; puis r&eacute;&eacute;crit, ce qui a pour effet de ne pas modifier les fichiers du m&ecirc;me nom dans les sauvegardes ant&eacute;rieures.</p>
<p>Le flag <em>--size-only</em> permet de ne synchroniser que les fichiers dont la taille a chang&eacute;. Vous pouvez utilisez le flag <em>-c</em> (ou <em>--checksum</em>) pour v&eacute;rifier plut&ocirc;t la signature de chaque fichier, ce qui est plus s&ucirc;r mais beaucoup plus long si votre dossier &agrave; sauvegarder est tr&egrave;s volumineux.</p>
<p>Il ne reste plus qu'&agrave; automatiser l'ex&eacute;cution du script sur votre pc (&ccedil;a se passe c&ocirc;t&eacute; client). Nous allons ajouter une ligne d'instruction dans les t&acirc;ches <em>cron</em>. Pour faire simple, tapez la commande :<br /><div class="code"><span style="color: #c20cb9; font-weight: bold;">sudo</span> crontab <span style="color: #660033;">-e</span><div style="display:none;">[code=bash]sudo crontab -e[/code]</div></div></p>
<p>Puis rajoutez la ligne :<br /><div class="code"><span style="color: #000000;">0</span> <span style="color: #000000;">20</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">bash</span> <span style="color: #000000; font-weight: bold;">/</span>chemin<span style="color: #000000; font-weight: bold;">/</span>absolu<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">du</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">bash</span><span style="color: #000000; font-weight: bold;">/</span>qu<span style="color: #000000; font-weight: bold;">/</span>on<span style="color: #000000; font-weight: bold;">/</span>vient<span style="color: #000000; font-weight: bold;">/</span>de<span style="color: #000000; font-weight: bold;">/</span>creer.sh <span style="color: #000000; font-weight: bold;">&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span><div style="display:none;">[code=bash]0 20 * * * /bin/bash /chemin/absolu/du/bash/qu/on/vient/de/creer.sh &gt;/dev/null 2&gt;&amp;1[/code]</div></div></p>
<p>Pour plus de d&eacute;tails sur le <em>cron</em>, et surtout sur la mani&egrave;re de configurer <em>ssh</em> pour que le script puisse s'ex&eacute;cuter sans votre intervention qui est normlament n&eacute;cessaire pour entrer le mot de passe ssh, vous pouvez consulter <a href="http://www.skreo.net//article-2906-91945-mes-solutions-de-backups-et-de-synchronisations-rsync-cron.html">mon pr&eacute;c&eacute;dent article au sujet des backups</a>.</p>
<p>J'esp&egrave;re que ce petit script pourra vous &ecirc;tre utile. J'attends vos retours et remarques <img src="http://www.skreo.net/images/emoticons/wink2.gif" border="0" alt=""/></p><br /><br /><strong>Partager cet article :</strong> <a href="javascript:;" onclick="window.open('http://ek.la/twitter?blog=1535&amp;path=faire-un-backup-incremental-avec-un-simple-bash-a335207&amp;title=Faire+un+backup+incr%C3%A9mental+avec+un+simple+bash');" onmouseover="if(Help.bubble) Help.bubble(this, &quot;Diffuser sur Twitter&quot;);"><img src="http://www.skreo.net//images/bookmarks/retweet.png" alt="Retweet" class="icon" /></a> <a href="http://www.wikio.fr/vote?url=http%3A%2F%2Fwww.skreo.net%2Ffaire-un-backup-incremental-avec-un-simple-bash-a335207" onmouseover="if(Help.bubble) Help.bubble(this, &quot;Voter sur wikio&quot;);"><img src="http://www.skreo.net//images/bookmarks/wikio.gif" alt="Wikio" class="icon" /></a> <iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.skreo.net%2Ffaire-un-backup-incremental-avec-un-simple-bash-a335207&amp;layout=button_count&amp;show_faces=false&amp;width=110&amp;action=like&amp;colorscheme=light&amp;height=20" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:110px; height:20px;" class="icon" allowTransparency="true"></iframe><br /><br /><hr />Article original rédigé par Skreo et publié sur <a href="http://skreo.eklablog.com">Godefroy de Compreignac</a> <br /> Reproduction interdite sans autorisation]]></content:encoded>
		<pubDate>Thu, 22 Jan 2009 23:03:10 +0100</pubDate>
		<guid isPermaLink="true">http://www.skreo.net/faire-un-backup-incremental-avec-un-simple-bash-a335207</guid>
		<dc:creator>Skreo</dc:creator>
		<dc:date>2009-01-22T23:03:10+01:00</dc:date>
	</item>
	<item>
		<title><![CDATA[[Sécurité PHP] Toujours vérifier le Referer lors d'un envoi par POST]]></title>
		<link>http://www.skreo.net/securite-php-toujours-verifier-le-referer-lors-d-un-envoi-par-post-a313986</link>
		<description><![CDATA[&copy; Photo de divarvel C'est un aspect tr&egrave;s souvent n&eacute;glig&eacute; de la s&eacute;curit&eacute; des sites web, et qui est pourtant critique . Par exemple, si Facebook n'avait pas pr&eacute;vu ce genre de s&eacute;curit&eacute;, nous pourrions partir du postulat qu'il y a une chance non n&eacute;gligeable qu'un visiteur soit connect&eacute; &agrave;...]]></description>
		<content:encoded><![CDATA[<p style="text-align: center; margin-bottom: 0;"><img src="http://data0.eklablog.com/skreo/mod_article313986_1.jpg" alt="[S&eacute;curit&eacute; PHP] Toujours v&eacute;rifier le Referer lors d'un envoi par POST"/></p>
<p style="text-align: right; margin-top: 0;"><a style="color: #999999;" href="http://www.divarvel.fr">&copy; Photo de divarvel</a></p>
<p>C'est un aspect <strong>tr&egrave;s souvent n&eacute;glig&eacute;</strong> de la s&eacute;curit&eacute; des sites web, et qui est pourtant <strong>critique</strong>.</p>
<p>Par exemple, si Facebook n'avait pas pr&eacute;vu ce genre de s&eacute;curit&eacute;, nous pourrions partir du postulat qu'il y a une chance non n&eacute;gligeable qu'un visiteur soit connect&eacute; &agrave; Facebook (par session ou cookies). Prenons alors une page web visit&eacute;e par quelques dizaines ou centaines de visiteurs par jour, un blog par exemple. Sur cette page, nous allons mettre un formulaire identique &agrave; celui permettant de modifier le profil sur Facebook. Une ligne de javascript suffira &agrave; envoyer le formulaire ( <em>$("id_form").submit()</em> ), avec tout plein de grossi&egrave;ret&eacute;s qui viendront &eacute;gayer le profil de l'utilisateur <img src="http://www.skreo.net/images/emoticons/happy.gif" border="0" alt=""/></p>
<p>C'est de cette mani&egrave;re qu'Olivier Duffez s'est fait<strong> pirater son compte Gmail</strong> puis le nom de domaine Webrankinfo.com ! En effet, le pirate s'est d&eacute;brouill&eacute; pour que M. Duffez se retrouve sur une page envoyant un formulaire vers la page de cr&eacute;ation de filtre de Gmail. Et comme une session Gmail &eacute;tait ouverte sur l'ordinateur de M. Duffez, le formulaire en question a pu cr&eacute;er un filtre qui transf&eacute;rait tous les e-mails re&ccedil;us au spammeur. Le spammeur a ensuite utilis&eacute; le formulaire "Mot de passe oubli&eacute;" du registrar chez lequel est enregistr&eacute; webrankinfo.com, et a donc re&ccedil;u l'e-mail permettant de modifier le mot de passe.</p>
<p>Alors ? N'est-ce pas <strong>critique</strong> comme faille ?<br />Ce type d'attaque est appel&eacute; <a href="http://fr.wikipedia.org/wiki/Cross-Site_Request_Forgeries">Cross-Site Request Forgery</a>, et n'est pas tr&egrave;s connu en raison d'un manque de communication &agrave; ce propos.<br />Voyons comment l'&eacute;tudier concr&egrave;tement, et <strong>comment &eacute;viter ce genre de d&eacute;boires</strong>.</p>
<p>&nbsp;</p>
<p>Pour vous montrer un <strong>exemple concret</strong>, cr&eacute;ons une page affichant les donn&eacute;es re&ccedil;ues par POST :<br /><a href="http://data0.eklablog.com/skreo/perso/test_referer.php">http://data0.eklablog.com/skreo/perso/test_referer.php</a></p>
<p>Code de la page :<br /><div class="code">&lt;pre&gt;<br />
Données reçues par POST :<br />
<span style="color: #0000ff;">$_POST</span> = <span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<a href="http://www.php.net/print_r"><span style="color: #000066;">print_r</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$_POST</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #000000; font-weight: bold;">?&gt;</span><br />
&lt;/pre&gt;<div style="display:none;">[code=php]&lt;pre&gt;<br />Donn&eacute;es re&ccedil;ues par POST :<br />$_POST = &lt;?php<br />print_r($_POST);<br />?&gt;<br />&lt;/pre&gt;[/code]</div></div></p>
<p>&nbsp;</p>
<p>Ensuite, sur un <strong>nom de domaine diff&eacute;rent</strong> (ici skreo.net), cr&eacute;ons un petit formulaire qui envoie des donn&eacute;es &agrave; cette page :</p>
<p><div class="code"><span style="color: #009900;"><a href="http://december.com/html/4/element/form.html"><span style="color: #000000; font-weight: bold;">&lt;form</span></a> <span style="color: #000066;">action</span>=<span style="color: #ff0000;">&quot;http://data0.eklablog.com/skreo/perso/test_referer.php&quot;</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;post&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;form_test_referer&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span><br />
    Variable &quot;var&quot; : <span style="color: #009900;"><a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">&lt;input</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;var&quot;</span> /<span style="color: #000000; font-weight: bold;">&gt;</span></a></span><span style="color: #009900;"><a href="http://december.com/html/4/element/br.html"><span style="color: #000000; font-weight: bold;">&lt;br</span></a> /<span style="color: #000000; font-weight: bold;">&gt;</span></a></span><br />
    <span style="color: #009900;"><a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">&lt;input</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;submit&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Envoyer&quot;</span> /<span style="color: #000000; font-weight: bold;">&gt;</span></a></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/form&gt;</span></span><div style="display:none;">[code=html]&lt;form action="http://data0.eklablog.com/skreo/perso/test_referer.php" method="post" id="form_test_referer"&gt;<br />&nbsp;&nbsp;&nbsp; Variable "var" : &lt;input type="text" value="" name="var" /&gt;&lt;br /&gt;<br />&nbsp;&nbsp;&nbsp; &lt;input type="submit" value="Envoyer" /&gt;<br />&lt;/form&gt;[/code]</div></div></p>
<p>Ce qui donne ceci :</p>
<form id="form_test_referer" style="border: 1px dashed red;" action="http://data0.eklablog.com/skreo/perso/test_referer.php" method="post"> Variable "var" : <input name="var" type="text"/><br /> <input type="submit" value="Envoyer"/> </form>
<p>Vous pouvez tester ce formulaire, vous voyez bien qu'on peut envoyer n'importe quelles donn&eacute;es par POST vers un autre domaine. Un petit bout de code Javascript &agrave; la suite du formulaire permet d'envoyer le formulaire imm&eacute;diatement sans m&ecirc;me demander l'avis du visiteur :</p>
<p><div class="code"><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">&lt;script</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/javascript&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span><br />
document.getElementById(&quot;form_test_referer&quot;).submit();<br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span><div style="display:none;">[code=html]&lt;script type="text/javascript"&gt;<br />document.getElementById("form_test_referer").submit();<br />&lt;/script&gt;[/code]</div></div></p>
<p>&nbsp;</p>
<p>Voyons maintenant <strong>comment emp&ecirc;cher dans la majorit&eacute; des cas ce genre de hacks</strong>, avec l'aide du <a href="http://fr.wikipedia.org/wiki/R%C3%A9f%C3%A9rant">Referer</a>. Je dis bien "dans la majorit&eacute; des cas", car parfois le visiteur r&egrave;gle son navigateur internet pour que le referer soit vide.</p>
<p>Nous allons donc comparer le Referer avec le nom de domaine de la page courante, et vider la variable $_POST s'il est diff&eacute;rent. Reprenons notre fichier test_referer.php et nommons le <a href="http://data0.eklablog.com/skreo/perso/test_referer2.php">test_referer2.php</a> :</p>
<p><div class="code"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<br />
<span style="color: #808080; font-style: italic;">// Vérification du Referer pour les variables passées en POST</span><br />
&nbsp;<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #000066;">isset</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$_SERVER</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'HTTP_REFERER'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><br />
  &amp;&amp; <span style="color: #0000ff;">$_SERVER</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'HTTP_REFERER'</span><span style="color: #66cc66;">&#93;</span>!=<span style="color: #ff0000;">''</span><br />
  &amp;&amp; <a href="http://www.php.net/substr"><span style="color: #000066;">substr</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$_SERVER</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'HTTP_REFERER'</span><span style="color: #66cc66;">&#93;</span>, <span style="color: #cc66cc;">7</span>, <a href="http://www.php.net/strlen"><span style="color: #000066;">strlen</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$_SERVER</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'SERVER_NAME'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> != <span style="color: #0000ff;">$_SERVER</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'SERVER_NAME'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp;    <span style="color: #0000ff;">$_POST</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp;<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">?&gt;</span><br />
&lt;pre&gt;<br />
Données reçues par POST :<br />
<span style="color: #0000ff;">$_POST</span> = <span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<a href="http://www.php.net/print_r"><span style="color: #000066;">print_r</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$_POST</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #000000; font-weight: bold;">?&gt;</span><br />
&lt;/pre&gt;<div style="display:none;">[code=php]&lt;?php<br /><br />// V&eacute;rification du Referer pour les variables pass&eacute;es en POST<br /> if(isset($_SERVER['HTTP_REFERER'])<br />&nbsp; &amp;&amp; $_SERVER['HTTP_REFERER']!=''<br />&nbsp; &amp;&amp; substr($_SERVER['HTTP_REFERER'], 7, strlen($_SERVER['SERVER_NAME'])) != $_SERVER['SERVER_NAME']){<br /> &nbsp;&nbsp;&nbsp; $_POST = array();<br /> }<br /><br />?&gt;<br />&lt;pre&gt;<br />Donn&eacute;es re&ccedil;ues par POST :<br />$_POST = &lt;?php<br />print_r($_POST);<br />?&gt;<br />&lt;/pre&gt;[/code]</div></div></p>
<p>Reprenons notre formulaire pour tester, mais cette fois vers test_referer2.php :</p>
<form style="border: 1px dashed red;" action="http://data0.eklablog.com/skreo/perso/test_referer2.php" method="post"> Variable "var" : <input name="var" type="text"/><br /> <input type="submit" value="Envoyer"/> </form>
<p>&nbsp;</p>
<p>Et <strong>le tour est jou&eacute;</strong> !<br />La page accepte toujours les envois de donn&eacute;es par POST provenant du m&ecirc;me nom de domaine, mais n'accepte pas les autres !</p>
<p>Si vous avez un site web, je vous conseille tr&egrave;s fortement de mettre en place cette s&eacute;curit&eacute;, si ce n'est pas d&eacute;j&agrave; le cas <img src="http://www.skreo.net/images/emoticons/wink2.gif" border="0" alt=""/></p><br /><br /><strong>Partager cet article :</strong> <a href="javascript:;" onclick="window.open('http://ek.la/twitter?blog=1535&amp;path=securite-php-toujours-verifier-le-referer-lors-d-un-envoi-par-post-a313986&amp;title=%5BS%C3%A9curit%C3%A9+PHP%5D+Toujours+v%C3%A9rifier+le+Referer+lors+d%27un+envoi+par+POST');" onmouseover="if(Help.bubble) Help.bubble(this, &quot;Diffuser sur Twitter&quot;);"><img src="http://www.skreo.net//images/bookmarks/retweet.png" alt="Retweet" class="icon" /></a> <a href="http://www.wikio.fr/vote?url=http%3A%2F%2Fwww.skreo.net%2Fsecurite-php-toujours-verifier-le-referer-lors-d-un-envoi-par-post-a313986" onmouseover="if(Help.bubble) Help.bubble(this, &quot;Voter sur wikio&quot;);"><img src="http://www.skreo.net//images/bookmarks/wikio.gif" alt="Wikio" class="icon" /></a> <iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.skreo.net%2Fsecurite-php-toujours-verifier-le-referer-lors-d-un-envoi-par-post-a313986&amp;layout=button_count&amp;show_faces=false&amp;width=110&amp;action=like&amp;colorscheme=light&amp;height=20" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:110px; height:20px;" class="icon" allowTransparency="true"></iframe><br /><br /><hr />Article original rédigé par Skreo et publié sur <a href="http://skreo.eklablog.com">Godefroy de Compreignac</a> <br /> Reproduction interdite sans autorisation]]></content:encoded>
		<pubDate>Fri, 26 Dec 2008 14:27:26 +0100</pubDate>
		<guid isPermaLink="true">http://www.skreo.net/securite-php-toujours-verifier-le-referer-lors-d-un-envoi-par-post-a313986</guid>
		<dc:creator>Skreo</dc:creator>
		<dc:date>2008-12-26T14:27:26+01:00</dc:date>
	</item>
</channel>
</rss><!--mdp=-->