<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
 
 <title>Made in Sp4ce</title>
 <link href="http://www.sp4ce.net/atom.xml" rel="self"/>
 <link href="http://www.sp4ce.net/"/>
 <updated>2012-05-25T10:53:54+02:00</updated>
 <id>http://www.sp4ce.net/</id>
 <author>
   <name>Baptiste Pernet Mugnier</name>
   <email>bapt@sp4ce.net</email>
 </author>

 
   
 <entry>
   <title>String Error Detection In Javascript</title>
   <link href="http://www.sp4ce.net/computer/2012/05/18/string-error-detection-in-javascript.html"/>
   <updated>2012-05-18T00:00:00+02:00</updated>
   <id>http://www.sp4ce.net/computer/2012/05/18/string-error-detection-in-javascript</id>
   <content type="html">&lt;h3&gt;String comparison&lt;/h3&gt;
&lt;p&gt;When you want to compare string in order to detect errors, it can get very complicated. You can use a simple function like this&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;compare&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;string1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;string2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// We are a the end of one of the string, return the differences of caracters (= numbers of errors).&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;string1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;string2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Math&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;abs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;string1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;string2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;string1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;string2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// The caracters are equal, we continue to the next caracters.&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;compare&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;string1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;string2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;j&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// We test BOTH insertion and deletion and return the least error weight.&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;insertion&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;compare&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;string1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;string2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;deletion&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;compare&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;string1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;string2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;j&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Math&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;min&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;insertion&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;deletion&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;However this have a bad complexity because it will compare again part of the string that has been already compare in another path of the comparison. For example, if you compare &amp;#8216;abcdefgh&amp;#8217; with &amp;#8216;aabcdefgh&amp;#8217;, you go into a deep recursion.&lt;/p&gt;
&lt;p&gt;By using a backtracking algorithm, we can reduce the complicity to be polynomial.&lt;/p&gt;
&lt;h3&gt;Backtracking matrix&lt;/h3&gt;
&lt;p&gt;The main idea is to initialize the border of a matrix, because we know the value (the difference between the length), and then backtrack the values until the beginning of the strings.&lt;/p&gt;
&lt;table style=&quot;margin-left: 40px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
      &lt;td&gt;&lt;/td&gt;
      &lt;td&gt;h&lt;/td&gt;
      &lt;td&gt;e&lt;/td&gt;
      &lt;td&gt;l&lt;/td&gt;
      &lt;td&gt;l&lt;/td&gt;
      &lt;td&gt;o&lt;/td&gt;
      &lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
      &lt;td&gt;h&lt;/td&gt;
      &lt;td&gt;&lt;/td&gt;
      &lt;td&gt;&lt;/td&gt;
      &lt;td&gt;&lt;/td&gt;
      &lt;td&gt;&lt;/td&gt;
      &lt;td&gt;&lt;/td&gt;
      &lt;td&gt;4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
      &lt;td&gt;l&lt;/td&gt;
      &lt;td&gt;&lt;/td&gt;
      &lt;td&gt;&lt;/td&gt;
      &lt;td&gt;&lt;/td&gt;
      &lt;td&gt;&lt;/td&gt;
      &lt;td&gt;&lt;/td&gt;
      &lt;td&gt;3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
      &lt;td&gt;l&lt;/td&gt;
      &lt;td&gt;&lt;/td&gt;
      &lt;td&gt;&lt;/td&gt;
      &lt;td&gt;&lt;/td&gt;
      &lt;td&gt;&lt;/td&gt;
      &lt;td&gt;&lt;/td&gt;
      &lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
      &lt;td&gt;o&lt;/td&gt;
      &lt;td&gt;&lt;/td&gt;
      &lt;td&gt;&lt;/td&gt;
      &lt;td&gt;&lt;/td&gt;
      &lt;td&gt;&lt;/td&gt;
      &lt;td&gt;&lt;/td&gt;
      &lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
      &lt;td&gt;&lt;/td&gt;
      &lt;td&gt;5&lt;/td&gt;
      &lt;td&gt;4&lt;/td&gt;
      &lt;td&gt;3&lt;/td&gt;
      &lt;td&gt;2&lt;/td&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The backtrack is very easy, you use this function:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;reference&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;reference&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;matrix&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;matrix&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;j&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;matrix&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Math&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;min&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;matrix&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;matrix&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;j&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;And if you want to remember the path you made thought the backtracking, the matrix value became an object and the backtracking function will be:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;reference&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;reference&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;matrix&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;nx&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;matrix&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;j&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;nx&quot;&gt;direction&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;diagonal&amp;#39;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;matrix&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;value&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;matrix&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;j&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;matrix&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;nx&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;matrix&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;nx&quot;&gt;direction&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;down&amp;#39;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;matrix&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;nx&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;matrix&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;j&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;nx&quot;&gt;direction&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;right&amp;#39;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;And so the backtracking matrix becomes something that look like this. The path that shows the error is highlighted in red. It shows where it detects insertion or deletion.&lt;/p&gt;
&lt;table style=&quot;margin-left: 40px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
      &lt;td&gt;&lt;/td&gt;
      &lt;td&gt;h&lt;/td&gt;
      &lt;td&gt;e&lt;/td&gt;
      &lt;td&gt;l&lt;/td&gt;
      &lt;td&gt;l&lt;/td&gt;
      &lt;td&gt;o&lt;/td&gt;
      &lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
      &lt;td&gt;h&lt;/td&gt;
      &lt;td style=&quot;color: red; &quot;&gt;1&lt;/td&gt;
      &lt;td&gt;2&lt;/td&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td&gt;2&lt;/td&gt;
      &lt;td&gt;3&lt;/td&gt;
      &lt;td&gt;4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;l&lt;/td&gt;
      &lt;td&gt;2&lt;/td&gt;
      &lt;td style=&quot;color: red; &quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;color: red; &quot;&gt;0&lt;/td&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td&gt;2&lt;/td&gt;
      &lt;td&gt;3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
      &lt;td&gt;l&lt;/td&gt;
      &lt;td&gt;3&lt;/td&gt;
      &lt;td&gt;2&lt;/td&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td style=&quot;color: red; &quot;&gt;0&lt;/td&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
      &lt;td&gt;o&lt;/td&gt;
      &lt;td&gt;4&lt;/td&gt;
      &lt;td&gt;3&lt;/td&gt;
      &lt;td&gt;2&lt;/td&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td style=&quot;color: red; &quot;&gt;0&lt;/td&gt;
      &lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
      &lt;td&gt;&lt;/td&gt;
      &lt;td&gt;5&lt;/td&gt;
      &lt;td&gt;4&lt;/td&gt;
      &lt;td&gt;3&lt;/td&gt;
      &lt;td&gt;2&lt;/td&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td style=&quot;color: red; &quot;&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;You can find the entire source code and examples on &lt;a href=&quot;https://github.com/sp4ce/javascript-lcs&quot;&gt;github&lt;/a&gt;.&lt;br /&gt;
You can play with the working code &lt;a href=&quot;/lcs&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This work was done with the help of &lt;a href=&quot;http://www.linkedin.com/pub/jean-marie-larchev%C3%AAque/2/920/159&quot;&gt;Jean-Marie Larchevêque&lt;/a&gt;.&lt;/p&gt;</content>
 </entry>
   
 
   
 <entry>
   <title>La Douleur, Mais Aussi Le Soulagement</title>
   <link href="http://www.sp4ce.net/miscellaneous/2012/04/02/la-douleur%2C-mais-aussi-le-soulagement.html"/>
   <updated>2012-04-02T00:00:00+02:00</updated>
   <id>http://www.sp4ce.net/miscellaneous/2012/04/02/la-douleur,-mais-aussi-le-soulagement</id>
   <content type="html">&lt;p&gt;La vitre se brisa. Il passa au travers. Pendant un bref instant, le sol se déroba sous ses pieds, il perdit pieds. Sa pensée fut d&amp;#8217;un bloc focalisée sur un seul fait. Je suis perdu, je vais tomber dans un gouffre haut de dix étages, je vais mourrir. On lui avait dit qu&amp;#8217;à ce moment-là il verrait sa vie entière défiler devant ses yeux, mais c&amp;#8217;était faux, il n&amp;#8217;avait rien vu. Il avait juste ressenti un immense désarroi, une grande peur et une résignation. Le fait de savoir que l&amp;#8217;on va mourir dans les prochaines secondes. Malgré tout, les mains tentent désespérément de s&amp;#8217;accrocher à un bout de vie, les jambes péparent une réception. Tous nos réflexes de survie se mobilisent pour tenter de parer à l&amp;#8217;inévitable. Notre coprs refuse, hors de contrôle, ce que l&amp;#8217;esprit espère, ou fatalement, passivement attend.&lt;/p&gt;
