<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>D-Sites &#187; Affichage</title>
	<atom:link href="http://www.d-sites.com/category/affichage/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.d-sites.com</link>
	<description>Web, PHP, Python, …</description>
	<lastBuildDate>Tue, 03 Jan 2012 08:39:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Polygones de Thyssen: algorithme de Steven Forture en PHP</title>
		<link>http://www.d-sites.com/2011/12/01/polygones-de-thyssen-algorithme-de-steven-forture-en-php/</link>
		<comments>http://www.d-sites.com/2011/12/01/polygones-de-thyssen-algorithme-de-steven-forture-en-php/#comments</comments>
		<pubDate>Thu, 01 Dec 2011 08:00:39 +0000</pubDate>
		<dc:creator>Samuel ROZE</dc:creator>
				<category><![CDATA[Affichage]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[forture]]></category>
		<category><![CDATA[polygon]]></category>
		<category><![CDATA[thyssen]]></category>
		<category><![CDATA[voronoï]]></category>

		<guid isPermaLink="false">http://www.d-sites.com/?p=958</guid>
		<description><![CDATA[Tweet Pour des besoins professionnels, j&#8217;ai réécrit l&#8217;algorithme de Steven Fortune permettant d&#8217;obtenir un diagramme de Voronoï à partir de points connus, en transformant la librairie JavaScript de gorhill. Vous pouvez trouver les fichiers sources (en PHP 5) sur ce &#8230; <a href="http://www.d-sites.com/2011/12/01/polygones-de-thyssen-algorithme-de-steven-forture-en-php/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="border:1px solid #808080;background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.d-sites.com%2F2011%2F12%2F01%2Fpolygones-de-thyssen-algorithme-de-steven-forture-en-php%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://www.d-sites.com/2011/12/01/polygones-de-thyssen-algorithme-de-steven-forture-en-php/"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.d-sites.com/2011/12/01/polygones-de-thyssen-algorithme-de-steven-forture-en-php/"  data-text="Polygones de Thyssen: algorithme de Steven Forture en PHP" data-count="horizontal">Tweet</a>
			</div><div style="float:left; width:105px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script type="in/share" data-url="http://www.d-sites.com/2011/12/01/polygones-de-thyssen-algorithme-de-steven-forture-en-php/" data-counter="right"></script></div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://www.d-sites.com/2011/12/01/polygones-de-thyssen-algorithme-de-steven-forture-en-php/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>Pour des besoins professionnels, j&#8217;ai réécrit l&#8217;algorithme de Steven Fortune permettant d&#8217;obtenir un diagramme de Voronoï à partir de points connus, en transformant la <a href="https://github.com/gorhill/Javascript-Voronoi">librairie JavaScript de <em>gorhill</em></a>.</p>
<p>Vous pouvez trouver les fichiers sources (en PHP 5) sur ce dépôt GitHub:</p>
<ul>
<li><a href="https://github.com/sroze/PHP-Voronoi-algorithm">https://github.com/sroze/PHP-Voronoi-algorithm</a></li>
</ul>
<h2>Exemple d&#8217;utilisation</h2>
<p>Voici un exemple d&#8217;utilisation, qui permet de générer un diagramme de Voronoï (ou autrement dit des polygones de Thyssen) à partir de points générés automatiquement:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'../library/Nurbs/Voronoi.php'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'../library/Nurbs/Point.php'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$bbox</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> stdClass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$bbox</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">xl</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$bbox</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">xr</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">400</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$bbox</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">yt</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$bbox</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">yb</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">400</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$xo</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$dx</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$width</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">400</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$yo</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$dy</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$height</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">400</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$n</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">20</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$sites</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// On créé l'image</span>
<span style="color: #000088;">$im</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecreatetruecolor</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$width</span><span style="color: #339933;">,</span> <span style="color: #000088;">$height</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$white</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecolorallocate</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">255</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">255</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$red</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecolorallocate</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">255</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$green</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecolorallocate</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$black</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecolorallocate</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">imagefill</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$white</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//imageantialias($im, true);</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// On créé des points aléatoires que l'on dessine</span>
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$n</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$point</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Nurbs_Point<span style="color: #009900;">&#40;</span><span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$xo</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dx</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$yo</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dy</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$sites</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$point</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #990000;">imagerectangle</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span> <span style="color: #000088;">$point</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">x</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #000088;">$point</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">y</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #000088;">$point</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">x</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #000088;">$point</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">y</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #000088;">$black</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$voronoi</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Voronoi<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$diagram</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$voronoi</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">compute</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sites</span><span style="color: #339933;">,</span> <span style="color: #000088;">$bbox</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//var_dump($diagram);</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//var_dump('sites', $sites, 'diagram', $diagram, 'cells', $diagram['cells']);//, 'voronoi', $voronoi);</span>
<span style="color: #000088;">$j</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$diagram</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'cells'</span><span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$cell</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// On va agreger les points du polygone.</span>
	<span style="color: #000088;">$points</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cell</span><span style="color: #339933;">-&gt;</span>_halfedges<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$v</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$cell</span><span style="color: #339933;">-&gt;</span>_halfedges<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getStartPoint</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$v</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$points</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$v</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">x</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$points</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$v</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">y</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$j</span><span style="color: #339933;">.</span><span style="color: #0000ff;">': no start point'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cell</span><span style="color: #339933;">-&gt;</span>_halfedges<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$halfedge</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$cell</span><span style="color: #339933;">-&gt;</span>_halfedges<span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$edge</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$halfedge</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">edge</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$edge</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">va</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$edge</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">vb</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #990000;">imageline</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span> <span style="color: #000088;">$edge</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">va</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$edge</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">va</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">y</span><span style="color: #339933;">,</span> <span style="color: #000088;">$edge</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">vb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">x</span><span style="color: #339933;">,</span> <span style="color: #000088;">$edge</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">vb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">y</span><span style="color: #339933;">,</span> <span style="color: #000088;">$red</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
			<span style="color: #000088;">$v</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$halfedge</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getEndPoint</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$v</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$points</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$v</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">x</span><span style="color: #339933;">;</span>
				<span style="color: #000088;">$points</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$v</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">y</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$j</span><span style="color: #339933;">.</span><span style="color: #0000ff;">': no end point #'</span><span style="color: #339933;">.</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// On construit le polygone</span>
	<span style="color: #000088;">$color</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecolorallocatealpha</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span> <span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">255</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">50</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">imagefilledpolygon</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span> <span style="color: #000088;">$points</span><span style="color: #339933;">,</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$points</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #000088;">$color</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$j</span><span style="color: #339933;">++;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// On affiche l'image</span>
<span style="color: #990000;">imagepng</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$im</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'voronoi.png'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Voici un exemple d&#8217;image:<br />
<a href="http://www.d-sites.com/wp-content/uploads/2011/11/voronoi.png"><img src="http://www.d-sites.com/wp-content/uploads/2011/11/voronoi.png" alt="" title="voronoi" width="400" height="400" class="aligncenter size-full wp-image-975" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.d-sites.com/2011/12/01/polygones-de-thyssen-algorithme-de-steven-forture-en-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Optimiser l&#8217;affichage de pages avec Google Adsense</title>
		<link>http://www.d-sites.com/2011/01/06/optimiser-laffichage-de-pages-avec-google-adsense/</link>
		<comments>http://www.d-sites.com/2011/01/06/optimiser-laffichage-de-pages-avec-google-adsense/#comments</comments>
		<pubDate>Thu, 06 Jan 2011 08:45:38 +0000</pubDate>
		<dc:creator>Samuel ROZE</dc:creator>
				<category><![CDATA[Affichage]]></category>
		<category><![CDATA[Conception]]></category>
		<category><![CDATA[Performances]]></category>

		<guid isPermaLink="false">http://www.d-sites.com/?p=785</guid>
		<description><![CDATA[Tweet Les pages Web contenant des publicités Google Adsense sont nettement plus lentes à charger que les pages qui n&#8217;en contiennent pas: c&#8217;est à cause de la méthode de chargement des publicités et de leur place dans la page. En &#8230; <a href="http://www.d-sites.com/2011/01/06/optimiser-laffichage-de-pages-avec-google-adsense/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="border:1px solid #808080;background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.d-sites.com%2F2011%2F01%2F06%2Foptimiser-laffichage-de-pages-avec-google-adsense%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://www.d-sites.com/2011/01/06/optimiser-laffichage-de-pages-avec-google-adsense/"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.d-sites.com/2011/01/06/optimiser-laffichage-de-pages-avec-google-adsense/"  data-text="Optimiser l&#8217;affichage de pages avec Google Adsense" data-count="horizontal">Tweet</a>
			</div><div style="float:left; width:105px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script type="in/share" data-url="http://www.d-sites.com/2011/01/06/optimiser-laffichage-de-pages-avec-google-adsense/" data-counter="right"></script></div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://www.d-sites.com/2011/01/06/optimiser-laffichage-de-pages-avec-google-adsense/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>Les pages Web contenant des publicités Google Adsense sont nettement plus lentes à charger que les pages qui n&#8217;en contiennent pas: c&#8217;est à cause de la méthode de chargement des publicités et de leur place dans la page. En général, les publicités se trouvent dans l&#8217;en-tête et/ou dans le menu vertical, elles sont donc chargées avant le corps de page.</p>
<h1>Le problème</h1>
<p>Le code fourni par Google pour afficher ses publicités est le suivant (avec des variables différentes):</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;script type=&quot;text/javascript&quot;&gt;
google_ad_client = &quot;ca-pub-7282418192222825&quot;;
/* Nom de la bannière */
google_ad_slot = &quot;4287714958&quot;;
google_ad_width = 468;
google_ad_height = 60;
&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;
src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot;&gt;
&lt;/script&gt;</pre></div></div>

<p>Or, lors du chargement d&#8217;un fichier JavaScript, le moteur de rendu du navigateur est arrêté et le chargement de tous les éléments autres est suspendu. Par conséquent, le navigateur doit attendre que la page <strong>externe</strong> finisse de charger avant même de continuer à charger les autres éléments internes de la page Web. Ainsi, la page est nettement plus longue à charger et le ressenti utilisateur est plus mauvais&#8230;<br />
<span id="more-785"></span></p>
<h1>La solution</h1>
<p>La solution est très simple: on charge la publicité dans un <code>div</code> en bas de page &#8211; ici le moteur de rendu a déjà modéliser la page &#8211; et à un nouveau grâce à du JavaScript, de replace la publicité à l&#8217;endroit prévu.</p>
<p>Plus concrètement, à l&#8217;endroit où vous souhaitez intégrer la publicité Google Adsense, créez un <code>div</code> vide, d&#8217;un <code>id</code> spécial en spécifiant bien les tailles. Par exemple:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;div id=&quot;adsense-head&quot; style=&quot;width: 468px; height: 60px;&quot;&gt;&lt;/div&gt;</pre></div></div>

<p>Ensuite, avant la balise de fin de page <code>&lt;/body&gt;</code>, créez un <code>div</code> d&#8217;un <code>id</code> particulier contenant le code JavaScript de Google Adsense, comme ceci:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;div id=&quot;adsense-loader-head&quot; style=&quot;display: block;&quot;&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
google_ad_client = &quot;ca-pub-7282418192222825&quot;;
/* Nom de la bannière */
google_ad_slot = &quot;4287714958&quot;;
google_ad_width = 468;
google_ad_height = 60;
&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;
src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot;&gt;
&lt;/script&gt;
&lt;/div&gt;</pre></div></div>

<p>Pour finir, en bas de page, ajoutez ce simple code JavaScript pour placer la publicité au bon endroit:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;script type=&quot;text/javascript&quot;&gt;
var loader = document.getElementById('adsense-loader-head');
document.getElementById('adsense-head').appendChild(loader);
&lt;/script&gt;</pre></div></div>

<p><strong>Note:</strong> il est important de préciser le <code>display: block;</code> dans le <em>loader</em> et le <code>height</code> dans le div qui contiendra la publicité pour permettre au moteur de rendu de pré-charger la page.</p>
<p>La solution n&#8217;est donc pas vraiment une solution de code JavaScript non-bloquant, mais tout simplement de mettre le JavaScript en fin de page, permettant le rendu simple. Voici <a href="http://www.aaronpeters.nl/blog/non-blocking-google-adsense-ads-improve-page-speed">une preuve</a> vous permettant de vous rendre compte, nombres à l&#8217;appui, que cette technique marche effectivement. <img src='http://www.d-sites.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.d-sites.com/2011/01/06/optimiser-laffichage-de-pages-avec-google-adsense/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Plusieurs fancybox simultanément</title>
		<link>http://www.d-sites.com/2010/01/29/plusieurs-fancybox-simultanement/</link>
		<comments>http://www.d-sites.com/2010/01/29/plusieurs-fancybox-simultanement/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 22:24:43 +0000</pubDate>
		<dc:creator>Samuel ROZE</dc:creator>
				<category><![CDATA[Affichage]]></category>
		<category><![CDATA[Nouveautées]]></category>
		<category><![CDATA[fancybox]]></category>
		<category><![CDATA[multiple]]></category>
		<category><![CDATA[simultanée]]></category>
		<category><![CDATA[simultaneous]]></category>

		<guid isPermaLink="false">http://www.d-sites.com/?p=737</guid>
		<description><![CDATA[Tweet Si vous ne connaissez pas, FancyBox est une petite librairie jQuery permettant de mettre en place de manière très simple de petites nouvelles petites sur-fenêtres, ou popup au sein de votre page Web. Le problème de FancyBox, en tous &#8230; <a href="http://www.d-sites.com/2010/01/29/plusieurs-fancybox-simultanement/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="border:1px solid #808080;background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.d-sites.com%2F2010%2F01%2F29%2Fplusieurs-fancybox-simultanement%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://www.d-sites.com/2010/01/29/plusieurs-fancybox-simultanement/"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.d-sites.com/2010/01/29/plusieurs-fancybox-simultanement/"  data-text="Plusieurs fancybox simultanément" data-count="horizontal">Tweet</a>
			</div><div style="float:left; width:105px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script type="in/share" data-url="http://www.d-sites.com/2010/01/29/plusieurs-fancybox-simultanement/" data-counter="right"></script></div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://www.d-sites.com/2010/01/29/plusieurs-fancybox-simultanement/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>Si vous ne connaissez pas, <a href="http://www.fancybox.net/">FancyBox</a> est une petite librairie jQuery permettant de mettre en place de manière très simple de petites nouvelles petites sur-fenêtres, ou popup au sein de votre page Web. Le problème de FancyBox, en tous les cas pour la version actuelle, la 1.2.6, c&#8217;est qu&#8217;il est impossible de créer deux popups en même temps, par exemple on ouvre une popup &#8220;inline&#8221;, puis dans celle-ci on a par exemple une nouvelle popup, qui affiche des photos, hé bien c&#8217;est impossible&#8230;</p>
<p>Pour ça, j&#8217;ai donc développé une version &#8220;multiple&#8221; de FancyBox 1.2.6, dont le fichier JavaScript (et CSS) se nomment <code>jquery.fancybox-1.2.6.multiple.js</code> et <code>.css</code>. Vous pouvez les télécharger à ces adresses:</p>
<ul>
<li><a href="http://www.d-sites.com/wp-content/uploads/2010/01/jquery.fancybox-1.2.6.multiple.js">http://www.d-sites.com/wp-content/uploads/2010/01/jquery.fancybox-1.2.6.multiple.js</a></li>
<li><a href="http://www.d-sites.com/wp-content/uploads/2010/01/jquery.fancybox-1.2.6.multiple.css">http://www.d-sites.com/wp-content/uploads/2010/01/jquery.fancybox-1.2.6.multiple.css</a></li>
</ul>
<p>L&#8217;utilisation est quasi identique, sauf qu&#8217;un nouvel argument est possible lors de l&#8217;appel de la méthode fancybox sur un élément. Le deuxième argument attendu est le parent de la fancybox, ce qui permet ainsi de les différencier (un parent par fancybox), qui est par défaut <code>$('body')</code>.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a#i2'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fancybox</span><span style="color: #009900;">&#40;</span>
	<span style="color: #009900;">&#123;</span>
		hideOnContentClick<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> 
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div#inline'</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>N&#8217;hésitez pas à me faire des retours. <img src='http://www.d-sites.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.d-sites.com/2010/01/29/plusieurs-fancybox-simultanement/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Installer Flash Player 10 Debug sur Ubuntu 64 bits (firefox)</title>
		<link>http://www.d-sites.com/2009/10/30/installer-flash-player-10-debug-sur-ubuntu-64-bits-firefox/</link>
		<comments>http://www.d-sites.com/2009/10/30/installer-flash-player-10-debug-sur-ubuntu-64-bits-firefox/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 23:27:09 +0000</pubDate>
		<dc:creator>Samuel ROZE</dc:creator>
				<category><![CDATA[Adm. Système]]></category>
		<category><![CDATA[Affichage]]></category>
		<category><![CDATA[Linux/Unix]]></category>
		<category><![CDATA[amd64]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[flash]]></category>

		<guid isPermaLink="false">http://www.d-sites.com/?p=565</guid>
		<description><![CDATA[Tweet La version de débugage de Flash Player 10 est uniquement disponible pour les architectures x86 (32 bits) sous linux. Si vous essayer néanmoins l&#8217;installation vous aurez un magnifique &#8220;l&#8217;architecture &#8216;x86_64&#8242; n&#8217;est pas supportée&#8221;. Pour l&#8217;installer sous un Ubuntu x86_64 &#8230; <a href="http://www.d-sites.com/2009/10/30/installer-flash-player-10-debug-sur-ubuntu-64-bits-firefox/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="border:1px solid #808080;background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.d-sites.com%2F2009%2F10%2F30%2Finstaller-flash-player-10-debug-sur-ubuntu-64-bits-firefox%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://www.d-sites.com/2009/10/30/installer-flash-player-10-debug-sur-ubuntu-64-bits-firefox/"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.d-sites.com/2009/10/30/installer-flash-player-10-debug-sur-ubuntu-64-bits-firefox/"  data-text="Installer Flash Player 10 Debug sur Ubuntu 64 bits (firefox)" data-count="horizontal">Tweet</a>
			</div><div style="float:left; width:105px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script type="in/share" data-url="http://www.d-sites.com/2009/10/30/installer-flash-player-10-debug-sur-ubuntu-64-bits-firefox/" data-counter="right"></script></div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://www.d-sites.com/2009/10/30/installer-flash-player-10-debug-sur-ubuntu-64-bits-firefox/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>La version de débugage de Flash Player 10 est uniquement disponible pour les architectures x86 (32 bits) sous linux. Si vous essayer néanmoins l&#8217;installation vous aurez un magnifique <em>&#8220;l&#8217;architecture &#8216;x86_64&#8242; n&#8217;est pas supportée&#8221;</em>. Pour l&#8217;installer sous un Ubuntu x86_64 (64 bits) il faut utiliser <code>nspluginwrapper</code>.</p>
<p><span id="more-565"></span><strong>Avant toute chose, fermez firefox.</strong></p>
<p>Dans un premier temps, nous allons nous assurer qu&#8217;aucun autre plug-in flash n&#8217;est installé sur votre système:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;"># apt-get remove -y --purge flashplugin-nonfree gnash gnash-common mozilla-plugin-gnash swfdec-mozilla libflashsupport nspluginwrapper</pre></div></div>

<p><strong>Note:</strong> <code>$</code> signifie que la ligne doit être exécutée en tant qu&#8217;utilisateur normal et <code>#</code> en tant que super-utilisateur (root)</p>
<p>Afin de supprimer toute trace d&#8217;anciens plug-ins, exécutez ces quelques commandes:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;"># rm -f /usr/lib/mozilla/plugins/*flash*
# rm -f ~/.mozilla/plugins/*flash*
# rm -f /usr/lib/firefox/plugins/*flash*
# rm -rfd /usr/lib/nspluginwrapper</pre></div></div>

<p>Nous allons maintenant (ré)installer les librairies dont nous avons besoin pour faire fonctionner cette librairie:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;"># apt-get install ia32-libs nspluginwrapper</pre></div></div>

<p>Puis, téléchargeons et décompressons la version de débugage de Flash depuis <a href="http://www.adobe.com/support/flashplayer/downloads.html">le site officiel</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">$ wget http://download.macromedia.com/pub/flashplayer/updaters/10/flash_player_10_linux_dev.tar.gz
$ tar -xf flash_player_10_linux_dev.tar.gz</pre></div></div>

<p>Maintenant, il nous faut décompresser l&#8217;archive contenue dans la précédente contenant le fichier <code>.so</code> du flash player à installer, puis le stocker dans le répertoire des plug-ins de firefox:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">$ tar -xf flash_player_10_linux_dev/plugin/debugger/libflashplayer.so.tar.gz
# cp libflashplayer.so /usr/lib/mozilla/plugins/
$ rm -rf flash_player_10_linux_dev libflashplayer.so</pre></div></div>

<p>Maintenant, grâce à <code>nspluginwrapper</code> nous allons pouvoir installer la librairie et la lier à firefox:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;"># nspluginwrapper -i /usr/lib/mozilla/plugins/libflashplayer.so
# ln -sf /usr/lib/nspluginwrapper/plugins/npwrapper.libflashplayer.so /usr/lib/mozilla/plugins/
# ln -sf /usr/lib/nspluginwrapper/plugins/npwrapper.libflashplayer.so /usr/lib/firefox-addons/plugins/
# ln -sf /usr/lib/nspluginwrapper/plugins/npwrapper.libflashplayer.so /usr/lib/xulrunner-addons/plugins/</pre></div></div>

<p>A présent, le plug-in est installé, vous pouvez vérifier la version de votre Flash Player avec le fichier flash suivant:</p>
<p><object width="600" height="200"><param></param><embed src="http://www.d-sites.com/wp-content/uploads/2009/10/flashplayerversion1.swf" width="600" height="200"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.d-sites.com/2009/10/30/installer-flash-player-10-debug-sur-ubuntu-64-bits-firefox/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Debian/Ubuntu: Changer la résolution de la console</title>
		<link>http://www.d-sites.com/2009/10/15/debianubuntu-changer-la-resolution-de-la-console/</link>
		<comments>http://www.d-sites.com/2009/10/15/debianubuntu-changer-la-resolution-de-la-console/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 17:48:07 +0000</pubDate>
		<dc:creator>Samuel ROZE</dc:creator>
				<category><![CDATA[Adm. Système]]></category>
		<category><![CDATA[Affichage]]></category>
		<category><![CDATA[Linux/Unix]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[console]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[resolution]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.d-sites.com/?p=509</guid>
		<description><![CDATA[Tweet Attention, ne marche qu&#8217;avec la version 1 de GRUB &#8211; c&#8217;est-à-dire pour les versions d&#8217;Ubuntu antérieures à la 9.10. Avoir un petit ordinateur annexe qui sert de serveur c&#8217;est bien, ne pas en avoir &#8211; ou vouloir utiliser des &#8230; <a href="http://www.d-sites.com/2009/10/15/debianubuntu-changer-la-resolution-de-la-console/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="border:1px solid #808080;background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.d-sites.com%2F2009%2F10%2F15%2Fdebianubuntu-changer-la-resolution-de-la-console%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://www.d-sites.com/2009/10/15/debianubuntu-changer-la-resolution-de-la-console/"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.d-sites.com/2009/10/15/debianubuntu-changer-la-resolution-de-la-console/"  data-text="Debian/Ubuntu: Changer la résolution de la console" data-count="horizontal">Tweet</a>
			</div><div style="float:left; width:105px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script type="in/share" data-url="http://www.d-sites.com/2009/10/15/debianubuntu-changer-la-resolution-de-la-console/" data-counter="right"></script></div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://www.d-sites.com/2009/10/15/debianubuntu-changer-la-resolution-de-la-console/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p align="center"><em>Attention, ne marche qu&#8217;avec la version 1 de GRUB &#8211; c&#8217;est-à-dire pour les versions d&#8217;Ubuntu antérieures à la 9.10.</em></p>
<p>Avoir un petit ordinateur annexe qui sert de serveur c&#8217;est bien, ne pas en avoir &#8211; ou vouloir utiliser des solutions plus portables &#8211; c&#8217;est moins pratique. Pour ça, on peut utiliser des Debian virtualisés avec VirtualBox par exemple. Néanmoins, on ne peut pas se connecter à distance sur les consoles de ces machines virtualisées depuis l&#8217;hôte. On est donc obligés d&#8217;utiliser le système d&#8217;exploitation, sans interface graphique, en mode console. Seulement, la console est parfois très petite, on peut donc facilement changer la résolution de celle-ci.<br />
<span id="more-509"></span><strong>La problème:</strong> Le gros problème, c&#8217;est que le pilote graphique VESA ne permet d&#8217;utiliser des résolutions pré-configurées, en petit nombre&#8230;</p>
<h2>Changer la résolution dans les paramètres de démarrage GRUB</h2>
<p>Pour changer la résolution de la console, il faut ajouter l&#8217;option vga dans la ligne kernel du groupe de lignes correspondant au système à utiliser. Ainsi, voilà la ligne de départ:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">kernel        /boot/vmlinuz-2.6.26-2-686 root=/dev/hda1 ro quiet</pre></div></div>

<p>Avec la ligne vga, la voici:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">kernel        /boot/vmlinuz-2.6.26-2-686 root=/dev/hda1 ro quiet vga=790</pre></div></div>

<h2>Valeur de vga</h2>
<p>La valeur de VGA correspond à la résolution, issue du tableau ci-dessous:</p>
<pre>Color depth	640x480	800x600	1024x768  1280x1024
---------------------------------------------------------
  8bit		769	771	773	775
 15bit		784	787	790	793
 16bit		785	788	791	794
 24bit		786	789	792	795</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.d-sites.com/2009/10/15/debianubuntu-changer-la-resolution-de-la-console/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Copies d&#8217;écrans et miniatures de sites : Print-Site</title>
		<link>http://www.d-sites.com/2009/09/06/copies-decrans-et-miniatures-de-sites-print-site/</link>
		<comments>http://www.d-sites.com/2009/09/06/copies-decrans-et-miniatures-de-sites-print-site/#comments</comments>
		<pubDate>Sun, 06 Sep 2009 07:24:09 +0000</pubDate>
		<dc:creator>Samuel ROZE</dc:creator>
				<category><![CDATA[Affichage]]></category>
		<category><![CDATA[D-Sites]]></category>
		<category><![CDATA[Nouveautées]]></category>
		<category><![CDATA[print]]></category>
		<category><![CDATA[print-site]]></category>
		<category><![CDATA[screen]]></category>

		<guid isPermaLink="false">http://www.d-sites.com/?p=452</guid>
		<description><![CDATA[Tweet Développé par D-Sites, Print-Site est un service qui vous propose de transformer un site en une image de différentes tailles (taille réelle, miniature de 100&#215;100 à 500&#215;500) de manière instantanée et illimitée. Il repose sur Webkit, le moteur de &#8230; <a href="http://www.d-sites.com/2009/09/06/copies-decrans-et-miniatures-de-sites-print-site/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="border:1px solid #808080;background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.d-sites.com%2F2009%2F09%2F06%2Fcopies-decrans-et-miniatures-de-sites-print-site%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://www.d-sites.com/2009/09/06/copies-decrans-et-miniatures-de-sites-print-site/"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.d-sites.com/2009/09/06/copies-decrans-et-miniatures-de-sites-print-site/"  data-text="Copies d&#8217;écrans et miniatures de sites : Print-Site" data-count="horizontal">Tweet</a>
			</div><div style="float:left; width:105px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script type="in/share" data-url="http://www.d-sites.com/2009/09/06/copies-decrans-et-miniatures-de-sites-print-site/" data-counter="right"></script></div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://www.d-sites.com/2009/09/06/copies-decrans-et-miniatures-de-sites-print-site/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>Développé par D-Sites, <a href="http://www.d-sites.com/projets/print-site/">Print-Site</a> est un service qui vous propose de transformer un site en une image de différentes tailles (taille réelle, miniature de 100&#215;100 à 500&#215;500) de manière instantanée et illimitée.</p>
<p>Il repose sur Webkit, le moteur de rendu le plus respectueux des standards (100% à tous les Acid Test !).</p>
<p>Pour plus d&#8217;informations, visitez la <a href="http://www.d-sites.com/projets/print-site/">page dédiée au projet Print-Site</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.d-sites.com/2009/09/06/copies-decrans-et-miniatures-de-sites-print-site/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Debian: Installer un serveur X</title>
		<link>http://www.d-sites.com/2009/09/05/debian-installer-un-serveur-x/</link>
		<comments>http://www.d-sites.com/2009/09/05/debian-installer-un-serveur-x/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 22:18:58 +0000</pubDate>
		<dc:creator>Samuel ROZE</dc:creator>
				<category><![CDATA[Adm. Système]]></category>
		<category><![CDATA[Affichage]]></category>
		<category><![CDATA[Linux/Unix]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[x]]></category>
		<category><![CDATA[xvfb]]></category>

		<guid isPermaLink="false">http://www.d-sites.com/?p=421</guid>
		<description><![CDATA[Tweet Si pour une raison ou une autre, vous avez besoin d&#8217;éxécuter des programmes avec un serveur X (graphique), vous pouvez utiliser xvfb (X Virtual Frame Buffer) &#8211; comme vu dans l&#8217;article présentant les copies d&#8217;écrans à la volée depuis &#8230; <a href="http://www.d-sites.com/2009/09/05/debian-installer-un-serveur-x/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="border:1px solid #808080;background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.d-sites.com%2F2009%2F09%2F05%2Fdebian-installer-un-serveur-x%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://www.d-sites.com/2009/09/05/debian-installer-un-serveur-x/"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.d-sites.com/2009/09/05/debian-installer-un-serveur-x/"  data-text="Debian: Installer un serveur X" data-count="horizontal">Tweet</a>
			</div><div style="float:left; width:105px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script type="in/share" data-url="http://www.d-sites.com/2009/09/05/debian-installer-un-serveur-x/" data-counter="right"></script></div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://www.d-sites.com/2009/09/05/debian-installer-un-serveur-x/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>Si pour une raison ou une autre, vous avez besoin d&#8217;éxécuter des programmes avec un serveur X (graphique), vous pouvez utiliser <code>xvfb</code> (X Virtual Frame Buffer) &#8211; comme vu dans l&#8217;article présentant <a href="http://www.d-sites.com/2009/09/03/creer-des-copies-decran-de-sites-avec-votre-serveur/">les copies d&#8217;écrans à la volée depuis votre serveur</a> &#8211; avec ses temps de latence important ou installer <em>tout simplement</em> un serveur X.</p>
<p>Vous pensez peut-être que vous allons installer un serveur X avec toute la panoplie de différents services, puis Gnome, etc&#8230; Oh non ! Il nous faut uniquement (et obligatoirement) un serveur X virtuel pour pouvoir le démarrer sans clavier, sans souris et sans écran. C&#8217;est ainsi que <strong>Xvfb</strong> nous est à nouveau utile !<br />
<span id="more-421"></span></p>
<h2>Installation de Xvfb</h2>
<p>Nous allons l&#8217;installer tout simplement depuis les dépôts :</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">apt-get install xvfb</pre></div></div>

<h2>Démarrage de Xvfb</h2>
<p>Pour démarrer Xvfb, c&#8217;est très simple, il vous suffit d&#8217;éxécuter cette commande:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">Xvfb :1 -screen 0 1024x768x24</pre></div></div>

<p>Ainsi, Xvfb est démarré:</p>
<ul>
<li><code>:1</code> &#8211; Sur l&#8217;écran virtuel numéro 1</li>
<li><code>0</code> &#8211; Avec un indice X à 0</li>
<li><code>1024x768x24</code> &#8211; Une résolution de 1024&#215;768 avec 24 de color depth</li>
</ul>
<p>C&#8217;est aussi simple. Néanmoins, il faut savoir que la plupart des applications utilisant un serveur X font appelle à la variable <code>DISPLAY</code>. Elle contient le numéro d&#8217;écran ainsi que l&#8217;indice X sous la forme: <code>[numéro écran]:[indice X]</code>. Il vous faut donc exporter cette variable pour qu&#8217;elle soit utilisée par ces programmes :</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">export DISPLAY = &quot;1:0&quot;</pre></div></div>

<p><strong>Note:</strong> Cette commande sera à exécuter à chaque fois que vous aurez une erreur du type &#8220;Impossible de se connecter au serveur X&#8221;</p>
<h2>Pour que Xvfb soit démarré à chaque fois&#8230;</h2>
<p>Pour que Xvfb soit démarré à chaque démarrage, il faut le mettre en tant que &#8220;service&#8221;. Pour cela, créez un petit script de démarrage ou <a href="http://www.d-sites.com/wp-content/uploads/2009/09/xvfb">téléchargez celui-ci</a>. Placez-le dans /etc/init.d/. Puis, nous allons lui ajouter les droits d&#8217;éxecution puis le faire démarrer par defaut :</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">chmod +x /etc/init.d/xvfb
update-rc.d xvfb defaults</pre></div></div>

<p>Si votre script est correct, Xvfb devrait démarrer à chaque fois.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.d-sites.com/2009/09/05/debian-installer-un-serveur-x/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Créer des copies d&#8217;écran de sites avec votre serveur</title>
		<link>http://www.d-sites.com/2009/09/03/creer-des-copies-decran-de-sites-avec-votre-serveur/</link>
		<comments>http://www.d-sites.com/2009/09/03/creer-des-copies-decran-de-sites-avec-votre-serveur/#comments</comments>
		<pubDate>Thu, 03 Sep 2009 16:56:06 +0000</pubDate>
		<dc:creator>Samuel ROZE</dc:creator>
				<category><![CDATA[Adm. Système]]></category>
		<category><![CDATA[Affichage]]></category>
		<category><![CDATA[Linux/Unix]]></category>
		<category><![CDATA[Nouveautées]]></category>
		<category><![CDATA[cutycapt]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[print]]></category>
		<category><![CDATA[qt]]></category>
		<category><![CDATA[screen]]></category>
		<category><![CDATA[system]]></category>

		<guid isPermaLink="false">http://www.d-sites.com/?p=412</guid>
		<description><![CDATA[Tweet Générer des miniatures (ou copies d&#8217;écran) de n&#8217;importe quel site pour en faire une page de présentation ou pour aider les visiteurs à mieux se repérer dans votre index est quelque chose de plutôt fastidieux si l&#8217;on doit le &#8230; <a href="http://www.d-sites.com/2009/09/03/creer-des-copies-decran-de-sites-avec-votre-serveur/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="border:1px solid #808080;background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.d-sites.com%2F2009%2F09%2F03%2Fcreer-des-copies-decran-de-sites-avec-votre-serveur%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://www.d-sites.com/2009/09/03/creer-des-copies-decran-de-sites-avec-votre-serveur/"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.d-sites.com/2009/09/03/creer-des-copies-decran-de-sites-avec-votre-serveur/"  data-text="Créer des copies d&#8217;écran de sites avec votre serveur" data-count="horizontal">Tweet</a>
			</div><div style="float:left; width:105px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script type="in/share" data-url="http://www.d-sites.com/2009/09/03/creer-des-copies-decran-de-sites-avec-votre-serveur/" data-counter="right"></script></div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://www.d-sites.com/2009/09/03/creer-des-copies-decran-de-sites-avec-votre-serveur/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>Générer des miniatures (ou copies d&#8217;écran) de n&#8217;importe quel site pour en faire une page de présentation ou pour aider les visiteurs à mieux se repérer dans votre index est quelque chose de plutôt fastidieux si l&#8217;on doit le faire soit-même à la main. C&#8217;est pourquoi, il existe des solutions pour faire ceci depuis votre ordinateur personnel (sous Debian et ses dérivées &#8211; Ubuntu, Xubuntu, etc&#8230;) avec (ou sans, avec <code>xvfb</code>) serveur X (graphique).</p>
<p><strong>Information:</strong> D-Sites a créer un service nommé Print-Site qui vous permet de créer ces images de sites gratuitement sans aucune installation. Les serveurs de D-Sites s&#8217;occupent de tout ! Visitez <a href="http://www.d-sites.com/2009/09/06/copies-decrans-et-miniatures-de-sites-print-site/">l&#8217;annonce</a> ou <a href="http://www.d-sites.com/projets/print-site/">la page du projet Print-Site</a>.<span id="more-412"></span></p>
<h2>CutyCapt, un programme tout fait</h2>
<p>Nous n&#8217;allons pas ré-inventer la roue, il existe des logiciels tous fait pour faire ça. C&#8217;est le cas de CutyCapt qui est une solution utilisant Qt4 et Webkit, que nous allons utiliser. Avant toute chose, nous allons installer Qt4 et tous les paquets relatifs nécessaires à l&#8217;exécution de CutyCapt :</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">apt-get install libqt4-webkit libqt4-dev g++</pre></div></div>

<p>Ces paquets font environ 20Mo à télécharger puis prennent près de 50Mo une fois installés. Lorsqu&#8217;ils sont installés, nous allons télécharger CutyCapt depuis une archive hébergée par Mes-Stats  :</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">wget http://sources.mes-stats.fr/cutycapt/cutycapt-r2.tar.gz</pre></div></div>

<p>Vous pouvez aussi télécharger la dernière version de CutyCapt depuis les dépots SVN, afin d&#8217;être sur d&#8217;avoir la dernière version. Néanmoins, il se peux qu&#8217;il y ait certains bugs ou certaines fonctionnalités de changées&#8230;</p>
<pre>svn co http://cutycapt.svn.sourceforge.net/svnroot/cutycapt</pre>
<p>Puis nous allons décompresser</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">tar -xzf cutycapt-r2.tar.gz
cd cutycapt</pre></div></div>

<p>Nous allons ensuite compiler ce programme Qt4 en exécutant ces deux commandes:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">qmake
make</pre></div></div>

<p><strong>Note:</strong> Si lors de la compilation (<code>make</code>) il y a un grand nombre d&#8217;erreurs, ré-essayez en remplacant <code>qmake</code> par <code>qmake-qt4</code>. En effet, sur certaines distributions, Qt est déjà installée en sa version 3 et <code>qmake</code> correspond à cette version.</p>
<h2>Exécuter CutyCapt</h2>
<h3>Avec un serveur X</h3>
<p>Si vous utilisez une machine qui a un serveur X installé, vous pourrez dès à présent utiliser CutyCapt en une seule commande:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">./CutyCapt --url=http://www.d-sites.com --out=d-sites.png</pre></div></div>

<p>Ce qui vous produit une image contenant une capture d&#8217;écran de D-Sites nommée &#8220;d-sites.png&#8221; encodée en&#8230; PNG ! <img src='http://www.d-sites.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p><strong>Note:</strong> CutyCapt vous permet d&#8217;exporter des images sous les formes svg, ps, pdf, itext, html, rtree, png, jpeg, mng, tiff, gif, bmp, ppm, xbm et xpm. Bien entendu, les rendus sous forme d&#8217;images fixes (png, gif, etc&#8230;) sont beaucoup plus surs que les rendus sous forme de PDF, SVG et autres.</p>
<h3>Sans serveur X</h3>
<p>Si vous n&#8217;avez pas de serveur X, en installer un prendrait trop de ressources par rapport à l&#8217;utilisation (probable) qu&#8217;il en serait fait. Pour ça, il existe <a href="http://en.wikipedia.org/wiki/Xvfb">Xvfb</a> (X Virtual Frame Buffer) qui vous permet de simuler un serveur X le temps d&#8217;une requête. Il faut donc l&#8217;installer avant tout:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">apt-get install xvfb</pre></div></div>

<p>Ensuite, nous allons exécuter CutyCapt dans un serveur X virtuel de cette manière:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">xvfb-run --server-args=&quot;-screen 0, 1024x768x24&quot; ./CutyCapt --url=http://www.d-sites.com --out=d-sites.png</pre></div></div>

<p>CutyCapt s&#8217;éxécutera ainsi dans une fenêtre de résolution 1024&#215;768, ce qui n&#8217;a en réalité aucune importance. Pour spécifier la largeur de la page, utilisez l&#8217;option &#8220;&#8211;max-width=[...]&#8221; avec une valeur en pixels.</p>
<p><strong>Attention:</strong> Malgré le fait que cette méthode est très attractive, elle n&#8217;est vraiment pas très performante. En effet, rien que pour s&#8217;initialiser, xvfb-run peut mettre jusqu&#8217;à 3 secondes ! <a href="http://www.d-sites.com/2009/09/05/debian-installer-un-serveur-x/">Installer un serveur X</a> n&#8217;est donc en fait pas une mauvaise alternative&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.d-sites.com/2009/09/03/creer-des-copies-decran-de-sites-avec-votre-serveur/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Mettre à jour Apache</title>
		<link>http://www.d-sites.com/2009/08/12/mettre-a-jour-apache/</link>
		<comments>http://www.d-sites.com/2009/08/12/mettre-a-jour-apache/#comments</comments>
		<pubDate>Wed, 12 Aug 2009 02:00:10 +0000</pubDate>
		<dc:creator>Samuel ROZE</dc:creator>
				<category><![CDATA[Adm. Système]]></category>
		<category><![CDATA[Affichage]]></category>
		<category><![CDATA[Linux/Unix]]></category>
		<category><![CDATA[apache2]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[update]]></category>

		<guid isPermaLink="false">http://www.d-sites.com/?p=330</guid>
		<description><![CDATA[Tweet Parfois, dans n&#8217;importe quel programme, il y a des bugs, qui sont corrigés dans des futures versions. Si vous êtes confronté à un bug, il faut donc mettre à jour le logiciel. Nous allons voir comment mettre à jour &#8230; <a href="http://www.d-sites.com/2009/08/12/mettre-a-jour-apache/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="border:1px solid #808080;background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.d-sites.com%2F2009%2F08%2F12%2Fmettre-a-jour-apache%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://www.d-sites.com/2009/08/12/mettre-a-jour-apache/"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.d-sites.com/2009/08/12/mettre-a-jour-apache/"  data-text="Mettre à jour Apache" data-count="horizontal">Tweet</a>
			</div><div style="float:left; width:105px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script type="in/share" data-url="http://www.d-sites.com/2009/08/12/mettre-a-jour-apache/" data-counter="right"></script></div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://www.d-sites.com/2009/08/12/mettre-a-jour-apache/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>Parfois, dans n&#8217;importe quel programme, il y a des bugs, qui sont corrigés dans des futures versions. Si vous êtes confronté à un bug, il faut donc mettre à jour le logiciel. Nous allons voir comment mettre à jour Apache vers une version mineure plus récente. C&#8217;est-à-dire par exemple de la version 2.2.9 à la version 2.2.13. Mais pas de la 2.0 à la 2.2, encore moins de la 1 à la 2 !</p>
<p>Nous allons prendre des valeurs pour tout l&#8217;article, qui sont:</p>
<ul>
<li>Répertoire de l&#8217;ancienne version d&#8217;Apache: <code>/etc/apache-2.2.9</code></li>
<li>Répertoire de la nouvelle version d&#8217;Apache: <code>/etc/apache-2.2.13</code></li>
</ul>
<p><span id="more-330"></span></p>
<h2>Installation de la nouvelle version dans un autre dossier</h2>
<p>Nous allons commencer à installer la nouvelle version d&#8217;Apache dans un autre dossier, en utilisant la directive <code>prefix</code> lors du <code>configure</code>. Pour <a href="http://www.d-sites.com/2009/06/24/compiler-et-installer-apache-2/">compiler et installer Apache, direction cet article</a>.</p>
<p><strong>Note:</strong> Allez toujours voir sur la page des téléchargements de Apache pour savoir s&#8217;il n&#8217;y a pas de nouvelle version mineure. S&#8217;il y en a, utilisez l&#8217;archive correspondante.<br />
<strong>Attention:</strong> Faites bien attention au chemin du fichier de configuration !<br />
<strong>Note:</strong> Si vous l&#8217;utilisez, <strong><a href="http://www.d-sites.com/2009/08/12/compiler-et-installer-php-5-2-sur-apache-2/">installez PHP maintenant</a></strong>.</p>
<h2>Copie de la configuration</h2>
<p>Nous allons copier les paramètres de configuration de l&#8217;ancienne configuration vers la nouvelle:</p>
<blockquote>
<pre>cd /etc/apache-2.2.9 &#038;&#038; cp conf /etc/apache-2.2.13 -rf</pre>
</blockquote>
<p><strong>Attention:</strong> Valable uniquement pour les configuration d&#8217;Apache compilé. Toutes les installations faites via <code>apt-get</code> et autres sont beaucoup plus compliquées à mettre à jour en compilant un nouveau Apache&#8230;</p>
<h2>Effectuons des tests</h2>
<p>Nous allons effectuer des tests en utilisant la nouvelle version d&#8217;Apache sur un autre port, le port 81 par exemple. Pour cela, nous allons modifier le fichier la valeur de <code>Listen</code> de 80 à 81.</p>
<p>Maintenant, accèdez à votre site en utilisant le port 81: http://www.example.com:81/index.php. Il faut que tous vos domaines/sous-domaines/scripts soient accessibles en utilisant le port 81.</p>
<p><strong>Attention:</strong> Si vous utilisez les <a href="http://www.d-sites.com/2009/06/15/virtualhosts-avec-apache-2/">VirtualHosts de Apache 2</a>, <code>NameVirtualHost</code> doit avoir pour valeur <code>*:81</code> ou plus simplement <code>*</code>. Et les <code><VirtualHosts></code> doivent être définis avec cette valeur. </p>
<p>Si tout marche bien, nous allons arrêter puis supprimer l&#8217;ancienne version et passer la nouvelle en production&#8230;</p>
<h2>Arrêt de l&#8217;ancienne version et démarrage de la nouvelle</h2>
<p>Afin d&#8217;éviter le maximum de temps d&#8217;inaccessibilité, nous allons arrêter l&#8217;ancienne et démarrer la nouvelle version d&#8217;Apache de manière quasi-simultanée.</p>
<p>Dans un premier temps, il faut arrêter la nouvelle version d&#8217;Apache (<code>/etc/apache-2.2.13/bin/apachectl stop</code>) et la configurer pour s&#8217;exécuter sur le port 80 (modifiez la propriété <code>Listen</code> dans httpd.conf ou ports.conf).</p>
<p>Ensuite, dans une même traite, nous allons arrête l&#8217;ancienne version et démarrer la nouvelle :</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">/etc/apache-2.2.9/bin/apachectl stop
/etc/apache-2.2.13/bin/apachectl start</pre></div></div>

<p>Ainsi, en toute logique, votre serveur Apache utilise maintenant la nouvelle version. Si vous avez installer une nouvelle version de PHP, il l&#8217;utilise aussi&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.d-sites.com/2009/08/12/mettre-a-jour-apache/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP: mb_substr à la place de substr pour l&#8217;UTF-8</title>
		<link>http://www.d-sites.com/2009/07/23/php-mb_substr-a-la-place-de-substr-pour-lutf-8/</link>
		<comments>http://www.d-sites.com/2009/07/23/php-mb_substr-a-la-place-de-substr-pour-lutf-8/#comments</comments>
		<pubDate>Thu, 23 Jul 2009 17:52:04 +0000</pubDate>
		<dc:creator>Samuel ROZE</dc:creator>
				<category><![CDATA[Affichage]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[encodage]]></category>
		<category><![CDATA[utf-8]]></category>

		<guid isPermaLink="false">http://blog.mes-stats.fr/?p=176</guid>
		<description><![CDATA[Tweet Si vous utilisez un hébergement mutualisé pour quelconque site ou service, lors du développement, tout doit être encodé de la même manière. Comme je le conseil dans l&#8217;article concernant les problèmes d&#8217;encodage, utiliser UTF-8 avec PHP n&#8217;est pas toujours &#8230; <a href="http://www.d-sites.com/2009/07/23/php-mb_substr-a-la-place-de-substr-pour-lutf-8/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="border:1px solid #808080;background-color:#F0F4F9;">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.d-sites.com%2F2009%2F07%2F23%2Fphp-mb_substr-a-la-place-de-substr-pour-lutf-8%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://www.d-sites.com/2009/07/23/php-mb_substr-a-la-place-de-substr-pour-lutf-8/"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.d-sites.com/2009/07/23/php-mb_substr-a-la-place-de-substr-pour-lutf-8/"  data-text="PHP: mb_substr à la place de substr pour l&#8217;UTF-8" data-count="horizontal">Tweet</a>
			</div><div style="float:left; width:105px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script type="in/share" data-url="http://www.d-sites.com/2009/07/23/php-mb_substr-a-la-place-de-substr-pour-lutf-8/" data-counter="right"></script></div>			
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1&amp;r=http://www.d-sites.com/2009/07/23/php-mb_substr-a-la-place-de-substr-pour-lutf-8/"></script></div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>Si vous utilisez un hébergement mutualisé pour quelconque site ou service, lors du développement, tout doit être encodé de la même manière. Comme je le conseil dans <a href="http://www.d-sites.com/2008/07/21/le-probleme-dencodage-des-accents-en-points-dinterrogation/">l&#8217;article concernant les problèmes d&#8217;encodage</a>, utiliser UTF-8 avec PHP n&#8217;est pas toujours facile, surtout quand c&#8217;est PHP lui-même qui vous transforme vos chaines de caractère UTF-8 en ISO-8859-1 (si c&#8217;est l&#8217;encodage de caractère utilisé sur le serveur&#8230;).</p>
<p>C&#8217;est en effet le cas de la fonction <strong>substr</strong> qui converti les chaines de caractères. Comprendre d&#8217;où vient l&#8217;erreur d&#8217;encodage sans penser que ça pourrait être PHP lui-même, c&#8217;est dur&#8230; Donc, pour spécifier l&#8217;encodage à utiliser pour substr, il faut utiliser la fonction mb_substr et lui ajouter un argument comme ceci:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$new_string</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mb_substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #339933;">,</span> <span style="color: #000088;">$start</span><span style="color: #339933;">,</span> <span style="color: #000088;">$end</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'UTF-8'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Que cet article aide de nombreuses personnes à ne pas chercher pendant des heures un problème qui n&#8217;est pas réellement de le ressort&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.d-sites.com/2009/07/23/php-mb_substr-a-la-place-de-substr-pour-lutf-8/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using apc
Database Caching 1/42 queries in 0.137 seconds using apc
Object Caching 887/993 objects using apc

Served from: d-sites.com @ 2012-02-04 20:00:31 -->
