<?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[Clément Delafargue]]></title>
	<description><![CDATA[Flux RSS des articles]]></description>
	<pubDate>Sat, 19 May 2012 13:31:19 +0200</pubDate>
	<link>http://www.divarvel.fr</link>
	<language>fr</language>
	<generator>http://www.eklablog.com</generator>
	
	<item>
		<title><![CDATA[TypeSafe URLs in Lift]]></title>
		<link>http://www.divarvel.fr/typesafe-urls-in-lift-a4755129</link>
		<description><![CDATA[I've been working for a few months with Lift , a really nice web framework. Lift takes ideas and concepts from a few other frameworks. The main difference between Lift and other frameworks is that Lift does not enforce MVC (even though you can do MVC if you want to). Lift's approach is view-first ,...]]></description>
		<content:encoded><![CDATA[<p>I've been working for a few months with <a href="http://liftweb.net/">Lift</a>, a really nice web framework. Lift takes ideas and concepts from a few other frameworks. The main difference between Lift and other frameworks is that Lift does not enforce MVC (even though you can do MVC if you want to). Lift's approach is <strong>view-first</strong>, which means you first create the view, then you tell which part of the code will take care of dynamism.</p>
<p>For more propaganda: <a href="http://seventhings.liftweb.net/">Seven Things</a> and <a href="http://lift.la/web-framework-manifesto-republished-from-2006">Web Framework Manifesto</a></p>
<p>I'll explain how to build <em>REST-y</em> URLs in a type-safe manner, with the SiteMap. The goal is to access a blog post with this kind of URL: <strong>/posts/<em>{id}</em></strong></p>
<p>I'll illustrate this article with something tremendously original: a Blog, with posts. I'll use mongoDB as a backend, but it's not really important.</p>
<h3>The model</h3>
<p>It's a simple blog post. Let's just assume the author is stored in plain text.</p>
<p><div class="code"><a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">class</span></a> BlogPost <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">private</span></a><span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span> <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">extends</span></a> MongoRecord <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">with</span></a> ObjectIdPk<span style="color: #F78811;">&#91;</span>BlogPost<span style="color: #F78811;">&#93;</span> <span style="color: #F78811;">&#123;</span><br />
  <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">def</span></a> meta <span style="color: #000080;">=</span> BlogPost<br />
  <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">object</span></a> author <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">extends</span></a> StringField<span style="color: #F78811;">&#40;</span><a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">this</span></a>, <span style="color: #F78811;">32</span><span style="color: #F78811;">&#41;</span><br />
  <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">object</span></a> date <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">extends</span></a> DateField<span style="color: #F78811;">&#40;</span><a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">this</span></a><span style="color: #F78811;">&#41;</span><br />
  <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">object</span></a> content <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">extends</span></a> TextareaField<span style="color: #F78811;">&#40;</span><a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">this</span></a>, <span style="color: #F78811;">500</span><span style="color: #F78811;">&#41;</span><br />
<br />
  <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">val</span></a> url <span style="color: #000080;">=</span> … <span style="color: #008000; font-style: italic;">// We'll see that later</span><br />
<span style="color: #F78811;">&#125;</span><br />
<br />
<a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">object</span></a> BlogPost <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">extends</span></a> BlogPost <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">with</span></a> MongoMetaRecord<span style="color: #F78811;">&#91;</span>BlogPost<span style="color: #F78811;">&#93;</span> <span style="color: #F78811;">&#123;</span><br />
  <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">val</span></a> entry <span style="color: #000080;">=</span> … <span style="color: #008000; font-style: italic;">// We'll see that later</span><br />
  <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">def</span></a> calcHref<span style="color: #F78811;">&#40;</span>bp<span style="color: #000080;">:</span> BlogPost<span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=</span> … <span style="color: #008000; font-style: italic;">// We'll see that later</span><br />
<span style="color: #F78811;">&#125;</span><div style="display:none;">[code=scala]<br/>class BlogPost private() extends MongoRecord with ObjectIdPk[BlogPost] {<br/>&nbsp; def meta = BlogPost<br/>&nbsp; object author extends StringField(this, 32)<br/>&nbsp; object date extends DateField(this)<br/>&nbsp; object content extends TextareaField(this, 500)<br/><br/>&nbsp; val url = &hellip; // We'll see that later<br/>}<br/><br/>object BlogPost extends BlogPost with MongoMetaRecord[BlogPost] {<br/>&nbsp; val entry = &hellip; // We'll see that later<br/>&nbsp; def calcHref(bp: BlogPost) = &hellip; // We'll see that later<br/>}<br/>[/code]</div></div></p>
<h3>The template</h3>
<p>Nothing special there. Just save it in <code>webapp/posts.html</code>. We have a <code>h1</code> for the title, a <code>p</code> for some info, and a <code>p</code> for the actual post.</p>
<p><div class="code"><span style="color: #009900;"><a href="http://december.com/html/4/element/%26amp%3Blt%3CSEMI%3Ediv.html"><span style="color: #000000; font-weight: bold;">&lt;div</span></a> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;lift:surround?with=default;at=content&quot;</span><a href="http://december.com/html/4/element/%26amp%3Bgt%3CSEMI%3E.html"><span style="color: #000000; font-weight: bold;">&gt;</span></a></span><br />
<span style="color: #009900;"><a href="http://december.com/html/4/element/%26amp%3Blt%3CSEMI%3Ediv.html"><span style="color: #000000; font-weight: bold;">&lt;div</span></a> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;lift:BlogPostSnippet&quot;</span><a href="http://december.com/html/4/element/%26amp%3Bgt%3CSEMI%3E.html"><span style="color: #000000; font-weight: bold;">&gt;</span></a></span><br />
<span style="color: #009900;"><a href="http://december.com/html/4/element/%26amp%3Blt%3CSEMI%3Eh1.html"><span style="color: #000000; font-weight: bold;">&lt;h1</span></a> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;title&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span>h1&gt;</span><br />
<span style="color: #009900;"><a href="http://december.com/html/4/element/%26amp%3Blt%3CSEMI%3Ep.html"><span style="color: #000000; font-weight: bold;">&lt;p</span></a> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;info&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span>p&gt;</span><br />
<span style="color: #009900;"><a href="http://december.com/html/4/element/%26amp%3Blt%3CSEMI%3Ep.html"><span style="color: #000000; font-weight: bold;">&lt;p</span></a> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;blogpost&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span>p&gt;</span><br />
<span style="color: #009900;"><a href="http://december.com/html/4/element/%26amp%3Blt%3CSEMI%3E%2Fdiv%26amp%3Bgt%3CSEMI%3E.html"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></a></span><br />
<span style="color: #009900;"><a href="http://december.com/html/4/element/%26amp%3Blt%3CSEMI%3E%2Fdiv%26amp%3Bgt%3CSEMI%3E.html"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></a></span><div style="display:none;">[code=html]<br/>&lt;div class="lift:surround?with=default;at=content"&gt;<br/>&lt;div class="lift:BlogPostSnippet"&gt;<br/>&lt;h1 class="title"&gt;&lt;/h1&gt;<br/>&lt;p class="info"&gt;&lt;/p&gt;<br/>&lt;p class="blogpost"&gt;&lt;/p&gt;<br/>&lt;/div&gt;<br/>&lt;/div&gt;<br/>[/code]</div></div></p>
<h3>The snippet</h3>
<p>This class will be instantiated with the blog post we want to display. We just inject data in the markup.</p>
<p><div class="code"><a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">class</span></a> BlogPostSnippet<span style="color: #F78811;">&#40;</span><a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">val</span></a> blogPost<span style="color: #000080;">:</span> BlogPost<span style="color: #F78811;">&#41;</span> <span style="color: #F78811;">&#123;</span><br />
  <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">def</span></a> render <span style="color: #000080;">=</span> <span style="color: #6666FF;">&quot;.title *&quot;</span> <span style="color: #000080;">#&gt;</span> blogPost.<span style="color: #000000;">title</span>.<span style="color: #000000;">is</span> <span style="color: #000080;">&amp;</span><br />
    <span style="color: #6666FF;">&quot;.info *&quot;</span> <span style="color: #000080;">#&gt;</span> <span style="color: #F78811;">&#40;</span><span style="color: #6666FF;">&quot;By &quot;</span> + blogPost.<span style="color: #000000;">author</span>.<span style="color: #000000;">is</span><span style="color: #F78811;">&#41;</span> <span style="color: #000080;">&amp;</span><br />
    <span style="color: #6666FF;">&quot;.blogpost *&quot;</span> <span style="color: #000080;">#&gt;</span> blogPost.<span style="color: #000000;">content</span>.<span style="color: #000000;">is</span><br />
<span style="color: #F78811;">&#125;</span><div style="display:none;">[code=scala]<br/>class BlogPostSnippet(val blogPost: BlogPost) {<br/>&nbsp; def render = ".title *" #&gt; blogPost.title.is &amp;<br/>&nbsp;&nbsp;&nbsp; ".info *" #&gt; ("By " + blogPost.author.is) &amp;<br/>&nbsp;&nbsp;&nbsp; ".blogpost *" #&gt; blogPost.content.is<br/>}<br/>[/code]</div></div></p>
<h3>The SiteMap</h3>
<p>So, back to <code>BlogPost.entry</code>, where the magic happens. We define an entry of the sitemap which is associated with the <code>BlogPost</code> class. The two first arguments are the id and the displayed name of the link. The third argument is a function which takes a <code>String</code> and returns a <code>Box[BlogPost]</code>. This tells Lift how to instantiate <code>BlogPostSnippet</code> with the right blog post. The fourth argument is used to create an url from a given blog post. Finally, we specify the address and tell Lift we don't want this entry to show up in the menus.</p>
<p>The calcHref method is just a shortcut.</p>
<p><div class="code"><a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">class</span></a> BlogPost … <span style="color: #F78811;">&#123;</span><br />
  <span style="color: #00ff00; font-style: italic;">/* Snip */</span><br />
  <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">val</span></a> url <span style="color: #000080;">=</span> BlogPost.<span style="color: #000000;">calcHref</span><span style="color: #F78811;">&#40;</span><a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">this</span></a><span style="color: #F78811;">&#41;</span><br />
<span style="color: #F78811;">&#125;</span><br />
<br />
<a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">object</span></a> BlogPost … <span style="color: #F78811;">&#123;</span><br />
  <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">val</span></a> entry <span style="color: #000080;">=</span> Menu.<span style="color: #000000;">param</span><span style="color: #F78811;">&#91;</span>BlogPost<span style="color: #F78811;">&#93;</span><span style="color: #F78811;">&#40;</span><br />
    <span style="color: #6666FF;">&quot;blogpost&quot;</span>,<br />
    S <span style="color: #000080;">?</span> <span style="color: #6666FF;">&quot;blogpost.view&quot;</span>,<br />
    <span style="color: #F78811;">&#40;</span>id<span style="color: #000080;">:</span> String<span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=&gt;</span> BlogPost.<span style="color: #000000;">find</span><span style="color: #F78811;">&#40;</span>id<span style="color: #F78811;">&#41;</span>,<br />
    <span style="color: #F78811;">&#40;</span>bp<span style="color: #000080;">:</span> BlogPost<span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=&gt;</span> bp.<span style="color: #000000;">id</span>.<span style="color: #000000;">is</span><br />
  <span style="color: #F78811;">&#41;</span> / <span style="color: #6666FF;">&quot;posts&quot;</span> / <span style="color: #000080;">*</span> <span style="color: #000080;">&gt;&gt;</span> Hidden<br />
<br />
  <a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">def</span></a> calcHref<span style="color: #F78811;">&#40;</span>bp<span style="color: #000080;">:</span> BlogPost<span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=</span> entry.<span style="color: #000000;">toLoc</span>.<span style="color: #000000;">calcHref</span><span style="color: #F78811;">&#40;</span>bp<span style="color: #F78811;">&#41;</span><br />
<span style="color: #F78811;">&#125;</span><div style="display:none;">[code=scala]<br/>class BlogPost &hellip; {<br/>&nbsp; /* Snip */<br/>&nbsp; val url = BlogPost.calcHref(this)<br/>}<br/><br/>object BlogPost &hellip; {<br/>&nbsp; val entry = Menu.param[BlogPost](<br/>&nbsp;&nbsp;&nbsp; "blogpost",<br/>&nbsp; &nbsp; S ? "blogpost.view",<br/>&nbsp;&nbsp;&nbsp; (id: String) =&gt; BlogPost.find(id),<br/>&nbsp;&nbsp;&nbsp; (bp: BlogPost) =&gt; bp.id.is<br/>&nbsp; ) / "posts" / * &gt;&gt; Hidden<br/><br/>&nbsp; def calcHref(bp: BlogPost) = entry.toLoc.calcHref(bp)<br/>}<br/>[/code]</div></div></p>
<p>Don't forget to add <code>BlogPost.entry</code> to the <code>SiteMap</code></p>
<p><div class="code"><a href="http://scala-lang.org"><span style="color: #0000ff; font-weight: bold;">val</span></a> entries <span style="color: #000080;">=</span> <span style="color: #00ff00; font-style: italic;">/* other entries */</span> <span style="color: #000080;">::</span> BlogPost.<span style="color: #000000;">entry</span> <span style="color: #000080;">::</span> Nil<br />
LiftRules.<span style="color: #000000;">setSiteMap</span><span style="color: #F78811;">&#40;</span>SiteMap<span style="color: #F78811;">&#40;</span>entries<span style="color: #000080;">:</span> <span style="color: #000080;">_*</span><span style="color: #F78811;">&#41;</span><span style="color: #F78811;">&#41;</span><div style="display:none;">[code=scala]<br/>val entries = /* other entries */ :: BlogPost.entry :: Nil<br/>LiftRules.setSiteMap(SiteMap(entries: _*))<br/>[/code]</div></div></p>
<p><br/>Next time I'll show you how to display comments after the blog post, while keeping the HTML structure of every comment in the template :)</p><br /><br />]]></content:encoded>
		<pubDate>Wed, 03 Aug 2011 16:07:45 +0200</pubDate>
		<guid isPermaLink="true">http://www.divarvel.fr/typesafe-urls-in-lift-a4755129</guid>
		<dc:creator>divarvel</dc:creator>
		<dc:date>2011-08-03T16:07:45+02:00</dc:date>
	</item>
	<item>
		<title><![CDATA[Installer PHP 5.3 en gardant PHP 5.2 sous Ubuntu]]></title>
		<link>http://www.divarvel.fr/installer-php-5-3-en-gardant-php-5-2-sous-ubuntu-a1168969</link>
		<description><![CDATA[Dans le cadre de mon stage, je bosse sur un site cod&eacute; pour PHP 5.3, et j'ai donc eu &agrave; installer PHP5.3 sur ma b&eacute;cane.

Cette version de PHP n'&eacute;tant pas encore dans les d&eacute;p&ocirc;ts, et les paquets disponibles ayant des probl&egrave;mes de d&eacute;pendances non r&eacute;solues, le plus simple c'est de compiler. Le...]]></description>
		<content:encoded><![CDATA[Dans le cadre de mon stage, je bosse sur un site cod&eacute; pour PHP 5.3, et j'ai donc eu &agrave; installer PHP5.3 sur ma b&eacute;cane.<br /><br />Cette version de PHP n'&eacute;tant pas encore dans les d&eacute;p&ocirc;ts, et les paquets disponibles ayant des probl&egrave;mes de d&eacute;pendances non r&eacute;solues, le plus simple c'est de compiler. Le probl&egrave;me c'est qu'on perd la souplesse de la gestion modulaire de PHP.<br /><br />Ce que j'ai donc fait, c'est installer PHP5.3 en tant que binaire CGI, sans toucher &agrave; ma version de PHP 5.2 install&eacute;e en tant que module apache.<br /><br /><strong>Warning :</strong> Je mets cette m&eacute;thode &agrave; titre exp&eacute;rimental, pour faire du<strong> dev</strong> et du test. Ne vous amusez pas &agrave; mettre &ccedil;a sur un serveur de prod sans plus d'infos. Il y a pas mal de diff&eacute;rences avec le fonctionnement sous forme de module.<br /><br /><a href="http://www.divarvel.fr/installer-php-5-3-en-gardant-php-5-2-sous-ubuntu-a1168969">Lire la suite...</a><br /><br />]]></content:encoded>
		<pubDate>Sun, 18 Apr 2010 22:23:32 +0200</pubDate>
		<guid isPermaLink="true">http://www.divarvel.fr/installer-php-5-3-en-gardant-php-5-2-sous-ubuntu-a1168969</guid>
		<dc:creator>divarvel</dc:creator>
		<dc:date>2010-04-18T22:23:32+02:00</dc:date>
	</item>
	<item>
		<title><![CDATA[Sortie de la V1.5 d'Eklablog !]]></title>
		<link>http://www.divarvel.fr/sortie-de-la-v1-5-d-eklablog-a296445</link>
		<description><![CDATA[Vous l'attendiez depuis longtemps, la Version 1.5 d'Eklablog est enfin dispo.

Au menu, beaucoup de choses cod&eacute;es cet &eacute;t&eacute;, dont quelques-unes qui me tiennent beaucoup &agrave; c&oelig;ur : les galeries Flickr , le nouveau syst&egrave;me d'ajout de media dans les articles, plus les sondages et plein de petites...]]></description>
		<content:encoded><![CDATA[Vous l'attendiez depuis longtemps, la Version 1.5 d'Eklablog est enfin dispo.<br /><br />Au menu, beaucoup de choses cod&eacute;es cet &eacute;t&eacute;, dont quelques-unes qui me tiennent beaucoup &agrave; c&oelig;ur : les <strong>galeries Flickr</strong>, le <strong>nouveau syst&egrave;me d'ajout de media</strong> dans les articles, plus les <strong>sondages</strong> et plein de petites am&eacute;liorations.<br />La navigation full AJAX a saut&eacute;, c'&eacute;tait pas si avantageux que &ccedil;a, et pas tr&egrave;s ergnomique (les boutons pr&eacute;c&eacute;dent / suivant de votre navigateur pr&eacute;f&eacute;r&eacute; reviennent en gr&acirc;ce).<br /><br />Ce qui me fait le plus plaisir, c'est de voir impl&eacute;ment&eacute; tout mon boulot de cet &eacute;t&eacute;, je suis vraiment content de le voir tourner en prod sur eklablog. J'esp&egrave;re que &ccedil;a vous sera tout aussi utile qu'&agrave; moi.<br /><br />J'en profite pour vous faire d&eacute;couvrir <a href="http://www.divarvel.fr//flickr-2-photo.html">la nouvelle rubrique "Photo"</a> de ce blog, qui int&egrave;gre mes derniers chargements sur Flickr.<br />La V1.5, c'est aussi la b&ecirc;ta de la V2, quelques privil&eacute;gi&eacute;s vont donc pouvoir tester en avant premi&egrave;re le syst&egrave;me de <strong>Designs Perso</strong> (dont moi, je suis en train de refaire le design de ce modeste blog)<br /><br /><br />Voil&agrave;, vous pouvez tous remercier <a href="http://www.skreo.net">Godefroy</a> pour tout le travail qu'il a fourni, je suis encore bluff&eacute; par le syst&egrave;me des Designs (et pourtant j'en entends parler depuis longtemps).<br />Enjoy, et n'h&eacute;sitez pas &agrave; rapporter tout bug* que vous pourriez d&eacute;busquer.<br /><br />Le feedback, c'est bon, mangez-en ! (Enfin bref, je me comprends)<br /><br />* It's not a bug, it's a random feature<br /><br /><br />]]></content:encoded>
		<pubDate>Thu, 04 Dec 2008 02:41:59 +0100</pubDate>
		<guid isPermaLink="true">http://www.divarvel.fr/sortie-de-la-v1-5-d-eklablog-a296445</guid>
		<dc:creator>divarvel</dc:creator>
		<dc:date>2008-12-04T02:41:59+01:00</dc:date>
	</item>
	<item>
		<title><![CDATA[Linéarisation de tableaux : JSON V. serialize]]></title>
		<link>http://www.divarvel.fr/linearisation-de-tableaux-json-v-serialize-a217587</link>
		<description><![CDATA[Je viens de faire un benchmark entre JSON et serialize en PHP, et apparemment JSON est vraiment plus rapide.
J'ai fait un tableau contenant 500 sous tableaux, puis j'ai test&eacute; la vitesse de serialize, json_encode, unserialize et json_decode. Par JSON , la lin&eacute;arisation et la d&eacute;lin&eacute;arisation...]]></description>
		<content:encoded><![CDATA[Je viens de faire un benchmark entre <a href="http://www.divarvel.fr/article-41-18549-le-format-de-donnees-json.html"><acronym title="JavaScript Object Notation">JSON</acronym></a> et serialize en PHP, et apparemment <acronym title="JavaScript Object Notation">JSON</acronym> est vraiment plus rapide.<br />J&#39;ai fait un tableau contenant 500 sous tableaux, puis j&#39;ai test&eacute; la vitesse de serialize, json_encode, unserialize et json_decode. Par <acronym title="JavaScript Object Notation">JSON</acronym>, la lin&eacute;arisation et la d&eacute;lin&eacute;arisation sont beaucoup plus rapides (2 secondes de moins sur 1000 it&eacute;rations, c&#39;est quand m&ecirc;me pas mal)<br />En plus, un tableau lin&eacute;aris&eacute; &agrave; la <acronym title="JavaScript Object Notation">JSON</acronym> prend un peu moins de place, ce qui n&#39;est pas plus mal.<br /><br /><div class="code"><span style="color: #0000ff;">$tableau</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Chaine'</span>,<br />
<span style="color: #ff0000;">'cle'</span> =&gt; <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'sous tableau'</span>, <span style="color: #cc66cc;">54</span><span style="color: #66cc66;">&#41;</span><br />
<span style="color: #66cc66;">&#41;</span>;<br />
<a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <a href="http://www.php.net/serialize"><span style="color: #000066;">serialize</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$tableau</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #808080; font-style: italic;">//Affiche a:2:{i:0;s:6:&quot;Chaine&quot;;s:3:&quot;cle&quot;;a:2:{i:0;s:12:&quot;sous tableau&quot;;i:1;i:54;}}</span><br />
<a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> json_encode<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$tableau</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #808080; font-style: italic;">//Affiche {&quot;0&quot;:&quot;Chaine&quot;,&quot;cle&quot;:[&quot;sous tableau&quot;,54]}</span><div style="display:none;">[code=php]$tableau = array(&#39;Chaine&#39;,<br />&#39;cle&#39; =&gt; array(&#39;sous tableau&#39;, 54)<br />);<br />echo serialize($tableau);<br />//Affiche a:2:{i:0;s:6:&quot;Chaine&quot;;s:3:&quot;cle&quot;;a:2:{i:0;s:12:&quot;sous tableau&quot;;i:1;i:54;}}<br />echo json_encode($tableau);<br />//Affiche {&quot;0&quot;:&quot;Chaine&quot;,&quot;cle&quot;:[&quot;sous tableau&quot;,54]}<br />[/code]</div></div><br /><br /><br /><br />]]></content:encoded>
		<pubDate>Fri, 29 Aug 2008 11:05:48 +0200</pubDate>
		<guid isPermaLink="true">http://www.divarvel.fr/linearisation-de-tableaux-json-v-serialize-a217587</guid>
		<dc:creator>divarvel</dc:creator>
		<dc:date>2008-08-29T11:05:48+02:00</dc:date>
	</item>
	<item>
		<title><![CDATA[[Chaîne] Mes habitudes de programmation]]></title>
		<link>http://www.divarvel.fr/chaine-mes-habitudes-de-programmation-a182006</link>
		<description><![CDATA[J'ai &eacute;t&eacute; gentiment oblig&eacute;^Wconvi&eacute; par Skreo &agrave; d&eacute;crire mes petites habitudes en programmation...
Je m'y attelle donc tout de suite.
 Les noms de variables, fonctions, m&eacute;thodes D&eacute;j&agrave;, j'utilise l'anglais pour nommer mes variables. Pour la capitalisation, tout d&eacute;pend de si je code Objet ou...]]></description>
		<content:encoded><![CDATA[<p><a href="http://www.skreo.net/article-2904-181807-mes-conventions-en-programmation.html">J&#39;ai &eacute;t&eacute; gentiment oblig&eacute;^Wconvi&eacute; par Skreo</a>  &agrave; d&eacute;crire mes petites habitudes en programmation...<br />Je m&#39;y attelle donc tout de suite.<br /></p><h2>Les noms de variables, fonctions, m&eacute;thodes</h2><p>D&eacute;j&agrave;, j&#39;utilise l&#39;anglais pour nommer mes variables. Pour la capitalisation, tout d&eacute;pend de si je code Objet ou pas. Si je ne code pas objet, je fais &ccedil;a &agrave; la <abbr title="PHP : Hypertext Preprocessor">PHP</abbr> c&#39;est &agrave; dire des mots s&eacute;par&eacute;s par des underscore _. Quand je code Objet, j&#39;utilise une CamelCase bidouill&eacute;e, je mets des majuscules au d&eacute;but de tous les mots, sauf des verbes, ce qui revient tr&egrave;s souvent &agrave; du lowerCamelCase.</p><h2>Indentation</h2><p>Indentation de 4, j&#39;indente tout le bloc. Pour le xHTML (je sais, ce n&#39;est pas de la programmation), j&#39;indente le contenu des balises de type bloc (sauf h[1-6]), et je vais &agrave; la ligne. Je vais &agrave; la ligne apr&egrave;s un &lt;br /&gt;, sauf s&#39;il y en a plusieurs &agrave; la suite (mais c&#39;est plut&ocirc;t rare que &ccedil;a arrive)</p><h2>Accolades</h2><p>Accolade ouvrante &agrave; la fin de la ligne de d&eacute;finition de la boucle. Accolade fermante sur une nouvelle ligne, au m&ecirc;me niveau que la d&eacute;finition de la boucle.<br />Pas d&#39;accolades pour un bloc mono-ligne. (par exemple un if suivi d&#39;une seule instruction).</p><h2>Espaces</h2><p>Pour les virgules et les point-virgules : pas d&#39;espace avant, un espace apr&egrave;s.<br />Pas d&#39;espace entre les noms de fonction et la parenth&egrave;se ouvrante. Idem pour les boucles.<br />Pas d&#39;espace entre la parenth&egrave;se fermante et l&#39;accolade ouvrante dans les boucles.<br />Pas d&#39;espace entre le else et le if dans les else if.<br />Un espace de part et d&#39;autre des op&eacute;rateurs de modification (=, +=, *=, ...).<br />Un espace de part et d&#39;autre pour les op&eacute;rateurs de comparaison (==, &lt;=, &gt;=) et pour les op&eacute;rateurs de modification dans les boucles (for, while, if), sauf pour les longues expressions.</p><h2>Guillemets</h2><p>En php, j&#39;utilise uniquement les guillemets simples (apostrophe), sauf pour afficher des caract&egrave;res sp&eacute;ciaux (\r, \n ...).<br />En JS, &ccedil;a d&eacute;pend du contenu de la cha&icirc;ne. Si c&#39;est du texte tout b&ecirc;te, des guillemets doubles, si &ccedil;a contient du HTML, je mets des guillemets simples<br />Dans les autres langages, des guillemets doubles.</p><h2>Commentaires</h2><p>Dans les fichiers lambda, des commentaires pour expliquer la fonction d&#39;un bloc, en particulier si c&#39;est <em>tricky</em><br />Dans les fichiers qui d&eacute;finissent les classes, quelques lignes au d&eacute;but, puis un bloc de commentaire avant chaque m&eacute;thode : utilit&eacute;, variables attendues (r&ocirc;le, type, valeur par d&eacute;faut), valeur de retour, puis &eacute;ventuellement des commentaires monolignes pour expliquer la fonction de tel ou tel bloc. Les commentaires monolignes pour les blocs sont mis apr&egrave;s l&#39;accolade ouvrante, pr&eacute;c&eacute;d&eacute;s d&#39;un espace.</p><div class="code"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<span style="color: #808080; font-style: italic;">//Code non_objet</span><br />
<span style="color: #0000ff;">$premiere_variable</span> = <span style="color: #ff0000;">'Texte'</span>;<br />
<span style="color: #000000; font-weight: bold;">function</span> get_property<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span> <span style="color: #808080; font-style: italic;">// Cette fonction retourne un truc</span><br />
    <span style="color: #0000ff;">$retour</span> = <span style="color: #ff0000;">'Un truc'</span>;<br />
    <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">$retour</span>; <br />
<span style="color: #66cc66;">&#125;</span><br />
<span style="color: #808080; font-style: italic;">//Code objet</span><br />
<span style="color: #000000; font-weight: bold;">class</span> ClasseBidon<span style="color: #66cc66;">&#123;</span><br />
<span style="color: #808080; font-style: italic;">/*<br />
Fonction sayHello<br />
Sert à dire Hello World<br />
Arguments : Aucun<br />
Retourne : string<br />
*/</span><br />
    <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.php.net/static"><span style="color: #000066;">static</span></a> <span style="color: #000000; font-weight: bold;">function</span> sayHello<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
        <span style="color: #b1b100;">return</span> <span style="color: #ff0000;">'Hello World !'</span><br />
    <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span><br />
<span style="color: #000000; font-weight: bold;">?&gt;</span><div style="display:none;">[code=php]&lt;?php<br />//Code non_objet<br />$premiere_variable = &#39;Texte&#39;;<br />function get_property(){ // Cette fonction retourne un truc<br />&nbsp;&nbsp;&nbsp;&nbsp;$retour = &#39;Un truc&#39;;<br />&nbsp;&nbsp;&nbsp;&nbsp;return $retour; <br />}<br />//Code objet<br />class ClasseBidon{<br />/*<br />Fonction sayHello<br />Sert &agrave; dire Hello World<br />Arguments : Aucun<br />Retourne : string<br />*/<br />&nbsp;&nbsp;&nbsp;&nbsp;public static function sayHello(){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return &#39;Hello World !&#39;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br />?&gt;[/code]</div></div><p>Je fais suivre la cha&icirc;ne &agrave; <a href="http://xipoons.eklablog.com">Xipoons</a>, puis &agrave; ceux qui sont motiv&eacute;s :p</p><br /><br />]]></content:encoded>
		<pubDate>Sat, 12 Jul 2008 10:46:15 +0200</pubDate>
		<guid isPermaLink="true">http://www.divarvel.fr/chaine-mes-habitudes-de-programmation-a182006</guid>
		<dc:creator>divarvel</dc:creator>
		<dc:date>2008-07-12T10:46:15+02:00</dc:date>
	</item>
	<item>
		<title><![CDATA[Quel avenir pour internet ? Partie 3 - L'avenir du Web]]></title>
		<link>http://www.divarvel.fr/quel-avenir-pour-internet-partie-3-l-avenir-du-web-a169863</link>
		<description><![CDATA[S'il est bien une chose difficilement dissociable de l'Internet, c'est le Web. La proximit&eacute; entre web et Internet conduit &agrave; la confusion fr&eacute;quente entre ces deux concepts. Il est difficile, voire impossible d'imaginer l'un sans l'autre. Sans l'Internet, le web ne pourrait techniquement pas...]]></description>
		<content:encoded><![CDATA[<img src="http://data0.eklablog.com/divarvel/mod_article169863.png" width="128" alt="Quel avenir pour internet ? Partie 3 - L'avenir du Web" style="float: left; padding-right: 5px;" /><p>S&#39;il est bien une chose difficilement dissociable de l&#39;Internet, c&#39;est le Web. La proximit&eacute; entre web et Internet conduit &agrave; la confusion fr&eacute;quente entre ces deux concepts. Il est difficile, voire impossible d&#39;imaginer l&#39;un sans l&#39;autre. Sans l&#39;Internet, le web ne pourrait techniquement pas exister, et c&#39;est l&#39;essor du Web qui a popularis&eacute; l&#39;usage de l&#39;Internet. Le succ&egrave;s du Web est tel que l&#39;on tente de tout faire transiter par ce biais, ce qui n&#39;est pas forc&eacute;ment une bonne chose, dans la mesure o&ugrave; l&#39;on d&eacute;tourne le Web de son usage premier. D&#39;apr&egrave;s la philosophie UNIX, un outil ne doit faire qu&#39;une chose, et la faire bien. L&#39;&eacute;volution actuelle du web est totalement contraire &agrave; cette philosophie.</p><h3>Le principe du Web</h3><p>Le Web est un syst&egrave;me hypertexte : une ressource peut mener &agrave; une autre <em>via</em> un hyperlien. Le Web a &eacute;t&eacute; invent&eacute; par Tim Berners-Lee, chercheur au CERN, pour permettre aux chercheurs de partager leurs donn&eacute;es (et non pas pour acheter Robert Caillau $12000 sur Friends on Sale). Le &quot;Web 1.0&quot; fonctionnait de mani&egrave;re statique : une page fournit des infos, le visiteur les lit, point barre. Depuis quelques ann&eacute;es, a &eacute;merg&eacute; le &quot;Web 2.0&quot;, o&ugrave; l&#39;utilisateur agit sur le contenu, et communique avec les autres utilisateurs.</p><p>Pour les sites tels que Wikipedia, c&#39;est g&eacute;nial, par contre pour les sites de partage de vid&eacute;os, ou les r&eacute;seaux sociaux, je ne pense pas que le Web soit le moyen le plus pertinent. Le terminal d&eacute;di&eacute; &agrave; la vid&eacute;o, c&#39;est la TV. De plus en plus de TV sont reli&eacute;es &agrave; l&#39;Internet (<em>via</em> les freebo&icirc;tes, par exemple). Quand aux r&eacute;seaux sociaux, je verrais plus &ccedil;a dans le t&eacute;l&eacute;phone, ou dans un gestionnaire de cartes de visites (en fait mon plus grand fantasme technologique, c&#39;est <strike>le bondage avec des c&acirc;bles RJ 45</strike> les <a href="http://www.divarvel.fr/article-139-32854-les-implants-bioniques.html">implants neuroniques</a>) donc un carnet d&#39;adresses. Les r&eacute;seaux sociaux &ccedil;a sert juste &agrave; garder une liste de ses connaissances, &agrave; les classer leurs fiches par cat&eacute;gories, pour les contacter plus simplement, c&#39;est pour &ccedil;a que je regrette toutes les fioritures inutiles de FaceBook (applications alakon, groupes, etc). Par contre les r&eacute;seaux sociaux peuvent &ecirc;tre une bonne base pour remplacer l&#39;email (surtout si on peut impl&eacute;menter l&#39;UUID dont je parle <a href="http://www.divarvel.fr/article-139-169861-quel-avenir-pour-internet-partie-2-le-systeme-de-nommage.html">ici (syst&egrave;me de nommage)</a> )<br /></p><p>J&#39;esp&egrave;re donc que l&#39;usage du Web se restreindra &agrave; ce qu&#39;il devrait &ecirc;tre : un partage d&#39;informations, au sens strict du terme.<br /></p><br /><br />]]></content:encoded>
		<pubDate>Sat, 28 Jun 2008 17:07:49 +0200</pubDate>
		<guid isPermaLink="true">http://www.divarvel.fr/quel-avenir-pour-internet-partie-3-l-avenir-du-web-a169863</guid>
		<dc:creator>divarvel</dc:creator>
		<dc:date>2008-06-28T17:07:49+02:00</dc:date>
	</item>
	<item>
		<title><![CDATA[Quel avenir pour internet ? Partie 1 - L'infrastructure]]></title>
		<link>http://www.divarvel.fr/quel-avenir-pour-internet-partie-1-l-infrastructure-a169328</link>
		<description><![CDATA[Suite &agrave; une petite discussion avec Godefroy , j'ai &eacute;t&eacute; amen&eacute; &agrave; formaliser quelques pens&eacute;es qui me trottaient dans la t&ecirc;te &agrave; propos du futur de l'Internet et de celui du Web, &agrave; moyen, voire &agrave; long terme. J'ai eu la flemme d'utiliser le subjonctif tout au long de l'article, mais c'est comme...]]></description>
		<content:encoded><![CDATA[Suite &agrave; une petite discussion avec <a href="http://www.skreo.net">Godefroy</a>, j&#39;ai &eacute;t&eacute; amen&eacute; &agrave; formaliser quelques pens&eacute;es qui me trottaient dans la t&ecirc;te &agrave; propos du futur de l&#39;Internet et de celui du Web, &agrave; moyen, voire &agrave; long terme. J&#39;ai eu la flemme d&#39;utiliser le subjonctif tout au long de l&#39;article, mais c&#39;est comme si, donc pas de m&eacute;prise, il s&#39;agit d&#39;une <strong>interpr&eacute;tation personnelle</strong>, pas de la divination.<br /><br /><br /><a href="http://www.divarvel.fr/quel-avenir-pour-internet-partie-1-l-infrastructure-a169328">Lire la suite...</a><br /><br />]]></content:encoded>
		<pubDate>Fri, 27 Jun 2008 19:45:31 +0200</pubDate>
		<guid isPermaLink="true">http://www.divarvel.fr/quel-avenir-pour-internet-partie-1-l-infrastructure-a169328</guid>
		<dc:creator>divarvel</dc:creator>
		<dc:date>2008-06-27T19:45:31+02:00</dc:date>
	</item>
	<item>
		<title><![CDATA[Module Twitter pour eklablog]]></title>
		<link>http://www.divarvel.fr/module-twitter-pour-eklablog-a86820</link>
		<description><![CDATA[J'ai enfin fignol&eacute; le module twitter pour eklablog, apr&egrave;s l'avoir enti&egrave;rement refait.
Le php va chercher un fichier JSON aveec cURL, et puis apr&egrave;s rien de tr&egrave;s nouveau, PHP g&egrave;re nativement JSON , donc pas trop de soucis. Pas trop compliqu&eacute;, sauf que le fichier JSON fourni par twitter est un...]]></description>
		<content:encoded><![CDATA[<img src="http://data0.eklablog.com/divarvel/mod_article86820.png" width="210" alt="Module Twitter pour eklablog" style="float: left; padding-right: 5px;" />J&#39;ai enfin fignol&eacute; le module twitter pour eklablog, apr&egrave;s l&#39;avoir enti&egrave;rement refait.<br />Le php va chercher un fichier JSON aveec cURL, et puis apr&egrave;s rien de tr&egrave;s nouveau, PHP g&egrave;re nativement <acronym title="JavaScript Object Notation">JSON</acronym>, donc pas trop de soucis. Pas trop compliqu&eacute;, sauf que le fichier <acronym title="JavaScript Object Notation">JSON</acronym> fourni par twitter est un peu bizarre, on peut pas l&#39;ouvrir avec fopen, mais bon avec cURL &ccedil;a marche, donc pas de soucis.<br /><br />J&#39;aime bien <acronym title="JavaScript Object Notation">JSON</acronym>, je pr&eacute;f&egrave;re de loin &ccedil;a &agrave; XML, c&#39;est vraiment moins la gal&egrave;re &agrave; traiter par JS, et plus c&#39;est moins volumineux. (Pour des pr&eacute;cisions sur <acronym title="JavaScript Object Notation">JSON</acronym>, voir <a href="http://www.divarvel.fr/article-41-18549-le-format-de-donnees-json.html">ici</a> )<br /><br /><br /><br />]]></content:encoded>
		<pubDate>Wed, 05 Mar 2008 17:36:50 +0100</pubDate>
		<guid isPermaLink="true">http://www.divarvel.fr/module-twitter-pour-eklablog-a86820</guid>
		<dc:creator>divarvel</dc:creator>
		<dc:date>2008-03-05T17:36:50+01:00</dc:date>
	</item>
	<item>
		<title><![CDATA[Chaque fois c'est la même chose]]></title>
		<link>http://www.divarvel.fr/chaque-fois-c-est-la-meme-chose-a85676</link>
		<description><![CDATA[Essayer de faire tourner un site en local, c'est la gal&egrave;re supr&ecirc;me
Faut commencer par configurer apache avec les localhosts, qui marchent jamais comme on veut.
Ensuite faut importer les bases, se d&eacute;brouiller pour que PHP crache pas 12k erreurs et notices, ensuite c'est le JS qui merde......]]></description>
		<content:encoded><![CDATA[Essayer de faire tourner un site en local, c&#39;est la gal&egrave;re supr&ecirc;me<br />Faut commencer par configurer apache avec les localhosts, qui marchent jamais comme on veut.<br />Ensuite faut importer les bases, se d&eacute;brouiller pour que PHP crache pas 12k erreurs et notices, ensuite c&#39;est le JS qui merde... Apr&egrave;s une journ&eacute;e pass&eacute;e &agrave; essayer de faire tourner eklablog, j&#39;abandonne.<br />&Agrave; chaque fois c&#39;est la m&ecirc;me gal&egrave;re, &agrave; chaque fois je gal&egrave;re, et j&#39;oublie comment faire pour tout configurer... Je d&eacute;teste perdre mon temps sur ce genre de conneries.&nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  <br /><br /><br />]]></content:encoded>
		<pubDate>Sun, 02 Mar 2008 22:33:14 +0100</pubDate>
		<guid isPermaLink="true">http://www.divarvel.fr/chaque-fois-c-est-la-meme-chose-a85676</guid>
		<dc:creator>divarvel</dc:creator>
		<dc:date>2008-03-02T22:33:14+01:00</dc:date>
	</item>
	<item>
		<title><![CDATA[Communiqué de presse Eklablog]]></title>
		<link>http://www.divarvel.fr/communique-de-presse-eklablog-a45133</link>
		<description><![CDATA[Voil&agrave; la version finale du communiqu&eacute; de presse destin&eacute; &agrave; pr&eacute;senter Eklablog (1Y thx 2 paydichnouchnette)]]></description>
		<content:encoded><![CDATA[Voil&agrave; la version finale du communiqu&eacute; de presse destin&eacute; &agrave; pr&eacute;senter Eklablog (1Y thx 2 paydichnouchnette)<br /><br /><a href="http://data0.murties.com/skreo/perso//cp_eklablog.pdf"><img alt="T&eacute;l&eacute;charger le communiqu&eacute; de presse (format PDF)" src="http://data0.eklablog.com/divarvel/perso//pdf_eb.png" /></a> <br /><br /><br />]]></content:encoded>
		<pubDate>Wed, 17 Oct 2007 22:12:36 +0200</pubDate>
		<guid isPermaLink="true">http://www.divarvel.fr/communique-de-presse-eklablog-a45133</guid>
		<dc:creator>divarvel</dc:creator>
		<dc:date>2007-10-17T22:12:36+02:00</dc:date>
	</item>
</channel>
</rss><!--mdp=-->