&lt;p&gt;Et puis directement, ou presque, c&amp;#8217;est le choc, beaucoup plus tôt que prévu. Et puis c&amp;#8217;est le noir aussi. Ensuite tout s&amp;#8217;enchaine à une telle vitesse que la peur et la surprise gènent l&amp;#8217;esprit, l&amp;#8217;empêche de réagir correctement. Et c&amp;#8217;est encore une chute, un chavirement sur le coté, le sol est dur, le dos fait mal. Alors qu&amp;#8217;il vient à peine de comprendre qu&amp;#8217;il vient de passer au travers d&amp;#8217;une fenêtre, il se retrouve étendu là par terre dans la cage d&amp;#8217;escalier. Une chute de quatre mètres au lieu de dix étages. La douleur, mais aussi le soulagement.&lt;/p&gt;</content>
 </entry>
   
 
   
 <entry>
   <title>Facebook Page: Automatic Answer</title>
   <link href="http://www.sp4ce.net/computer/2012/02/15/facebook-page%3A-automatic-answer.html"/>
   <updated>2012-02-15T00:00:00+01:00</updated>
   <id>http://www.sp4ce.net/computer/2012/02/15/facebook-page:-automatic-answer</id>
   <content type="html">&lt;h3&gt;Facebook Page: Santa Claus&lt;/h3&gt;
&lt;p&gt;Facebook page is a way to promote your business or someone. In the company I work, we decided to make a Santa Claus page that is in fact a bot that replies to user comments on the wall. It is really fun to see people interact with it, and we currently have 120 000 fan on the page. The page in the French, but please &lt;a href=&quot;https://www.facebook.com/ParlerAuPereNoel&quot;&gt;have a look&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The architecture needs a fb connector that:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;polls the fb page&lt;/li&gt;
	&lt;li&gt;get the answer for the bot&lt;/li&gt;
	&lt;li&gt;post the answer to the corresponding conversation&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In this post, I give more details on how do a programatic post on a facebook page wall, answering a comment of a user.&lt;/p&gt;
&lt;h3&gt;Posting Message&lt;/h3&gt;
&lt;p&gt;Facebook has a fully &lt;span class=&quot;caps&quot;&gt;REST&lt;/span&gt; &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt; that is know as the open graph &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt;. There are various library on the web to connect to it, using C#, JavaScript or php. Please visit the &lt;a href=&quot;http://developers.facebook.com/docs/sdks/&quot;&gt;facebook SDKs &amp;amp; tools page&lt;/a&gt; to know more about that, and the &lt;a href=&quot;http://developers.facebook.com/docs/reference/api/&quot;&gt;graph &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt; page&lt;/a&gt; about the &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt; itself.&lt;/p&gt;
&lt;p&gt;Once you know that, have a look at&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;http://graph.facebook.com/167471789945400&quot;&gt;http://graph.facebook.com/167471789945400&lt;/a&gt;,&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;http://graph.facebook.com/167471789945400/feed&quot;&gt;http://graph.facebook.com/167471789945400/feed&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The first request is the publis Santa Claus page, it gives you general information about the page. However, the second gives you the stream of the page wall (&lt;span class=&quot;caps&quot;&gt;GET&lt;/span&gt;) or allows you to post content to the wall (&lt;span class=&quot;caps&quot;&gt;POST&lt;/span&gt;), then you should get this message:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;javascript&quot;&gt;    &lt;span class=&quot;nx&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nx&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;An access token is required to request this resource.&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;nx&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;OAuthException&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;nx&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;104&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;You need an &lt;strong&gt;&lt;code&gt;access token&lt;/code&gt;&lt;/strong&gt; to access the resource. If you want to know more about access token and OAuth 2.0 authentication and authorization, please do, but here, the only thing you need to know is that &lt;code&gt;access token&lt;/code&gt; is the way to say to facebook: &lt;em&gt;hello, I am this guy and I have the right to do that and that&lt;/em&gt;. Once you have the access token, Facebook trusts you.&lt;/p&gt;
&lt;h3&gt;Access Token&lt;/h3&gt;
&lt;p&gt;In order to get an access token for your page, you need an application key and of course a page. In order to create the application, go to &lt;a href=&quot;http://www.facebook.com/developers/apps.php&quot;&gt;My Applications&lt;/a&gt; page and create one application. Now you need to setup a temporary site url in order to execute a small JavaScript code that will help you to get the &lt;code&gt;access token&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;You need:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;site url: http://www.sp4ce.net/facebook/access_token&lt;/li&gt;
	&lt;li&gt;domain name: sp4ce.net&lt;/li&gt;
&lt;/ul&gt;
&lt;a href=&quot;/images/facebook_app_config.png&quot; class=&quot;image_dialog&quot; id=&quot;image_dialog3294180_link&quot;&gt;
   &lt;img src=&quot;/images/facebook_app_config.min.png&quot; alt=&quot;facebook_app_config&quot;/&gt;
   &lt;img src=&quot;/images/facebook_app_config.png&quot; id=&quot;image_dialog3294180_image&quot; alt=&quot;facebook_app_config&quot;/&gt;
&lt;/a&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
$(function() { 
   $('#image_dialog3294180_image').dialog({
      autoOpen: false,
      width: 1035 ,
      modal: true,
   });
});
$('#image_dialog3294180_link').click(function(e) {
   e.preventDefault();
   $('#image_dialog3294180_image').dialog('open');
}); 
&lt;/script&gt;

&lt;p&gt;Then you can go to &lt;a href=&quot;http://www.sp4ce.net/facebook/access_token&quot;&gt;http://www.sp4ce.net/facebook/access_token&lt;/a&gt;, enter the application id and click enter. You can check that the permission given if enought but it should be ok. You should be request to give some access to the applicatio you just created and after 1 second, you will see a table with the access token&lt;/p&gt;
&lt;p&gt;Enjoy !&lt;/p&gt;</content>
 </entry>
   
 
   
 <entry>
   <title>Importez Ses Contacts Google Dans Un Nokia C3</title>
   <link href="http://www.sp4ce.net/miscellaneous/2012/01/23/importez-ses-contacts-google-dans-un-nokia-c3.html"/>
   <updated>2012-01-23T00:00:00+01:00</updated>
   <id>http://www.sp4ce.net/miscellaneous/2012/01/23/importez-ses-contacts-google-dans-un-nokia-c3</id>
   <content type="html">&lt;p&gt;J&amp;#8217;ai récemment changé d&amp;#8217;opérateur téléphonique: je suis passé de Bouygues Télécom à Free Mobile. Depuis novembre 2011 jusqu&amp;#8217;à la semaine dernière, de peur de me ré engager avec Bouygues, et en attendant les offres de Free, j&amp;#8217;avais un Nokia 1616, qui est un des téléphones les plus simples du marché.&lt;/p&gt;
