<?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]]></title>
	<description><![CDATA[Flux RSS des articles]]></description>
	<pubDate>Sun, 05 Feb 2012 17:39:47 +0100</pubDate>
	<link>http://godefroy.me</link>
	<language>fr</language>
	<generator>http://www.eklablog.com</generator>
	
	<item>
		<title><![CDATA[SortDC, un nouvel outil open-source de catégorisation automatique]]></title>
		<link>http://godefroy.me/sortdc-un-nouvel-outil-open-source-de-categorisation-automatique-a5144452</link>
		<description><![CDATA[Cette ann&eacute;e, j'ai travaill&eacute; sur un projet de recherche avec Ronan au sein de l' ISEP : nous nous sommes fix&eacute; pour but de d&eacute;velopper une application open source de cat&eacute;gorisation automatique de documents , fournissant une API RESTful . Son nom est un habile jeu de mots :&nbsp; SortDC Concr&egrave;tement,...]]></description>
		<content:encoded><![CDATA[<p>Cette ann&eacute;e, j'ai travaill&eacute; sur un projet de recherche avec <a href="http://www.gimmickit.org/">Ronan</a> au sein de l'<a href="http://www.isep.fr/">ISEP</a> : nous nous sommes fix&eacute; pour but de d&eacute;velopper une <strong>application open source de cat&eacute;gorisation automatique de documents</strong>, fournissant une <strong>API RESTful</strong>.</p>
<p>Son nom est un habile jeu de mots :&nbsp;<a href="https://github.com/sortdc/SortDC">SortDC</a></p>
<h2>Concr&egrave;tement, &agrave; quoi &ccedil;a sert ?</h2>
<p>Les utilisations possibles sont vari&eacute;es, elles peuvent &ecirc;tre par exemple :</p>
<ul>
<li>Antispam (cat&eacute;gories spam / non spam)</li>
<li>Cat&eacute;gorisation par th&eacute;matiques (sport, cin&eacute;ma, cuisine, politique...)</li>
<li>D&eacute;tection de la langue</li>
</ul>
<p>Dans quelques jours, <a href="http://www.eklablog.com/">EklaBlog</a> commencera &agrave; l'utiliser comme antispam, puis nous l'utiliserons pour cat&eacute;goriser les articles (plus de 2 millions &agrave; ce jour) par th&eacute;matiques.</p>
<h2>Quelles technologies ?</h2>
<p>L'application est en Java et repose sur peu de biblioth&egrave;ques. L'API qu'elle fournie d&eacute;pend de <a href="http://jersey.java.net">Jersey</a>. Elle est loin d'&ecirc;tre optimis&eacute;e, mais elle est propre et fonctionne bien.</p>
<p>Les donn&eacute;es (documents et cat&eacute;gories) peuvent &ecirc;tre stock&eacute;es au choix dans une base <a href="http://www.mongodb.org/">MongoDB</a> ou MySQL. Pour l'instant, nous avons obtenu de meilleures performances avec MongoDB.</p>
<p>L'algorithme utilise le th&eacute;or&egrave;me de Bayes, il est d&eacute;crit dans l'article anglophone que nous avons r&eacute;dig&eacute; pour la pr&eacute;sentation du projet :</p>
<p><iframe style="border: none;" src="http://docs.google.com/viewer?url=http%3A//data0.eklablog.com/skreo/mod_article5144452_1.pdf%3F9227&amp;embedded=true" width="100%" height="500"></iframe></p>
<p><a href="http://data0.eklablog.com/skreo/mod_article5144452_1.pdf">T&eacute;l&eacute;charger le PDF</a></p>
<h2>Open source</h2>
<p>Nous avons d&egrave;s le d&eacute;part d&eacute;cid&eacute; de publier cette application sous licence GNU/GPL3, les sources sont disponibles sur Github :<br/><a href="https://github.com/sortdc/SortDC">https://github.com/sortdc/SortDC</a></p>
<p>Ne vous privez donc pas pour la tester, l'utiliser dans un projet commercial ou non (les sources &nbsp;que vous ajoutez et modifiez doivent rester libres, mais votre application qui contacte l'API peut &ecirc;tre propri&eacute;taire), et pourquoi pas aussi pour participer en l'am&eacute;liorant.</p>
<p>SortDC n'en est qu'&agrave; ses pr&eacute;mices, on va continuer &agrave; l'am&eacute;liorer et on esp&egrave;re que &ccedil;a servira &agrave; d'autres !</p><br /><br /><div class="article_sharebtns"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fgodefroy.me%2Fsortdc-un-nouvel-outil-open-source-de-categorisation-automatique-a5144452&amp;layout=button_count&amp;show_faces=false&amp;width=65&amp;action=like&amp;font&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:65px; height:21px;" allowTransparency="true"><br /></iframe><iframe allowtransparency="true" frameborder="0" scrolling="no" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fgodefroy.me%2Fsortdc-un-nouvel-outil-open-source-de-categorisation-automatique-a5144452&amp;text=SortDC%2C%20un%20nouvel%20outil%20open-source%20de%20cat%C3%A9gorisation%20automatique&amp;count=none" style="width: 55px; height: 20px;"></iframe><span><g:plusone size="medium" count="true" href="http://godefroy.me/sortdc-un-nouvel-outil-open-source-de-categorisation-automatique-a5144452"></g:plusone></span></div><br /><hr />Article original rédigé par Godefroy et publié sur <a href="http://skreo.eklablog.com">Godefroy</a> <br /> Reproduction interdite sans autorisation]]></content:encoded>
		<pubDate>Sat, 27 Aug 2011 14:42:00 +0200</pubDate>
		<guid isPermaLink="true">http://godefroy.me/sortdc-un-nouvel-outil-open-source-de-categorisation-automatique-a5144452</guid>
		<dc:creator>Godefroy</dc:creator>
		<dc:date>2011-08-27T14:42:00+02:00</dc:date>
	</item>
	<item>
		<title><![CDATA[[MySQL] Optimisation du COUNT(*) avec des triggers]]></title>
		<link>http://godefroy.me/mysql-optimisation-du-count-avec-des-triggers-a968910</link>
		<description><![CDATA[On a souvent besoin de connaitre le nombre d'entr&eacute;es dans une table, avec certaines conditions. Par exemple le nombre d'articles par cat&eacute;gories dans le cas d'un blog. Faire un SELECT COUNT(*) peut vite devenir tr&egrave;s lourd quand le nombre d'entr&eacute;es devient significatif, surtout si le moteur...]]></description>
		<content:encoded><![CDATA[<p>On a souvent besoin de connaitre le nombre d'entr&eacute;es dans une table, avec certaines conditions. Par exemple le nombre d'articles par cat&eacute;gories dans le cas d'un blog. Faire un SELECT COUNT(*) peut vite devenir tr&egrave;s lourd quand le nombre d'entr&eacute;es devient significatif, surtout si le moteur utilis&eacute; est InnoDB.</p>
<p>En effet, on peut arriver vite &agrave; de gros probl&egrave;mes de performances avec des COUNT(*) s'ex&eacute;cutant en plusieurs secondes si vous commencez &agrave; avoir beaucoup d'entr&eacute;es (1M entr&eacute;es par exemple).</p>
<p>Je vous propose donc une astuce pour remplacer avantageusement ces disgracieux COUNT(*). On va garder ici l'exemple des articles et des cat&eacute;gories, avec une table <em>posts</em> et une table <em>categories</em>&nbsp;de structure basique :</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> <span style="color: #008000;">`categories`</span> <span style="color: #FF00FF;">&#40;</span><br />
&nbsp;<span style="color: #008000;">`id`</span> <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> <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> <a href="http://search.mysql.com/search?site=refman-51&amp;q=AUTO_INCREMENT&amp;lr=lang_en"><span style="color: #FF9900; font-weight: bold;">AUTO_INCREMENT</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=PRIMARY%20KEY&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">PRIMARY KEY</span></a><span style="color: #000033;">,</span><br />
&nbsp;<span style="color: #008000;">`title`</span> <a href="http://search.mysql.com/search?site=refman-51&amp;q=VARCHAR&amp;lr=lang_en"><span style="color: #999900; font-weight: bold;">VARCHAR</span></a><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">200</span><span style="color: #FF00FF;">&#41;</span> CHARACTER <a href="http://search.mysql.com/search?site=refman-51&amp;q=SET&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">SET</span></a> utf8 <a href="http://dev.mysql.com/doc/refman/5.1/en/non-typed-operators.html"><span style="color: #CC0099; font-weight: bold;">COLLATE</span></a> utf8_general_ci <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 />
&nbsp;<span style="color: #008000;">`nbposts`</span> <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> <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> <a href="http://search.mysql.com/search?site=refman-51&amp;q=DEFAULT&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">DEFAULT</span></a> <span style="color: #008000;">'0'</span><br />
&nbsp;<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> <a href="http://search.mysql.com/search?site=refman-51&amp;q=INNODB&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">INNODB</span></a> CHARACTER <a href="http://search.mysql.com/search?site=refman-51&amp;q=SET&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">SET</span></a> utf8 <a href="http://dev.mysql.com/doc/refman/5.1/en/non-typed-operators.html"><span style="color: #CC0099; font-weight: bold;">COLLATE</span></a> utf8_general_ci<span style="color: #000033;">;</span><br />
&nbsp;<br />
&nbsp;<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> <span style="color: #008000;">`posts`</span> <span style="color: #FF00FF;">&#40;</span><br />
&nbsp;<span style="color: #008000;">`id`</span> <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> <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> <a href="http://search.mysql.com/search?site=refman-51&amp;q=AUTO_INCREMENT&amp;lr=lang_en"><span style="color: #FF9900; font-weight: bold;">AUTO_INCREMENT</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=PRIMARY%20KEY&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">PRIMARY KEY</span></a><span style="color: #000033;">,</span><br />
&nbsp;<span style="color: #008000;">`category<span style="color: #008080; font-weight: bold;">_</span>id`</span> <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> <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 />
&nbsp;<span style="color: #008000;">`title`</span> <a href="http://search.mysql.com/search?site=refman-51&amp;q=VARCHAR&amp;lr=lang_en"><span style="color: #999900; font-weight: bold;">VARCHAR</span></a><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">200</span><span style="color: #FF00FF;">&#41;</span> CHARACTER <a href="http://search.mysql.com/search?site=refman-51&amp;q=SET&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">SET</span></a> utf8 <a href="http://dev.mysql.com/doc/refman/5.1/en/non-typed-operators.html"><span style="color: #CC0099; font-weight: bold;">COLLATE</span></a> utf8_general_ci <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 />
&nbsp;<span style="color: #008000;">`content`</span> <a href="http://search.mysql.com/search?site=refman-51&amp;q=TEXT&amp;lr=lang_en"><span style="color: #999900; font-weight: bold;">TEXT</span></a> CHARACTER <a href="http://search.mysql.com/search?site=refman-51&amp;q=SET&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">SET</span></a> utf8 <a href="http://dev.mysql.com/doc/refman/5.1/en/non-typed-operators.html"><span style="color: #CC0099; font-weight: bold;">COLLATE</span></a> utf8_general_ci <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 />
&nbsp;<span style="color: #008000;">`time`</span> <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> <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 />
&nbsp;<a href="http://search.mysql.com/search?site=refman-51&amp;q=INDEX&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">INDEX</span></a> <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">`category<span style="color: #008080; font-weight: bold;">_</span>id`</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span><br />
&nbsp;<a href="http://search.mysql.com/search?site=refman-51&amp;q=INDEX&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">INDEX</span></a> <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">`time`</span><span style="color: #FF00FF;">&#41;</span><br />
&nbsp;<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> <a href="http://search.mysql.com/search?site=refman-51&amp;q=INNODB&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">INNODB</span></a> CHARACTER <a href="http://search.mysql.com/search?site=refman-51&amp;q=SET&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">SET</span></a> utf8 <a href="http://dev.mysql.com/doc/refman/5.1/en/non-typed-operators.html"><span style="color: #CC0099; font-weight: bold;">COLLATE</span></a> utf8_general_ci<span style="color: #000033;">;</span><br />
&nbsp;<br />
&nbsp;<a href="http://search.mysql.com/search?site=refman-51&amp;q=ALTER&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">ALTER</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> <span style="color: #008000;">`posts`</span> <a href="http://search.mysql.com/search?site=refman-51&amp;q=ADD&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">ADD</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=FOREIGN%20KEY&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">FOREIGN KEY</span></a> <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">`category<span style="color: #008080; font-weight: bold;">_</span>id`</span><span style="color: #FF00FF;">&#41;</span> <a href="http://search.mysql.com/search?site=refman-51&amp;q=REFERENCES&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">REFERENCES</span></a> <span style="color: #008000;">`categories`</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">`id`</span><span style="color: #FF00FF;">&#41;</span> <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 href="http://search.mysql.com/search?site=refman-51&amp;q=DELETE&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">DELETE</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=CASCADE&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">CASCADE</span></a><span style="color: #000033;">;</span><div style="display:none;">[code=mysql]CREATE TABLE `categories` (<br/> `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,<br/> `title` VARCHAR(200) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,<br/> `nbposts` INT UNSIGNED NOT NULL DEFAULT '0'<br/> ) ENGINE = INNODB CHARACTER SET utf8 COLLATE utf8_general_ci;<br/> <br/> CREATE TABLE  `posts` (<br/> `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,<br/> `category_id` INT UNSIGNED NOT NULL,<br/> `title` VARCHAR(200) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,<br/> `content` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,<br/> `time` INT UNSIGNED NOT NULL,<br/> INDEX (`category_id`),<br/> INDEX (`time`)<br/> ) ENGINE = INNODB CHARACTER SET utf8 COLLATE utf8_general_ci;<br/> <br/> ALTER TABLE  `posts` ADD FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`) ON DELETE CASCADE;[/code]</div></div></p>
<p>Le champ&nbsp;<em>nbposts</em> va nous servir &agrave; garder en m&eacute;moire le nombre d'articles dans chaque cat&eacute;gorie. Certains diront que du coup on peut perdre de la consistance, eh bien oui... mais il faudrait avoir un sacr&eacute; coup de pas de bol ou modifier la valeur du champ &agrave; la bourrin pour fausser les valeurs.</p>
<p>Pour actualiser le champ <em>nbposts</em>, on va utiliser des triggers ("d&eacute;clencheurs" en fran&ccedil;ais), qui l'incr&eacute;menteront &agrave; chaque insertion et le d&eacute;cr&eacute;menteront &agrave; chaque suppression :</p>
<p><div class="code">DELIMITER <span style="color: #000033;">;;</span><br />
&nbsp;<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=TRIGGER&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">TRIGGER</span></a> <span style="color: #008000;">`posts<span style="color: #008080; font-weight: bold;">_</span>insert<span style="color: #008080; font-weight: bold;">_</span>after`</span> <a href="http://search.mysql.com/search?site=refman-51&amp;q=AFTER&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">AFTER</span></a> <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=ON&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">ON</span></a> <span style="color: #008000;">`posts`</span><br />
&nbsp;<a href="http://search.mysql.com/search?site=refman-51&amp;q=FOR%20EACH%20ROW&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">FOR EACH ROW</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=BEGIN&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">BEGIN</span></a><br />
&nbsp;<a href="http://search.mysql.com/search?site=refman-51&amp;q=UPDATE&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">UPDATE</span></a> <span style="color: #008000;">`categories`</span> <a href="http://search.mysql.com/search?site=refman-51&amp;q=SET&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">SET</span></a> <span style="color: #008000;">`nbposts`</span> <span style="color: #CC0099;">=</span> <span style="color: #008000;">`nbposts`</span><span style="color: #CC0099;">+</span><span style="color: #008080;">1</span> <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> id<span style="color: #CC0099;">=</span>NEW.<span style="color: #008000;">`category<span style="color: #008080; font-weight: bold;">_</span>id`</span> <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><span style="color: #000033;">;</span><br />
&nbsp;<a href="http://dev.mysql.com/doc/refman/5.1/en/control-flow-functions.html"><span style="color: #009900;">END</span></a> <span style="color: #000033;">;;</span><br />
&nbsp;<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=TRIGGER&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">TRIGGER</span></a> <span style="color: #008000;">`posts<span style="color: #008080; font-weight: bold;">_</span>delete<span style="color: #008080; font-weight: bold;">_</span>after`</span> <a href="http://search.mysql.com/search?site=refman-51&amp;q=AFTER&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">AFTER</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=DELETE&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">DELETE</span></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> <span style="color: #008000;">`posts`</span><br />
&nbsp;<a href="http://search.mysql.com/search?site=refman-51&amp;q=FOR%20EACH%20ROW&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">FOR EACH ROW</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=BEGIN&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">BEGIN</span></a><br />
&nbsp;<a href="http://search.mysql.com/search?site=refman-51&amp;q=UPDATE&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">UPDATE</span></a> <span style="color: #008000;">`categories`</span> <a href="http://search.mysql.com/search?site=refman-51&amp;q=SET&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">SET</span></a> <span style="color: #008000;">`nbposts`</span> <span style="color: #CC0099;">=</span> <span style="color: #008000;">`nbposts`</span><span style="color: #CC0099;">-</span><span style="color: #008080;">1</span> <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> id<span style="color: #CC0099;">=</span>OLD.<span style="color: #008000;">`category<span style="color: #008080; font-weight: bold;">_</span>id`</span> <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><span style="color: #000033;">;</span><br />
&nbsp;<a href="http://dev.mysql.com/doc/refman/5.1/en/control-flow-functions.html"><span style="color: #009900;">END</span></a> <span style="color: #000033;">;;</span><br />
&nbsp;DELIMITER <span style="color: #000033;">;</span><div style="display:none;">[code=mysql]DELIMITER ;;<br/> CREATE TRIGGER `posts_insert_after` AFTER INSERT ON `posts`<br/> FOR EACH ROW BEGIN<br/> UPDATE `categories` SET `nbposts` = `nbposts`+1 WHERE id=NEW.`category_id` LIMIT 1;<br/> END ;;<br/> CREATE TRIGGER `posts_delete_after` AFTER DELETE ON `posts`<br/> FOR EACH ROW BEGIN<br/> UPDATE `categories` SET `nbposts` = `nbposts`-1 WHERE id=OLD.`category_id` LIMIT 1;<br/> END ;;<br/> DELIMITER ;[/code]</div></div></p>
<p>Et voil&agrave;, votre champ <em>nbposts</em> s'actualise maintenant automatiquement, plus besoin de faire des COUNT(*) !</p><br /><br /><div class="article_sharebtns"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fgodefroy.me%2Fmysql-optimisation-du-count-avec-des-triggers-a968910&amp;layout=button_count&amp;show_faces=false&amp;width=65&amp;action=like&amp;font&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:65px; height:21px;" allowTransparency="true"><br /></iframe><iframe allowtransparency="true" frameborder="0" scrolling="no" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fgodefroy.me%2Fmysql-optimisation-du-count-avec-des-triggers-a968910&amp;text=%5BMySQL%5D%20Optimisation%20du%20COUNT%28%2A%29%20avec%20des%20triggers&amp;count=none" style="width: 55px; height: 20px;"></iframe><span><g:plusone size="medium" count="true" href="http://godefroy.me/mysql-optimisation-du-count-avec-des-triggers-a968910"></g:plusone></span></div><br /><hr />Article original rédigé par Godefroy et publié sur <a href="http://skreo.eklablog.com">Godefroy</a> <br /> Reproduction interdite sans autorisation]]></content:encoded>
		<pubDate>Tue, 23 Nov 2010 17:53:00 +0100</pubDate>
		<guid isPermaLink="true">http://godefroy.me/mysql-optimisation-du-count-avec-des-triggers-a968910</guid>
		<dc:creator>Godefroy</dc:creator>
		<dc:date>2010-11-23T17:53:00+01:00</dc:date>
	</item>
	<item>
		<title><![CDATA[Changement d'adresse : skreo.net devient godefroy.me]]></title>
		<link>http://godefroy.me/changement-d-adresse-skreo-net-devient-godefroy-me-a2019644</link>
		<description><![CDATA[Pendant l'&eacute;t&eacute; 2004, en vacances &agrave; la plage, Cl&eacute;ment et moi avons choisi nos pseudonymes : &quot;divarvel&quot; pour lui, et &quot;Skreo&quot; pour moi. J'ai donc utilis&eacute; le pseudo Skreo pendant un peu plus de 6 ans jusqu'&agrave; maintenant un peu partout sur la toile. Mais je n'ai pas envie de garder ce pseudo plus...]]></description>
		<content:encoded><![CDATA[<p>Pendant l'&eacute;t&eacute; 2004, en vacances &agrave; la plage, Cl&eacute;ment et moi avons choisi nos pseudonymes : "divarvel" pour lui, et "Skreo" pour moi. J'ai donc utilis&eacute; le pseudo Skreo pendant un peu plus de 6 ans jusqu'&agrave; maintenant un peu partout sur la toile.</p>
<p>Mais je n'ai pas envie de garder ce pseudo plus longtemps, j'ai un pr&eacute;nom assez original pour que je puisse l'utiliser sans trop risquer qu'on me confonde avec quelqu'un d'autre, et je pense qu'utiliser son pr&eacute;nom fait plus s&eacute;rieux.</p>
<p>J'ai donc d&eacute;cid&eacute; de remplacer progressivement un peu partout mon pseudo "Skreo" par "Godefroy" sur le web. &Agrave; commencer par :</p>
<ul>
<li>Mon blog www.skreo.net devient <a href="http://godefroy.me/">godefroy.me</a>&nbsp;(poke <a href="http://gonzague.me/nouveau-nom-de-domaine-important">Gonzague</a>)</li>
<li>Mon compte Twitter @Skreo devient <a href="http://twitter.com/Godefroy">@Godefroy</a></li>
</ul>
<p>Et j'en profite pour changer de design de blog :-)</p>
<p>Merci &agrave; S&eacute;bastien (@sebg) pour l'astuce pour <a href="http://sebastien.co/astuce-twitter-recuperer-un-compte-inactif">r&eacute;cup&eacute;rer un compte Twitter inactif</a>.</p><br /><br /><div class="article_sharebtns"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fgodefroy.me%2Fchangement-d-adresse-skreo-net-devient-godefroy-me-a2019644&amp;layout=button_count&amp;show_faces=false&amp;width=65&amp;action=like&amp;font&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:65px; height:21px;" allowTransparency="true"><br /></iframe><iframe allowtransparency="true" frameborder="0" scrolling="no" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fgodefroy.me%2Fchangement-d-adresse-skreo-net-devient-godefroy-me-a2019644&amp;text=Changement%20d%27adresse%20%3A%20skreo.net%20devient%20godefroy.me&amp;count=none" style="width: 55px; height: 20px;"></iframe><span><g:plusone size="medium" count="true" href="http://godefroy.me/changement-d-adresse-skreo-net-devient-godefroy-me-a2019644"></g:plusone></span></div><br /><hr />Article original rédigé par Godefroy et publié sur <a href="http://skreo.eklablog.com">Godefroy</a> <br /> Reproduction interdite sans autorisation]]></content:encoded>
		<pubDate>Fri, 12 Nov 2010 02:48:40 +0100</pubDate>
		<guid isPermaLink="true">http://godefroy.me/changement-d-adresse-skreo-net-devient-godefroy-me-a2019644</guid>
		<dc:creator>Godefroy</dc:creator>
		<dc:date>2010-11-12T02:48:40+01:00</dc:date>
	</item>
	<item>
		<title><![CDATA[[Linux] Trouver et corriger les fichiers avec des fins de ligne CRLF]]></title>
		<link>http://godefroy.me/linux-trouver-et-corriger-les-fichiers-avec-des-fins-de-ligne-crlf-a1880493</link>
		<description><![CDATA[Il peut arriver que des fichiers ayant des fins de ligne CRLF tra&icirc;nent dans un projet &agrave; cause d'un d&eacute;veloppeur windowsien ou adepte de la pomme qui a mal r&eacute;gl&eacute; son IDE. (troll inside ?) Je vais vous pr&eacute;senter une petite astuce pour trouver ces fichiers et les corriger. Pour rappel, on utilise...]]></description>
		<content:encoded><![CDATA[<p>Il peut arriver que des fichiers ayant des fins de ligne <a href="http://fr.wikipedia.org/wiki/Carriage_Return_Line_Feed">CRLF</a> tra&icirc;nent dans un projet &agrave; cause d'un d&eacute;veloppeur windowsien ou adepte de la pomme qui a mal r&eacute;gl&eacute; son IDE. (troll inside ?) Je vais vous pr&eacute;senter une petite astuce pour trouver ces fichiers et les corriger.</p>
<p>Pour rappel, on utilise g&eacute;n&eacute;ralement les fins de lignes <abbr title="Line Feed">LF</abbr> sous Linux, <abbr title="Carriage Return">CR</abbr> sous Mac, et <abbr title="Carriage Return Line Feed">CRLF</abbr> sous Windows. Dans la plupart des langages de programmation, CR est repr&eacute;sent&eacute; par \r, et LF par \n.&nbsp;L&agrave;, le but est d'enlever les CR.</p>
<p>Placez-vous dans le dossier &agrave; v&eacute;rifier, puis entrez la commande :<br/><div class="code"><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-rlIP</span> <span style="color: #ff0000;">'\r\n'</span> .<span style="color: #000000; font-weight: bold;">/</span><div style="display:none;">[code=bash]grep -rlIP '\r\n' ./[/code]</div></div></p>
<p>Vous obtiendrez la liste des fichiers en CRLF.<br/>Pour bien comprendre, d&eacute;taillons les options utilis&eacute;es :</p>
<ul>
<li><span style="font-family: 'andale mono', times;">r</span> : cherche r&eacute;cursivement dans les dossiers</li>
<li><span style="font-family: 'andale mono', times;">l</span> : affiche uniquement le nom de fichier (on s'arr&ecirc;te &agrave; la premi&egrave;re occurrence dans chaque fichier</li>
<li><span style="font-family: 'andale mono', times;">I</span> : ignore les fichiers binaires (images...etc)</li>
<li><span style="font-family: 'andale mono', times;">P</span> : expression r&eacute;guli&egrave;re Perl</li>
</ul>
<p>Pour supprimer les CR, et n'avoir donc plus que des LF dans ces fichiers, on va utiliser <em>sed</em> :&nbsp;<br/><div class="code"><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-rlIP</span> <span style="color: #ff0000;">'\r\n'</span> .<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">xargs</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-i</span> <span style="color: #660033;">-r</span> <span style="color: #ff0000;">'s/\r//g'</span><div style="display:none;">[code=bash]grep -rlIP '\r\n' ./ | xargs&nbsp;sed -i -r 's/\r//g'[/code]</div></div></p>
<p>Attention, n'oubliez pas d'exclure les dossiers / fichier que vous ne voulez pas traiter avec <em>grep -v</em>. Par exemple pour exclure les fichiers de Git :<br/><div class="code"><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-rlIP</span> <span style="color: #ff0000;">'\r\n'</span> .<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> .git <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">xargs</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-i</span> <span style="color: #660033;">-r</span> <span style="color: #ff0000;">'s/\r//g'</span><div style="display:none;">[code=bash]grep -rlIP '\r\n' ./ | grep -v .git | xargs&nbsp;sed -i -r 's/\r//g'[/code]</div></div>&nbsp;</p><br /><br /><div class="article_sharebtns"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fgodefroy.me%2Flinux-trouver-et-corriger-les-fichiers-avec-des-fins-de-ligne-crlf-a1880493&amp;layout=button_count&amp;show_faces=false&amp;width=65&amp;action=like&amp;font&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:65px; height:21px;" allowTransparency="true"><br /></iframe><iframe allowtransparency="true" frameborder="0" scrolling="no" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fgodefroy.me%2Flinux-trouver-et-corriger-les-fichiers-avec-des-fins-de-ligne-crlf-a1880493&amp;text=%5BLinux%5D%20Trouver%20et%20corriger%20les%20fichiers%20avec%20des%20fins%20de%20ligne%20CRLF&amp;count=none" style="width: 55px; height: 20px;"></iframe><span><g:plusone size="medium" count="true" href="http://godefroy.me/linux-trouver-et-corriger-les-fichiers-avec-des-fins-de-ligne-crlf-a1880493"></g:plusone></span></div><br /><hr />Article original rédigé par Godefroy et publié sur <a href="http://skreo.eklablog.com">Godefroy</a> <br /> Reproduction interdite sans autorisation]]></content:encoded>
		<pubDate>Tue, 26 Oct 2010 14:39:25 +0200</pubDate>
		<guid isPermaLink="true">http://godefroy.me/linux-trouver-et-corriger-les-fichiers-avec-des-fins-de-ligne-crlf-a1880493</guid>
		<dc:creator>Godefroy</dc:creator>
		<dc:date>2010-10-26T14:39:25+02:00</dc:date>
	</item>
	<item>
		<title><![CDATA[[Linux] Switcher entre Dual Screen et Mono Screen sans redémarrer le serveur X]]></title>
		<link>http://godefroy.me/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 /><div class="article_sharebtns"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fgodefroy.me%2Flinux-switcher-entre-dual-screen-et-mono-screen-sans-redemarrer-le-ser-a1442268&amp;layout=button_count&amp;show_faces=false&amp;width=65&amp;action=like&amp;font&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:65px; height:21px;" allowTransparency="true"><br /></iframe><iframe allowtransparency="true" frameborder="0" scrolling="no" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fgodefroy.me%2Flinux-switcher-entre-dual-screen-et-mono-screen-sans-redemarrer-le-ser-a1442268&amp;text=%5BLinux%5D%20Switcher%20entre%20Dual%20Screen%20et%20Mono%20Screen%20sans%20red%C3%A9marrer%20le%20serveur%20X&amp;count=none" style="width: 55px; height: 20px;"></iframe><span><g:plusone size="medium" count="true" href="http://godefroy.me/linux-switcher-entre-dual-screen-et-mono-screen-sans-redemarrer-le-ser-a1442268"></g:plusone></span></div><br /><hr />Article original rédigé par Godefroy et publié sur <a href="http://skreo.eklablog.com">Godefroy</a> <br /> Reproduction interdite sans autorisation]]></content:encoded>
		<pubDate>Fri, 16 Jul 2010 18:27:52 +0200</pubDate>
		<guid isPermaLink="true">http://godefroy.me/linux-switcher-entre-dual-screen-et-mono-screen-sans-redemarrer-le-ser-a1442268</guid>
		<dc:creator>Godefroy</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://godefroy.me/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 /><div class="article_sharebtns"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fgodefroy.me%2Fsvn-etre-averti-en-temps-reel-des-commits-envoyes-a890030&amp;layout=button_count&amp;show_faces=false&amp;width=65&amp;action=like&amp;font&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:65px; height:21px;" allowTransparency="true"><br /></iframe><iframe allowtransparency="true" frameborder="0" scrolling="no" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fgodefroy.me%2Fsvn-etre-averti-en-temps-reel-des-commits-envoyes-a890030&amp;text=%5BSVN%5D%20%C3%8Atre%20averti%20en%20temps%20r%C3%A9el%20des%20commits%20envoy%C3%A9s&amp;count=none" style="width: 55px; height: 20px;"></iframe><span><g:plusone size="medium" count="true" href="http://godefroy.me/svn-etre-averti-en-temps-reel-des-commits-envoyes-a890030"></g:plusone></span></div><br /><hr />Article original rédigé par Godefroy et publié sur <a href="http://skreo.eklablog.com">Godefroy</a> <br /> Reproduction interdite sans autorisation]]></content:encoded>
		<pubDate>Wed, 23 Dec 2009 15:18:12 +0100</pubDate>
		<guid isPermaLink="true">http://godefroy.me/svn-etre-averti-en-temps-reel-des-commits-envoyes-a890030</guid>
		<dc:creator>Godefroy</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://godefroy.me/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 /><div class="article_sharebtns"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fgodefroy.me%2Fmysql-optimisation-d-une-recherche-avec-multiples-jointures-a860197&amp;layout=button_count&amp;show_faces=false&amp;width=65&amp;action=like&amp;font&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:65px; height:21px;" allowTransparency="true"><br /></iframe><iframe allowtransparency="true" frameborder="0" scrolling="no" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fgodefroy.me%2Fmysql-optimisation-d-une-recherche-avec-multiples-jointures-a860197&amp;text=%5BMySQL%5D%20Optimisation%20d%27une%20recherche%20avec%20multiples%20jointures&amp;count=none" style="width: 55px; height: 20px;"></iframe><span><g:plusone size="medium" count="true" href="http://godefroy.me/mysql-optimisation-d-une-recherche-avec-multiples-jointures-a860197"></g:plusone></span></div><br /><hr />Article original rédigé par Godefroy et publié sur <a href="http://skreo.eklablog.com">Godefroy</a> <br /> Reproduction interdite sans autorisation]]></content:encoded>
		<pubDate>Thu, 10 Dec 2009 16:42:07 +0100</pubDate>
		<guid isPermaLink="true">http://godefroy.me/mysql-optimisation-d-une-recherche-avec-multiples-jointures-a860197</guid>
		<dc:creator>Godefroy</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://godefroy.me/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://godefroy.me//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://godefroy.me//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 /><div class="article_sharebtns"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fgodefroy.me%2Fubuntu-mes-nouveaux-choix-de-logiciels-a610241&amp;layout=button_count&amp;show_faces=false&amp;width=65&amp;action=like&amp;font&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:65px; height:21px;" allowTransparency="true"><br /></iframe><iframe allowtransparency="true" frameborder="0" scrolling="no" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fgodefroy.me%2Fubuntu-mes-nouveaux-choix-de-logiciels-a610241&amp;text=%5BUbuntu%5D%20Mes%20nouveaux%20choix%20de%20logiciels&amp;count=none" style="width: 55px; height: 20px;"></iframe><span><g:plusone size="medium" count="true" href="http://godefroy.me/ubuntu-mes-nouveaux-choix-de-logiciels-a610241"></g:plusone></span></div><br /><hr />Article original rédigé par Godefroy et publié sur <a href="http://skreo.eklablog.com">Godefroy</a> <br /> Reproduction interdite sans autorisation]]></content:encoded>
		<pubDate>Sun, 02 Aug 2009 13:37:52 +0200</pubDate>
		<guid isPermaLink="true">http://godefroy.me/ubuntu-mes-nouveaux-choix-de-logiciels-a610241</guid>
		<dc:creator>Godefroy</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://godefroy.me/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://godefroy.me/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 /><div class="article_sharebtns"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fgodefroy.me%2Flatex-comment-faire-rapidement-une-facture-super-classe-a530591&amp;layout=button_count&amp;show_faces=false&amp;width=65&amp;action=like&amp;font&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:65px; height:21px;" allowTransparency="true"><br /></iframe><iframe allowtransparency="true" frameborder="0" scrolling="no" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fgodefroy.me%2Flatex-comment-faire-rapidement-une-facture-super-classe-a530591&amp;text=%5BLaTeX%5D%20Comment%20faire%20rapidement%20une%20facture%20super%20classe&amp;count=none" style="width: 55px; height: 20px;"></iframe><span><g:plusone size="medium" count="true" href="http://godefroy.me/latex-comment-faire-rapidement-une-facture-super-classe-a530591"></g:plusone></span></div><br /><hr />Article original rédigé par Godefroy et publié sur <a href="http://skreo.eklablog.com">Godefroy</a> <br /> Reproduction interdite sans autorisation]]></content:encoded>
		<pubDate>Sun, 14 Jun 2009 23:15:39 +0200</pubDate>
		<guid isPermaLink="true">http://godefroy.me/latex-comment-faire-rapidement-une-facture-super-classe-a530591</guid>
		<dc:creator>Godefroy</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://godefroy.me/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 /><div class="article_sharebtns"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fgodefroy.me%2Fzim-gerez-vos-notes-et-todo-lists-super-facilement-a417068&amp;layout=button_count&amp;show_faces=false&amp;width=65&amp;action=like&amp;font&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:65px; height:21px;" allowTransparency="true"><br /></iframe><iframe allowtransparency="true" frameborder="0" scrolling="no" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fgodefroy.me%2Fzim-gerez-vos-notes-et-todo-lists-super-facilement-a417068&amp;text=Zim%20%3A%20G%C3%A9rez%20vos%20notes%20et%20todo-lists%20super%20facilement&amp;count=none" style="width: 55px; height: 20px;"></iframe><span><g:plusone size="medium" count="true" href="http://godefroy.me/zim-gerez-vos-notes-et-todo-lists-super-facilement-a417068"></g:plusone></span></div><br /><hr />Article original rédigé par Godefroy et publié sur <a href="http://skreo.eklablog.com">Godefroy</a> <br /> Reproduction interdite sans autorisation]]></content:encoded>
		<pubDate>Sun, 05 Apr 2009 21:05:40 +0200</pubDate>
		<guid isPermaLink="true">http://godefroy.me/zim-gerez-vos-notes-et-todo-lists-super-facilement-a417068</guid>
		<dc:creator>Godefroy</dc:creator>
		<dc:date>2009-04-05T21:05:40+02:00</dc:date>
	</item>
</channel>
</rss><!--mdp=-->