&lt;p&gt;Après etre abonné chez Free, et constaté que le prix du téléphone que j&amp;#8217;aurais aimé avoir (à savoir un android) dépassait largement le budget que j&amp;#8217;alloue pour ce genre de choses, j&amp;#8217;ai décidé de jeter un oeil sur les entrées de gamme. J&amp;#8217;ai donc choisi le &lt;a href=&quot;http://www.nokia.com/fr-fr/produits/mobiles/c3-00/&quot;&gt;Nokia C3&lt;/a&gt; après 10 minutes de réflexion (j&amp;#8217;ai aussi un budget &lt;em&gt;temps de réflexion pour ce genre de choses&lt;/em&gt; que je devrais d&amp;#8217;ailleurs revoir à la hausse).&lt;/p&gt;
&lt;p&gt;Toujours est-il que maintenant j&amp;#8217;ai mon téléphone Nokia tout vide, sans aucun contact à l&amp;#8217;intérieur. Le temps de pleurer sur les bienfaits de la synchronization avec son compte gmail, fonctionalité proposée par les androids, que me vient l&amp;#8217;idée d&amp;#8217;essayer d&amp;#8217;importer mes contacts. Grâce à l&amp;#8217;application &lt;a href=&quot;http://www.nokia.com/fr-fr/support/telechargement/&quot;&gt;Nokia Suite&lt;/a&gt; je peux synchroniser mon téléphone avec un fichier de sauvegarde sur mon pc. Le fichier de sauvegarde se trouve dans &lt;code&gt;~\AppData\Local\Nokia\Nokia Data Store\DataBase\MDataStore.db3&lt;/code&gt; et c&amp;#8217;est une base de données SQLite. Un peu de &lt;em&gt;reverse engineering&lt;/em&gt; dans leur base de données et j&amp;#8217;ai accouché cet après midi d&amp;#8217;un petit script &lt;code&gt;ruby&lt;/code&gt; d&amp;#8217;import depuis le fichier &lt;span class=&quot;caps&quot;&gt;CSV&lt;/span&gt; que l&amp;#8217;on peut facilement obtenir depuis l&amp;#8217;interface web de Google.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;import.rb&lt;/code&gt;&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;&lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;csv&amp;#39;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;rubygems&amp;#39;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;sqlite3&amp;#39;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;uuid&amp;#39;&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Parameters&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;GOOGLE_EXPORT&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;google.csv&amp;#39;&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;NOKIA_DATABASE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;C:\Users\bpernetmugnier.VIRTUOZ\AppData\Local\Nokia\Nokia Data Store\DataBase\MDataStore.db3&amp;#39;&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Read the csv file and create a array of hash table&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;csv_data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;CSV&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;read&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;GOOGLE_EXPORT&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;headers&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;csv_data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shift&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;map&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;to_s&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;string_data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;csv_data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;map&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;row&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;row&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;map&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cell&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cell&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;to_s&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;users&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;string_data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;map&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;row&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Hash&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;headers&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;zip&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;row&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;flatten&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Create sqlite connection.&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;database&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;SQLite3&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Database&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;NOKIA_DATABASE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;uuid_lib&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;UUID&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;new&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;users&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;each&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;Name&amp;#39;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start_with?&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;.&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;next&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;rows&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;database&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;execute&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;SELECT * FROM Contact WHERE GivenName=&amp;quot;%s&amp;quot; AND LastName=&amp;quot;%s&amp;quot;&amp;#39;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;Given Name&amp;#39;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;Family Name&amp;#39;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rows&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;size&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;next&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;uuid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;uuid_lib&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;generate&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;database&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;execute&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;INSERT INTO Contact (GUID, GivenName, LastName, GeneralMobile) VALUES (&amp;#39;{%s}&amp;#39;, &amp;#39;%s&amp;#39;, &amp;#39;%s&amp;#39;, &amp;#39;%s&amp;#39;);&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;uuid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;Given Name&amp;#39;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;Family Name&amp;#39;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;Phone 1 - Value&amp;#39;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;database&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;execute&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;INSERT INTO Contact_NOS (GUID, PreferredNumberId) VALUES (&amp;#39;{%s}&amp;#39;, 1);&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;uuid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;database&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;execute&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;INSERT INTO Item (GUID, CreationDate, LastModifiedDate, ImportDate, ItemType) VALUES (&amp;#39;{%s}&amp;#39;, 40931.58788489, 40931.58788489, 40931.58788489, &amp;#39;application/vnd.nokia.nos.contact&amp;#39;);&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;uuid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Petite remarque concernant Google et Nokia, si le premier offre de nombreuses possibilités pour importer, exporter, merger ses contacts, le deuxième n&amp;#8217;y a pas pensé. J&amp;#8217;était trčè surpris de ne pas trouver, même une basique fonction &amp;#8220;export&amp;#8221; dans &lt;em&gt;Nokia Suite&lt;/em&gt;. Est-ce un manque de temps ? d&amp;#8217;investissement ? ou tout simplement d&amp;#8217;idée ?&lt;/p&gt;
&lt;p&gt;Et sinon, dans la base de données, les timestamp sont représentés sous un format de nombres réels qui m&amp;#8217;est totalement inconnu. J&amp;#8217;ai essayé de faire des soutraction, division, regression affine, etc. Mais je n&amp;#8217;ai rien trouvé de très logique.&lt;/p&gt;
&lt;p&gt;40931.58788489 == le 23 janvier 2012 à environ 15h06&lt;br /&gt;
40931,6428253646 == le 23 janvier 2012 à environ 16h25&lt;/p&gt;</content>
 </entry>
   
 
   
 <entry>
   <title>Macports Outdated Port Notification</title>
   <link href="http://www.sp4ce.net/computer/2012/01/22/macports-outdated-port-notification.html"/>
   <updated>2012-01-22T00:00:00+01:00</updated>
   <id>http://www.sp4ce.net/computer/2012/01/22/macports-outdated-port-notification</id>
   <content type="html">&lt;p&gt;The &lt;a href=&quot;http://www.macports.org/&quot;&gt;MacPorts&lt;/a&gt; Project is an open-source initiative for compiling, installing, and upgrading open-source software on Max OS X operating system. I&amp;#8217;ve been using it for some years now and it is very stable and easy to use.&lt;/p&gt;
&lt;p&gt;Yesterday afternoon, I wanted to finish the tag cloud plugin of my website when I run into a error in Jekyll. I fixed it, but I needed to upgrade MacPorts. I didn&amp;#8217;t touch to it for months and I had a lot of outdated ports. It took me more than one hour to update everything and so delayed my work. I thought that I really needed to have notifications, or automatic update of ports.&lt;/p&gt;
&lt;p&gt;I read at the &lt;a href=&quot;https://trac.macports.org/wiki/UsingMacPortsQuickStart#HowdoIknowwhenanupdateisavailableDoIhavetoconstantlyperformmanualchecks&quot;&gt;MacPorts Project documentation&lt;/a&gt; and I found exactly what I needed in the &lt;span class=&quot;caps&quot;&gt;FAQ&lt;/span&gt;: &amp;#8220;How do I know when an update is available? Do I have to constantly perform manual checks?&amp;#8221;.&lt;/p&gt;
&lt;p&gt;Based on this, I created a small shell script:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;update.sh&lt;/code&gt;&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;c&quot;&gt;#!/bin/sh&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# This script updates MacPorts and send you and email when there are ports to manually update.&lt;/span&gt;

&lt;span class=&quot;nv&quot;&gt;MSMTP_DEST&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;bapt at sp4ce.net
&lt;span class=&quot;nv&quot;&gt;MSMTP_CONFIG&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/Users/baptiste/.msmtprc

&lt;span class=&quot;c&quot;&gt;# This command &amp;quot;teaches&amp;quot; MacPorts about new updates.&lt;/span&gt;
/opt/local/bin/port selfupdate

&lt;span class=&quot;c&quot;&gt;# Get the outdated ports&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;outdated&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;/opt/local/bin/port outdated&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$outdated&lt;/span&gt; &amp;gt; /Users/baptiste/Scripts/MacPorts/outdated.txt

&lt;span class=&quot;c&quot;&gt;# mail the result&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# echo $outdated | msmtp -C $MSMTP_CONFIG $MSMTP_DEST&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;I disable the mail command line because I finally didn&amp;#8217;t want to receive email everyday, because if I can&amp;#8217;t connect to my mac and perform the update, I will simply forget to do it. The best thing to do is to get the notification when I can really update the ports just after: when I open a terminal.&lt;/p&gt;
&lt;p&gt;Then I put a line in my &lt;code&gt;.bashrc&lt;/code&gt; file: &lt;code&gt;echo /Users/baptiste/Scripts/MacPorts/outdated.txt&lt;/code&gt; and so I get a nice message in my terminal:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/images/macports_no_outdated_port.png&quot;/&gt;&lt;/p&gt;
&lt;p&gt;Finally I setup a cron job as the root user (needed to run the selfupdate):&lt;/p&gt;
&lt;p&gt;&lt;code&gt;sudo crontab -e&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;*	*	*	*	*	sh /Users/baptiste/Scripts/MacPorts/update.sh&lt;/code&gt;&lt;/p&gt;</content>
 </entry>
   
 
   
 <entry>
   <title>Mutex global en Ruby</title>
   <link href="http://www.sp4ce.net/computer/2011/02/21/global-mutex-in-ruby.fr.html"/>
   <updated>2011-02-21T00:00:00+01:00</updated>
   <id>http://www.sp4ce.net/computer/2011/02/21/global-mutex-in-ruby.fr</id>
   <content type="html">&lt;h3&gt;Mutex Global&lt;/h3&gt;
&lt;p&gt;Dans un environnement multi thread, si vous voulez protéger une section critique, vous pouvez utiliser des sémaphores. Cependant en Ruby, le sémaphore is uniquement instancié dans le processsus courant et ne peut pas être partagé avec d&amp;#8217;autres processus ruby.&lt;/p&gt;
&lt;p&gt;Imaginez maintenant que vous avez un code ruby qui est exécuté par une application extern. Ce code contient une section critique et vous voulez la protéger.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;chech.rb&lt;/code&gt;&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;&lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;take lock&amp;quot;&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# to be defined&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;begin critical section&amp;quot;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sleep&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;end critical section&amp;quot;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;release lock&amp;quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Ensuite, pour simuler les appels de l&amp;#8217;application externe, nous avons un petit batch &lt;code&gt;loop.bat&lt;/code&gt; qui appelle le code Ruby quatre fois.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;loop.bat&lt;/code&gt;&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;bat&quot;&gt;&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;/L&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;%%i&lt;/span&gt; in (&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;3&lt;/span&gt;) &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt; start ruby check.rb &lt;span class=&quot;nv&quot;&gt;%%i&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;h3&gt;Méthode File.flock&lt;/h3&gt;
&lt;p&gt;Pour résoudre cela, la méthode &lt;code&gt;File.flock&lt;/code&gt; permet de prendre une ressource exclusive sur un fichier. Donc &lt;code&gt;check.rb&lt;/code&gt; devient :&lt;/p&gt;
&lt;p&gt;&lt;code&gt;chech.rb&lt;/code&gt;&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;&lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;fileutils.rb&amp;#39;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;tmpdir&amp;#39;&lt;/span&gt;

&lt;span class=&quot;no&quot;&gt;File&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Dir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tmpdir&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/test.synchro&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;w&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;take lock &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;ARGV&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;flock&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;File&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;LOCK_EX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;sleep &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;ARGV&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;sleep&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;end &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;ARGV&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;nb&quot;&gt;sleep&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;60&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Ensuite, quand vous exécutez &lt;code&gt;loop.bat&lt;/code&gt; vous avez un mutex global, cela veut dire que chaque processus attend que les autres processus relâchent le verrou sur le fichier &lt;code&gt;test.synchro&lt;/code&gt;. Le fichier est dans un répertoire &lt;code&gt;TEMP&lt;/code&gt; pour être sûr d&amp;#8217;avoir les accès en écriture sur ce répertoire. Cela sera &lt;code&gt;/temp&lt;/code&gt; sur linux, &lt;code&gt;c:\users\UTILISATEUR_COURANT\app_data\temp&lt;/code&gt; sur MS Windows. Je n&amp;#8217;ai pas essayé sur mon Mac, mais je pense que chaque appel à &lt;code&gt;Dit.tmpdir&lt;/code&gt; renvoie le même répertoire.&lt;/p&gt;
&lt;h3&gt;Demo&lt;/h3&gt;
&lt;p&gt;Voici une capture d&amp;#8217;écran quand ce petit bout de code toutne (cliquez pour agrandir). Examinez les horodatages de chaque action (plus spécifiquement les sécondes) pour comprendre ce qui se passe.&lt;/p&gt;
&lt;a href=&quot;/images/ruby_global_mutex.png&quot; class=&quot;image_dialog&quot; id=&quot;image_dialog12187110_link&quot;&gt;
   &lt;img src=&quot;/images/ruby_global_mutex.min.png&quot; alt=&quot;ruby_global_mutex&quot;/&gt;
   &lt;img src=&quot;/images/ruby_global_mutex.png&quot; id=&quot;image_dialog12187110_image&quot; alt=&quot;ruby_global_mutex&quot;/&gt;
&lt;/a&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
$(function() { 
   $('#image_dialog12187110_image').dialog({
      autoOpen: false,
      width: 840 ,
      modal: true,
   });
});
$('#image_dialog12187110_link').click(function(e) {
   e.preventDefault();
   $('#image_dialog12187110_image').dialog('open');
}); 
&lt;/script&gt;
</content>
 </entry>
   
 
   
 
   
 <entry>
   <title>How To Have A Multilingual Website With Jekyll</title>
   <link href="http://www.sp4ce.net/site/2011/01/15/how-to-have-a-multilingual-website-with-jekyll.html"/>
   <updated>2011-01-15T00:00:00+01:00</updated>
   <id>http://www.sp4ce.net/site/2011/01/15/how-to-have-a-multilingual-website-with-jekyll</id>
   <content type="html">&lt;h3&gt;Languages&lt;/h3&gt;
&lt;p&gt;The site is both in English and French. Jekyll doesn&amp;#8217;t provide any support to have posts in two languages. It means that in your website meta data, the variable &lt;code&gt;site.posts&lt;/code&gt; contains all your posts (both in English and French).&lt;/p&gt;
&lt;p&gt;However, I wanted two versions of the home page, one version that contains only the English posts and the French only posts, and another version that contains only the French posts and the English only posts. So I am sure that every post is displayed, and available in the user favorite language. There is one home page called &lt;code&gt;index.en.html&lt;/code&gt; and &lt;code&gt;index.fr.html&lt;/code&gt;, both are laid out with &lt;code&gt;_layout/index.html&lt;/code&gt; layout.&lt;/p&gt;
&lt;h3&gt;Categories&lt;/h3&gt;
&lt;p&gt;The site contains three categories of posts: &lt;em&gt;site&lt;/em&gt; , &lt;em&gt;computer&lt;/em&gt; and &lt;em&gt;miscellaneous&lt;/em&gt; The &lt;code&gt;_layout/index.html&lt;/code&gt; layout contains three widgets with the posts related to a category. Jekyll allows you to include part of pages in another using the &lt;code&gt;include&lt;/code&gt; statemenent. So for a category (for example &lt;em&gt;computer&lt;/em&gt;) it is:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;html&quot;&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;class=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;panel&amp;quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
   &lt;span class=&quot;nt&quot;&gt;&amp;lt;h2&amp;gt;&lt;/span&gt;{{ page.computer_activities  }}&lt;span class=&quot;nt&quot;&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;
   &lt;span class=&quot;nt&quot;&gt;&amp;lt;ul&amp;gt;&lt;/span&gt;
   {% for post in site.categories.computer  %}
      {% include category.html  %}
   {% endfor  %}
   &lt;span class=&quot;nt&quot;&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;&lt;code&gt;page.computer_activities&lt;/code&gt; contains the localized title of the category, specified in &lt;code&gt;index.fr.thml&lt;/code&gt; (in French) and &lt;code&gt;index.en.html&lt;/code&gt; (in English).&lt;br /&gt;
&lt;code&gt;site.categories.computer&lt;/code&gt; is a list of all the posts in the &lt;em&gt;computer&lt;/em&gt; category.&lt;/p&gt;
&lt;p&gt;Then the file &lt;code&gt;_includes/category.html&lt;/code&gt; is very simple:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;html&quot;&gt;{% if post.multilingual != true  %}
   &lt;span class=&quot;nt&quot;&gt;&amp;lt;li&amp;gt;&lt;/span&gt;{% include post_link.html  %}
   {% if post.language == &amp;#39;en&amp;#39;  %}
      {% include english_only.html  %}
   {% elsif post.language == &amp;#39;fr&amp;#39;  %}
      {% include french_only.html  %}
   {% endif  %}
   &lt;span class=&quot;nt&quot;&gt;&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
{% elsif post.language == page.language  %}
   &lt;span class=&quot;nt&quot;&gt;&amp;lt;li&amp;gt;&lt;/span&gt;{% include post_link.html  %}&lt;span class=&quot;nt&quot;&gt;&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
{% endif  %}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;So if it is not a multilingual post, I display it with a small flag that explain that it is a French only or English only post, else I display only the posts which have the same language as the page. (&lt;code&gt;_includes/post_link.html&lt;/code&gt; is a small code that displays a post link, and open a &amp;lt;p&amp;gt; tag, for those who notified the closing &amp;lt;/p&amp;gt;)&lt;/p&gt;
&lt;h3&gt;Get the page language&lt;/h3&gt;
&lt;p&gt;I choose these conventions:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;When a page is multilingual, it is named &lt;code&gt;page_name.language.textile&lt;/code&gt; (&lt;code&gt;language&lt;/code&gt; is &lt;code&gt;fr&lt;/code&gt; or &lt;code&gt;en&lt;/code&gt;)&lt;/li&gt;
	&lt;li&gt;When a page is only in one language, you don&amp;#8217;t put the &lt;code&gt;language&lt;/code&gt; extension, you set the language in the jekyll &lt;code&gt;yaml&lt;/code&gt; header of the post.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So, in both case, you know the language of a page, by looking at the url, if it is a multilingual post, or by looking at the post meta data. Then I extend the &lt;code&gt;Page&lt;/code&gt; and &lt;code&gt;Post&lt;/code&gt; class using ruby monkey patching in order to make this information available in the post and the page meta data in both case. For example, in the &lt;code&gt;_plugins/page.rb&lt;/code&gt;&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;&lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;_plugins/get_language&amp;#39;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;module&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Jekyll&lt;/span&gt;
   &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Page&lt;/span&gt;
      &lt;span class=&quot;c1&quot;&gt;# Return the data of the page with additional&lt;/span&gt;
      &lt;span class=&quot;c1&quot;&gt;# information if the page has a specific language.&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;alias&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;orig_to_liquid&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;to_liquid&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;to_liquid&lt;/span&gt;
         &lt;span class=&quot;c1&quot;&gt;# Gather all the basic information of the page.&lt;/span&gt;
         &lt;span class=&quot;nb&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;orig_to_liquid&lt;/span&gt;

         &lt;span class=&quot;c1&quot;&gt;# Get the language of the page from the name of the post&lt;/span&gt;
         &lt;span class=&quot;n&quot;&gt;language&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;GetLanguage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get_language&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
         &lt;span class=&quot;c1&quot;&gt;# merge the language information with the page meta data.&lt;/span&gt;
         &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;GetLanguage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;merge_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;language&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
   &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;The method &lt;code&gt;GetLanguage.merge_date&lt;/code&gt; looks like:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;&lt;span class=&quot;c1&quot;&gt;# Merge the data with the language values.&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;GetLanguage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;merge_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;language&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
   &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;language&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;title&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;title&amp;#39;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;kp&quot;&gt;nil&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;title&amp;#39;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;&amp;#39;&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;deep_merge&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;
         &lt;span class=&quot;s1&quot;&gt;&amp;#39;language&amp;#39;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;language&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
         &lt;span class=&quot;s1&quot;&gt;&amp;#39;multilingual&amp;#39;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;kp&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
         &lt;span class=&quot;c1&quot;&gt;# remove the language extension of the title&lt;/span&gt;
         &lt;span class=&quot;s1&quot;&gt;&amp;#39;title&amp;#39;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;gsub&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;.&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;language&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
      &lt;span class=&quot;p&quot;&gt;})&lt;/span&gt;
   &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

   &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;So now, I know the language of each page, available in &lt;code&gt;page.language&lt;/code&gt; or &lt;code&gt;post.language&lt;/code&gt;, and I know also if it is multilingual page or not. Then I can display the small french or english flag at the bottom left corner when another language is available for a post. I also create two rss feeds &lt;code&gt;atom.en.xml&lt;/code&gt; and &lt;code&gt;atom.fr.xml&lt;/code&gt;&lt;/p&gt;
&lt;h3&gt;Get user favorite language&lt;/h3&gt;
&lt;p&gt;At the top level of the site, there is a small &lt;code&gt;index.php&lt;/code&gt; page, that redirects the request to the correct &lt;code&gt;index.fr.html&lt;/code&gt; or &lt;code&gt;index.en.html&lt;/code&gt;. This is the only piece of php code I have on the site, because it was available on my hosting server, but you could do the same thing in JavaScript if you want. The goal is to get the user favorite language by reading this information in the browser.&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;php&quot;&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// Définir ici les langues disponibles&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$lang_list&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;fr&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;en&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;nv&quot;&gt;$accept_lang&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;explode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;,&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$_SERVER&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;HTTP_ACCEPT_LANGUAGE&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]);&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;reset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$accept_lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$language&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;each&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$accept_lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;eregi&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;^(.+);q=([0-9.]*)$&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$language&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$part&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;nv&quot;&gt;$accept_lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$part&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;;&amp;#39;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$part&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
   &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;nv&quot;&gt;$accept_lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;1.0;&amp;#39;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$accept_lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
   &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;nb&quot;&gt;arsort&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$accept_lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;//tri par ordre de préférence&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;reset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$accept_lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$a_lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;each&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$accept_lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;nb&quot;&gt;reset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$lang_list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
   &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$language&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;each&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$lang_list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;strpos&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$a_lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$language&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
         &lt;span class=&quot;nv&quot;&gt;$selected_language&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$language&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
         &lt;span class=&quot;k&quot;&gt;break&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
      &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
   &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;nb&quot;&gt;unset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$accept_lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$a_lang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$language&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// langague par default (english)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;isset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$selected_language&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;nv&quot;&gt;$selected_language&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;en&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;cp&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;span class=&quot;x&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;x&quot;&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
&lt;span class=&quot;x&quot;&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
&lt;span class=&quot;x&quot;&gt;&amp;lt;meta http-equiv=&amp;quot;Refresh&amp;quot; content=&amp;quot;0; url=/index.&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$selected_language&lt;/span&gt; &lt;span class=&quot;cp&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;span class=&quot;x&quot;&gt;.html&amp;quot; /&amp;gt;&lt;/span&gt;
&lt;span class=&quot;x&quot;&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;span class=&quot;x&quot;&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
&lt;span class=&quot;x&quot;&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class=&quot;x&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;I get this code from my old web site and I don&amp;#8217;t remember if it really comes out of my mind. I am definitly not a php guru, so please be kind with my skills :p I am open to any improvement you may suggest.&lt;/p&gt;</content>
 </entry>
   
 
   
 <entry>
   <title>Utilisation de WatiN avec NUnit</title>
   <link href="http://www.sp4ce.net/computer/2011/01/06/how-to-use-WatiN-with-NUnit.fr.html"/>
   <updated>2011-01-06T00:00:00+01:00</updated>
   <id>http://www.sp4ce.net/computer/2011/01/06/how-to-use-WatiN-with-NUnit.fr</id>
   <content type="html">&lt;h3&gt;WatiN Framework&lt;/h3&gt;
&lt;p&gt;On m&amp;#8217;a demandé d&amp;#8217;écrire des tests web pour une suite d&amp;#8217;applications web. Nous avions déjà une bonne couverture (environ 65 %) avec beaucoup de test sur les &lt;em&gt;controllers&lt;/em&gt; et les &lt;em&gt;models&lt;/em&gt; mais c&amp;#8217;était difficile de tester les &lt;em&gt;views&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Beaucoup de functionnalités sont codées en &lt;span class=&quot;caps&quot;&gt;HTML&lt;/span&gt;, &lt;span class=&quot;caps&quot;&gt;CSS&lt;/span&gt; et JavaScript et ne sont que peu testable avec le code du &lt;em&gt;back-end&lt;/em&gt;. Elles requièrent un evironnement spécifique : le navigateur. Le navigateur qui lit le &lt;span class=&quot;caps&quot;&gt;HTML&lt;/span&gt; et le &lt;span class=&quot;caps&quot;&gt;CSS&lt;/span&gt; et exécute le JavaScript.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://watin.sourceforge.net/&quot;&gt;WatiN&lt;/a&gt; (&lt;em&gt;prononcé What-in&lt;/em&gt;) est un &lt;em&gt;framework&lt;/em&gt; qui permet d&amp;#8217;exécuter un navigateur et de lui envoyer directement des instructions. Vous pouvez visiter des pages, cliquer sur des buttons et tester du contenu.&lt;/p&gt;
&lt;h3&gt;NUnit Framework&lt;/h3&gt;
&lt;p&gt;NUnit est un librairie en .Net pour écrire et maintenir facilement des tests unitaires en C#. Si vous combinez l&amp;#8217;utilisation de WatiN et de NUnit, vous pouves facilement écrire des tests unitaires pour une application web.&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;csharp&quot;&gt;&lt;span class=&quot;na&quot;&gt;[Test, Category(&amp;quot;WEB&amp;quot;)]&lt;/span&gt; 
&lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;SearchForWatiNOnGoogle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;k&quot;&gt;using&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;browser&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;http://www.google.com&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
   &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;browser&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;TextField&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Find&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ByName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;q&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;TypeText&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;WatiN&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;browser&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Button&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Find&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ByName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;btnG&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Click&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;Assert&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IsTrue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;browser&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ContainsText&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;WatiN&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
   &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;h3&gt;Étendre WatiN au sélecteur &lt;span class=&quot;caps&quot;&gt;CSS&lt;/span&gt; selector avec jQuery&lt;/h3&gt;
&lt;p&gt;WatiN est super, mais vous ne pouvez pas utiliser de sélecteur &lt;span class=&quot;caps&quot;&gt;CSS&lt;/span&gt; (cf. exemple ci-dessus pour comment trouver des éléments). Dans les &lt;em&gt;framework&lt;/em&gt; JavaScript (comme &lt;code&gt;jQuery&lt;/code&gt;), vous pouvez utiliser des sélecteurs &lt;span class=&quot;caps&quot;&gt;CSS&lt;/span&gt; pour chercher un élément. WatiN vous permet d&amp;#8217;injecter du JavaScript dans le navigateur.&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;csharp&quot;&gt;&lt;span class=&quot;n&quot;&gt;using&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;browser&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;http://www.google.com&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;n&quot;&gt;browser&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Eval&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;alert(&amp;#39;Hello World!&amp;#39;);&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Donc you pouvez injecter un moniteur de recherche &lt;span class=&quot;caps&quot;&gt;CSS&lt;/span&gt; qui va effectuer la recherche en utilisant &lt;code&gt;jQuery&lt;/code&gt;, vérifier si l&amp;#8217;élément possède un attribut &lt;code&gt;id&lt;/code&gt;, en donner un sinon et retourner cet &lt;code&gt;id&lt;/code&gt;. Puis WatiN va utiliser cet &lt;code&gt;id&lt;/code&gt; pour récupérer l&amp;#8217;élément.&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;CssSearchMonitor&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;uniqueId&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

   &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;getElementId&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;selector&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;_no_element_&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
         &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;elements&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;selector&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
         &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;elements&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;element&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;elements&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
               &lt;span class=&quot;nx&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
               &lt;span class=&quot;nx&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;watin_search_&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;uniqueId&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
               &lt;span class=&quot;nx&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;id&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
         &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
 
      &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
      &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
   &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

   &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;getElementId&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;getElementId&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;jQuery&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Et ensuite, du coté de WatiN, vous pouvez injecter le JavaScript et appeler &lt;code&gt;CssSearchMonitor.getElementId&lt;/code&gt; afin de récuperer cet élement.&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;csharp&quot;&gt;&lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;javascript&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;getJavaScript&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// Get the javascript of the css search monitor.&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;using&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;browser&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;http://www.google.com&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;n&quot;&gt;browser&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Eval&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;javascript&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
   &lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;id&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;browser&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Eval&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;CssSearchMonitor.getElementId(&amp;#39;div.myClass input[input=\&amp;quot;button\&amp;quot;]&amp;#39;, 1)&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
   &lt;span class=&quot;n&quot;&gt;Button&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;button&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;browser&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Button&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
   &lt;span class=&quot;n&quot;&gt;button&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Click&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Dans le but d&amp;#8217;utiliser ceci de façon intensive, vous avez besoin de le réfactorer pour le rendre facile d&amp;#8217;utilisation, mais l&amp;#8217;idée générale est là. Bon tests avec WatiN et NUnit !&lt;/p&gt;
&lt;p&gt;Mais il y a toujours un problème ouvert, comment mesure-t-on la couverture de l&amp;#8217;application web ?&lt;/p&gt;
&lt;h3&gt;Liens&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;http://spin.atomicobject.com/2010/11/11/fast-er-css-selector-based-element-lookups-in-watin-via-jquery&quot;&gt;Fast(er) &lt;span class=&quot;caps&quot;&gt;CSS&lt;/span&gt; Selector Based Element lookups in Watin via jQuery&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://stackoverflow.com/questions/2375709/how-to-wait-for-jquery-ajax-requests-to-complete-from-watin&quot;&gt;How to wait for jQuery Ajax requests to complete from WatiN?&lt;/a&gt;&lt;/p&gt;</content>
 </entry>
   
 
   
 
   
 <entry>
   <title>Jekyll Migration</title>
   <link href="http://www.sp4ce.net/site/2010/12/29/Jekyll-Migration.html"/>
   <updated>2010-12-29T00:00:00+01:00</updated>
   <id>http://www.sp4ce.net/site/2010/12/29/Jekyll-Migration</id>
   <content type="html">&lt;h3&gt;Static &lt;span class=&quot;caps&quot;&gt;HTML&lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;My website is entirely done in static &lt;span class=&quot;caps&quot;&gt;HTML&lt;/span&gt;. There is no dynamic rendering on the server side and every page is shown as it is. I think dynamic pages are cool but not really a requirement in most of case. The site is a blog and you don&amp;#8217;t need a database behind it to store each article and a web engine that displays them.&lt;/p&gt;
&lt;p&gt;A blog post is only content that is decorated with some &lt;span class=&quot;caps&quot;&gt;HTML&lt;/span&gt;/&lt;span class=&quot;caps&quot;&gt;CSS&lt;/span&gt; to make it nice. However this &lt;span class=&quot;caps&quot;&gt;HTML&lt;/span&gt; won&amp;#8217;t change (except if I decide it), so once you generate your blog post, you don&amp;#8217;t have to do it again. That is how static web generator works, they create every page that exists on the site using specific layouts. If you compare it to a dynamic blog, you realize that the blog generates a page every time you visit it !&lt;/p&gt;
&lt;h3&gt;Jekyll&lt;/h3&gt;
&lt;p&gt;Jekyll is a blog aware static web generator. It is done in Ruby so you can easily (cf. monkey patching for example) extend the behavior or add a new feature. It uses Markdown or Textile format for blog posts and Liquid converters. This is also the engine behind GitHub Pages, which you can use to host your project&amp;#8217;s page or blog.&lt;/p&gt;
&lt;p&gt;When you run &lt;code&gt;jekyll&lt;/code&gt; command, it goes thought your template directory and generate the html of the site.&lt;/p&gt;
&lt;h3&gt;Template directory&lt;/h3&gt;
&lt;pre&gt;
|-- _config.yml
|-- _includes
    |-- category.html
    `-- post_link.html
|-- _layouts
    |-- default.html
    |-- index.html
    |-- post.html
    `-- under_construction.html
|-- _plugins
    |-- get_language.rb
    |-- page.rb
    `-- post.rb
|-- _site
|-- computer
    |-- _drafts
    `-- _posts
|-- miscellaneous 
    |-- _drafts
    `-- _posts
|-- site 
    |-- _drafts
    `-- _posts
|-- css
|-- data
|-- images
|-- index.en.html
|-- index.fr.html
`-- index.html
&lt;/pre&gt;
&lt;p&gt;The website is generated in the &lt;code&gt;_site&lt;/code&gt; folder. I use three categories of posts: &lt;code&gt;computer&lt;/code&gt;, &lt;code&gt;site&lt;/code&gt; and &lt;code&gt;miscellaneous&lt;/code&gt;. In the index page I display the lastest posts of each category in 3 panels. &lt;code&gt;index.html&lt;/code&gt; redirects the request to &lt;code&gt;index.en.html&lt;/code&gt; which is the English version of the index.&lt;/p&gt;
&lt;h3&gt;Comming soon&lt;/h3&gt;
&lt;p&gt;I will post another article on how language is handled on the site. Also I will add the possibility to use twitter to leave reaction on each article.&lt;/p&gt;</content>
 </entry>
   
 
   
 <entry>
   <title>Paris Old Quaries Network</title>
   <link href="http://www.sp4ce.net/miscellaneous/2010/03/22/paris-old-quaries-network.fr.html"/>
   <updated>2010-03-22T00:00:00+01:00</updated>
   <id>http://www.sp4ce.net/miscellaneous/2010/03/22/paris-old-quaries-network.fr</id>
   <content type="html"></content>
 </entry>
   
 
   
 
   
 <entry>
   <title>Josso Csharp Agent</title>
   <link href="http://www.sp4ce.net/computer/2009/09/14/josso-csharp-agent.fr.html"/>
   <updated>2009-09-14T00:00:00+02:00</updated>
   <id>http://www.sp4ce.net/computer/2009/09/14/josso-csharp-agent.fr</id>
   <content type="html">&lt;h3&gt;Qu&amp;#8217;est-ce que &lt;span class=&quot;caps&quot;&gt;JOSSO&lt;/span&gt; ?&lt;/h3&gt;
&lt;p&gt;&lt;span class=&quot;caps&quot;&gt;JOSSO&lt;/span&gt; est un système de &lt;a href=&quot;http://fr.wikipedia.org/wiki/Single_sign-on&quot;&gt;&lt;span class=&quot;caps&quot;&gt;SSO&lt;/span&gt;&lt;/a&gt; (Single Sign-On ou en français Authentification Unique) qui est libre et écrit en java. Il permet d&amp;#8217;obtenir une solution pour une authentification et les autorisations des utilisateurs de façon centralisée et multi-platform.&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;caps&quot;&gt;JOSSO&lt;/span&gt; tourne sur de nombreux serveurs J2EE : Apache Tomcat, JBoss application server, WebLogic application server, Apache Geronimo server, etc. La partie cliente a aussi été adaptée sur de nombreuses environnement: &lt;span class=&quot;caps&quot;&gt;IIS&lt;/span&gt;, Apache (Ruby, Python, Perl) and &lt;span class=&quot;caps&quot;&gt;PHP&lt;/span&gt; afin de permettre un système de &lt;span class=&quot;caps&quot;&gt;SSO&lt;/span&gt; de façon la plus large possible.&lt;/p&gt;
&lt;p&gt;Pour avoir plus d&amp;#8217;informations sur le système, comment l&amp;#8217;installer, ses possibilités, rendez-vous sur &lt;a href=&quot;http://www.josso.org&quot;&gt;josso.org&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;Client &lt;span class=&quot;caps&quot;&gt;ASP&lt;/span&gt;.Net&lt;/h3&gt;
&lt;p&gt;Maintenant que vous avez visité le site de &lt;a href=&quot;http://www.josso.org&quot;&gt;&lt;span class=&quot;caps&quot;&gt;JOSSO&lt;/span&gt;&lt;/a&gt;, que vous l&amp;#8217;avez installé, testé et re-testé, vous avez peut être remarqué que le client proposé pour microsoft est écrit en &lt;span class=&quot;caps&quot;&gt;ASP&lt;/span&gt;. Maintenant, de nombreuses applications utilise le framework .Net dans les entreprises. J&amp;#8217;ai donc pris la liberté d&amp;#8217;écrire un agent très simple en .Net&lt;/p&gt;
&lt;p&gt;Pour télécharger la solution (VS 2008, framework 3.5)&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;/data/josso-agent-asp_net.zip&quot;&gt;&lt;span class=&quot;caps&quot;&gt;JOSSO&lt;/span&gt; (~ 20 Ko)(format zip)&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Pour faire tourner le client, il faut avoir enregistrer le client ActiveX de la version 1.8.1 de josso. Pour ce faire, téléchargez &lt;a href=&quot;https://josso.svn.sourceforge.net/svnroot/josso/josso1/branches/JOSSO_1_8_1_B/josso/distributions/josso/src/main/resources/dist/agents/bin/&quot;&gt;JossoActiveX.dll&lt;/a&gt; et suivez les instructions du &lt;a href=&quot;http://www.josso.org/confluence/display/JOSSO1/Setup+JOSSO+Agent+-+ASP&quot;&gt;site josso.org&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Ensuite, pour configurer votre client, utilisez le web.config du projet Josso.Agent.Test&lt;/p&gt;</content>
 </entry>
   
 
   
 
   
 <entry>
   <title>Vivre Six Mois Au Japon</title>
   <link href="http://www.sp4ce.net/miscellaneous/2008/02/08/vivre-six-mois-au-japon.html"/>
   <updated>2008-02-08T00:00:00+01:00</updated>
   <id>http://www.sp4ce.net/miscellaneous/2008/02/08/vivre-six-mois-au-japon</id>
   <content type="html">&lt;h3&gt;Mon Stage&lt;/h3&gt;
&lt;p&gt;Commençons par ce qui m&amp;#8217;a pris le plus de mon temps. J&amp;#8217;ai fais mon stage à &lt;a href=&quot;http://www.atr.jp&quot;&gt;&lt;span class=&quot;caps&quot;&gt;ATR&lt;/span&gt;&lt;/a&gt;, un labo de recherche en télécommunications. Le sujet de mon stage était la reconnaissance de comportements humains aux alentours du robot pour aider celui-ci à interargir de façon correcte avec les humains.&lt;/p&gt;
&lt;p&gt;C&amp;#8217;était très stimulant de travailler au sein d&amp;#8217;une équipe de chercheur de haut niveau. Au début je pensais faire de la robotique, mais en fait j&amp;#8217;ai fais de l&amp;#8217;intelligence artifielle codée en Java. je travaillais sur des données que je devais recupérer sur un serveur, traiter, et mettre à disposition sur un autre serveur pour que le robot s&amp;#8217;y connecte.&lt;/p&gt;
&lt;p&gt;En plus, il n&amp;#8217;y avait pas trop de pressions et une assez grande marge de manoeuvre pour les idées personnelles. J&amp;#8217;ai vraiment profité de ça pour mettre en avant ma façon de voir les interactions. Mon seul regret est d&amp;#8217;avoir codé une application off-line et d&amp;#8217;avoir très peu utilisé le robot.&lt;/p&gt;
&lt;p&gt;Bon passons maintenant aux choses serieuses :p&lt;/p&gt;
&lt;h3&gt;La Vie Japonnaise&lt;/h3&gt;
&lt;p&gt;La vie était plutot douce où j&amp;#8217;habitais, dans la campagne japonnaise entre Kyoto (京都) et Nara (奈良). J&amp;#8217;habitais à &lt;a href=&quot;http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=fr&amp;geocode=&amp;q=Takanohara+Station,+Japan&amp;sll=39.520992,140.537109&amp;sspn=8.065831,20.983887&amp;ie=UTF8&amp;hq=&amp;hnear=Takanohara+Station,+Japon&amp;ll=34.742741,135.688705&amp;spn=0.268573,0.655746&amp;t=h&amp;z=11&quot;&gt;Takanohara (高の原)&lt;/a&gt;, c&amp;#8217;est une petite ville assez tranquille avec son centre commerciale, sa banque, sa gare et ses danchis (quartiers résidentiels).&lt;/p&gt;
&lt;p&gt;En dehors de mon travail, le week end, j&amp;#8217;essayais de m&amp;#8217;amuser autant que possible et de rencontrer de nouveaux amis. À mon arrivé je suis beaucoup sorti avec un américain prénommé de Ben qui venait du &lt;span class=&quot;caps&quot;&gt;MIT&lt;/span&gt;. Mais ensuite, j&amp;#8217;ai commencé a connaitre quelques Japonnais, et à avoir des amis. C&amp;#8217;était vraiment une expérience de re-commencer une vie là-bas, se refaire des amis, etc.&lt;/p&gt;
&lt;h3&gt;Les Japonnais&lt;/h3&gt;
&lt;p&gt;À cause de la langue, c&amp;#8217;est pas forcément facile de se faire des rencontres&amp;#8230; le japonnais, c&amp;#8217;est quand même très dur et j&amp;#8217;ai jamais été fort en langue. Cependant les japonnais sont dans l&amp;#8217;ensemble très très gentils. S&amp;#8217;ils décident de vous aider dans la rue, vous êtes sûres qu&amp;#8217;ils ne vous laisseront pas tant que vous ne saurez pas votre route. Je ne compte plus le nombre de fois où j&amp;#8217;ai été accompagné par un japonnais jusqu&amp;#8217;à l&amp;#8217;endroit où je voulais aller même si ça lui faisait faire un détour !&lt;/p&gt;
&lt;p&gt;Cependant, derrière cette gentillesse, se cache une certaine froideur et une distance infranchissable. Lorsque vous êtes au Japon, vous êtes un Gaijin (外人 litt. personne de l&amp;#8217;exterieure) et vous le sentez. Ce n&amp;#8217;est pas du racisme, attention, c&amp;#8217;est juste que pour un japonnais, toutes choses doivent être à leurs places et votre place, c&amp;#8217;est celle du Gaijin.&lt;/p&gt;
&lt;h3&gt;Liens&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;http://jpoptrash.nihon-fr.com/&quot;&gt;JPop Trash&lt;/a&gt;, un site troisième degrée sur la culture japonnaise.&lt;/p&gt;</content>
 </entry>
   
 
   
 <entry>
   <title>Serveur IRC en Erlang</title>
   <link href="http://www.sp4ce.net/computer/2007/10/04/irc-server-with-erlang-language.fr.html"/>
   <updated>2007-10-04T00:00:00+02:00</updated>
   <id>http://www.sp4ce.net/computer/2007/10/04/irc-server-with-erlang-language.fr</id>
   <content type="html">&lt;h3&gt;Erlang&lt;/h3&gt;
&lt;p&gt;Erlang est un langage assez peu commun mais très pratique. vous pourrez trouver des infos sur l&amp;#8217;inévitable &lt;a href=&quot;http://fr.wikipedia.org/wiki/Erlang_%28langage%29&quot;&gt;wikipedia&lt;/a&gt;. De mon point de vue, j&amp;#8217;ai bien aimé Erlang pour deux raisons. premièremenent, il ressemble à CamL, un langage que j&amp;#8217;apprécie, pour le fonctionnement par &amp;#8220;match&amp;#8221; sur les expressions. Et deuxièmement, LE point fort d&amp;#8217;Erlang est que le développeur a le pouvoir modifier le code, et d&amp;#8217;appliquer directement les changements sans devoir relancer le module.&lt;/p&gt;
&lt;p&gt;Cette faculté est bien adapté à l&amp;#8217;irc. En effet, si vous avez des clients (utilisateurs) connectés à votre serveur et que vous devez faire une modification sur le serveur. Vous pouvez donc mettre à jour votre serveur sans qu&amp;#8217;aucun client ne s&amp;#8217;en rendre compte et ne soit déconnecté. Cela assure une grande stabilité du serveur.&lt;/p&gt;
&lt;h3&gt;&lt;span class=&quot;caps&quot;&gt;IRC&lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;Internet Relay Chat permet de discuter sur le net par un systême de channel qui sont des sortes de salles de rencontre. on peut ainsi avoir plusieurs utilisateurs qui discutent tous en même temps. &lt;span class=&quot;caps&quot;&gt;IRC&lt;/span&gt; est assez vieux, mais c&amp;#8217;est un protocole de communication qui a aussi évolué. la dernière rfc concernant les serveurs est la &lt;a href=&quot;http://www.irchelp.org/irchelp/rfc/rfc2813.txt&quot;&gt;rfc2813&lt;/a&gt;. J&amp;#8217;ai essayé de suivi &amp;#8220;au maximum&amp;#8221; cette rfc, mais en fait, mon serveur est très simple et donc, on peut pas vraiment dire qu&amp;#8217;il la respecte vraiment.&lt;/p&gt;
&lt;p&gt;H3. Liens&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;/data/server_irc_erlang.tar&quot;&gt;Source du projet&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;/data/server_irc_erlang.pdf&quot;&gt;Présentation du projet&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.irchelp.org/irchelp/rfc/&quot;&gt;détails sur les rfc d&amp;#8217;irc&lt;/a&gt;&lt;/p&gt;</content>
 </entry>
   
 
   
 
   
 <entry>
   <title>Mail Promo des Élèves</title>
   <link href="http://www.sp4ce.net/computer/2007/09/18/student-mailpromo.fr.html"/>
   <updated>2007-09-18T00:00:00+02:00</updated>
   <id>http://www.sp4ce.net/computer/2007/09/18/student-mailpromo.fr</id>
   <content type="html">&lt;h3&gt;Version 2.0 ??&lt;/h3&gt;
&lt;p&gt;Commençons par la commencement. Qu&amp;#8217;est-ce que la version 1.0, puis 1.1 ensuite ? Il s&amp;#8217;agit de la première interface qui a été utilisé du lancement du projet à novembre 2007. L&amp;#8217;interface n&amp;#8217;est pas très intuitive et utilise un format texte pour sauvegarder les messages.&lt;/p&gt;
&lt;p&gt;la version 2.0 utilise la base de données MySQL du serveur du &lt;span class=&quot;caps&quot;&gt;BDE&lt;/span&gt; pour organiser les mails, les différents destinataires et l&amp;#8217;édition des messages. Chaque lundi de chaque semaine, elle crée automatiquement un nouveau mail vierge qui sera le mail de la semaine à être envoyé.&lt;/p&gt;
&lt;p&gt;h3.Capture d&amp;#8217;écran&lt;/p&gt;
&lt;p&gt;l&amp;#8217;accueil de l&amp;#8217;interface où l&amp;#8217;on choisit le mail que l&amp;#8217;on veut éditer, etc. c&amp;#8217;est la gestion des mails.&lt;br /&gt;
&lt;img src=&quot;/images/mailpromo/accueil.png&quot; alt=&quot;dashboard&quot; class=&quot;screenshot&quot; /&gt;&lt;/p&gt;
&lt;p&gt;l&amp;#8217;interface d&amp;#8217;édition des messages pour chaque mail, avec choix des destinataires et visualisation avant envoie&lt;br /&gt;
&lt;img src=&quot;/images/mailpromo/edition.png&quot; alt=&quot;edit&quot; class=&quot;screenshot&quot; /&gt;&lt;/p&gt;</content>
 </entry>
   
 
   
 
   
 <entry>
   <title>Représentation 3D avec l'algorithme de Catmull et Clark</title>
   <link href="http://www.sp4ce.net/computer/2005/11/27/playing-with-3D-and-Catmull-and-Clark-algorithm.fr.html"/>
   <updated>2005-11-27T00:00:00+01:00</updated>
   <id>http://www.sp4ce.net/computer/2005/11/27/playing-with-3D-and-Catmull-and-Clark-algorithm.fr</id>
   <content type="html">&lt;h3&gt;Quelques images&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;/images/cattmull_clark.png&quot; alt=&quot;Surfaces 3D&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Le logiciel prend en entrée une série de point (figure de gauche) et avec un algorithme (Cattmull et Clarke), il lisse la surface et la dessine (figure de droite).&lt;/p&gt;
&lt;h3&gt;Source Code&lt;/h3&gt;
&lt;p&gt;Le code source de mon application est très peu commenté et l&amp;#8217;application n&amp;#8217;est pas très intuitive. Si vous avez des questions, contactez-moi.&lt;/p&gt;
&lt;p&gt;&lt;a href='/data/catmull_clark.tar.gz'&gt;Télécharger&lt;/a&gt;&lt;/p&gt;</content>
 </entry>
   
 
   
 
 
</feed>

