Recompiled

This commit is contained in:
Yann Esposito 2012-05-02 17:43:56 +02:00
parent 52631e4e73
commit 70314df976
284 changed files with 11447 additions and 9944 deletions

View file

@ -6,7 +6,7 @@ menupriority: 1
<img src="/Scratch/img/about/avatar.png" alt="Avatar" class="left"/> <img src="/Scratch/img/about/avatar.png" alt="Avatar" class="left"/>
<%= mail_perso %> %mailperso
Follow me on [twitter](http://twitter.com/yogsototh) Follow me on [twitter](http://twitter.com/yogsototh)
My preferred bookmarks [pinboard](http://pinboard.in/u:yogsototh) My preferred bookmarks [pinboard](http://pinboard.in/u:yogsototh)
Open Source [github](http://github.com/yogsototh) Open Source [github](http://github.com/yogsototh)

View file

@ -12,11 +12,9 @@ tags:
----- -----
blogimage("main.png","Title image") blogimage("main.png","Title image")
<% password="P45sW0r|)" %>
begindiv(intro) begindiv(intro)
<%= tldr %> How I manage safely my password with success for some years now. %tldr How I manage safely my password with success for some years now.
**`sha1( password + domain_name )`** **`sha1( password + domain_name )`**
I memorize only one password. I memorize only one password.
I use a different password on all website. I use a different password on all website.
@ -67,9 +65,9 @@ A _bad_ solution would be to
chose passwords like this: chose passwords like this:
- twitter: `<%=password%>Twitter` - twitter: `P45sW0r|)Twitter`
- gmail: `<%=password%>gmail` - gmail: `P45sW0r|)gmail`
- badonlinegame: `<%=password%>badonlinegame` - badonlinegame: `P45sW0r|)badonlinegame`
Unfortunately, if someone get your password on Unfortunately, if someone get your password on
@ -88,7 +86,7 @@ hash("P45sW0r|)") = 9f00fd5dbba232b7c03afd2b62b5fce5cdc7df63
</code> </code>
If someone has `9f00fd5dbba232b7c03afd2b62b5fce5cdc7df63`, If someone has `9f00fd5dbba232b7c03afd2b62b5fce5cdc7df63`,
he will have hard time to recover `<%=password%>`. he will have hard time to recover `P45sW0r|)`.
Let choose SHA1 as hash function. Let choose SHA1 as hash function.

View file

@ -25,7 +25,7 @@ begindiv(intro)
_update_: updated for yesod 0.10 _update_: updated for yesod 0.10
<%= tldr %> A simple yesod tutorial. %tldr A simple yesod tutorial.
Yesod is a Haskell web framework. Yesod is a Haskell web framework.
You shouldn't need to know Haskell. You shouldn't need to know Haskell.

View file

@ -7,8 +7,8 @@ error_message: Authorization required
noSubMenu: true noSubMenu: true
----- -----
If you don't have the password or believe it is an error you can mail me at <% mail_perso %>. If you don't have the password or believe it is an error you can mail me at %mailperso.
newcorps newcorps
Vous pouvez me contacter par mail: <% mail_perso %>. Vous pouvez me contacter par mail: %mailperso.

View file

@ -7,4 +7,4 @@ error_message: Forbidden
noSubMenu: true noSubMenu: true
----- -----
Contact: <% mail_perso %> Contact: %mailperso

View file

@ -8,9 +8,9 @@ noSubMenu: true
layout: error layout: error
----- -----
The page you're looking at doesn't exists on the server. The page you're looking at doesn't exists on the server.
If you have followed an internal link, you can tell me by mail <% mail_perso %> and I'll fix it as soon as possible. If you have followed an internal link, you can tell me by mail %mailperso and I'll fix it as soon as possible.
newcorps newcorps
La page que vous recherchez n'est pas présente sur le site. La page que vous recherchez n'est pas présente sur le site.
Si vous avez suivi un lien vous pouvez me prévenir par mail <% mail_perso %> et je réparerai ça dès que possible. Si vous avez suivi un lien vous pouvez me prévenir par mail %mailperso et je réparerai ça dès que possible.

View file

@ -7,4 +7,4 @@ error_message: Request Timed Out
noSubMenu: true noSubMenu: true
----- -----
Contact: <% mail_perso %> Contact: %mailperso

View file

@ -7,4 +7,4 @@ error_message: Internal Server Error
noSubMenu: true noSubMenu: true
----- -----
Contact: <% mail_perso %> Contact: %mailperso

View file

@ -7,4 +7,4 @@ error_message: Service Unaviable
noSubMenu: true noSubMenu: true
----- -----
Contact: <% mail_perso %> Contact: %mailperso

View file

@ -6,7 +6,7 @@ menupriority: 1
<img src="/Scratch/img/about/avatar.png" alt="Avatar" class="left"/> <img src="/Scratch/img/about/avatar.png" alt="Avatar" class="left"/>
<%= mail_perso %> %mailperso
Suivez moi sur [twitter](http://twitter.com/yogsototh) Suivez moi sur [twitter](http://twitter.com/yogsototh)
Mes "bookmarks" [pinboard](http://pinboard.in/u:yogsototh) Mes "bookmarks" [pinboard](http://pinboard.in/u:yogsototh)
Open Source [github](http://github.com/yogsototh) Open Source [github](http://github.com/yogsototh)

View file

@ -12,12 +12,10 @@ tags:
----- -----
blogimage("main.png","Title image") blogimage("main.png","Title image")
<% password="P45sW0r|)" %>
begindiv(intro) begindiv(intro)
<%= tlal %> Une méthode de gestion des mots de passes que j'utilise avec succès depuis quelques années. %tlal Une méthode de gestion des mots de passes que j'utilise avec succès depuis quelques années.
**`sha1( mot_de_passe + nom_de_domaine )`** **`sha1( mot_de_passe + nom_de_domaine )`**
Je ne mémorise qu'un seul mot de passe de très bonne qualité. Je ne mémorise qu'un seul mot de passe de très bonne qualité.
J'utilise des mots de passe différents sur tous les sites. J'utilise des mots de passe différents sur tous les sites.
@ -67,9 +65,9 @@ Un _mauvaise_ solution peut être de choisir ses
mots de passes de la façon suivante : mots de passes de la façon suivante :
- twitter: `<%=password%>Twitter` - twitter: `P45sW0r|)Twitter`
- gmail: `<%=password%>gmail` - gmail: `P45sW0r|)gmail`
- badonlinegame: `<%=password%>badonlinegame` - badonlinegame: `P45sW0r|)badonlinegame`
Malheureusement, si quelqu'un récupère votre mot de passe sur Malheureusement, si quelqu'un récupère votre mot de passe sur
@ -86,7 +84,7 @@ Prenons un exemple :
Si quelqu'un possède `9f00fd5dbba232b7c03afd2b62b5fce5cdc7df63`, Si quelqu'un possède `9f00fd5dbba232b7c03afd2b62b5fce5cdc7df63`,
il va avoir de grande difficulté pour retrouver `<%=password%>`. il va avoir de grande difficulté pour retrouver `P45sW0r|)`.
Choisisson la fonction de hashage `sha1`. Choisisson la fonction de hashage `sha1`.

View file

@ -26,7 +26,7 @@ begindiv(intro)
_mise à jour_: mise à jour pour la version 0.10 de yesod. _mise à jour_: mise à jour pour la version 0.10 de yesod.
<%= tlal %> Un tutoriel pour yesod, un framework web Haskell. %tlal Un tutoriel pour yesod, un framework web Haskell.
Vous ne devriez pas avoir besoin de savoir programmer en Haskell. Vous ne devriez pas avoir besoin de savoir programmer en Haskell.
Par contre je suis désolé pour les francophones, Par contre je suis désolé pour les francophones,
mais je n'ai pas eu le courage de traduire cet article en Français. mais je n'ai pas eu le courage de traduire cet article en Français.

View file

@ -15,6 +15,7 @@ class Macros < Nanoc3::Filter
@macro={} @macro={}
@macro[:tlal] = %{<span class="sc"><abbr title="Trop long à lire">tlàl</abbr> : </span>} @macro[:tlal] = %{<span class="sc"><abbr title="Trop long à lire">tlàl</abbr> : </span>}
@macro[:tldr] = %{<span class="sc"><abbr title="Too long; didn't read">tl;dr</abbr>: </span>} @macro[:tldr] = %{<span class="sc"><abbr title="Too long; didn't read">tl;dr</abbr>: </span>}
@macro[:mailperso] = %{<a href="&#109;&#097;&#105;&#108;&#116;&#111;:&#121;&#097;&#110;&#110;&#046;&#101;&#115;&#112;&#111;&#115;&#105;&#116;&#111;&#064;&#103;&#109;&#097;&#105;&#108;&#046;&#099;&#111;&#109;">&#121;&#097;&#110;&#110;&#046;&#101;&#115;&#112;&#111;&#115;&#105;&#116;&#111;&#064;&#103;&#109;&#097;&#105;&#108;&#046;&#099;&#111;&#109;</a>}
if @item.nil? if @item.nil?
if not arg.nil? if not arg.nil?
@macro.merge!( arg ) @macro.merge!( arg )

View file

@ -9,7 +9,7 @@ fr: # Comment me contacter
en: <img src="/Scratch/img/about/avatar.png" alt="Avatar" class="left"/> en: <img src="/Scratch/img/about/avatar.png" alt="Avatar" class="left"/>
fr: <img src="/Scratch/img/about/avatar.png" alt="Avatar" class="left"/> fr: <img src="/Scratch/img/about/avatar.png" alt="Avatar" class="left"/>
<%= mail_perso %> %mailperso
en: Follow me on [twitter](http://twitter.com/yogsototh) en: Follow me on [twitter](http://twitter.com/yogsototh)
en: My preferred bookmarks [pinboard](http://pinboard.in/u:yogsototh) en: My preferred bookmarks [pinboard](http://pinboard.in/u:yogsototh)
en: Open Source [github](http://github.com/yogsototh) en: Open Source [github](http://github.com/yogsototh)

File diff suppressed because one or more lines are too long

View file

@ -133,7 +133,7 @@ Orginal Style from ethanschoonover.com/solarized (c) Jeremy Hull <sourdrums@gmai
*/ */
pre code { pre code {
display: block; padding: 0.5em; display: block;
background: #002b36; color: #839496; background: #002b36; color: #839496;
} }

View file

@ -60,7 +60,7 @@
<p><img src="/Scratch/img/about/avatar.png" alt="Avatar" class="left" /></p> <p><img src="/Scratch/img/about/avatar.png" alt="Avatar" class="left" /></p>
<p><a href="&#109;&#097;&#105;&#108;&#116;&#111;:&#121;&#097;&#110;&#110;&#046;&#101;&#115;&#112;&#111;&#115;&#105;&#116;&#111;&#064;&#103;&#109;&#097;&#105;&#108;&#046;&#099;&#111;&#109;">&#121;&#097;&#110;&#110;&#046;&#101;&#115;&#112;&#111;&#115;&#105;&#116;&#111;&#064;&#103;&#109;&#097;&#105;&#108;&#046;&#099;&#111;&#109;</a><br /> <p><a href="&#109;&#097;&#105;&#108;&#116;&#111;:&#121;&#097;&#110;&#110;&#046;&#101;&#115;&#112;&#111;&#115;&#105;&#116;&#111;&#064;&#103;&#109;&#097;&#105;&#108;&#046;&#099;&#111;&#109;">yann.esposito@gmail.com</a>
Follow me on <a href="http://twitter.com/yogsototh">twitter</a><br /> Follow me on <a href="http://twitter.com/yogsototh">twitter</a><br />
My preferred bookmarks <a href="http://pinboard.in/u:yogsototh">pinboard</a><br /> My preferred bookmarks <a href="http://pinboard.in/u:yogsototh">pinboard</a><br />
Open Source <a href="http://github.com/yogsototh">github</a><br /> Open Source <a href="http://github.com/yogsototh">github</a><br />

View file

@ -104,7 +104,7 @@
<li>Computer Security: <a href="http://yann.esposito.free.fr/enseignement/rez0.php#projet">I designed a secure web protocol (similar to TOR)</a>, <a href="/YBlog/Computer/Entries/2008/7/30_Easy,_secure_and_portable_password_management_system.html">a method to securely remember strong passwords</a> (<a href="/YBlog/YPassword.html">programmed a dashboard widget</a> and a shell script to use this method). </li> <li>Computer Security: <a href="http://yann.esposito.free.fr/enseignement/rez0.php#projet">I designed a secure web protocol (similar to TOR)</a>, <a href="/YBlog/Computer/Entries/2008/7/30_Easy,_secure_and_portable_password_management_system.html">a method to securely remember strong passwords</a> (<a href="/YBlog/YPassword.html">programmed a dashboard widget</a> and a shell script to use this method). </li>
</ul> </ul>
<p>But before all, I love to learn. For example, I learned many programming languages: <code>C</code>, <code>C++</code>, <code>Objective-C</code>, <code>Python</code>, <code>Java</code>, <code>Perl</code>, <code>awk</code>, <code>bash</code>, <code>zsh</code>, <code>LaTeX</code>, <code>Metapost</code>, <code>camL</code>&hellip; And Ive got the same passion about computer science research, computer security, philosophy and many other things.</p> <p>But before all, I love to learn. For example, I learned many programming languages: <code>C</code>, <code>C++</code>, <code>Objective-C</code>, <code>Python</code>, <code>Java</code>, <code>Perl</code>, <code>awk</code>, <code>bash</code>, <code>zsh</code>, <code>LaTeX</code>, <code>Metapost</code>, <code>camL</code> And Ive got the same passion about computer science research, computer security, philosophy and many other things.</p>
</div> </div>
@ -118,7 +118,7 @@
<p>Then I had a post Ph. D. Degree position in the Hubert Curien Laboratory at St-Etienne. My mission consisted to develop a scientific application (SEDiL). This application should be used by biologist and should have a simple and nice user interface.</p> <p>Then I had a post Ph. D. Degree position in the Hubert Curien Laboratory at St-Etienne. My mission consisted to develop a scientific application (SEDiL). This application should be used by biologist and should have a simple and nice user interface.</p>
<p>Today I work for AirFrance<small>&copy;</small> via Astek. This job need many differents skills, CMS and Web technologies, Perl, JSP, meta-programming&hellip;</p> <p>Today I work for AirFrance<small>&copy;</small> via Astek. This job need many differents skills, CMS and Web technologies, Perl, JSP, meta-programming</p>
<div class="return"><a href="#entete" onclick="fastShowMenu()">&uarr;</a></div> <div class="return"><a href="#entete" onclick="fastShowMenu()">&uarr;</a></div>

View file

@ -10,6 +10,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="nanoc" type="text/html" hreflang="fr" href="/Scratch/fr/blog/01_nanoc/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="nanoc" type="text/html" hreflang="fr" href="/Scratch/fr/blog/01_nanoc/" />
@ -17,6 +18,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -59,11 +62,11 @@
But a Framework to generate static web pages.</p> But a Framework to generate static web pages.</p>
<p>You have to program yourself webpages, the code <p>You have to program yourself webpages, the code
to generate the menu&hellip;</p> to generate the menu</p>
<p>I added feature to make my website multilingual for example</p> <p>I added feature to make my website multilingual for example</p>
<p>You&rsquo;ll can find many informations on the <p>Youll can find many informations on the
<a href="http://nanoc.stoneship.org">official nanoc website</a>.</p> <a href="http://nanoc.stoneship.org">official nanoc website</a>.</p>
</div> </div>

View file

@ -1,4 +1,3 @@
#!/usr/bin/env zsh #!/usr/bin/env zsh
(($#<1)) && { print 'usage: ack "regexp"' >&2; exit 1 } (($#<1)) && { print 'usage: ack "regexp"' >&2; exit 1 }

View file

@ -10,6 +10,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Mieux que grep" type="text/html" hreflang="fr" href="/Scratch/fr/blog/02_ackgrep/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Mieux que grep" type="text/html" hreflang="fr" href="/Scratch/fr/blog/02_ackgrep/" />
@ -17,6 +18,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -54,11 +57,11 @@
<div class="corps"> <div class="corps">
<h1 class="first" id="update">update</h1> <h1 class="first" id="update">update</h1>
<p>As <a href="http://www.theworkinggeek.com">Andy Lester</a> told me <a href="http://betterthangrep.com"><code>ack</code></a> is a simple file you only have to copy in your <code>~/bin</code> folder. Now I&rsquo;ve got <code>ack</code> on my professional server.</p> <p>As <a href="http://www.theworkinggeek.com">Andy Lester</a> told me <a href="http://betterthangrep.com"><code>ack</code></a> is a simple file you only have to copy in your <code>~/bin</code> folder. Now Ive got <code>ack</code> on my professional server.</p>
<p>Go on <a href="http://betterthangrep.com">http://betterthangrep.com</a> to download it.</p> <p>Go on <a href="http://betterthangrep.com">http://betterthangrep.com</a> to download it.</p>
<p>Sincerely, I don&rsquo;t understand <code>ack</code> don&rsquo;t become a common command on all UNIX systems. I can no more live without. For me it is as essential as <code>which</code> or <code>find</code>.</p> <p>Sincerely, I dont understand <code>ack</code> dont become a common command on all UNIX systems. I can no more live without. For me it is as essential as <code>which</code> or <code>find</code>.</p>
</div> </div>
@ -71,35 +74,38 @@
<p>One of the my main usage of <code>grep</code> is</p> <p>One of the my main usage of <code>grep</code> is</p>
<div> <div>
<pre class="twilight">
grep <span class="String"><span class="String">'</span>pattern<span class="String">'</span></span> **/*(.)
</pre> <pre><code class="zsh">grep 'pattern' **/*(.)</code></pre>
</div> </div>
<p>Most of time it is enough. <p>Most of time it is enough.
But it is far better with colored output. But it is far better with colored output.
<code>ack-grep</code> in Ubuntu does that. <code>ack-grep</code> in Ubuntu does that.
As I couldn&rsquo;t install it on my &lsquo;Evil Company Server&rsquo;, As I couldnt install it on my Evil Company Server,
I had done one myself in very few lines:</p> I had done one myself in very few lines:</p>
<div> <div>
<div class="code"><div class="file"><a href="/Scratch/en/blog/02_ackgrep/code/ack"> &#x27A5; ack </a></div><div class="withfile"> <div class="codefile"><a href="/Scratch/en/blog/02_ackgrep/code/ack">&#x27A5; ack</a></div>
<pre class="twilight">
<span class="Comment"><span class="Comment">#</span>!/usr/bin/env zsh</span>
((<span class="Variable"><span class="Variable">$</span>#</span><span class="Keyword">&lt;</span>1)) <span class="Keyword">&amp;&amp;</span> { print <span class="String"><span class="String">'</span>usage: ack &quot;regexp&quot;<span class="String">'</span></span> <span class="Keyword">&gt;&amp;2</span><span class="Keyword">;</span> exit 1 } <pre><code class="zsh">#!/usr/bin/env zsh
(($#&lt;1)) &amp;&amp; { print 'usage: ack "regexp"' &gt;&2; exit 1 }
listeFic=( **/*(.) ) listeFic=( **/*(.) )
autoload zargs autoload zargs
zargs -- <span class="Variable"><span class="Variable">$</span>listeFic</span> -- grep <span class="Variable"><span class="Variable">$</span>1</span> <span class="Keyword">|</span> perl -ne <span class="String"><span class="String">'</span>use Term::ANSIColor;</span> zargs -- $listeFic -- grep $1 | perl -ne 'use Term::ANSIColor;
<span class="String">if (m/([^:]*)(:.*)(<span class="String">'</span></span><span class="Variable"><span class="Variable">$</span>1</span><span class="String"><span class="String">'</span>)(.*)/) {</span> if (m/([^:]*)(:.*)('$1')(.*)/) {
<span class="String"> print color(&quot;green&quot;).$1;</span> print color("green").$1;
<span class="String"> print color(&quot;reset&quot;).$2;</span> print color("reset").$2;
<span class="String"> print color(&quot;black&quot;,&quot;on_yellow&quot;).$3;</span> print color("black","on_yellow").$3;
<span class="String"> print color(&quot;reset&quot;).$4.&quot;\n&quot;;</span> print color("reset").$4."\n";
<span class="String">} <span class="String">'</span></span> } '
</code></pre>
</pre>
</div></div>
</div> </div>
<p>For my team and I it is usable enough. <p>For my team and I it is usable enough.

View file

@ -10,6 +10,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Lost Highway démystifié (un peu)" type="text/html" hreflang="fr" href="/Scratch/fr/blog/03_losthighway/03_losthighway_1/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Lost Highway démystifié (un peu)" type="text/html" hreflang="fr" href="/Scratch/fr/blog/03_losthighway/03_losthighway_1/" />
@ -17,6 +18,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -56,7 +59,7 @@
<div class="flush"></div> <div class="flush"></div>
<div id="afterheader"> <div id="afterheader">
<div class="corps"> <div class="corps">
<h1 class="first" id="movies-keys">Movie&rsquo;s keys</h1> <h1 class="first" id="movies-keys">Movies keys</h1>
<div class="encadre" style="text-align: center"> <div class="encadre" style="text-align: center">
<strong> <strong>
@ -64,32 +67,32 @@
</strong> </strong>
</div> </div>
<p>In a first, it is clear for me, it is not a fantastic movie. If you follow this line, you&rsquo;ll face many problem explaining some scenes.</p> <p>In a first, it is clear for me, it is not a fantastic movie. If you follow this line, youll face many problem explaining some scenes.</p>
<p>My hypothesis is the movie describe the Fred&rsquo;s representation of reality. <p>My hypothesis is the movie describe the Freds representation of reality.
Each of his tries to escape reality will fail.</p> Each of his tries to escape reality will fail.</p>
<p>Fred had commited an horrible act, a murder, and try to <em>repair</em> his memory to accepts it. He&rsquo;ll then create alternative realities.</p> <p>Fred had commited an horrible act, a murder, and try to <em>repair</em> his memory to accepts it. Hell then create alternative realities.</p>
<ul> <ul>
<li>In a first time he kills his wife (Renee) because he believes she cheated at him.</li> <li>In a first time he kills his wife (Renee) because he believes she cheated at him.</li>
<li>In the second part, he&rsquo;s weaker and will be manipulated by the blond equivalent of Renee to kill Dick Laurent.</li> <li>In the second part, hes weaker and will be manipulated by the blond equivalent of Renee to kill Dick Laurent.</li>
<li>In a third part, he kills Dick Laurent</li> <li>In a third part, he kills Dick Laurent</li>
</ul> </ul>
<h2 id="why-this-interpretation-can-be-valid">Why this interpretation can be valid?</h2> <h2 id="why-this-interpretation-can-be-valid">Why this interpretation can be valid?</h2>
<p>Because of the dialog at the begining of the movie. Cops ask Fred if he&rsquo;s own a video camera:</p> <p>Because of the dialog at the begining of the movie. Cops ask Fred if hes own a video camera:</p>
<blockquote> <blockquote>
<p>&ldquo;Do you own a video camera?&rdquo;<br /> <p>“Do you own a video camera?”<br />
&ldquo;No, Fred hates them.&rdquo;<br /> “No, Fred hates them.”<br />
&ldquo;I like to remember things my own way.&rdquo;<br /> “I like to remember things my own way.”<br />
&ldquo;What do you mean by that?&rdquo;<br /> “What do you mean by that?”<br />
&ldquo;How I remember them, not necessarily the way they happened.&rdquo; </p> “How I remember them, not necessarily the way they happened.” </p>
</blockquote> </blockquote>
<p>Then, what we see is not reality but the Fred&rsquo;s perception. Fred is the God of the reality we see. This is why some God/Devil interpretation of the movie works not so bad.</p> <p>Then, what we see is not reality but the Freds perception. Fred is the God of the reality we see. This is why some God/Devil interpretation of the movie works not so bad.</p>
</div> </div>

View file

@ -10,6 +10,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Lost Highway démystifié (un peu)" type="text/html" hreflang="fr" href="/Scratch/fr/blog/03_losthighway/03_losthighway_2/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Lost Highway démystifié (un peu)" type="text/html" hreflang="fr" href="/Scratch/fr/blog/03_losthighway/03_losthighway_2/" />
@ -17,6 +18,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -58,17 +61,17 @@
<div class="corps"> <div class="corps">
<h2 class="first" id="who-is-the-mysterious-man">Who is the mysterious man?</h2> <h2 class="first" id="who-is-the-mysterious-man">Who is the mysterious man?</h2>
<p><img alt="l'homme mystérieux" src="/Scratch/img/blog/03_losthighway/03_losthighway_2/mysteryman.jpg" class="left" /></p> <p><img alt="l'homme mystérieux" src="/Scratch/img/blog/03_losthighway/03_losthighway_2/mysteryman.jpg" class=" left" /></p>
<p>Who&rsquo;s this mysterious man? He tells Fred it&rsquo;s him who invited him in his house. He&rsquo;s present at the party and in the house of Fred in the same time. Eyes wide open, looking everything Fred&rsquo;s doing?</p> <p>Whos this mysterious man? He tells Fred its him who invited him in his house. Hes present at the party and in the house of Fred in the same time. Eyes wide open, looking everything Freds doing?</p>
<p>It&rsquo;s a key of the movie. In my humble opinion, I believe it represents the bad part of Fred. Certainly jalousy. If I was catholic, I&rsquo;ll said he&rsquo;s Satan. He observe, film but don&rsquo;t act. He helps Fred to kill Dick Laurent. <p>Its a key of the movie. In my humble opinion, I believe it represents the bad part of Fred. Certainly jalousy. If I was catholic, Ill said hes Satan. He observe, film but dont act. He helps Fred to kill Dick Laurent.
Fred had let him enter and cannot let him go. Fred had let him enter and cannot let him go.
As <em>Iago</em> of Shakespeare is imprisonned by its own jalousy. As <em>Iago</em> of Shakespeare is imprisonned by its own jalousy.
The Mysterious Man help Fred doing the acts of violence. The Mysterious Man help Fred doing the acts of violence.
It also force Fred to remember the reality.</p> It also force Fred to remember the reality.</p>
<p>When he makes love to his wife (Renee), he sees the face of the Mysterious Man instead of his wife&rsquo;s face. In reality, it&rsquo;s the same person for Fred. It should be her who&rsquo;s the origin of his interior badness.</p> <p>When he makes love to his wife (Renee), he sees the face of the Mysterious Man instead of his wifes face. In reality, its the same person for Fred. It should be her whos the origin of his interior badness.</p>
</div> </div>
@ -173,7 +176,7 @@ It also force Fred to remember the reality.</p>
</div> </div>
<div id="lastmod"> <div id="lastmod">
Created: 08/04/2009 Created: 08/04/2009
Modified: 05/09/2010 Modified: 04/26/2012
</div> </div>
<div> <div>
Entirely done with Entirely done with

View file

@ -10,6 +10,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Lost Highway démystifié (un peu)" type="text/html" hreflang="fr" href="/Scratch/fr/blog/03_losthighway/03_losthighway_3/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Lost Highway démystifié (un peu)" type="text/html" hreflang="fr" href="/Scratch/fr/blog/03_losthighway/03_losthighway_3/" />
@ -17,6 +18,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -56,9 +59,9 @@
<div class="flush"></div> <div class="flush"></div>
<div id="afterheader"> <div id="afterheader">
<div class="corps"> <div class="corps">
<h2 class="first" id="whos-at-the-origin-of-the-video-tapes">Who&rsquo;s at the origin of the video tapes?</h2> <h2 class="first" id="whos-at-the-origin-of-the-video-tapes">Whos at the origin of the video tapes?</h2>
<p>Certainly it&rsquo;s the mysterious man (Fred himself) who makes them. <p>Certainly its the mysterious man (Fred himself) who makes them.
Their reason should be:</p> Their reason should be:</p>
<ul> <ul>

View file

@ -10,6 +10,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Lost Highway démystifié (un peu)" type="text/html" hreflang="fr" href="/Scratch/fr/blog/03_losthighway/03_losthighway_4/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Lost Highway démystifié (un peu)" type="text/html" hreflang="fr" href="/Scratch/fr/blog/03_losthighway/03_losthighway_4/" />
@ -17,6 +18,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -71,7 +74,7 @@
<h2 id="which-one-then">which one then?</h2> <h2 id="which-one-then">which one then?</h2>
<p>The second hypothesis seems better. We can make much more interpretation with it. It explain in most part the strange phone call from Dick Laurent to Pete. <p>The second hypothesis seems better. We can make much more interpretation with it. It explain in most part the strange phone call from Dick Laurent to Pete.
But the first hypothesis remain coherent. And, we should probably make an in depth explanantion using the first hypothesis. And I&rsquo;m not sure it would be better.</p> But the first hypothesis remain coherent. And, we should probably make an in depth explanantion using the first hypothesis. And Im not sure it would be better.</p>
<p>One of the strength of this movie is to understand there is many other coherent hypothesis. It is an expression of the <a href="http://en.wikipedia.org/wiki/Rashomon_effect">Rashomon effect</a>. Many different persons could describe in a coherent manner what they saw. But each description contradicts the others.</p> <p>One of the strength of this movie is to understand there is many other coherent hypothesis. It is an expression of the <a href="http://en.wikipedia.org/wiki/Rashomon_effect">Rashomon effect</a>. Many different persons could describe in a coherent manner what they saw. But each description contradicts the others.</p>
@ -85,9 +88,9 @@ But the first hypothesis remain coherent. And, we should probably make an in dep
<p>There is much to tell about this movie. But I believe I put all essential keys here. It is a proof this movie is not a random one.</p> <p>There is much to tell about this movie. But I believe I put all essential keys here. It is a proof this movie is not a random one.</p>
<p>I believe it is essential to remember the &ldquo;test of Rorschach effet&rdquo; when watching this movie.</p> <p>I believe it is essential to remember the “test of Rorschach effet” when watching this movie.</p>
<p>I&rsquo;d like to know or opinion&nbsp;; is my interpration wrong?</p> <p>Id like to know or opinion&nbsp;; is my interpration wrong?</p>
</div> </div>

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Lost Highway démystifié (un peu)" type="text/html" hreflang="fr" href="/Scratch/fr/blog/03_losthighway/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Lost Highway démystifié (un peu)" type="text/html" hreflang="fr" href="/Scratch/fr/blog/03_losthighway/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -58,7 +61,7 @@
<div class="flush"></div> <div class="flush"></div>
<div id="afterheader"> <div id="afterheader">
<div class="corps"> <div class="corps">
<p><img alt="Lost Highway" src="/Scratch/img/blog/03_losthighway/intro.jpg" /></p> <p>blogimage( intro.jpg , Lost Highway )</p>
<div class="small"> <div class="small">
...this movie must be watched knowing you'll cannot resolve the solution. At his best you'll can suggest an interpretation close to the one of David Lynch.<br />I believe I had found a coherent interpretation which allow to follow the movie without being totally lost. I believed it can give the keys necessary to make its own idea of the movie... ...this movie must be watched knowing you'll cannot resolve the solution. At his best you'll can suggest an interpretation close to the one of David Lynch.<br />I believe I had found a coherent interpretation which allow to follow the movie without being totally lost. I believed it can give the keys necessary to make its own idea of the movie...
@ -72,10 +75,10 @@ Here some of explanations of Lost Highway I found on the Internet:</p>
<ul> <ul>
<li>Fred make a pact with the devil incarnated by the <em>Mysterious Man</em>,</li> <li>Fred make a pact with the devil incarnated by the <em>Mysterious Man</em>,</li>
<li><em>Mysterious Man</em> is a video camera,</li> <li><em>Mysterious Man</em> is a video camera,</li>
<li>Just the first part of the story is real. The rest is in the Fred&rsquo;s imagination,</li> <li>Just the first part of the story is real. The rest is in the Freds imagination,</li>
</ul> </ul>
<p>and I don&rsquo;t speak about many point of view found in forums.</p> <p>and I dont speak about many point of view found in forums.</p>
<p>I finished to find two good site talking about this movie. But none of them still totally convinced me:</p> <p>I finished to find two good site talking about this movie. But none of them still totally convinced me:</p>
@ -84,24 +87,24 @@ Here some of explanations of Lost Highway I found on the Internet:</p>
<li>the second which state almost the same interpretation about the movie and explain with even more details is on <a href="http://www.jasonsweb.com/LostHighway/main.htm">jasonweb</a></li> <li>the second which state almost the same interpretation about the movie and explain with even more details is on <a href="http://www.jasonsweb.com/LostHighway/main.htm">jasonweb</a></li>
</ul> </ul>
<p>Nonetheless, this movie must be watched knowing you&rsquo;ll cannot resolve the solution. At his best you&rsquo;ll can suggest an interpretation close to the one of David Lynch.</p> <p>Nonetheless, this movie must be watched knowing youll cannot resolve the solution. At his best youll can suggest an interpretation close to the one of David Lynch.</p>
<p>I believe I had found a coherent interpretation which allow to follow the movie <strong>without being totally lost</strong>. I believed it can give the keys necessary to make its own idea of the movie.</p> <p>I believe I had found a coherent interpretation which allow to follow the movie <strong>without being totally lost</strong>. I believed it can give the keys necessary to make its own idea of the movie.</p>
<h2 id="the-rorschach-test">The Rorschach test</h2> <h2 id="the-rorschach-test">The Rorschach test</h2>
<p><img alt="test de Rorschach" src="/Scratch/img/blog/03_losthighway/rorschach.gif" class="left" /></p> <p>leftblogimage(rorschach.gif , test de Rorschach)</p>
<p>Like the protagonist, everybody see what he want to see in this movie. It is an invitation to think. Watch this movie is a little like watch a Rorschach&rsquo;s test. What do we see in it? Everybody put its own personnality in the interpretation of the movie.</p> <p>Like the protagonist, everybody see what he want to see in this movie. It is an invitation to think. Watch this movie is a little like watch a Rorschachs test. What do we see in it? Everybody put its own personnality in the interpretation of the movie.</p>
<ul> <ul>
<li>If you are mystic, you&rsquo;ll see in the mysterious man a devil,</li> <li>If you are mystic, youll see in the mysterious man a devil,</li>
<li>If you are more psychanalytics, you&rsquo;ll see an inconscient part of the protagonist&hellip;</li> <li>If you are more psychanalytics, youll see an inconscient part of the protagonist…</li>
</ul> </ul>
<p>Generally, we stay in this movie and we fail explaining everything. There is almost always a point that don&rsquo;t fit within the interpretation of the movie. This is why trying to find a unique good interpretation of this movie is a mistake.</p> <p>Generally, we stay in this movie and we fail explaining everything. There is almost always a point that dont fit within the interpretation of the movie. This is why trying to find a unique good interpretation of this movie is a mistake.</p>
<h2 id="interprtation-ne-explanation">Interprétation&nbsp;&ne; Explanation</h2> <h2 id="interprtation-ne-explanation">Interprétation Explanation</h2>
<p>I give an <strong>interpretation</strong> and not an <strong>explanation</strong>. Just to tell my vision of the movie should be very different from yours. <p>I give an <strong>interpretation</strong> and not an <strong>explanation</strong>. Just to tell my vision of the movie should be very different from yours.
There is certainly many coherent explanations.</p> There is certainly many coherent explanations.</p>
@ -219,7 +222,7 @@ There is certainly many coherent explanations.</p>
</div> </div>
<div id="lastmod"> <div id="lastmod">
Created: 08/04/2009 Created: 08/04/2009
Modified: 05/09/2010 Modified: 04/26/2012
</div> </div>
<div> <div>
Entirely done with Entirely done with

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Les protections anti-copies sont LE MAL" type="text/html" hreflang="fr" href="/Scratch/fr/blog/04_drm/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Les protections anti-copies sont LE MAL" type="text/html" hreflang="fr" href="/Scratch/fr/blog/04_drm/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -66,7 +69,7 @@
<p style="text-align: center; font-size: 5em"><strong>WTF?</strong></p> <p style="text-align: center; font-size: 5em"><strong>WTF?</strong></p>
</div> </div>
<p>Result, my wife would never buy any TV show on iTunes. She don&rsquo;t like DVD because it is not as easy to buy and to use than to simply download episodes.</p> <p>Result, my wife would never buy any TV show on iTunes. She dont like DVD because it is not as easy to buy and to use than to simply download episodes.</p>
<div class="encadre"> <div class="encadre">
@ -74,8 +77,8 @@ Therefore far less money for you EVIL Copyrighter!!!!!
</div> </div>
<p>My wife won&rsquo;t see these episodes.<br /> <p>My wife wont see these episodes.<br />
This is a <strong>&lsquo;LOSE-LOSE&rsquo;</strong> cooperation.</p> This is a <strong>LOSE-LOSE</strong> cooperation.</p>
</div> </div>

View file

@ -1,4 +1,3 @@
#!/usr/bin/env zsh #!/usr/bin/env zsh
if (($#<1)); then if (($#<1)); then

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Création de branches externe avec Git" type="text/html" hreflang="fr" href="/Scratch/fr/blog/05_git_create_remote_branch/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Création de branches externe avec Git" type="text/html" hreflang="fr" href="/Scratch/fr/blog/05_git_create_remote_branch/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -63,23 +66,24 @@ branch to be created remotely.</p>
<p>Here is the script I use to achieve that: </p> <p>Here is the script I use to achieve that: </p>
<div> <div>
<div class="code"><div class="file"><a href="/Scratch/en/blog/05_git_create_remote_branch/code/git-create-new-branch.sh"> &#x27A5; git-create-new-branch.sh </a></div><div class="withfile"> <div class="codefile"><a href="/Scratch/en/blog/05_git_create_remote_branch/code/git-create-new-branch.sh">&#x27A5; git-create-new-branch.sh</a></div>
<pre class="twilight">
<span class="Comment"><span class="Comment">#</span>!/usr/bin/env zsh</span>
<span class="Keyword">if</span> ((<span class="Variable"><span class="Variable">$</span>#</span><span class="Keyword">&lt;</span>1))<span class="Keyword">;</span> <span class="Keyword">then</span>
print -- <span class="String"><span class="String">&quot;</span>usage: <span class="StringVariable"><span class="StringVariable">$</span>0</span>:t branch_name<span class="String">&quot;</span></span> <span class="Keyword">&gt;&amp;2</span> <pre><code class="zsh">#!/usr/bin/env zsh
if (($#&lt;1)); then
print -- "usage: $0:t branch_name" &gt;&amp;2
exit 1 exit 1
<span class="Keyword">fi</span> fi
branch=$1
git br ${branch}
git co ${branch}
git config branch.${branch}.remote origin
git config branch.${branch}.merge refs/heads/${branch}
</code></pre>
branch=<span class="Variable"><span class="Variable">$</span>1</span>
git br <span class="Variable"><span class="Variable">${</span>branch<span class="Variable">}</span></span>
git co <span class="Variable"><span class="Variable">${</span>branch<span class="Variable">}</span></span>
git config branch.<span class="Variable"><span class="Variable">${</span>branch<span class="Variable">}</span></span>.remote origin
git config branch.<span class="Variable"><span class="Variable">${</span>branch<span class="Variable">}</span></span>.merge refs/heads/<span class="Variable"><span class="Variable">${</span>branch<span class="Variable">}</span></span>
</pre>
</div></div>
</div> </div>
<p>Of course, I suppose <code>origin</code> is already configured.</p> <p>Of course, I suppose <code>origin</code> is already configured.</p>

View file

@ -1,4 +1,3 @@
#!/usr/bin/env zsh #!/usr/bin/env zsh
if (($#<1)); then if (($#<1)); then

View file

@ -1,4 +1,3 @@
#!/usr/bin/env zsh #!/usr/bin/env zsh
# recup branches not on local # recup branches not on local

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Git en solo" type="text/html" hreflang="fr" href="/Scratch/fr/blog/06_How_I_use_git/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Git en solo" type="text/html" hreflang="fr" href="/Scratch/fr/blog/06_How_I_use_git/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -58,7 +61,7 @@
<p>I use <a href="http://www.git-scm.org/">Git</a> to manage my personnal projects. <p>I use <a href="http://www.git-scm.org/">Git</a> to manage my personnal projects.
I have a centralized repository which all my computer should synchronize with. I have a centralized repository which all my computer should synchronize with.
Unfortunately I didn&rsquo;t find clearly what I needed on the official Git documentation.</p> Unfortunately I didnt find clearly what I needed on the official Git documentation.</p>
<p>In two words, if you want to use an SVN workflow with Git (and all its advantages) here is how to proceed.</p> <p>In two words, if you want to use an SVN workflow with Git (and all its advantages) here is how to proceed.</p>
@ -70,15 +73,18 @@ Unfortunately I didn&rsquo;t find clearly what I needed on the official Git docu
<h2 class="first" id="initialisation">Initialisation</h2> <h2 class="first" id="initialisation">Initialisation</h2>
<p>Suppose I&rsquo;ve got a directory on my local computer containing a project I want to manage via Git. Here what to do: </p> <p>Suppose Ive got a directory on my local computer containing a project I want to manage via Git. Here what to do: </p>
<div> <div>
<pre class="twilight">
cd to/project/directory/
<pre><code class="zsh">cd to/project/directory/
git init git init
git add git add
git commit git commit
</pre> </code></pre>
</div> </div>
<p>Now all files in the <code>to/project/directory/</code> are versionned. <p>Now all files in the <code>to/project/directory/</code> are versionned.
@ -87,31 +93,40 @@ If you want not to follow some just edit the file <code>.gitignore</code></p>
<p>for example mine is: </p> <p>for example mine is: </p>
<div> <div>
<pre class="twilight">
*.swp
<pre><code class="zsh">*.swp
.DS_Store .DS_Store
ikog.py.bak ikog.py.bak
output/Scratch/assets output/Scratch/assets
output/Scratch/en output/Scratch/en
output/Scratch/fr output/Scratch/fr
output/Scratch/multi output/Scratch/multi
</pre> </code></pre>
</div> </div>
<p>Next, you want to put your project on a directory accessible from the web:</p> <p>Next, you want to put your project on a directory accessible from the web:</p>
<div> <div>
<pre class="twilight">
git clone --bare . /path/to/repository
</pre> <pre><code class="zsh">git clone --bare . /path/to/repository
</code></pre>
</div> </div>
<p>Now on any computer you can do: </p> <p>Now on any computer you can do: </p>
<div> <div>
<pre class="twilight">
git clone protocol://path/to/repository local_directory
</pre> <pre><code class="zsh">git clone protocol://path/to/repository local_directory
</code></pre>
</div> </div>
<p>and <code>local_directory</code> will contain an up-to-date project.</p> <p>and <code>local_directory</code> will contain an up-to-date project.</p>
@ -135,27 +150,36 @@ You should make this operation also on the computer used to create the repositor
<p>Before begining your work, the first thing to do is to get all modification from the Internet to your local host: </p> <p>Before begining your work, the first thing to do is to get all modification from the Internet to your local host: </p>
<div> <div>
<pre class="twilight">
git pull
</pre> <pre><code class="zsh">git pull
</code></pre>
</div> </div>
<p>After that you can do (many times): </p> <p>After that you can do (many times): </p>
<div> <div>
<pre class="twilight">
hack, hack, hack...
<pre><code class="zsh">hack, hack, hack...
git add some files git add some files
git commit git commit
</pre> </code></pre>
</div> </div>
<p>When you want your local modification to be on the Internet just do a simple:</p> <p>When you want your local modification to be on the Internet just do a simple:</p>
<div> <div>
<pre class="twilight">
git push
</pre> <pre><code class="zsh">git push
</code></pre>
</div> </div>
<p>All should be ok.</p> <p>All should be ok.</p>
@ -163,16 +187,19 @@ git push
<p>If you have some trouble with the <code>push</code> and <code>pull</code> verify your <code>.git/config</code> file&nbsp;; it should contain the following lines:</p> <p>If you have some trouble with the <code>push</code> and <code>pull</code> verify your <code>.git/config</code> file&nbsp;; it should contain the following lines:</p>
<div> <div>
<pre class="twilight">
...
[remote <span class="String"><span class="String">&quot;</span>origin<span class="String">&quot;</span></span>] <pre><code class="zsh">...
[remote "origin"]
url = protocol://url/of/the/repository url = protocol://url/of/the/repository
fetch = +refs/heads/*:refs/remotes/origin/* fetch = +refs/heads/*:refs/remotes/origin/*
[branch <span class="String"><span class="String">&quot;</span>master<span class="String">&quot;</span></span>] [branch "master"]
remote = origin remote = origin
merge = refs/heads/master merge = refs/heads/master
... ...
</pre> </code></pre>
</div> </div>
<h2 id="branches-synchronisation">Branches Synchronisation</h2> <h2 id="branches-synchronisation">Branches Synchronisation</h2>
@ -183,53 +210,63 @@ git push
<p>Then when you want to create a new branch (locally and remotely)&nbsp;; you simply have to do a: </p> <p>Then when you want to create a new branch (locally and remotely)&nbsp;; you simply have to do a: </p>
<div><pre class="twilight">git-create-new-branch branch_name <div>
</pre></div>
<pre><code class="zsh">git-create-new-branch branch_name</code></pre>
</div>
<p>and when you are on another computer and want to get locally all the remote branches you execute: </p> <p>and when you are on another computer and want to get locally all the remote branches you execute: </p>
<div><pre class="twilight">git-get-remote-branches <div>
</pre></div>
<pre><code class="zsh">git-get-remote-branches</code></pre>
</div>
<p>Here are the code of theese two scripts: </p> <p>Here are the code of theese two scripts: </p>
<div> <div>
<div class="code"><div class="file"><a href="/Scratch/en/blog/06_How_I_use_git/code/git-create-new-branch"> &#x27A5; git-create-new-branch </a></div><div class="withfile"> <div class="codefile"><a href="/Scratch/en/blog/06_How_I_use_git/code/git-create-new-branch">&#x27A5; git-create-new-branch</a></div>
<pre class="twilight">
<span class="Comment"><span class="Comment">#</span>!/usr/bin/env zsh</span>
<span class="Keyword">if</span> ((<span class="Variable"><span class="Variable">$</span>#</span><span class="Keyword">&lt;</span>1))<span class="Keyword">;</span> <span class="Keyword">then</span>
print -- <span class="String"><span class="String">&quot;</span>usage: <span class="StringVariable"><span class="StringVariable">$</span>0</span>:t branch_name<span class="String">&quot;</span></span> <span class="Keyword">&gt;&amp;2</span> <pre><code class="zsh">#!/usr/bin/env zsh
if (($#&lt;1)); then
print -- "usage: $0:t branch_name" &gt;&amp;2
exit 1 exit 1
<span class="Keyword">fi</span> fi
branch=$1
git br ${branch}
git co ${branch}
git config branch.${branch}.remote origin
git config branch.${branch}.merge refs/heads/${branch}
</code></pre>
branch=<span class="Variable"><span class="Variable">$</span>1</span>
git br <span class="Variable"><span class="Variable">${</span>branch<span class="Variable">}</span></span>
git co <span class="Variable"><span class="Variable">${</span>branch<span class="Variable">}</span></span>
git config branch.<span class="Variable"><span class="Variable">${</span>branch<span class="Variable">}</span></span>.remote origin
git config branch.<span class="Variable"><span class="Variable">${</span>branch<span class="Variable">}</span></span>.merge refs/heads/<span class="Variable"><span class="Variable">${</span>branch<span class="Variable">}</span></span>
</pre>
</div></div>
</div> </div>
<div> <div>
<div class="code"><div class="file"><a href="/Scratch/en/blog/06_How_I_use_git/code/git-get-remote-branches"> &#x27A5; git-get-remote-branches </a></div><div class="withfile"> <div class="codefile"><a href="/Scratch/en/blog/06_How_I_use_git/code/git-get-remote-branches">&#x27A5; git-get-remote-branches</a></div>
<pre class="twilight">
<span class="Comment"><span class="Comment">#</span>!/usr/bin/env zsh</span>
<pre><code class="zsh">#!/usr/bin/env zsh
# recup branches not on local
localbranches=( $(git br | sed 's/\*/ /') )
remoteMissingBranches=( $(git br -r | \
egrep -v "origin/HEAD|(${(j:|:)localbranches})" ) )
for br in $remoteMissingBranches; do
branch=${br#origin/}
print "get remote branch $branch"
git br ${branch}
git config branch.${branch}.remote origin
git config branch.${branch}.merge refs/heads/${branch}
done
</code></pre>
<span class="Comment"><span class="Comment">#</span> recup branches not on local</span>
localbranches=( <span class="String"><span class="String">$(</span>git br <span class="Keyword">|</span> sed <span class="String"><span class="String">'</span>s/\*/ /<span class="String">'</span></span><span class="String">)</span></span> )
remoteMissingBranches=( <span class="String"><span class="String">$(</span>git br -r <span class="Keyword">|</span> \</span>
<span class="String"> egrep -v <span class="String"><span class="String">&quot;</span>origin/HEAD|(<span class="StringVariable"><span class="StringVariable">${</span>(j:|:)localbranches<span class="StringVariable">}</span></span>)<span class="String">&quot;</span></span> <span class="String">)</span></span> )
<span class="Keyword">for</span> br <span class="Keyword">in</span> <span class="Variable"><span class="Variable">$</span>remoteMissingBranches</span><span class="Keyword">;</span> <span class="Keyword">do</span>
branch=<span class="Variable"><span class="Variable">${</span>br#origin/<span class="Variable">}</span></span>
print <span class="String"><span class="String">&quot;</span>get remote branch <span class="StringVariable"><span class="StringVariable">$</span>branch</span><span class="String">&quot;</span></span>
git br <span class="Variable"><span class="Variable">${</span>branch<span class="Variable">}</span></span>
git config branch.<span class="Variable"><span class="Variable">${</span>branch<span class="Variable">}</span></span>.remote origin
git config branch.<span class="Variable"><span class="Variable">${</span>branch<span class="Variable">}</span></span>.merge refs/heads/<span class="Variable"><span class="Variable">${</span>branch<span class="Variable">}</span></span>
<span class="Keyword">done</span>
</pre>
</div></div>
</div> </div>
</div> </div>
@ -347,7 +384,7 @@ remoteMissingBranches=( <span class="String"><span class="String">$(</span>git b
</div> </div>
<div id="lastmod"> <div id="lastmod">
Created: 08/18/2009 Created: 08/18/2009
Modified: 04/20/2011 Modified: 04/26/2012
</div> </div>
<div> <div>
Entirely done with Entirely done with

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Compilation d'économiseur d'écran sous Snow Leopard<small>&copy;</small>" type="text/html" hreflang="fr" href="/Scratch/fr/blog/07_Screensaver_compilation_option_for_Snow_Leopard/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Compilation d'économiseur d'écran sous Snow Leopard<small>&copy;</small>" type="text/html" hreflang="fr" href="/Scratch/fr/blog/07_Screensaver_compilation_option_for_Snow_Leopard/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -56,15 +59,15 @@
<div class="corps"> <div class="corps">
<h1 class="first" id="how-to-recompile-your-screensaver-to-be-snow-leopardc-compatible">How to recompile your screensaver to be Snow Leopard<small>&copy;</small> compatible</h1> <h1 class="first" id="how-to-recompile-your-screensaver-to-be-snow-leopardc-compatible">How to recompile your screensaver to be Snow Leopard<small>&copy;</small> compatible</h1>
<p>I upgraded to Mac OS X 10.6 Snow Leopard<small>&copy;</small>, and my <a href="/YBlog/YClock.html">YClock</a> screensaver didn&rsquo;t work on it. After searching on google, the problem seems to be just a recompilation away. <p>I upgraded to Mac OS X 10.6 Snow Leopard<small>&copy;</small>, and my <a href="/YBlog/YClock.html">YClock</a> screensaver didnt work on it. After searching on google, the problem seems to be just a recompilation away.
Unfortunately, even recompiling it in 64 bit it didn&rsquo;t work either. Unfortunately, even recompiling it in 64 bit it didnt work either.
After a bit more research (thanks to <a href="http://community.electricsheep.org/node/236">ElectricSheep</a> ).</p> After a bit more research (thanks to <a href="http://community.electricsheep.org/node/236">ElectricSheep</a> ).</p>
<p>I discovered the good parameters for compilation.</p> <p>I discovered the good parameters for compilation.</p>
<p><img alt="XCode configuration" src="/Scratch/img/blog/07_Screensaver_compilation_option_for_Snow_Leopard/xcodeConfig.png" /></p> <p><img alt="XCode configuration" src="/Scratch/img/blog/07_Screensaver_compilation_option_for_Snow_Leopard/xcodeConfig.png" /></p>
<p>For now I didn&rsquo;t compiled it to work also on Tiger and Leopard. I don&rsquo;t know XCode enought to know how to make the Garbage collector to be disabled on 32 bits version and enabled on 64 bits version.</p> <p>For now I didnt compiled it to work also on Tiger and Leopard. I dont know XCode enought to know how to make the Garbage collector to be disabled on 32 bits version and enabled on 64 bits version.</p>
<p>It was a bit difficult to discover these informations. Hope this post helped someone.</p> <p>It was a bit difficult to discover these informations. Hope this post helped someone.</p>
@ -183,7 +186,7 @@ After a bit more research (thanks to <a href="http://community.electricsheep.org
</div> </div>
<div id="lastmod"> <div id="lastmod">
Created: 09/06/2009 Created: 09/06/2009
Modified: 01/11/2012 Modified: 04/26/2012
</div> </div>
<div> <div>
Entirely done with Entirely done with

View file

@ -1,4 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="ssh sur le port 443 avec Snow Leopard" type="text/html" hreflang="fr" href="/Scratch/fr/blog/08_Configure_ssh_to_listen_the_port_443_on_Snow_Leopard/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="ssh sur le port 443 avec Snow Leopard" type="text/html" hreflang="fr" href="/Scratch/fr/blog/08_Configure_ssh_to_listen_the_port_443_on_Snow_Leopard/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -61,9 +64,12 @@
<p>Then from my laptop or my local computer I just have to launch the marvelous</p> <p>Then from my laptop or my local computer I just have to launch the marvelous</p>
<div> <div>
<pre class="twilight">
ssh -p 443 -D 9050 username@host
</pre> <pre><code class="zsh">ssh -p 443 -D 9050 username@host
</code></pre>
</div> </div>
<p>and a local <span class="sc">socks</span> proxy listening on port 9050 is launched. The <span class="sc">socks</span> proxy will transfer local requests via the ssh tunnel. Therefore I can surf locally as if I was on my own computer. I can put password and card number without fear the local <span class="sc">wifi</span> network to be <em>sniffed</em>. I simply need to configure my web browser to user the <span class="sc">socks</span> proxy on localhost and port 9050.</p> <p>and a local <span class="sc">socks</span> proxy listening on port 9050 is launched. The <span class="sc">socks</span> proxy will transfer local requests via the ssh tunnel. Therefore I can surf locally as if I was on my own computer. I can put password and card number without fear the local <span class="sc">wifi</span> network to be <em>sniffed</em>. I simply need to configure my web browser to user the <span class="sc">socks</span> proxy on localhost and port 9050.</p>
@ -72,7 +78,7 @@ ssh -p 443 -D 9050 username@host
<h1 id="ssh-and-snow-leopardc">Ssh and Snow Leopard<small>&copy;</small></h1> <h1 id="ssh-and-snow-leopardc">Ssh and Snow Leopard<small>&copy;</small></h1>
<p>Here I don&rsquo;t want to talk about how great <span class="sc">socks</span> proxy via ssh tunneling is but how to configure my local server.</p> <p>Here I dont want to talk about how great <span class="sc">socks</span> proxy via ssh tunneling is but how to configure my local server.</p>
<p>I have Mac with Snow Leopard<small>&copy;</small> at home and it is far from enough to modify the <code>/etc/sshd.config</code> file. The system use <code>launchd</code> to launch starting daemons.</p> <p>I have Mac with Snow Leopard<small>&copy;</small> at home and it is far from enough to modify the <code>/etc/sshd.config</code> file. The system use <code>launchd</code> to launch starting daemons.</p>
@ -81,44 +87,46 @@ ssh -p 443 -D 9050 username@host
<p>Create the file <tt>/Library/LaunchDaemons/ssh-443.plist</tt> containing:</p> <p>Create the file <tt>/Library/LaunchDaemons/ssh-443.plist</tt> containing:</p>
<div> <div>
<div class="code"><div class="file"><a href="/Scratch/en/blog/08_Configure_ssh_to_listen_the_port_443_on_Snow_Leopard/code/ssh-443.plist"> &#x27A5; ssh-443.plist </a></div><div class="withfile"> <div class="codefile"><a href="/Scratch/en/blog/08_Configure_ssh_to_listen_the_port_443_on_Snow_Leopard/code/ssh-443.plist">&#x27A5; ssh-443.plist</a></div>
<pre class="twilight">
<span class="DoctypeXmlProcessing"><span class="DoctypeXmlProcessing">&lt;?</span><span class="DoctypeXmlProcessing">xml</span><span class="DoctypeXmlProcessing"> version</span>=<span class="DoctypeXmlProcessing"><span class="DoctypeXmlProcessing">&quot;</span>1.0<span class="DoctypeXmlProcessing">&quot;</span></span><span class="DoctypeXmlProcessing"> encoding</span>=<span class="DoctypeXmlProcessing"><span class="DoctypeXmlProcessing">&quot;</span>UTF-8<span class="DoctypeXmlProcessing">&quot;</span></span><span class="DoctypeXmlProcessing">?&gt;</span></span>
<span class="DoctypeXmlProcessing"><span class="DoctypeXmlProcessing">&lt;!</span><span class="DoctypeXmlProcessing">DOCTYPE</span> plist PUBLIC &quot;-//Apple Computer//DTD PLIST 1.0//EN&quot; &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;<span class="DoctypeXmlProcessing">&gt;</span></span> <pre><code class="xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">plist</span> <span class="MetaTagAll">version</span>=<span class="String"><span class="String">&quot;</span>1.0<span class="String">&quot;</span></span><span class="MetaTagAll">&gt;</span></span> &lt;!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">dict</span><span class="MetaTagAll">&gt;</span></span> &lt;plist version="1.0"&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">key</span><span class="MetaTagAll">&gt;</span></span>Disabled<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">key</span><span class="MetaTagAll">&gt;</span></span> &lt;dict&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">false</span><span class="MetaTagAll">/&gt;</span></span> &lt;key&gt;Disabled&lt;/key&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">key</span><span class="MetaTagAll">&gt;</span></span>Label<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">key</span><span class="MetaTagAll">&gt;</span></span> &lt;false/&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">string</span><span class="MetaTagAll">&gt;</span></span>local.sshd<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">string</span><span class="MetaTagAll">&gt;</span></span> &lt;key&gt;Label&lt;/key&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">key</span><span class="MetaTagAll">&gt;</span></span>Program<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">key</span><span class="MetaTagAll">&gt;</span></span> &lt;string&gt;local.sshd&lt;/string&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">string</span><span class="MetaTagAll">&gt;</span></span>/usr/libexec/sshd-keygen-wrapper<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">string</span><span class="MetaTagAll">&gt;</span></span> &lt;key&gt;Program&lt;/key&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">key</span><span class="MetaTagAll">&gt;</span></span>ProgramArguments<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">key</span><span class="MetaTagAll">&gt;</span></span> &lt;string&gt;/usr/libexec/sshd-keygen-wrapper&lt;/string&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">array</span><span class="MetaTagAll">&gt;</span></span> &lt;key&gt;ProgramArguments&lt;/key&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">string</span><span class="MetaTagAll">&gt;</span></span>/usr/sbin/sshd<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">string</span><span class="MetaTagAll">&gt;</span></span> &lt;array&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">string</span><span class="MetaTagAll">&gt;</span></span>-i<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">string</span><span class="MetaTagAll">&gt;</span></span> &lt;string&gt;/usr/sbin/sshd&lt;/string&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">array</span><span class="MetaTagAll">&gt;</span></span> &lt;string&gt;-i&lt;/string&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">key</span><span class="MetaTagAll">&gt;</span></span>Sockets<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">key</span><span class="MetaTagAll">&gt;</span></span> &lt;/array&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">dict</span><span class="MetaTagAll">&gt;</span></span> &lt;key&gt;Sockets&lt;/key&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">key</span><span class="MetaTagAll">&gt;</span></span>Listeners<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">key</span><span class="MetaTagAll">&gt;</span></span> &lt;dict&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">dict</span><span class="MetaTagAll">&gt;</span></span> &lt;key&gt;Listeners&lt;/key&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">key</span><span class="MetaTagAll">&gt;</span></span>SockServiceName<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">key</span><span class="MetaTagAll">&gt;</span></span> &lt;dict&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">string</span><span class="MetaTagAll">&gt;</span></span>https<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">string</span><span class="MetaTagAll">&gt;</span></span> &lt;key&gt;SockServiceName&lt;/key&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">dict</span><span class="MetaTagAll">&gt;</span></span> &lt;string&gt;https&lt;/string&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">dict</span><span class="MetaTagAll">&gt;</span></span> &lt;/dict&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">key</span><span class="MetaTagAll">&gt;</span></span>inetdCompatibility<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">key</span><span class="MetaTagAll">&gt;</span></span> &lt;/dict&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">dict</span><span class="MetaTagAll">&gt;</span></span> &lt;key&gt;inetdCompatibility&lt;/key&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">key</span><span class="MetaTagAll">&gt;</span></span>Wait<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">key</span><span class="MetaTagAll">&gt;</span></span> &lt;dict&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">false</span><span class="MetaTagAll">/&gt;</span></span> &lt;key&gt;Wait&lt;/key&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">dict</span><span class="MetaTagAll">&gt;</span></span> &lt;false/&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">key</span><span class="MetaTagAll">&gt;</span></span>StandardErrorPath<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">key</span><span class="MetaTagAll">&gt;</span></span> &lt;/dict&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">string</span><span class="MetaTagAll">&gt;</span></span>/dev/null<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">string</span><span class="MetaTagAll">&gt;</span></span> &lt;key&gt;StandardErrorPath&lt;/key&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">key</span><span class="MetaTagAll">&gt;</span></span>SHAuthorizationRight<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">key</span><span class="MetaTagAll">&gt;</span></span> &lt;string&gt;/dev/null&lt;/string&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">string</span><span class="MetaTagAll">&gt;</span></span>system.preferences<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">string</span><span class="MetaTagAll">&gt;</span></span> &lt;key&gt;SHAuthorizationRight&lt;/key&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">dict</span><span class="MetaTagAll">&gt;</span></span> &lt;string&gt;system.preferences&lt;/string&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">plist</span><span class="MetaTagAll">&gt;</span></span> &lt;/dict&gt;
</pre> &lt;/plist&gt;
</div></div> </code></pre>
</div> </div>
<p>It is a copy of <code>/System/Library/LaunchDaemons/ssh.plist</code> with some modifications:</p> <p>It is a copy of <code>/System/Library/LaunchDaemons/ssh.plist</code> with some modifications:</p>

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Pourquoi je n'ai pas conservé whos.amung.us" type="text/html" hreflang="fr" href="/Scratch/fr/blog/09_Why_I_didn-t_keep_whosamung-us/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Pourquoi je n'ai pas conservé whos.amung.us" type="text/html" hreflang="fr" href="/Scratch/fr/blog/09_Why_I_didn-t_keep_whosamung-us/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->

View file

@ -1,4 +1,3 @@
#!/usr/bin/env zsh #!/usr/bin/env zsh
# Author: Yann Esposito # Author: Yann Esposito

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Héberger son site personnel sur le site mobileMe" type="text/html" hreflang="fr" href="/Scratch/fr/blog/10_Synchronize_Custom_WebSite_with_mobileMe/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Héberger son site personnel sur le site mobileMe" type="text/html" hreflang="fr" href="/Scratch/fr/blog/10_Synchronize_Custom_WebSite_with_mobileMe/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -83,232 +86,236 @@
<p>The idea are: </p> <p>The idea are: </p>
<ul> <ul>
<li>synchronize to a temporary folder then swap the name therefore the website isn&rsquo;t accessible only during the swap time. It takes only the time of two rename.</li> <li>synchronize to a temporary folder then swap the name therefore the website isnt accessible only during the swap time. It takes only the time of two rename.</li>
<li>reiterate all operations until they work (for example, renaming).</li> <li>reiterate all operations until they work (for example, renaming).</li>
</ul> </ul>
<p>For now I use <code>rsync</code> which in fact is no more efficient than a simple <code>cp</code> with WebDav. And I should use a method to keep track of elements who have changed. before the publication.</p> <p>For now I use <code>rsync</code> which in fact is no more efficient than a simple <code>cp</code> with WebDav. And I should use a method to keep track of elements who have changed. before the publication.</p>
<p>In fact when I&rsquo;m on a Mac, I use <a href="http://www.panic.com/transmit">Transmit</a> which is very cool and far more efficient than the Finder to synchronize files. After the synchronization, I swap the directories.</p> <p>In fact when Im on a Mac, I use <a href="http://www.panic.com/transmit">Transmit</a> which is very cool and far more efficient than the Finder to synchronize files. After the synchronization, I swap the directories.</p>
<p>My script take a <code>-s</code> option in order to make only the swap option. It also take a <code>-a</code> in order to put the new <code>index.html</code> which should point to the new homepage (not the iWeb one).</p> <p>My script take a <code>-s</code> option in order to make only the swap option. It also take a <code>-a</code> in order to put the new <code>index.html</code> which should point to the new homepage (not the iWeb one).</p>
<p>In order to keep this script working for you, just modify the username by yours (the value of the <code>mobileMeUser</code>).</p> <p>In order to keep this script working for you, just modify the username by yours (the value of the <code>mobileMeUser</code>).</p>
<div class="fr"> <div class="fr">
<div class="code"><div class="file"><a href="/Scratch/en/blog/10_Synchronize_Custom_WebSite_with_mobileMe/code/publish"> &#x27A5; publish </a></div><div class="withfile"> <div class="codefile"><a href="/Scratch/en/blog/10_Synchronize_Custom_WebSite_with_mobileMe/code/publish">&#x27A5; publish</a></div>
<pre class="twilight">
<span class="Comment"><span class="Comment">#</span>!/usr/bin/env zsh</span>
<span class="Comment"><span class="Comment">#</span> Script synchronisant le site sur me.com</span>
<span class="Comment"><span class="Comment">#</span> normalement, le site est indisponible le moins de temps possible</span>
<span class="Comment"><span class="Comment">#</span> le temps de deux renommages de répertoire</span>
mobileMeUser=<span class="String"><span class="String">&quot;</span>yann.esposito<span class="String">&quot;</span></span> <pre><code class="zsh">#!/usr/bin/env zsh
siteName=<span class="String"><span class="String">&quot;</span>siteName<span class="String">&quot;</span></span>
<span class="Comment"><span class="Comment">#</span> Depending of my hostname the </span> # Script synchronisant le site sur me.com
<span class="Keyword">if</span> [[ <span class="String"><span class="String">$(</span>hostname<span class="String">)</span></span> <span class="Keyword">==</span> <span class="String"><span class="String">'</span>ubuntu<span class="String">'</span></span> ]]<span class="Keyword">;</span> <span class="Keyword">then</span> # normalement, le site est indisponible le moins de temps possible
iDisk=<span class="String"><span class="String">'</span>/mnt/iDisk<span class="String">'</span></span> # le temps de deux renommages de répertoire
<span class="Keyword">else</span>
iDisk=<span class="String"><span class="String">&quot;</span>/Volumes/<span class="StringVariable"><span class="StringVariable">$</span>mobileMeUser</span><span class="String">&quot;</span></span>
<span class="Keyword">fi</span>
root=<span class="Variable"><span class="Variable">$</span>HOME</span>/Sites/<span class="Variable"><span class="Variable">$</span>siteName</span> mobileMeUser="yann.esposito"
destRep=<span class="Variable"><span class="Variable">$</span>iDisk</span>/Web/Sites/<span class="Variable"><span class="Variable">$</span>siteName</span> siteName="siteName"
[[ <span class="Keyword">!</span> -d <span class="Variable"><span class="Variable">$</span>root</span> ]] <span class="Keyword">&amp;&amp;</span> { # Depending of my hostname the
print -- <span class="String"><span class="String">&quot;</span><span class="StringVariable"><span class="StringVariable">$</span>root</span> n'existe pas ; vérifiez la conf<span class="String">&quot;</span></span> <span class="Keyword">&gt;&amp;2</span><span class="Keyword">;</span> if [[ $(hostname) == 'ubuntu' ]]; then
iDisk='/mnt/iDisk'
else
iDisk="/Volumes/$mobileMeUser"
fi
root=$HOME/Sites/$siteName
destRep=$iDisk/Web/Sites/$siteName
[[ ! -d $root ]] &amp;&amp; {
print -- "$root n'existe pas ; vérifiez la conf" &gt;&2;
exit 1 exit 1
} }
[[ <span class="Keyword">!</span> -d <span class="Variable"><span class="Variable">$</span>destRep</span> ]] <span class="Keyword">&amp;&amp;</span> { [[ ! -d $destRep ]] &amp;&amp; {
print -- <span class="String"><span class="String">&quot;</span><span class="StringVariable"><span class="StringVariable">$</span>destRep</span> n'existe pas, veuillez remonter le FS<span class="String">&quot;</span></span> <span class="Keyword">&gt;&amp;2</span><span class="Keyword">;</span> print -- "$destRep n'existe pas, veuillez remonter le FS" &gt;&2;
exit 1 exit 1
} }
<span class="Keyword">if</span> [[ <span class="Variable"><span class="Variable">$</span>1</span> <span class="Keyword">==</span> <span class="String"><span class="String">'</span>-h<span class="String">'</span></span> ]]<span class="Keyword">;</span> <span class="Keyword">then</span> if [[ $1 == '-h' ]]; then
print -- <span class="String"><span class="String">&quot;</span>usage: <span class="StringVariable"><span class="StringVariable">$</span>0</span>:h [-h|-a|-s]<span class="String">&quot;</span></span> print -- "usage: $0:h [-h|-a|-s]"
print -- <span class="String"><span class="String">&quot;</span> -a sychronise aussi l'index<span class="String">&quot;</span></span> print -- " -a sychronise aussi l'index"
print -- <span class="String"><span class="String">&quot;</span> -h affiche l'aide<span class="String">&quot;</span></span> print -- " -h affiche l'aide"
print -- <span class="String"><span class="String">&quot;</span> -s swappe simplement les répertoires<span class="String">&quot;</span></span> print -- " -s swappe simplement les répertoires"
<span class="Keyword">fi</span> fi
<span class="Keyword">if</span> [[ <span class="Variable"><span class="Variable">$</span>1</span> <span class="Keyword">==</span> <span class="String"><span class="String">'</span>-a<span class="String">'</span></span> ]]<span class="Keyword">;</span> <span class="Keyword">then</span> if [[ $1 == '-a' ]]; then
print -- <span class="String"><span class="String">&quot;</span>Synchronisation de l'index (<span class="StringVariable"><span class="StringVariable">${</span>destRep:h<span class="StringVariable">}</span></span>)<span class="String">&quot;</span></span> print -- "Synchronisation de l'index (${destRep:h})"
rsync -av <span class="Variable"><span class="Variable">$</span>root</span>/index.html <span class="Variable"><span class="Variable">${</span>destRep:h<span class="Variable">}</span></span>/index.html rsync -av $root/index.html ${destRep:h}/index.html
<span class="Keyword">fi</span> fi
print -- <span class="String"><span class="String">&quot;</span>Root = <span class="StringVariable"><span class="StringVariable">$</span>root</span><span class="String">&quot;</span></span> print -- "Root = $root"
print -- <span class="String"><span class="String">&quot;</span>Dest = <span class="StringVariable"><span class="StringVariable">$</span>destRep</span><span class="String">&quot;</span></span> print -- "Dest = $destRep"
<span class="Keyword">if</span> [[ <span class="Keyword">!</span> <span class="Variable"><span class="Variable">$</span>1</span> = <span class="String"><span class="String">'</span>-s<span class="String">'</span></span> ]]<span class="Keyword">;</span> <span class="Keyword">then</span> if [[ ! $1 = '-s' ]]; then
[[ <span class="Keyword">!</span> -d <span class="Variable"><span class="Variable">$</span>destRep</span>.tmp ]] <span class="Keyword">&amp;&amp;</span> mkdir <span class="Variable"><span class="Variable">$</span>destRep</span>.tmp [[ ! -d $destRep.tmp ]] &amp;&amp; mkdir $destRep.tmp
print -P -- <span class="String"><span class="String">&quot;</span>%B[Sync =&gt; tmp]%b<span class="String">&quot;</span></span> print -P -- "%B[Sync =&gt; tmp]%b"
result=1 result=1
essai=1 essai=1
<span class="Keyword">while</span> (( <span class="Variable"><span class="Variable">$</span>result</span> <span class="Keyword">&gt;</span> 0 ))<span class="Keyword">;</span> <span class="Keyword">do</span> while (( $result &gt; 0 )); do
rsync -arv <span class="Variable"><span class="Variable">$</span>root</span>/Scratch/ <span class="Variable"><span class="Variable">$</span>destRep</span>.tmp rsync -arv $root/Scratch/ $destRep.tmp
result=<span class="Variable"><span class="Variable">$</span>?</span> result=$?
<span class="Keyword">if</span> (( <span class="Variable"><span class="Variable">$</span>result</span> <span class="Keyword">&gt;</span> 0 ))<span class="Keyword">;</span> <span class="Keyword">then</span> if (( $result &gt; 0 )); then
print -P -- <span class="String"><span class="String">&quot;</span>%BEchec du rsync%b (essai n°<span class="StringVariable"><span class="StringVariable">$</span>essai</span>)<span class="String">&quot;</span></span> <span class="Keyword">&gt;&amp;2</span> print -P -- "%BEchec du rsync%b (essai n°$essai)" &gt;&amp;2
<span class="Keyword">fi</span> fi
((essai++)) ((essai++))
<span class="Keyword">done</span> done
<span class="Keyword">fi</span> fi
<span class="Comment"><span class="Comment">#</span> SWAP</span> # SWAP
print -P -- <span class="String"><span class="String">&quot;</span>%B[Swap des Répertoires (tmp &lt;=&gt; target)]%b<span class="String">&quot;</span></span> print -P -- "%B[Swap des Répertoires (tmp &lt;=&gt; target)]%b"
essai=1 essai=1
<span class="Keyword">while</span> [[ -e <span class="Variable"><span class="Variable">$</span>destRep</span>.old ]]<span class="Keyword">;</span> <span class="Keyword">do</span> while [[ -e $destRep.old ]]; do
print -n -- <span class="String"><span class="String">&quot;</span>suppression de <span class="StringVariable"><span class="StringVariable">$</span>destRep</span>.old<span class="String">&quot;</span></span> print -n -- "suppression de $destRep.old"
<span class="Keyword">if</span> ((essai<span class="Keyword">&gt;</span>1))<span class="Keyword">;</span> <span class="Keyword">then</span> if ((essai&gt;1)); then
print <span class="String"><span class="String">&quot;</span> (essai n°<span class="StringVariable"><span class="StringVariable">$</span>essai</span>)<span class="String">&quot;</span></span> print " (essai n°$essai)"
<span class="Keyword">else</span> else
print print
<span class="Keyword">fi</span> fi
((essai++)) ((essai++))
<span class="Constant">\r</span>m -rf <span class="Variable"><span class="Variable">$</span>destRep</span>.old \rm -rf $destRep.old
<span class="Keyword">done</span> done
print -- <span class="String"><span class="String">&quot;</span> renommage du repertoire sandard vers le .old<span class="String">&quot;</span></span> print -- " renommage du repertoire sandard vers le .old"
essai=1 essai=1
<span class="Keyword">while</span> [[ -e <span class="Variable"><span class="Variable">$</span>destRep</span> ]]<span class="Keyword">;</span> <span class="Keyword">do</span> while [[ -e $destRep ]]; do
mv <span class="Variable"><span class="Variable">$</span>destRep</span> <span class="Variable"><span class="Variable">$</span>destRep</span>.old mv $destRep $destRep.old
((<span class="Variable"><span class="Variable">$</span>?</span>)) <span class="Keyword">&amp;&amp;</span> print -- <span class="String"><span class="String">&quot;</span>Echec du renommage (essai n°<span class="StringVariable"><span class="StringVariable">$</span>essai</span>)<span class="String">&quot;</span></span> <span class="Keyword">&gt;&amp;2</span> (($?)) &amp;&amp; print -- "Echec du renommage (essai n°$essai)" &gt;&amp;2
((essai++)) ((essai++))
<span class="Keyword">done</span> done
print -- <span class="String"><span class="String">&quot;</span> renommage du repertoire tmp (nouveau) vers le standard<span class="String">&quot;</span></span> print -- " renommage du repertoire tmp (nouveau) vers le standard"
print -P -- <span class="String"><span class="String">&quot;</span> %BSite Indisponible%b <span class="String"><span class="String">$(</span>date<span class="String">)</span></span><span class="String">&quot;</span></span> print -P -- " %BSite Indisponible%b $(date)"
essai=1 essai=1
<span class="Keyword">while</span> [[ <span class="Keyword">!</span> -e <span class="Variable"><span class="Variable">$</span>destRep</span> ]]<span class="Keyword">;</span> <span class="Keyword">do</span> while [[ ! -e $destRep ]]; do
mv <span class="Variable"><span class="Variable">$</span>destRep</span>.tmp <span class="Variable"><span class="Variable">$</span>destRep</span> mv $destRep.tmp $destRep
((<span class="Variable"><span class="Variable">$</span>?</span>)) <span class="Keyword">&amp;&amp;</span> print -P -- <span class="String"><span class="String">&quot;</span>%B[Site Indisponible]%b(essai n°<span class="StringVariable"><span class="StringVariable">$</span>essai</span>) Echec du renommage (mv <span class="StringVariable"><span class="StringVariable">$</span>destRep</span>.tmp <span class="StringVariable"><span class="StringVariable">$</span>destRep</span>)<span class="String">&quot;</span></span> <span class="Keyword">&gt;&amp;2</span> (($?)) &amp;&amp; print -P -- "%B[Site Indisponible]%b(essai n°$essai) Echec du renommage (mv $destRep.tmp $destRep)" &gt;&amp;2
((essai++)) ((essai++))
<span class="Keyword">done</span> done
print -P -- <span class="String"><span class="String">&quot;</span>\t===\t%BSITE DISPONIBLE%b\t===<span class="String">&quot;</span></span> print -P -- "\t===\t%BSITE DISPONIBLE%b\t==="
print -- <span class="String"><span class="String">&quot;</span> renommage du repertoire old vers le tmp<span class="String">&quot;</span></span> print -- " renommage du repertoire old vers le tmp"
essai=1 essai=1
<span class="Keyword">while</span> [[ <span class="Keyword">!</span> -e <span class="Variable"><span class="Variable">$</span>destRep</span> ]]<span class="Keyword">;</span> <span class="Keyword">do</span> while [[ ! -e $destRep ]]; do
mv <span class="Variable"><span class="Variable">$</span>destRep</span>.old <span class="Variable"><span class="Variable">$</span>destRep</span>.tmp mv $destRep.old $destRep.tmp
((<span class="Variable"><span class="Variable">$</span>?</span>)) <span class="Keyword">&amp;&amp;</span> print -P -- <span class="String"><span class="String">&quot;</span>Echec du renommage n°<span class="StringVariable"><span class="StringVariable">$</span>essai</span><span class="String">&quot;</span></span> <span class="Keyword">&gt;&amp;2</span> (($?)) &amp;&amp; print -P -- "Echec du renommage n°$essai" &gt;&amp;2
((essai++)) ((essai++))
<span class="Keyword">done</span> done
print -P -- " publication terminée"
</code></pre>
print -P -- <span class="String"><span class="String">&quot;</span> publication terminée<span class="String">&quot;</span></span>
</pre>
</div></div>
</div> </div>
<div class="en"> <div class="en">
<div class="code"><div class="file"><a href="/Scratch/en/blog/10_Synchronize_Custom_WebSite_with_mobileMe/code/publish"> &#x27A5; publish </a></div><div class="withfile"> <div class="codefile"><a href="/Scratch/en/blog/10_Synchronize_Custom_WebSite_with_mobileMe/code/publish">&#x27A5; publish</a></div>
<pre class="twilight">
<span class="Comment"><span class="Comment">#</span>!/usr/bin/env zsh</span>
<span class="Comment"><span class="Comment">#</span> Author: Yann Esposito</span>
<span class="Comment"><span class="Comment">#</span> Mail: yann.esposito@gmail.com</span>
<span class="Comment"><span class="Comment">#</span> Synchronize with &quot;mobileMe&quot; iDisk account.</span>
mobileMeUser=<span class="String"><span class="String">&quot;</span>firstname.lastname<span class="String">&quot;</span></span> <pre><code class="zsh">#!/usr/bin/env zsh
siteName=<span class="String"><span class="String">&quot;</span>siteName<span class="String">&quot;</span></span>
<span class="Comment"><span class="Comment">#</span> Depending of my hostname the </span> # Author: Yann Esposito
<span class="Keyword">if</span> [[ <span class="String"><span class="String">$(</span>hostname<span class="String">)</span></span> <span class="Keyword">==</span> <span class="String"><span class="String">'</span>ubuntu<span class="String">'</span></span> ]]<span class="Keyword">;</span> <span class="Keyword">then</span> # Mail: yann.esposito@gmail.com
iDisk=<span class="String"><span class="String">'</span>/mnt/iDisk<span class="String">'</span></span> # Synchronize with "mobileMe" iDisk account.
<span class="Keyword">else</span>
iDisk=<span class="String"><span class="String">&quot;</span>/Volumes/<span class="StringVariable"><span class="StringVariable">$</span>mobileMeUser</span><span class="String">&quot;</span></span>
<span class="Keyword">fi</span>
root=<span class="Variable"><span class="Variable">$</span>HOME</span>/Sites/<span class="Variable"><span class="Variable">$</span>siteName</span> mobileMeUser="firstname.lastname"
destRep=<span class="Variable"><span class="Variable">$</span>iDisk</span>/Web/Sites/<span class="Variable"><span class="Variable">$</span>siteName</span> siteName="siteName"
[[ <span class="Keyword">!</span> -d <span class="Variable"><span class="Variable">$</span>root</span> ]] <span class="Keyword">&amp;&amp;</span> { # Depending of my hostname the
print -- <span class="String"><span class="String">&quot;</span><span class="StringVariable"><span class="StringVariable">$</span>root</span> does not exist ; please verify the configuration (<span class="StringVariable"><span class="StringVariable">$</span>0</span>)<span class="String">&quot;</span></span> <span class="Keyword">&gt;&amp;2</span><span class="Keyword">;</span> if [[ $(hostname) == 'ubuntu' ]]; then
iDisk='/mnt/iDisk'
else
iDisk="/Volumes/$mobileMeUser"
fi
root=$HOME/Sites/$siteName
destRep=$iDisk/Web/Sites/$siteName
[[ ! -d $root ]] &amp;&amp; {
print -- "$root does not exist ; please verify the configuration ($0)" &gt;&2;
exit 1 exit 1
} }
[[ <span class="Keyword">!</span> -d <span class="Variable"><span class="Variable">$</span>destRep</span> ]] <span class="Keyword">&amp;&amp;</span> { [[ ! -d $destRep ]] &amp;&amp; {
print -- <span class="String"><span class="String">&quot;</span><span class="StringVariable"><span class="StringVariable">$</span>destRep</span> does not exist, please mount the filesystem<span class="String">&quot;</span></span> <span class="Keyword">&gt;&amp;2</span><span class="Keyword">;</span> print -- "$destRep does not exist, please mount the filesystem" &gt;&2;
exit 1 exit 1
} }
<span class="Keyword">if</span> [[ <span class="Variable"><span class="Variable">$</span>1</span> <span class="Keyword">==</span> <span class="String"><span class="String">'</span>-h<span class="String">'</span></span> ]]<span class="Keyword">;</span> <span class="Keyword">then</span> if [[ $1 == '-h' ]]; then
print -- <span class="String"><span class="String">&quot;</span>usage: <span class="StringVariable"><span class="StringVariable">$</span>0</span>:h [-h|-a|-s]<span class="String">&quot;</span></span> print -- "usage: $0:h [-h|-a|-s]"
print -- <span class="String"><span class="String">&quot;</span> -a sychronize primary index<span class="String">&quot;</span></span> print -- " -a sychronize primary index"
print -- <span class="String"><span class="String">&quot;</span> -h show this help<span class="String">&quot;</span></span> print -- " -h show this help"
print -- <span class="String"><span class="String">&quot;</span> -s only swap directories<span class="String">&quot;</span></span> print -- " -s only swap directories"
<span class="Keyword">fi</span> fi
<span class="Keyword">if</span> [[ <span class="Variable"><span class="Variable">$</span>1</span> <span class="Keyword">==</span> <span class="String"><span class="String">'</span>-a<span class="String">'</span></span> ]]<span class="Keyword">;</span> <span class="Keyword">then</span> if [[ $1 == '-a' ]]; then
print -- <span class="String"><span class="String">&quot;</span>Index synchronisation (<span class="StringVariable"><span class="StringVariable">${</span>destRep:h<span class="StringVariable">}</span></span>)<span class="String">&quot;</span></span> print -- "Index synchronisation (${destRep:h})"
rsync -av <span class="Variable"><span class="Variable">$</span>root</span>/index.html <span class="Variable"><span class="Variable">${</span>destRep:h<span class="Variable">}</span></span>/index.html rsync -av $root/index.html ${destRep:h}/index.html
<span class="Keyword">fi</span> fi
print -- <span class="String"><span class="String">&quot;</span>Root = <span class="StringVariable"><span class="StringVariable">$</span>root</span><span class="String">&quot;</span></span> print -- "Root = $root"
print -- <span class="String"><span class="String">&quot;</span>Dest = <span class="StringVariable"><span class="StringVariable">$</span>destRep</span><span class="String">&quot;</span></span> print -- "Dest = $destRep"
<span class="Keyword">if</span> [[ <span class="Keyword">!</span> <span class="Variable"><span class="Variable">$</span>1</span> = <span class="String"><span class="String">'</span>-s<span class="String">'</span></span> ]]<span class="Keyword">;</span> <span class="Keyword">then</span> if [[ ! $1 = '-s' ]]; then
[[ <span class="Keyword">!</span> -d <span class="Variable"><span class="Variable">$</span>destRep</span>.tmp ]] <span class="Keyword">&amp;&amp;</span> mkdir <span class="Variable"><span class="Variable">$</span>destRep</span>.tmp [[ ! -d $destRep.tmp ]] &amp;&amp; mkdir $destRep.tmp
print -P -- <span class="String"><span class="String">&quot;</span>%B[Sync =&gt; tmp]%b<span class="String">&quot;</span></span> print -P -- "%B[Sync =&gt; tmp]%b"
result=1 result=1
essai=1 essai=1
<span class="Keyword">while</span> (( <span class="Variable"><span class="Variable">$</span>result</span> <span class="Keyword">&gt;</span> 0 ))<span class="Keyword">;</span> <span class="Keyword">do</span> while (( $result &gt; 0 )); do
rsync -arv <span class="Variable"><span class="Variable">$</span>root</span>/Scratch/ <span class="Variable"><span class="Variable">$</span>destRep</span>.tmp rsync -arv $root/Scratch/ $destRep.tmp
result=<span class="Variable"><span class="Variable">$</span>?</span> result=$?
<span class="Keyword">if</span> (( <span class="Variable"><span class="Variable">$</span>result</span> <span class="Keyword">&gt;</span> 0 ))<span class="Keyword">;</span> <span class="Keyword">then</span> if (( $result &gt; 0 )); then
print -P -- <span class="String"><span class="String">&quot;</span>%Brsync failed%b (try n°<span class="StringVariable"><span class="StringVariable">$</span>essai</span>)<span class="String">&quot;</span></span> <span class="Keyword">&gt;&amp;2</span> print -P -- "%Brsync failed%b (try n°$essai)" &gt;&amp;2
<span class="Keyword">fi</span> fi
((essai++)) ((essai++))
<span class="Keyword">done</span> done
<span class="Keyword">fi</span> fi
<span class="Comment"><span class="Comment">#</span> SWAP</span> # SWAP
print -P -- <span class="String"><span class="String">&quot;</span>%B[Directory Swap (tmp &lt;=&gt; target)]%b<span class="String">&quot;</span></span> print -P -- "%B[Directory Swap (tmp &lt;=&gt; target)]%b"
essai=1 essai=1
<span class="Keyword">while</span> [[ -e <span class="Variable"><span class="Variable">$</span>destRep</span>.old ]]<span class="Keyword">;</span> <span class="Keyword">do</span> while [[ -e $destRep.old ]]; do
print -n -- <span class="String"><span class="String">&quot;</span>remove <span class="StringVariable"><span class="StringVariable">$</span>destRep</span>.old<span class="String">&quot;</span></span> print -n -- "remove $destRep.old"
<span class="Keyword">if</span> ((essai<span class="Keyword">&gt;</span>1))<span class="Keyword">;</span> <span class="Keyword">then</span> if ((essai&gt;1)); then
print <span class="String"><span class="String">&quot;</span> (try n°<span class="StringVariable"><span class="StringVariable">$</span>essai</span>)<span class="String">&quot;</span></span> print " (try n°$essai)"
<span class="Keyword">else</span> else
print print
<span class="Keyword">fi</span> fi
((essai++)) ((essai++))
<span class="Constant">\r</span>m -rf <span class="Variable"><span class="Variable">$</span>destRep</span>.old \rm -rf $destRep.old
<span class="Keyword">done</span> done
print -- <span class="String"><span class="String">&quot;</span> renommage du repertoire sandard vers le .old<span class="String">&quot;</span></span> print -- " renommage du repertoire sandard vers le .old"
essai=1 essai=1
<span class="Keyword">while</span> [[ -e <span class="Variable"><span class="Variable">$</span>destRep</span> ]]<span class="Keyword">;</span> <span class="Keyword">do</span> while [[ -e $destRep ]]; do
mv <span class="Variable"><span class="Variable">$</span>destRep</span> <span class="Variable"><span class="Variable">$</span>destRep</span>.old mv $destRep $destRep.old
((<span class="Variable"><span class="Variable">$</span>?</span>)) <span class="Keyword">&amp;&amp;</span> print -- <span class="String"><span class="String">&quot;</span>Failed to rename (try n°<span class="StringVariable"><span class="StringVariable">$</span>essai</span>)<span class="String">&quot;</span></span> <span class="Keyword">&gt;&amp;2</span> (($?)) &amp;&amp; print -- "Failed to rename (try n°$essai)" &gt;&amp;2
((essai++)) ((essai++))
<span class="Keyword">done</span> done
print -- <span class="String"><span class="String">&quot;</span> renaming folder tmp (new) to the standard one<span class="String">&quot;</span></span> print -- " renaming folder tmp (new) to the standard one"
print -P -- <span class="String"><span class="String">&quot;</span> %BThe WebSite isn't working%b <span class="String"><span class="String">$(</span>date<span class="String">)</span></span><span class="String">&quot;</span></span> print -P -- " %BThe WebSite isn't working%b $(date)"
essai=1 essai=1
<span class="Keyword">while</span> [[ <span class="Keyword">!</span> -e <span class="Variable"><span class="Variable">$</span>destRep</span> ]]<span class="Keyword">;</span> <span class="Keyword">do</span> while [[ ! -e $destRep ]]; do
mv <span class="Variable"><span class="Variable">$</span>destRep</span>.tmp <span class="Variable"><span class="Variable">$</span>destRep</span> mv $destRep.tmp $destRep
((<span class="Variable"><span class="Variable">$</span>?</span>)) <span class="Keyword">&amp;&amp;</span> print -P -- <span class="String"><span class="String">&quot;</span>%B[WebSite not working]%b(try n°<span class="StringVariable"><span class="StringVariable">$</span>essai</span>) Failed to rename (mv <span class="StringVariable"><span class="StringVariable">$</span>destRep</span>.tmp <span class="StringVariable"><span class="StringVariable">$</span>destRep</span>)<span class="String">&quot;</span></span> <span class="Keyword">&gt;&amp;2</span> (($?)) &amp;&amp; print -P -- "%B[WebSite not working]%b(try n°$essai) Failed to rename (mv $destRep.tmp $destRep)" &gt;&amp;2
((essai++)) ((essai++))
<span class="Keyword">done</span> done
print -P -- <span class="String"><span class="String">&quot;</span>\t===\t%BWEBSITE SHOULD WORK NOW%b\t===<span class="String">&quot;</span></span> print -P -- "\t===\t%BWEBSITE SHOULD WORK NOW%b\t==="
print -- <span class="String"><span class="String">&quot;</span> rename old folder to tmp folder<span class="String">&quot;</span></span> print -- " rename old folder to tmp folder"
essai=1 essai=1
<span class="Keyword">while</span> [[ <span class="Keyword">!</span> -e <span class="Variable"><span class="Variable">$</span>destRep</span> ]]<span class="Keyword">;</span> <span class="Keyword">do</span> while [[ ! -e $destRep ]]; do
mv <span class="Variable"><span class="Variable">$</span>destRep</span>.old <span class="Variable"><span class="Variable">$</span>destRep</span>.tmp mv $destRep.old $destRep.tmp
((<span class="Variable"><span class="Variable">$</span>?</span>)) <span class="Keyword">&amp;&amp;</span> print -P -- <span class="String"><span class="String">&quot;</span>Failed to rename n°<span class="StringVariable"><span class="StringVariable">$</span>essai</span><span class="String">&quot;</span></span> <span class="Keyword">&gt;&amp;2</span> (($?)) &amp;&amp; print -P -- "Failed to rename n°$essai" &gt;&amp;2
((essai++)) ((essai++))
<span class="Keyword">done</span> done
print -P -- " Publish terminated"
</code></pre>
print -P -- <span class="String"><span class="String">&quot;</span> Publish terminated<span class="String">&quot;</span></span>
</pre>
</div></div>
</div> </div>
</div> </div>

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Load Disqus Asynchronously [en]" type="text/html" hreflang="fr" href="/Scratch/fr/blog/11_Load_Disqus_Asynchronously/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Load Disqus Asynchronously [en]" type="text/html" hreflang="fr" href="/Scratch/fr/blog/11_Load_Disqus_Asynchronously/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -58,7 +61,7 @@
<p>In fact this method works for old threads. But it fails to create new post threads. This is why I tried and be conquered by <a href="http://intensedebate.com">intensedebate</a>, as you can see in the bottom of this page.</p> <p>In fact this method works for old threads. But it fails to create new post threads. This is why I tried and be conquered by <a href="http://intensedebate.com">intensedebate</a>, as you can see in the bottom of this page.</p>
<p>Remark I didn&rsquo;t have any comment on my blog when I switched. Therefore my lack of influence was a good thing&nbsp;:-).</p> <p>Remark I didnt have any comment on my blog when I switched. Therefore my lack of influence was a good thing&nbsp;:-).</p>
</div> </div>
@ -72,7 +75,7 @@
<p>I also know there is a jQuery plugin to make just that. Unfortunately I had some issue with CSS.</p> <p>I also know there is a jQuery plugin to make just that. Unfortunately I had some issue with CSS.</p>
<p><em>Now let&rsquo;s begin.</em></p> <p><em>Now lets begin.</em></p>
</div> </div>
@ -85,7 +88,7 @@
<p>Why should I want to load the disqus javascript asynchronously?</p> <p>Why should I want to load the disqus javascript asynchronously?</p>
<ul> <ul>
<li>Efficiency: I don&rsquo;t want my page to wait the complete execution of disqus script to load.</li> <li>Efficiency: I dont want my page to wait the complete execution of disqus script to load.</li>
<li>More independance: when disqus is down, my page is blocked!</li> <li>More independance: when disqus is down, my page is blocked!</li>
</ul> </ul>
@ -97,27 +100,33 @@
<h1 class="first" id="how">How?</h1> <h1 class="first" id="how">How?</h1>
<p>I give a solution with jQuery, but I&rsquo;m certain it will work with many other js library.</p> <p>I give a solution with jQuery, but Im certain it will work with many other js library.</p>
<h3 id="javascript">Javascript</h3> <h3 id="javascript">Javascript</h3>
<p>replace:</p> <p>replace:</p>
<div> <div>
<pre class="twilight">
<span class="Keyword">&lt;</span>script type<span class="Keyword">=</span><span class="String"><span class="String">&quot;</span>text/javascript<span class="String">&quot;</span></span> src<span class="Keyword">=</span><span class="String"><span class="String">&quot;</span>http://disqus.com/forums/YOUR_DISQUS_ID/embed.js<span class="String">&quot;</span></span><span class="Keyword">&gt;</span><span class="Keyword">&lt;</span>/script<span class="Keyword">&gt;</span>
</pre> <pre><code class="javascript">&lt;script type="text/javascript" src="http://disqus.com/forums/YOUR_DISQUS_ID/embed.js"&gt;&lt;/script&gt;
</code></pre>
</div> </div>
<p>by</p> <p>by</p>
<div> <div>
<pre class="twilight">
<span class="Support">window</span>.disqus_no_style<span class="Keyword">=</span><span class="Constant">true</span>;
<span class="Keyword">$</span>(<span class="Support">document</span>).ready(<span class="Storage">function</span>(){ <pre><code class="javascript">window.disqus_no_style=true;
<span class="Keyword">$</span>.getScript(<span class="String"><span class="String">&quot;</span>http://disqus.com/forums/YOUR_DISQUS_ID/embed.js<span class="String">&quot;</span></span>); $(document).ready(function(){
$.getScript("http://disqus.com/forums/YOUR_DISQUS_ID/embed.js");
}); });
</pre> </code></pre>
</div> </div>
<p>If you forget the <code>window.disqus_no_style=true;</code> then your page will be blank. Simply because without this option, the javascript use a <code>document.write</code> action after the document was closed, which cause a complete erasing of it.</p> <p>If you forget the <code>window.disqus_no_style=true;</code> then your page will be blank. Simply because without this option, the javascript use a <code>document.write</code> action after the document was closed, which cause a complete erasing of it.</p>
@ -127,7 +136,7 @@
<p>But with this option you still need to provide a CSS. This is why you have to copy the css code from the <code>embed.js</code> file and rewrite it in a CSS file. You can <a href="/Scratch/en/blog/11_Load_Disqus_Asynchronously/code/original_disqus.css">download the CSS</a> I obtained.</p> <p>But with this option you still need to provide a CSS. This is why you have to copy the css code from the <code>embed.js</code> file and rewrite it in a CSS file. You can <a href="/Scratch/en/blog/11_Load_Disqus_Asynchronously/code/original_disqus.css">download the CSS</a> I obtained.</p>
<hr /> <hr />
<p>Now it&rsquo;s done. I believe all should be fine but I just finished the manip for my own site only 1 hour ago. Therefore there should be some error, tell me if it is the case.</p> <p>Now its done. I believe all should be fine but I just finished the manip for my own site only 1 hour ago. Therefore there should be some error, tell me if it is the case.</p>
</div> </div>

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Disqus contre Intense Debate (pourquois j'ai changé)" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2009-09-Disqus-versus-Intense-Debate--Why-I-switched-/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Disqus contre Intense Debate (pourquois j'ai changé)" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2009-09-Disqus-versus-Intense-Debate--Why-I-switched-/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -56,7 +59,7 @@
<div class="corps"> <div class="corps">
<h1 class="first" id="disqushttpdisquscom-vs-intense-debatehttpintensedebatecom"><a href="http://disqus.com/">Disqus</a> <em>vs.</em> <a href="http://intensedebate.com/">Intense Debate</a></h1> <h1 class="first" id="disqushttpdisquscom-vs-intense-debatehttpintensedebatecom"><a href="http://disqus.com/">Disqus</a> <em>vs.</em> <a href="http://intensedebate.com/">Intense Debate</a></h1>
<p>I made a blog entry about how I tried to integrate <a href="http://disqus.com">Disqus</a>. I had to wait Disqus comment to be displayed before loading correctly my page. This is why I tried to include it in a &ldquo;non-blocking&rdquo; way. Unfortunately, I had <a href="/Scratch/en/blog/11_Load_Disqus_Asynchronously/">difficulties to make it works correctly</a>. </p> <p>I made a blog entry about how I tried to integrate <a href="http://disqus.com">Disqus</a>. I had to wait Disqus comment to be displayed before loading correctly my page. This is why I tried to include it in a “non-blocking” way. Unfortunately, I had <a href="/Scratch/en/blog/11_Load_Disqus_Asynchronously/">difficulties to make it works correctly</a>. </p>
<p>Furthermore, it was not trivial to make comment to be shared between multiple version of the same page (each page has three differents representations, one for each language and one more for the multi-language version).</p> <p>Furthermore, it was not trivial to make comment to be shared between multiple version of the same page (each page has three differents representations, one for each language and one more for the multi-language version).</p>
@ -64,22 +67,28 @@
<p>During the time I tried to integrate <a href="http://disqus.com/">Disqus</a> I never tried <a href="http://intensedebate.com">Intense Debate</a>. Now that I have tried, i must confess it does exactly what I needed. </p> <p>During the time I tried to integrate <a href="http://disqus.com/">Disqus</a> I never tried <a href="http://intensedebate.com">Intense Debate</a>. Now that I have tried, i must confess it does exactly what I needed. </p>
<p>In order to make it fully asynchronous, you&rsquo;ve just to download their common js and replace the following line:</p> <p>In order to make it fully asynchronous, youve just to download their common js and replace the following line:</p>
<div> <div>
<pre class="twilight">
<span class="Support">document</span>.<span class="SupportFunction">getElementsByTagName</span>(<span class="String"><span class="String">&quot;</span>head<span class="String">&quot;</span></span>)[<span class="Constant">0</span>].<span class="SupportFunction">appendChild</span>(commentScript);
</pre> <pre><code class="javascript">document.getElementsByTagName("head")[0].appendChild(commentScript);
</code></pre>
</div> </div>
<p>by: </p> <p>by: </p>
<div> <div>
<pre class="twilight">
<span class="Keyword">$</span>(<span class="Support">document</span>).ready( <span class="Storage">function</span>() {
<span class="Support">document</span>.<span class="SupportFunction">getElementsByTagName</span>(<span class="String"><span class="String">&quot;</span>head<span class="String">&quot;</span></span>)[<span class="Constant">0</span>].<span class="SupportFunction">appendChild</span>(commentScript); <pre><code class="javascript">$(document).ready( function() {
document.getElementsByTagName("head")[0].appendChild(commentScript);
}); });
</pre> </code></pre>
</div> </div>
<h2 id="and-the-winner-is-intense-debatehttpintensedebatecom">And the Winner is: <a href="http://intensedebate.com/">Intense Debate</a></h2> <h2 id="and-the-winner-is-intense-debatehttpintensedebatecom">And the Winner is: <a href="http://intensedebate.com/">Intense Debate</a></h2>
@ -87,8 +96,8 @@
<p>To conclude, main advantages (for me) of <a href="http://intensedebate.com/">Intense Debate</a> over <a href="http://disqus.com/">Disqus</a>: </p> <p>To conclude, main advantages (for me) of <a href="http://intensedebate.com/">Intense Debate</a> over <a href="http://disqus.com/">Disqus</a>: </p>
<ul> <ul>
<li>Load Asynchronously&nbsp;; don&rsquo;t block my website</li> <li>Load Asynchronously&nbsp;; dont block my website</li>
<li>Add for free buttons like &ldquo;share to any&rdquo; and load them <strong>asynchronously</strong>.</li> <li>Add for free buttons like “share to any” and load them <strong>asynchronously</strong>.</li>
</ul> </ul>
<p>Voilà.</p> <p>Voilà.</p>

File diff suppressed because one or more lines are too long

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Remplacer tout sauf une partie" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2009-09-replace-all-except-some-part/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Remplacer tout sauf une partie" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2009-09-replace-all-except-some-part/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -56,11 +59,12 @@
<div class="corps"> <div class="corps">
<p>My problem is simple:</p> <p>My problem is simple:</p>
<p>I want to filter a text except some part of it. I can match easily the part I don&rsquo;t want to be filtered. For example</p> <p>I want to filter a text except some part of it. I can match easily the part I dont want to be filtered. For example</p>
<div> <div>
<pre class="twilight">
...
<pre><code class="html">...
text text
... ...
BEGIN not to filter BEGIN not to filter
@ -71,66 +75,77 @@ END not to filter
... ...
text text
... ...
</pre> </code></pre>
</div> </div>
<p>I searched a better way to do that, but the best I can do is using <code>split</code> and <code>scan</code>.</p> <p>I searched a better way to do that, but the best I can do is using <code>split</code> and <code>scan</code>.</p>
<div> <div>
<pre class="twilight">
<span class="Keyword">def</span> <span class="Entity">allExceptCode</span>(<span class="Variable"> f<span class="Variable">,</span> content </span>)
<span class="Comment"> <span class="Comment">#</span> Beware the behaviour will change if you add</span> <pre><code class="ruby">def allExceptCode( f, content )
<span class="Comment"> <span class="Comment">#</span> parenthesis (groups) to the regexp!</span> # Beware the behaviour will change if you add
regexp<span class="Keyword">=</span><span class="StringRegexp"><span class="StringRegexp">/</span></span><span class="StringRegexp">&lt;code<span class="StringRegexp"><span class="StringRegexp">[</span>^&gt;<span class="StringRegexp">]</span></span>*&gt;.*?&lt;<span class="StringRegexpSpecial">\/</span>code&gt;|&lt;pre<span class="StringRegexp"><span class="StringRegexp">[</span>^&gt;<span class="StringRegexp">]</span></span>*&gt;.*?&lt;<span class="StringRegexpSpecial">\/</span>pre&gt;</span><span class="StringRegexp"><span class="StringRegexp">/m</span></span> # parenthesis (groups) to the regexp!
tmp<span class="Keyword">=</span><span class="String"><span class="String">&quot;</span><span class="String">&quot;</span></span> regexp=/&lt;code[^&gt;]*&gt;.*?&lt;\/code&gt;|&lt;pre[^&gt;]*&gt;.*?&lt;\/pre&gt;/m
mem<span class="Keyword">=</span>[] tmp=""
content.<span class="Entity">scan</span>(regexp).<span class="Entity">each</span> <span class="Keyword">do </span>|<span class="Variable">c</span>| mem=[]
mem <span class="Keyword">&lt;&lt;=</span> c content.scan(regexp).each do |c|
<span class="Keyword">end</span> mem &lt;&lt;= c
i<span class="Keyword">=</span><span class="Constant">0</span> end
content.<span class="Entity">split</span>(regexp).<span class="Entity">each</span> <span class="Keyword">do </span>|<span class="Variable">x</span>| i=0
tmp <span class="Keyword">&lt;&lt;=</span> <span class="Entity">send</span>(f,x) content.split(regexp).each do |x|
<span class="Keyword">if</span> <span class="Keyword">not</span> mem[i].<span class="Entity">nil?</span> tmp &lt;&lt;= send(f,x)
tmp <span class="Keyword">&lt;&lt;=</span> mem[i] if not mem[i].nil?
i<span class="Keyword">+=</span><span class="Constant">1</span> tmp &lt;&lt;= mem[i]
<span class="Keyword">end</span> i+=1
<span class="Keyword">end</span> end
end
tmp tmp
<span class="Keyword">end</span> end
</pre> </code></pre>
</div> </div>
<p>An usage is:</p> <p>An usage is:</p>
<div> <div>
<pre class="twilight">
<span class="Keyword">def</span> <span class="Entity">filter</span>(<span class="Variable">content</span>)
content.<span class="Entity">gsub</span>(<span class="StringRegexp"><span class="StringRegexp">/</span></span><span class="StringRegexp">e</span><span class="StringRegexp"><span class="StringRegexp">/</span></span>,<span class="String"><span class="String">'</span>X<span class="String">'</span></span>) <pre><code class="ruby">def filter(content)
<span class="Keyword">end</span> content.gsub(/e/,'X')
end
... ...
<span class="Entity">allExceptCode</span>(<span class="Constant"><span class="Constant">:</span>filter</span>, content) allExceptCode(:filter, content)
... ...
</pre> </code></pre>
</div> </div>
<p>A better syntax would be:</p> <p>A better syntax would be:</p>
<div> <div>
<pre class="twilight">
<span class="Comment"><span class="Comment">#</span> !!!!!!!!!! THIS SYNTAX DOES NOT WORK !!!!!!! #</span>
<span class="Keyword">def</span> <span class="Entity">allExceptCode</span>(<span class="Variable"> f<span class="Variable">,</span> content </span>) <pre><code class="ruby"># !!!!!!!!!! THIS SYNTAX DOES NOT WORK !!!!!!! #
regexp<span class="Keyword">=</span><span class="StringRegexp"><span class="StringRegexp">/</span></span><span class="StringRegexp">&lt;code<span class="StringRegexp"><span class="StringRegexp">[</span>^&gt;<span class="StringRegexp">]</span></span>*&gt;.*?&lt;<span class="StringRegexpSpecial">\/</span>code&gt;</span><span class="StringRegexp"><span class="StringRegexp">/m</span></span> def allExceptCode( f, content )
tmp<span class="Keyword">=</span><span class="String"><span class="String">&quot;</span><span class="String">&quot;</span></span> regexp=/&lt;code[^&gt;]*&gt;.*?&lt;\/code&gt;/m
content.<span class="Entity">split</span>(regexp).<span class="Entity">each</span> <span class="Keyword">do </span>|<span class="Variable">x</span>| tmp=""
separator<span class="Keyword">=</span><span class="Variable"><span class="Variable">$</span>&amp;</span> content.split(regexp).each do |x|
tmp <span class="Keyword">&lt;&lt;=</span> <span class="Entity">send</span>(f,x) separator=$&amp;
<span class="Keyword">if</span> <span class="Keyword">not</span> separator.<span class="Entity">nil?</span> tmp &lt;&lt;= send(f,x)
tmp <span class="Keyword">&lt;&lt;=</span> separator if not separator.nil?
<span class="Keyword">end</span> tmp &lt;&lt;= separator
<span class="Keyword">end</span> end
end
tmp tmp
<span class="Keyword">end</span> end
</pre> </code></pre>
</div> </div>
<p>I would expect the split make a search on a regular expression and then give the matched expression into the <code>$&amp;</code> variable. But it is not the case.</p> <p>I would expect the split make a search on a regular expression and then give the matched expression into the <code>$&amp;</code> variable. But it is not the case.</p>

View file

@ -1,4 +1,3 @@
#!/usr/bin/env zsh #!/usr/bin/env zsh
# Script synchronisant le site sur me.com # Script synchronisant le site sur me.com

View file

@ -1,4 +1,3 @@
#!/usr/bin/env zsh #!/usr/bin/env zsh
function samelineprint { function samelineprint {

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Synchronisation avec mobileme (2)" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2009-10-28-custom-website-synchronisation-with-mobileme--2-/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Synchronisation avec mobileme (2)" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2009-10-28-custom-website-synchronisation-with-mobileme--2-/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -58,263 +61,273 @@
<p>Here is my new script, it first create a map which associate to each file its hash. After that it compare this file to the remote one. Then for each different file, update the content.</p> <p>Here is my new script, it first create a map which associate to each file its hash. After that it compare this file to the remote one. Then for each different file, update the content.</p>
<p>Even with this script I also have some problem. Mostly due to &lsquo;webdav&rsquo; issues. For example, renaming a folder work really badly (on Linux at least). I use webdavfs. For example:</p> <p>Even with this script I also have some problem. Mostly due to webdav issues. For example, renaming a folder work really badly (on Linux at least). I use webdavfs. For example:</p>
<div><pre class="twilight"> <div>
mv folder folder2
</pre></div>
<p>It returns OK and I&rsquo;ve got: </p> <pre><code class="zsh">mv folder folder2
</code></pre>
<div><pre class="twilight"> </div>
$ ls
<p>It returns OK and Ive got: </p>
<div>
<pre><code class="zsh">$ ls
folder folder2 folder folder2
</pre></div> </code></pre>
<p>Booh&hellip;.</p> </div>
<p>In order to handle most webdav issues I use a <em>framework</em> in zsh. It handle almost all except the correct renaming of folder. Working on it&hellip; Anyway here is the code I use.</p> <p>Booh….</p>
<div><div class="code"><div class="file"><a href="/Scratch/en/blog/2009-10-28-custom-website-synchronisation-with-mobileme--2-/code/webdav-framework"> &#x27A5; webdav-framework </a></div><div class="withfile"> <p>In order to handle most webdav issues I use a <em>framework</em> in zsh. It handle almost all except the correct renaming of folder. Working on it… Anyway here is the code I use.</p>
<pre class="twilight">
<span class="Comment"><span class="Comment">#</span>!/usr/bin/env zsh</span> <div><div class="codefile"><a href="/Scratch/en/blog/2009-10-28-custom-website-synchronisation-with-mobileme--2-/code/webdav-framework">&#x27A5; webdav-framework</a></div>
<pre><code class="zsh">#!/usr/bin/env zsh
function samelineprint { function samelineprint {
print -n -P -- <span class="String"><span class="String">&quot;</span>\r<span class="StringVariable"><span class="StringVariable">$</span>*</span><span class="String">&quot;</span></span> print -n -P -- "\r$*"
} }
<span class="Comment"><span class="Comment">#</span> avec 1 essai par seconde: 300 = 5 minutes</span> # avec 1 essai par seconde: 300 = 5 minutes
maxessais=300 maxessais=300
<span class="Comment"><span class="Comment">#</span> try to create a directory until success</span> # try to create a directory until success
function trymkdir { function trymkdir {
target=<span class="String"><span class="String">&quot;</span><span class="StringVariable"><span class="StringVariable">$</span>1</span><span class="String">&quot;</span></span> target="$1"
print -- mkdir -p <span class="Variable"><span class="Variable">$</span>target</span> print -- mkdir -p $target
local essai=1 local essai=1
<span class="Keyword">while</span> <span class="Keyword">!</span> mkdir -p <span class="Variable"><span class="Variable">$</span>target</span><span class="Keyword">;</span> <span class="Keyword">do</span> while ! mkdir -p $target; do
samelineprint <span class="String"><span class="String">&quot;</span>Echec: essai n°<span class="StringVariable"><span class="StringVariable">$</span>essai</span><span class="String">&quot;</span></span> samelineprint "Echec: essai n°$essai"
((essai++)) ((essai++))
((essai<span class="Keyword">&gt;</span>maxessais)) <span class="Keyword">&amp;&amp;</span> exit 5 ((essai&gt;maxessais)) &amp;&amp; exit 5
<span class="Keyword">done</span> done
print print
} }
<span class="Comment"><span class="Comment">#</span> try to copy until success</span> # try to copy until success
function trycp { function trycp {
element=<span class="String"><span class="String">&quot;</span><span class="StringVariable"><span class="StringVariable">$</span>1</span><span class="String">&quot;</span></span> element="$1"
target=<span class="String"><span class="String">&quot;</span><span class="StringVariable"><span class="StringVariable">$</span>2</span><span class="String">&quot;</span></span> target="$2"
<span class="Keyword">if</span> [[ <span class="Keyword">!</span> -d <span class="Variable"><span class="Variable">${</span>target:h<span class="Variable">}</span></span> ]]<span class="Keyword">;</span> <span class="Keyword">then</span> if [[ ! -d ${target:h} ]]; then
trymkdir <span class="Variable"><span class="Variable">${</span>target:h<span class="Variable">}</span></span> trymkdir ${target:h}
<span class="Keyword">fi</span> fi
local essai=1 local essai=1
print -- cp <span class="Variable"><span class="Variable">$</span>element</span> <span class="Variable"><span class="Variable">$</span>target</span> print -- cp $element $target
<span class="Keyword">while</span> <span class="Keyword">!</span> <span class="Constant">\c</span>p <span class="Variable"><span class="Variable">$</span>element</span> <span class="Variable"><span class="Variable">$</span>target</span><span class="Keyword">;</span> <span class="Keyword">do</span> while ! \cp $element $target; do
samelineprint <span class="String"><span class="String">&quot;</span>Echec: essai n°<span class="StringVariable"><span class="StringVariable">$</span>essai</span><span class="String">&quot;</span></span> samelineprint "Echec: essai n°$essai"
((essai++)) ((essai++))
((essai<span class="Keyword">&gt;</span>maxessais)) <span class="Keyword">&amp;&amp;</span> exit 5 ((essai&gt;maxessais)) &amp;&amp; exit 5
<span class="Keyword">done</span> done
print print
} }
<span class="Comment"><span class="Comment">#</span> try to remove until success</span> # try to remove until success
function tryrm { function tryrm {
target=<span class="String"><span class="String">&quot;</span><span class="StringVariable"><span class="StringVariable">$</span>1</span><span class="String">&quot;</span></span> target="$1"
local essai=1 local essai=1
local options=<span class="String"><span class="String">'</span><span class="String">'</span></span> local options=''
[[ -d <span class="Variable"><span class="Variable">$</span>target</span> ]] <span class="Keyword">&amp;&amp;</span> options=<span class="String"><span class="String">'</span>-rf<span class="String">'</span></span> [[ -d $target ]] &amp;&amp; options='-rf'
print -- rm <span class="Variable"><span class="Variable">$</span>options</span> <span class="Variable"><span class="Variable">$</span>target</span> print -- rm $options $target
<span class="Keyword">while</span> <span class="Keyword">!</span> rm <span class="Variable"><span class="Variable">$</span>options</span> <span class="Variable"><span class="Variable">$</span>target</span><span class="Keyword">;</span> <span class="Keyword">do</span> while ! rm $options $target; do
samelineprint <span class="String"><span class="String">&quot;</span>Echec: essai n°<span class="StringVariable"><span class="StringVariable">$</span>essai</span><span class="String">&quot;</span></span> samelineprint "Echec: essai n°$essai"
((essai++)) ((essai++))
((essai<span class="Keyword">&gt;</span>maxessais)) <span class="Keyword">&amp;&amp;</span> exit 5 ((essai&gt;maxessais)) &amp;&amp; exit 5
<span class="Keyword">done</span> done
essai=1 essai=1
<span class="Keyword">while</span> [[ -e <span class="Variable"><span class="Variable">$</span>element</span> ]]<span class="Keyword">;</span> <span class="Keyword">do</span> while [[ -e $element ]]; do
samelineprint <span class="String"><span class="String">&quot;</span>rm reussi mais fichier source non disparu n°<span class="StringVariable"><span class="StringVariable">$</span>essai</span><span class="String">&quot;</span></span> samelineprint "rm reussi mais fichier source non disparu n°$essai"
sleep 1 sleep 1
((essai++)) ((essai++))
((essai<span class="Keyword">&gt;</span>maxessais)) <span class="Keyword">&amp;&amp;</span> exit 5 ((essai&gt;maxessais)) &amp;&amp; exit 5
<span class="Keyword">done</span> done
print print
} }
<span class="Comment"><span class="Comment">#</span> try to rename until success</span> # try to rename until success
function tryrename { function tryrename {
element=<span class="String"><span class="String">&quot;</span><span class="StringVariable"><span class="StringVariable">$</span>1</span><span class="String">&quot;</span></span> element="$1"
target=<span class="String"><span class="String">&quot;</span><span class="StringVariable"><span class="StringVariable">$</span>2</span><span class="String">&quot;</span></span> target="$2"
local essai=1 local essai=1
<span class="Keyword">while</span> [[ -e <span class="Variable"><span class="Variable">$</span>target</span> ]]<span class="Keyword">;</span> <span class="Keyword">do</span> while [[ -e $target ]]; do
samelineprint <span class="String"><span class="String">&quot;</span>Echec n°<span class="StringVariable"><span class="StringVariable">$</span>essai</span> le fichier <span class="StringVariable"><span class="StringVariable">$</span>target</span> existe déjà<span class="String">&quot;</span></span> samelineprint "Echec n°$essai le fichier $target existe déjà"
((essai++)) ((essai++))
((essai<span class="Keyword">&gt;</span>maxessais)) <span class="Keyword">&amp;&amp;</span> exit 5 ((essai&gt;maxessais)) &amp;&amp; exit 5
sleep 1 sleep 1
<span class="Keyword">done</span> done
print -- mv <span class="Variable"><span class="Variable">$</span>element</span> <span class="Variable"><span class="Variable">$</span>target</span> print -- mv $element $target
<span class="Keyword">while</span> <span class="Keyword">!</span> mv <span class="Variable"><span class="Variable">$</span>element</span> <span class="Variable"><span class="Variable">$</span>target</span><span class="Keyword">;</span> <span class="Keyword">do</span> while ! mv $element $target; do
samelineprint <span class="String"><span class="String">&quot;</span>Echec: essai n°<span class="StringVariable"><span class="StringVariable">$</span>essai</span><span class="String">&quot;</span></span> samelineprint "Echec: essai n°$essai"
((essai++)) ((essai++))
((essai<span class="Keyword">&gt;</span>maxessais)) <span class="Keyword">&amp;&amp;</span> exit 4 ((essai&gt;maxessais)) &amp;&amp; exit 4
<span class="Keyword">done</span> done
essai=1 essai=1
<span class="Keyword">while</span> [[ -e <span class="Variable"><span class="Variable">$</span>element</span> ]]<span class="Keyword">;</span> <span class="Keyword">do</span> while [[ -e $element ]]; do
samelineprint <span class="String"><span class="String">&quot;</span>mv reussi mais fichier source non disparu n°<span class="StringVariable"><span class="StringVariable">$</span>essai</span><span class="String">&quot;</span></span> samelineprint "mv reussi mais fichier source non disparu n°$essai"
sleep 1 sleep 1
((essai++)) ((essai++))
((essai<span class="Keyword">&gt;</span>maxessais)) <span class="Keyword">&amp;&amp;</span> exit 5 ((essai&gt;maxessais)) &amp;&amp; exit 5
<span class="Keyword">done</span> done
print print
} }
<span class="Comment"><span class="Comment">#</span> try to move until success</span> # try to move until success
function trymv { function trymv {
element=<span class="String"><span class="String">&quot;</span><span class="StringVariable"><span class="StringVariable">$</span>1</span><span class="String">&quot;</span></span> element="$1"
target=<span class="String"><span class="String">&quot;</span><span class="StringVariable"><span class="StringVariable">$</span>2</span><span class="String">&quot;</span></span> target="$2"
local essai=1 local essai=1
print -- mv <span class="Variable"><span class="Variable">$</span>element</span> <span class="Variable"><span class="Variable">$</span>target</span> print -- mv $element $target
<span class="Keyword">while</span> <span class="Keyword">!</span> mv <span class="Variable"><span class="Variable">$</span>element</span> <span class="Variable"><span class="Variable">$</span>target</span><span class="Keyword">;</span> <span class="Keyword">do</span> while ! mv $element $target; do
samelineprint <span class="String"><span class="String">&quot;</span>Echec: essai n°<span class="StringVariable"><span class="StringVariable">$</span>essai</span><span class="String">&quot;</span></span> samelineprint "Echec: essai n°$essai"
((essai++)) ((essai++))
((essai<span class="Keyword">&gt;</span>maxessais)) <span class="Keyword">&amp;&amp;</span> exit 5 ((essai&gt;maxessais)) &amp;&amp; exit 5
<span class="Keyword">done</span> done
essai=1 essai=1
<span class="Keyword">while</span> [[ -e <span class="Variable"><span class="Variable">$</span>element</span> ]]<span class="Keyword">;</span> <span class="Keyword">do</span> while [[ -e $element ]]; do
samelineprint <span class="String"><span class="String">&quot;</span>mv reussi mais fichier source non disparu n°<span class="StringVariable"><span class="StringVariable">$</span>essai</span><span class="String">&quot;</span></span> samelineprint "mv reussi mais fichier source non disparu n°$essai"
sleep 1 sleep 1
((essai++)) ((essai++))
((essai<span class="Keyword">&gt;</span>maxessais)) <span class="Keyword">&amp;&amp;</span> exit 5 ((essai&gt;maxessais)) &amp;&amp; exit 5
<span class="Keyword">done</span> done
print print
} }
</pre> </code></pre>
</div></div></div>
</div>
<p>And here is the code on how I synchronize my website. There is a little cryptic code. It correspond a problem caused by the bluecloth filter which is a markdown program made in ruby. Each time my email is written it is transformed differently. This is why I remove this part from the content of each html file. Without it, all my files containing email are different at each regeneration of my website.</p> <p>And here is the code on how I synchronize my website. There is a little cryptic code. It correspond a problem caused by the bluecloth filter which is a markdown program made in ruby. Each time my email is written it is transformed differently. This is why I remove this part from the content of each html file. Without it, all my files containing email are different at each regeneration of my website.</p>
<div><div class="code"><div class="file"><a href="/Scratch/en/blog/2009-10-28-custom-website-synchronisation-with-mobileme--2-/code/publish"> &#x27A5; publish </a></div><div class="withfile"> <div><div class="codefile"><a href="/Scratch/en/blog/2009-10-28-custom-website-synchronisation-with-mobileme--2-/code/publish">&#x27A5; publish</a></div>
<pre class="twilight">
<span class="Comment"><span class="Comment">#</span>!/usr/bin/env zsh</span>
<span class="Comment"><span class="Comment">#</span> Script synchronisant le site sur me.com</span>
<span class="Comment"><span class="Comment">#</span> normalement, le site est indisponible le moins de temps possible</span>
<span class="Comment"><span class="Comment">#</span> le temps de deux renommages de répertoire</span>
<span class="Comment"><span class="Comment">#</span> get configuration</span> <pre><code class="zsh">#!/usr/bin/env zsh
<span class="Comment"><span class="Comment">#</span> mostly directories</span>
source <span class="Variable"><span class="Variable">$</span>0</span>:h/config
<span class="Comment"><span class="Comment">#</span> get trycp function (copy until success)</span> # Script synchronisant le site sur me.com
source <span class="Variable"><span class="Variable">$</span>0</span>:h/webdav-framework # normalement, le site est indisponible le moins de temps possible
# le temps de deux renommages de répertoire
<span class="Keyword">if</span> [[ <span class="Variable"><span class="Variable">$</span>1</span> <span class="Keyword">==</span> <span class="String"><span class="String">'</span>-h<span class="String">'</span></span> ]]<span class="Keyword">;</span> <span class="Keyword">then</span> # get configuration
print -- <span class="String"><span class="String">&quot;</span>usage : <span class="StringVariable"><span class="StringVariable">$</span>0</span>:h [-h|-s|-d]<span class="String">&quot;</span></span> # mostly directories
print -- <span class="String"><span class="String">&quot;</span> -a sychronise aussi l'index<span class="String">&quot;</span></span> source $0:h/config
print -- <span class="String"><span class="String">&quot;</span> -h affiche l'aide<span class="String">&quot;</span></span>
print -- <span class="String"><span class="String">&quot;</span> -d modification directe (pas de swap)<span class="String">&quot;</span></span>
print -- <span class="String"><span class="String">&quot;</span> -s swappe simplement les répertoires<span class="String">&quot;</span></span>
<span class="Keyword">fi</span>
<span class="Comment"><span class="Comment">#</span> publication incrementale</span> # get trycp function (copy until success)
source $0:h/webdav-framework
if [[ $1 == '-h' ]]; then
print -- "usage : $0:h [-h|-s|-d]"
print -- " -a sychronise aussi l'index"
print -- " -h affiche l'aide"
print -- " -d modification directe (pas de swap)"
print -- " -s swappe simplement les répertoires"
fi
# publication incrementale
function incrementalPublish { function incrementalPublish {
local ydestRep=<span class="Variable"><span class="Variable">$</span>destRep</span><span class="Variable"><span class="Variable">$</span>suffix</span> local ydestRep=$destRep$suffix
localRef=<span class="String"><span class="String">&quot;</span><span class="StringVariable"><span class="StringVariable">$</span>srcRep</span>/map.yrf<span class="String">&quot;</span></span> localRef="$srcRep/map.yrf"
print -- <span class="String"><span class="String">&quot;</span>Creation du fichier de references<span class="String">&quot;</span></span> print -- "Creation du fichier de references"
create-reference-file.sh <span class="Keyword">&gt;</span> <span class="Variable"><span class="Variable">$</span>localRef</span> create-reference-file.sh &gt; $localRef
remoteRef=<span class="String"><span class="String">&quot;</span>/tmp/remoteSiteMapRef.<span class="StringVariable"><span class="StringVariable">$</span>$</span>.yrf<span class="String">&quot;</span></span> remoteRef="/tmp/remoteSiteMapRef.$$.yrf"
<span class="Keyword">if</span> [[ <span class="Keyword">!</span> -e <span class="String"><span class="String">&quot;</span><span class="StringVariable"><span class="StringVariable">$</span>ydestRep</span>/map.yrf<span class="String">&quot;</span></span> ]]<span class="Keyword">;</span> <span class="Keyword">then</span> if [[ ! -e "$ydestRep/map.yrf" ]]; then
<span class="Comment"><span class="Comment">#</span> pas de fichier de reference sur la cible</span> # pas de fichier de reference sur la cible
print -- <span class="String"><span class="String">&quot;</span>pas de fichier de reference sur la cible, passage en mode rsync<span class="String">&quot;</span></span> print -- "pas de fichier de reference sur la cible, passage en mode rsync"
rsyncPublish rsyncPublish
swap swap
<span class="Keyword">else</span> else
trycp <span class="String"><span class="String">&quot;</span><span class="StringVariable"><span class="StringVariable">$</span>ydestRep</span>/map.yrf<span class="String">&quot;</span></span> <span class="String"><span class="String">&quot;</span><span class="StringVariable"><span class="StringVariable">$</span>remoteRef</span><span class="String">&quot;</span></span> trycp "$ydestRep/map.yrf" "$remoteRef"
typeset -U filesToUpdate typeset -U filesToUpdate
filesToUpdate=( <span class="String"><span class="String">$(</span>diff <span class="StringVariable"><span class="StringVariable">$</span>localRef</span> <span class="StringVariable"><span class="StringVariable">$</span>remoteRef</span> <span class="Keyword">|</span> awk <span class="String"><span class="String">'</span>/^[&lt;&gt;]/ {print $2}<span class="String">'</span></span> <span class="String">)</span></span> ) filesToUpdate=( $(diff $localRef $remoteRef | awk '/^[&lt;&gt;]/ {print $2}' ) )
<span class="Keyword">if</span> ((<span class="Variable"><span class="Variable">${</span>#filesToUpdate<span class="Variable">}</span></span> == 1))<span class="Keyword">;</span> <span class="Keyword">then</span> if ((${#filesToUpdate} == 1)); then
print -- <span class="String"><span class="String">&quot;</span>Seul le fichier <span class="StringVariable"><span class="StringVariable">${</span>filesToUpdate<span class="StringVariable">}</span></span> sera téléversé<span class="String">&quot;</span></span> print -- "Seul le fichier ${filesToUpdate} sera téléversé"
<span class="Keyword">elif</span> ((<span class="Variable"><span class="Variable">${</span>#filesToUpdate<span class="Variable">}</span></span><span class="Keyword">&lt;</span>10))<span class="Keyword">;</span> <span class="Keyword">then</span> elif ((${#filesToUpdate}&lt;10)); then
print -- <span class="String"><span class="String">&quot;</span><span class="StringVariable"><span class="StringVariable">${</span>#filesToUpdate<span class="StringVariable">}</span></span> fichiers seront téléversés :<span class="String">&quot;</span></span> print -- "${#filesToUpdate} fichiers seront téléversés :"
print -- <span class="String"><span class="String">&quot;</span><span class="StringVariable"><span class="StringVariable">${</span>filesToUpdate<span class="StringVariable">}</span></span><span class="String">&quot;</span></span> print -- "${filesToUpdate}"
<span class="Keyword">else</span> else
print -- <span class="String"><span class="String">&quot;</span><span class="StringVariable"><span class="StringVariable">${</span>#filesToUpdate<span class="StringVariable">}</span></span> fichiers seront téléversés<span class="String">&quot;</span></span> print -- "${#filesToUpdate} fichiers seront téléversés"
<span class="Keyword">fi</span> fi
<span class="Comment"><span class="Comment">#</span> copy all file with some differences</span> # copy all file with some differences
<span class="Comment"><span class="Comment">#</span> except the map in case of error</span> # except the map in case of error
<span class="Keyword">for</span> element <span class="Keyword">in</span> <span class="Variable"><span class="Variable">$</span>filesToUpdate</span><span class="Keyword">;</span> <span class="Keyword">do</span> for element in $filesToUpdate; do
<span class="Keyword">if</span> [[ <span class="Variable"><span class="Variable">$</span>element</span> <span class="Keyword">==</span> <span class="String"><span class="String">&quot;</span>/map.yrf<span class="String">&quot;</span></span> ]]<span class="Keyword">;</span> <span class="Keyword">then</span> if [[ $element == "/map.yrf" ]]; then
<span class="Keyword">continue</span> continue
<span class="Keyword">fi</span> fi
<span class="Keyword">if</span> [[ -e <span class="Variable"><span class="Variable">$</span>srcRep</span><span class="Variable"><span class="Variable">$</span>element</span> ]]<span class="Keyword">;</span> <span class="Keyword">then</span> if [[ -e $srcRep$element ]]; then
trycp <span class="Variable"><span class="Variable">$</span>srcRep</span><span class="Variable"><span class="Variable">$</span>element</span> <span class="Variable"><span class="Variable">$</span>ydestRep</span><span class="Variable"><span class="Variable">$</span>element</span> trycp $srcRep$element $ydestRep$element
<span class="Keyword">else</span> else
tryrm <span class="Variable"><span class="Variable">$</span>ydestRep</span><span class="Variable"><span class="Variable">$</span>element</span> tryrm $ydestRep$element
<span class="Keyword">fi</span> fi
<span class="Keyword">done</span> done
<span class="Comment"><span class="Comment">#</span> if all went fine, copy the map file</span> # if all went fine, copy the map file
trycp <span class="Variable"><span class="Variable">$</span>srcRep</span>/map.yrf <span class="Variable"><span class="Variable">$</span>ydestRep</span>/map.yrf trycp $srcRep/map.yrf $ydestRep/map.yrf
<span class="Comment"><span class="Comment">#</span> remove the temporary file</span> # remove the temporary file
<span class="Constant">\r</span>m <span class="Variable"><span class="Variable">$</span>remoteRef</span> \rm $remoteRef
<span class="Comment"><span class="Comment">#</span> if we have used the tmp directory we swap</span> # if we have used the tmp directory we swap
<span class="Keyword">if</span> [[ <span class="String"><span class="String">&quot;</span><span class="StringVariable"><span class="StringVariable">$</span>suffix</span><span class="String">&quot;</span></span> <span class="Keyword">!=</span> <span class="String"><span class="String">&quot;</span><span class="String">&quot;</span></span> ]]<span class="Keyword">;</span> <span class="Keyword">then</span> if [[ "$suffix" != "" ]]; then
swap swap
<span class="Keyword">fi</span> fi
<span class="Keyword">fi</span> fi
} }
<span class="Comment"><span class="Comment">#</span> publication via rsync</span> # publication via rsync
function rsyncPublish { function rsyncPublish {
result=1 result=1
essai=1 essai=1
<span class="Keyword">while</span> (( <span class="Variable"><span class="Variable">$</span>result</span> <span class="Keyword">&gt;</span> 0 ))<span class="Keyword">;</span> <span class="Keyword">do</span> while (( $result &gt; 0 )); do
print -- rsync -arv <span class="Variable"><span class="Variable">$</span>srcRep</span>/ <span class="Variable"><span class="Variable">$</span>destRep</span>.tmp print -- rsync -arv $srcRep/ $destRep.tmp
<span class="Keyword">if</span> ((<span class="Keyword">!</span>testmode))<span class="Keyword">;</span> <span class="Keyword">then</span> if ((!testmode)); then
rsync -arv <span class="Variable"><span class="Variable">$</span>srcRep</span>/ <span class="Variable"><span class="Variable">$</span>destRep</span>.tmp rsync -arv $srcRep/ $destRep.tmp
<span class="Keyword">fi</span> fi
result=<span class="Variable"><span class="Variable">$</span>?</span> result=$?
<span class="Keyword">if</span> (( <span class="Variable"><span class="Variable">$</span>result</span> <span class="Keyword">&gt;</span> 0 ))<span class="Keyword">;</span> <span class="Keyword">then</span> if (( $result &gt; 0 )); then
print -P -- <span class="String"><span class="String">&quot;</span>%BEchec du rsync%b (essai n°<span class="StringVariable"><span class="StringVariable">$</span>essai</span>)<span class="String">&quot;</span></span> <span class="Keyword">&gt;&amp;2</span> print -P -- "%BEchec du rsync%b (essai n°$essai)" &gt;&amp;2
<span class="Keyword">fi</span> fi
((essai++)) ((essai++))
<span class="Keyword">done</span> done
} }
<span class="Comment"><span class="Comment">#</span> swap</span> # swap
function swap { function swap {
print -P -- <span class="String"><span class="String">&quot;</span>%B[Directory Swap (tmp &lt;=&gt; target)]%b<span class="String">&quot;</span></span> print -P -- "%B[Directory Swap (tmp &lt;=&gt; target)]%b"
[[ -e <span class="Variable"><span class="Variable">$</span>destRep</span>.old ]] <span class="Keyword">&amp;&amp;</span> tryrm <span class="Variable"><span class="Variable">$</span>destRep</span>.old [[ -e $destRep.old ]] &amp;&amp; tryrm $destRep.old
print -- <span class="String"><span class="String">&quot;</span> renommage du repertoire sandard vers le .old<span class="String">&quot;</span></span> print -- " renommage du repertoire sandard vers le .old"
tryrename <span class="Variable"><span class="Variable">$</span>destRep</span> <span class="Variable"><span class="Variable">$</span>destRep</span>.old tryrename $destRep $destRep.old
print -- <span class="String"><span class="String">&quot;</span> renommage du repertoire tmp (nouveau) vers le standard<span class="String">&quot;</span></span> print -- " renommage du repertoire tmp (nouveau) vers le standard"
print -P -- <span class="String"><span class="String">&quot;</span>%B[Site Indisponible]%b <span class="String"><span class="String">$(</span>date<span class="String">)</span></span><span class="String">&quot;</span></span> print -P -- "%B[Site Indisponible]%b $(date)"
tryrename <span class="Variable"><span class="Variable">$</span>destRep</span>.tmp <span class="Variable"><span class="Variable">$</span>destRep</span> tryrename $destRep.tmp $destRep
print -P -- <span class="String"><span class="String">&quot;</span>%B[Site Disponible]%b <span class="String"><span class="String">$(</span>date<span class="String">)</span></span><span class="String">&quot;</span></span> print -P -- "%B[Site Disponible]%b $(date)"
print -- <span class="String"><span class="String">&quot;</span> renommage du repertoire old vers le tmp<span class="String">&quot;</span></span> print -- " renommage du repertoire old vers le tmp"
tryrename <span class="Variable"><span class="Variable">$</span>destRep</span>.old <span class="Variable"><span class="Variable">$</span>destRep</span>.tmp tryrename $destRep.old $destRep.tmp
print -P -- <span class="String"><span class="String">&quot;</span> publication terminée<span class="String">&quot;</span></span> print -P -- " publication terminée"
} }
print -- <span class="String"><span class="String">&quot;</span>Root = <span class="StringVariable"><span class="StringVariable">$</span>webroot</span><span class="String">&quot;</span></span> print -- "Root = $webroot"
print -- <span class="String"><span class="String">&quot;</span>Dest = <span class="StringVariable"><span class="StringVariable">$</span>destRep</span><span class="String">&quot;</span></span> print -- "Dest = $destRep"
<span class="Keyword">if</span> [[ <span class="String"><span class="String">&quot;</span><span class="StringVariable"><span class="StringVariable">$</span>1</span><span class="String">&quot;</span></span> = <span class="String"><span class="String">&quot;</span>-s<span class="String">&quot;</span></span> ]]<span class="Keyword">;</span> <span class="Keyword">then</span> if [[ "$1" = "-s" ]]; then
swap swap
<span class="Keyword">else</span> else
<span class="Keyword">if</span> [[ <span class="String"><span class="String">&quot;</span><span class="StringVariable"><span class="StringVariable">$</span>1</span><span class="String">&quot;</span></span> = <span class="String"><span class="String">&quot;</span>-d<span class="String">&quot;</span></span> ]]<span class="Keyword">;</span> <span class="Keyword">then</span> if [[ "$1" = "-d" ]]; then
suffix=<span class="String"><span class="String">&quot;</span><span class="String">&quot;</span></span> suffix=""
<span class="Keyword">else</span> else
suffix=<span class="String"><span class="String">&quot;</span>.tmp<span class="String">&quot;</span></span> suffix=".tmp"
<span class="Keyword">fi</span> fi
print -P -- <span class="String"><span class="String">&quot;</span>%BSync%b[<span class="StringVariable"><span class="StringVariable">${</span>Root:t<span class="StringVariable">}</span></span> =&gt; <span class="StringVariable"><span class="StringVariable">${</span>destRep:t<span class="StringVariable">}</span></span><span class="StringVariable"><span class="StringVariable">$</span>suffix</span>]<span class="String">&quot;</span></span> print -P -- "%BSync%b[${Root:t} =&gt; ${destRep:t}$suffix]"
incrementalPublish incrementalPublish
<span class="Keyword">fi</span> fi
</pre> </code></pre>
</div></div></div>
</div>
<p>This is my way to replace <code>rsync</code> with filesystem not handling it. <p>This is my way to replace <code>rsync</code> with filesystem not handling it.
Hope it is usefull. I&rsquo;ll be happy to hear a way to handle the webdav rename folder problem. This is really annoying.</p> Hope it is usefull. Ill be happy to hear a way to handle the webdav rename folder problem. This is really annoying.</p>
</div> </div>

View file

@ -1,4 +1,3 @@
// Remove all CSS I don't want to use on IE // Remove all CSS I don't want to use on IE
$('link[rel=stylesheet]').each(function(i) $('link[rel=stylesheet]').each(function(i)
{ {

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Une CSS pour IE seulement" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2009-10-30-How-to-handle-evil-IE/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Une CSS pour IE seulement" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2009-10-30-How-to-handle-evil-IE/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -56,38 +59,43 @@
<div class="corps"> <div class="corps">
<p>For developer IE is a nightmare. This is why, I use a method to disable my standard CSS and enable a IE only CSS. I use jQuery to accomplish that.</p> <p>For developer IE is a nightmare. This is why, I use a method to disable my standard CSS and enable a IE only CSS. I use jQuery to accomplish that.</p>
<div><pre class="twilight"> <div>
<span class="Keyword">$</span>(<span class="Support">document</span>).ready( <span class="Storage">function</span>() {
<span class="Keyword">if</span> (<span class="Keyword">$</span>.browser[<span class="String"><span class="String">&quot;</span>msie<span class="String">&quot;</span></span>]) { <pre><code class="javascript">$(document).ready( function() {
<span class="Comment"><span class="Comment">//</span> include the ie.js file</span> if ($.browser["msie"]) {
<span class="Keyword">$</span>(<span class="String"><span class="String">'</span>head<span class="String">'</span></span>).append(<span class="String"><span class="String">'</span>&lt;script type=&quot;text/javascript&quot; src=&quot;/js/ie.js&quot;&gt;&lt;/scr<span class="String">'</span></span> <span class="Keyword">+</span> <span class="String"><span class="String">'</span>ipt&gt;<span class="String">'</span></span>); // include the ie.js file
$('head').append('&lt;script type="text/javascript" src="/js/ie.js"&gt;&lt;/scr' + 'ipt&gt;');
} }
}); });
</pre></div> </code></pre>
<div><div class="code"><div class="file"><a href="/Scratch/en/blog/2009-10-30-How-to-handle-evil-IE/code/ie.js"> &#x27A5; ie.js </a></div><div class="withfile"> </div>
<pre class="twilight">
<span class="Comment"><span class="Comment">//</span> Remove all CSS I don't want to use on IE</span> <div><div class="codefile"><a href="/Scratch/en/blog/2009-10-30-How-to-handle-evil-IE/code/ie.js">&#x27A5; ie.js</a></div>
<span class="Keyword">$</span>(<span class="String"><span class="String">'</span>link[rel=stylesheet]<span class="String">'</span></span>).each(<span class="Storage">function</span>(i)
<pre><code class="javascript">// Remove all CSS I don't want to use on IE
$('link[rel=stylesheet]').each(function(i)
{ {
<span class="Keyword">if</span> (<span class="Variable">this</span>.<span class="SupportFunction">getAttribute</span>(<span class="String"><span class="String">'</span>href<span class="String">'</span></span>) <span class="Keyword">==</span> <span class="String"><span class="String">'</span>/css/layout.css<span class="String">'</span></span>) if (this.getAttribute('href') == '/css/layout.css')
<span class="Variable">this</span>.<span class="SupportConstant">disabled</span> <span class="Keyword">=</span> <span class="Constant">true</span>; this.disabled = true;
<span class="Keyword">if</span> (<span class="Variable">this</span>.<span class="SupportFunction">getAttribute</span>(<span class="String"><span class="String">'</span>href<span class="String">'</span></span>) <span class="Keyword">==</span> <span class="String"><span class="String">'</span>/css/shadows.css<span class="String">'</span></span>) if (this.getAttribute('href') == '/css/shadows.css')
<span class="Variable">this</span>.<span class="SupportConstant">disabled</span> <span class="Keyword">=</span> <span class="Constant">true</span>; this.disabled = true;
<span class="Keyword">if</span> (<span class="Variable">this</span>.<span class="SupportFunction">getAttribute</span>(<span class="String"><span class="String">'</span>href<span class="String">'</span></span>) <span class="Keyword">==</span> <span class="String"><span class="String">'</span>/css/gen.css<span class="String">'</span></span>) if (this.getAttribute('href') == '/css/gen.css')
<span class="Variable">this</span>.<span class="SupportConstant">disabled</span> <span class="Keyword">=</span> <span class="Constant">true</span>; this.disabled = true;
}) ; }) ;
<span class="Comment"><span class="Comment">//</span> Append the CSS for IE only</span> // Append the CSS for IE only
<span class="Keyword">$</span>(<span class="String"><span class="String">'</span>head<span class="String">'</span></span>).append(<span class="String"><span class="String">'</span>&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;/css/ie.css&quot;/&gt;<span class="String">'</span></span>); $('head').append('&lt;link rel="stylesheet" type="text/css" href="/css/ie.css"/&gt;');
<span class="Comment"><span class="Comment">//</span> I also add a message on top of the page</span> // I also add a message on top of the page
<span class="Keyword">$</span>(<span class="String"><span class="String">'</span>body<span class="String">'</span></span>).prepend(<span class="String"><span class="String">'</span>&lt;div id=&quot;iemessage&quot;&gt;&lt;p&gt;&lt;span class=&quot;fr&quot;&gt;&lt;em&gt;Avec &lt;a href=&quot;http://www.firefox.com&quot;&gt; Firefox &lt;/a&gt; et &lt;a href=&quot;http://www.apple.com/safari&quot;&gt;Safari&lt;/a&gt; cette page est bien plus jolie !&lt;/em&gt;&lt;/span&gt;&lt;span class=&quot;en&quot;&gt;&lt;em&gt;This page is far nicer with &lt;a href=&quot;http://www.firefox.com&quot;&gt; Firefox &lt;/a&gt; and &lt;a href=&quot;http://www.apple.com/safari&quot;&gt;Safari&lt;/a&gt;!&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;.&lt;/div&gt;<span class="String">'</span></span>); $('body').prepend('&lt;div id="iemessage"&gt;&lt;p&gt;&lt;span class="fr"&gt;&lt;em&gt;Avec &lt;a href="http://www.firefox.com"&gt; Firefox &lt;/a&gt; et &lt;a href="http://www.apple.com/safari"&gt;Safari&lt;/a&gt; cette page est bien plus jolie !&lt;/em&gt;&lt;/span&gt;&lt;span class="en"&gt;&lt;em&gt;This page is far nicer with &lt;a href="http://www.firefox.com"&gt; Firefox &lt;/a&gt; and &lt;a href="http://www.apple.com/safari"&gt;Safari&lt;/a&gt;!&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;.&lt;/div&gt;');
</pre> </code></pre>
</div></div></div>
<p>That&rsquo;s it.</p> </div>
<p>Thats it.</p>
</div> </div>

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="<em>Focus</em> &gt; Minimalisme" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2009-10-Focus-vs-Minimalism/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="<em>Focus</em> &gt; Minimalisme" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2009-10-Focus-vs-Minimalism/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -54,9 +57,9 @@
<div class="flush"></div> <div class="flush"></div>
<div id="afterheader"> <div id="afterheader">
<div class="corps"> <div class="corps">
<p>I believe the goal researched by minimalism is <strong>Focus</strong>. But I don&rsquo;t believe minimalism should be the goal. Focus should be the goal, and I believe minimalism isn&rsquo;t necessary to reach it.</p> <p>I believe the goal researched by minimalism is <strong>Focus</strong>. But I dont believe minimalism should be the goal. Focus should be the goal, and I believe minimalism isnt necessary to reach it.</p>
<p>This is why my design is not minimalist, but I decided to remove most of the navigation stuff of all pages of my website. May be I&rsquo;ll prefer to hide the menu only when you are on blog article. For now, I hide the menu everywhere on the website.</p> <p>This is why my design is not minimalist, but I decided to remove most of the navigation stuff of all pages of my website. May be Ill prefer to hide the menu only when you are on blog article. For now, I hide the menu everywhere on the website.</p>
</div> </div>
@ -71,57 +74,66 @@
<p>The HTML: </p> <p>The HTML: </p>
<div> <div>
<pre class="twilight">
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">div</span> <span class="MetaTagAll"><span class="MetaTagAll">id</span><span class="MetaTagAll">=</span><span class="String"><span class="String">&quot;</span><span class="String">menuButton</span><span class="String">&quot;</span></span></span><span class="MetaTagAll">&gt;<span class="MetaTagAll">&lt;</span>/</span><span class="MetaTagAll">div</span><span class="MetaTagAll">&gt;</span></span>
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">div</span> <span class="MetaTagAll"><span class="MetaTagAll">id</span><span class="MetaTagAll">=</span><span class="String"><span class="String">&quot;</span><span class="String">entete</span><span class="String">&quot;</span></span></span><span class="MetaTagAll">&gt;</span></span>#content of the menu<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">div</span><span class="MetaTagAll">&gt;</span></span> <pre><code class="html">&lt;div id="menuButton"&gt;&lt;/div&gt;
</pre> &lt;div id="entete"&gt;#content of the menu&lt;/div&gt;
</code></pre>
</div> </div>
<p>The CSS: </p> <p>The CSS: </p>
<div><pre class="twilight"> <div>
<span class="CssId"><span class="CssId">#</span>menuButton</span> {
<span class="CssPropertyName">font-size</span>: <span class="CssAdditionalConstants">2</span><span class="Keyword">em</span>; <pre><code class="css">#menuButton {
<span class="CssPropertyName">height</span>: <span class="CssAdditionalConstants">2</span><span class="Keyword">em</span>; font-size: 2em;
<span class="CssPropertyName">line-height</span>: <span class="CssAdditionalConstants">1.8</span><span class="Keyword">em</span>; height: 2em;
<span class="CssPropertyName">width</span>: <span class="CssAdditionalConstants">2</span><span class="Keyword">em</span>; line-height: 1.8em;
<span class="CssPropertyName">position</span>: <span class="CssPropertyValue">fixed</span>; width: 2em;
<span class="CssPropertyName">left</span>: <span class="CssAdditionalConstants">0</span>; position: fixed;
<span class="CssPropertyName">top</span>: <span class="CssAdditionalConstants">0</span>; left: 0;
<span class="CssPropertyName">z-index</span>: <span class="CssAdditionalConstants">9001</span> } top: 0;
z-index: 9001 }
#menuButton:hover {
cursor: pointer; }
#entete {
top: 5em;
left: 0;
position: fixed;
width: 10em;
z-index: 9000; }
</code></pre>
<span class="CssId"><span class="CssId">#</span>menuButton</span><span class="MetaTagInline"><span class="MetaTagInline">:</span>hover</span> {
<span class="CssPropertyName">cursor</span>: <span class="CssPropertyValue">pointer</span>; }
<span class="CssId"><span class="CssId">#</span>entete</span> {
<span class="CssPropertyName">top</span>: <span class="CssAdditionalConstants">5</span><span class="Keyword">em</span>;
<span class="CssPropertyName">left</span>: <span class="CssAdditionalConstants">0</span>;
<span class="CssPropertyName">position</span>: <span class="CssPropertyValue">fixed</span>;
<span class="CssPropertyName">width</span>: <span class="CssAdditionalConstants">10</span><span class="Keyword">em</span>;
<span class="CssPropertyName">z-index</span>: <span class="CssAdditionalConstants">9000</span>; }
</pre>
</div> </div>
<p>The javascript code (using jQuery)</p> <p>The javascript code (using jQuery)</p>
<div> <div>
<pre class="twilight">
<span class="Storage">function</span> <span class="Entity">hideMenu</span>() {
<span class="Keyword">$</span>(<span class="String"><span class="String">'</span>#entete<span class="String">'</span></span>).animate({left:<span class="String"><span class="String">&quot;</span>-10em<span class="String">&quot;</span></span>}, <span class="Constant">500</span> ); <pre><code class="javascript">function hideMenu() {
<span class="Keyword">$</span>(<span class="String"><span class="String">'</span>#menuButton<span class="String">'</span></span>).html(<span class="String"><span class="String">'</span>&amp;rarr;<span class="String">'</span></span>); $('#entete').animate({left:"-10em"}, 500 );
$('#menuButton').html('&rarr;');
} }
<span class="Storage">function</span> <span class="Entity">showMenu</span>() { function showMenu() {
<span class="Keyword">$</span>(<span class="String"><span class="String">'</span>#entete<span class="String">'</span></span>).animate({left:<span class="String"><span class="String">&quot;</span>0em<span class="String">&quot;</span></span>}, <span class="Constant">500</span> ); $('#entete').animate({left:"0em"}, 500 );
<span class="Keyword">$</span>(<span class="String"><span class="String">'</span>#menuButton<span class="String">'</span></span>).html(<span class="String"><span class="String">'</span>&amp;larr;<span class="String">'</span></span>); $('#menuButton').html('&larr;');
} }
<span class="Storage">function</span> <span class="Entity">toggleMenu</span>() { function toggleMenu() {
<span class="Keyword">if</span> ( <span class="Keyword">$</span>(<span class="String"><span class="String">'</span>#entete<span class="String">'</span></span>).css(<span class="String"><span class="String">'</span>left<span class="String">'</span></span>)<span class="Keyword">==</span><span class="String"><span class="String">'</span>-10em<span class="String">'</span></span> ) { if ( $('#entete').css('left')=='-10em' ) {
showMenu(); showMenu();
} <span class="Keyword">else</span> { } else {
hideMenu(); hideMenu();
} }
} }
</pre> </code></pre>
</div> </div>
<p>And the result is shown in the top left corner of this website.</p> <p>And the result is shown in the top left corner of this website.</p>

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Charger une page web avec style" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2009-10-How-to-preload-your-site-with-style/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Charger une page web avec style" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2009-10-How-to-preload-your-site-with-style/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -79,7 +82,7 @@
</script> </script>
</div> </div>
<p>I first tried to integrate <a href="http://www.gayadesign.com/diy/queryloader-preload-your-website-in-style/">queryLoader</a>, but it didn&rsquo;t fill my needs.</p> <p>I first tried to integrate <a href="http://www.gayadesign.com/diy/queryloader-preload-your-website-in-style/">queryLoader</a>, but it didnt fill my needs.</p>
<p>The plugin add a black div to hide all the content. But as the script had to be launched at the end of the source code my website show for a small time.</p> <p>The plugin add a black div to hide all the content. But as the script had to be launched at the end of the source code my website show for a small time.</p>
@ -90,21 +93,25 @@
<p>In a first time, I added at the top of the body the div hiding all the content.</p> <p>In a first time, I added at the top of the body the div hiding all the content.</p>
<div> <div>
<pre class="twilight">
...
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">body</span><span class="MetaTagAll">&gt;</span></span> <pre><code class="html">...
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">div</span> <span class="MetaTagAll"><span class="MetaTagAll">id</span><span class="MetaTagAll">=</span><span class="String"><span class="String">&quot;</span><span class="String">blackpage</span><span class="String">&quot;</span></span></span><span class="MetaTagAll">&gt;</span></span> &lt;body&gt;
&lt;div id="blackpage"&gt;
content to display during the loading. content to display during the loading.
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">div</span><span class="MetaTagAll">&gt;</span></span> &lt;/div&gt;
... ...
</pre> </code></pre>
</div> </div>
<p>and here is the associated CSS to <code>#blackpage</code>: </p> <p>and here is the associated CSS to <code>#blackpage</code>: </p>
<div> <div>
<pre class="twilight">
<span class="CssId"><span class="CssId">#</span>blackpage</span>
<pre><code class="css">#blackpage
top: 0 top: 0
left: 0 left: 0
width: 100% width: 100%
@ -117,19 +124,24 @@
text-align: center text-align: center
color: #666 color: #666
padding-top: 10em padding-top: 10em
background-color: <span class="CssId"><span class="CssId">#</span>eee</span> background-color: #eee
z-index: 9000 z-index: 9000
</pre> </code></pre>
</div> </div>
<p>and the associated jQuery code: </p> <p>and the associated jQuery code: </p>
<div> <div>
<pre class="twilight">
<span class="Keyword">$</span>(<span class="Support">document</span>).ready(<span class="Storage">function</span>(){
<span class="Keyword">$</span>(<span class="String"><span class="String">'</span>#blackpage<span class="String">'</span></span>).fadeOut(); <pre><code class="javascript">$(document).ready(function(){
$('#blackpage').fadeOut();
}); });
</pre> </code></pre>
</div> </div>
<p>Yes, it is as simple as that. And, putting the <code>#blackpage</code> div at the top of my page, I ensure to hide anything while loading.</p> <p>Yes, it is as simple as that. And, putting the <code>#blackpage</code> div at the top of my page, I ensure to hide anything while loading.</p>

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Un menu qui attends avant de se cacher" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2009-10-Wait-to-hide-a-menu-in-jQuery/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Un menu qui attends avant de se cacher" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2009-10-Wait-to-hide-a-menu-in-jQuery/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -61,81 +64,90 @@
<p>HTML: </p> <p>HTML: </p>
<div> <div>
<pre class="twilight">
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">div</span> <span class="MetaTagAll"><span class="MetaTagAll">id</span><span class="MetaTagAll">=</span><span class="String"><span class="String">&quot;</span><span class="String">menuButton</span><span class="String">&quot;</span></span></span><span class="MetaTagAll">&gt;<span class="MetaTagAll">&lt;</span>/</span><span class="MetaTagAll">div</span><span class="MetaTagAll">&gt;</span></span>
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">div</span> <span class="MetaTagAll"><span class="MetaTagAll">id</span><span class="MetaTagAll">=</span><span class="String"><span class="String">&quot;</span><span class="String">entete</span><span class="String">&quot;</span></span></span><span class="MetaTagAll">&gt;</span></span> <pre><code class="html"> &lt;div id="menuButton"&gt;&lt;/div&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">ul</span><span class="MetaTagAll">&gt;</span></span> &lt;div id="entete"&gt;
<span class="MetaTagInline"><span class="MetaTagInline">&lt;</span><span class="MetaTagInline">li</span><span class="MetaTagInline">&gt;</span></span> menu item 1 <span class="MetaTagInline"><span class="MetaTagInline">&lt;/</span><span class="MetaTagInline">li</span><span class="MetaTagInline">&gt;</span></span> &lt;ul&gt;
&lt;li&gt; menu item 1 &lt;/li&gt;
... ...
<span class="MetaTagInline"><span class="MetaTagInline">&lt;</span><span class="MetaTagInline">li</span><span class="MetaTagInline">&gt;</span></span> menu item n <span class="MetaTagInline"><span class="MetaTagInline">&lt;/</span><span class="MetaTagInline">li</span><span class="MetaTagInline">&gt;</span></span> &lt;li&gt; menu item n &lt;/li&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">ul</span><span class="MetaTagAll">&gt;</span></span> &lt;/ul&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">div</span><span class="MetaTagAll">&gt;</span></span> &lt;/div&gt;
</pre> </code></pre>
</div> </div>
<p>CSS: </p> <p>CSS: </p>
<div><pre class="twilight"> <div>
<span class="CssId"><span class="CssId">#</span>entete</span> {
<span class="CssPropertyName">top</span>: <span class="CssAdditionalConstants">1</span><span class="Keyword">em</span>; <pre><code class="css"> #entete {
<span class="CssPropertyName">left</span>: <span class="CssAdditionalConstants">0</span>; top: 1em;
<span class="CssPropertyName">position</span>: <span class="CssPropertyValue">fixed</span>; left: 0;
<span class="CssPropertyName">width</span>: <span class="CssAdditionalConstants">10</span><span class="Keyword">em</span>; position: fixed;
<span class="CssPropertyName">z-index</span>: <span class="CssAdditionalConstants">2000</span>; } width: 10em;
z-index: 2000; }
<span class="CssId"><span class="CssId">#</span>entete</span> { #entete {
<span class="CssPropertyName">top</span>: <span class="CssAdditionalConstants">1</span><span class="Keyword">em</span>; top: 1em;
<span class="CssPropertyName">height</span>: <span class="CssAdditionalConstants">22</span><span class="Keyword">em</span>; height: 22em;
<span class="CssPropertyName">left</span>: <span class="CssAdditionalConstants">0</span>; left: 0;
<span class="CssPropertyName">position</span>: <span class="CssPropertyValue">fixed</span>; position: fixed;
<span class="CssPropertyName">width</span>: <span class="CssAdditionalConstants">10</span><span class="Keyword">em</span>; } width: 10em; }
</pre></div> </code></pre>
</div>
<p>Javascript: </p> <p>Javascript: </p>
<div><pre class="twilight"> <div>
<span class="Storage">var</span> last<span class="Keyword">=</span><span class="Constant">0</span>;
<span class="Comment"><span class="Comment">//</span> will hide the menu in 5 seconds</span> <pre><code class="javascript">var last=0;
<span class="Comment"><span class="Comment">//</span> if the variable 'last' has not changed its value</span>
<span class="Storage">function</span> <span class="Entity">autoHideMenu</span>(<span class="Variable">value</span>) { // will hide the menu in 5 seconds
<span class="SupportFunction">setTimeout</span>(<span class="Storage">function</span>(){ // if the variable 'last' has not changed its value
<span class="Keyword">if</span> ( last <span class="Keyword">==</span> value ) { hideMenu(); } function autoHideMenu(value) {
},<span class="Constant">5000</span>); setTimeout(function(){
if ( last == value ) { hideMenu(); }
},5000);
} }
<span class="Keyword">$</span>(<span class="Support">document</span>).ready( <span class="Storage">function</span>() { $(document).ready( function() {
<span class="Comment"><span class="Comment">//</span> show the menu when the mouse is on</span> // show the menu when the mouse is on
<span class="Comment"><span class="Comment">//</span> the good area</span> // the good area
<span class="Keyword">$</span>(<span class="String"><span class="String">'</span>#menuButton<span class="String">'</span></span>).hover(showMenu); $('#menuButton').hover(showMenu);
<span class="Comment"><span class="Comment">//</span> If the mouse is on the menu change the</span> // If the mouse is on the menu change the
<span class="Comment"><span class="Comment">//</span> value of 'last'</span> // value of 'last'
<span class="Comment"><span class="Comment">//</span> try to hide the menu when the mouse </span> // try to hide the menu when the mouse
<span class="Comment"><span class="Comment">//</span> go out off the menu.</span> // go out off the menu.
<span class="Keyword">$</span>(<span class="String"><span class="String">'</span>#entete<span class="String">'</span></span>).hover( $('#entete').hover(
<span class="Storage">function</span>(){last<span class="Keyword">+</span><span class="Keyword">=</span><span class="Constant">1</span>;}, function(){last+=1;},
<span class="Storage">function</span>(){autoHideMenu(last);} ); function(){autoHideMenu(last);} );
autoHideMenu(<span class="Constant">0</span>); autoHideMenu(0);
}); });
<span class="Comment"><span class="Comment">//</span> show / hide menu functions details</span> // show / hide menu functions details
<span class="Comment"><span class="Comment">//</span> move to the left</span> // move to the left
<span class="Storage">function</span> <span class="Entity">hideMenu</span>() { function hideMenu() {
<span class="Keyword">$</span>(<span class="String"><span class="String">'</span>#entete<span class="String">'</span></span>).animate({left:<span class="String"><span class="String">&quot;</span>-10em<span class="String">&quot;</span></span>}, <span class="Constant">500</span> ); $('#entete').animate({left:"-10em"}, 500 );
} }
<span class="Comment"><span class="Comment">//</span> move to right and will try to hide in 5 sec.</span> // move to right and will try to hide in 5 sec.
<span class="Storage">function</span> <span class="Entity">showMenu</span>() { function showMenu() {
<span class="Keyword">$</span>(<span class="String"><span class="String">'</span>#entete<span class="String">'</span></span>).animate({left:<span class="String"><span class="String">&quot;</span>0em<span class="String">&quot;</span></span>}, <span class="Constant">500</span> ); $('#entete').animate({left:"0em"}, 500 );
last<span class="Keyword">+</span><span class="Keyword">=</span><span class="Constant">1</span>; last+=1;
autoHideMenu(last); autoHideMenu(last);
} }
</pre></div> </code></pre>
<p>Simple and lightweight. No timer (almost), no memory leak, no Date&hellip;</p> </div>
<p>Simple and lightweight. No timer (almost), no memory leak, no Date…</p>
</div> </div>

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="lancer un démon en ligne de commande" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2009-10-launch-daemon-from-command-line/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="lancer un démon en ligne de commande" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2009-10-launch-daemon-from-command-line/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -54,13 +57,16 @@
<div class="flush"></div> <div class="flush"></div>
<div id="afterheader"> <div id="afterheader">
<div class="corps"> <div class="corps">
<p>Here is a tip, I don&rsquo;t know why, but I almost always forgot how to do that.</p> <p>Here is a tip, I dont know why, but I almost always forgot how to do that.</p>
<p>When you want to launch a command and this command should not be killed after you close your terminal. Here is how to accomplish that from command line: </p> <p>When you want to launch a command and this command should not be killed after you close your terminal. Here is how to accomplish that from command line: </p>
<div><pre class="twilight"> <div>
nohup cmd <span class="Keyword">&amp;</span>
</pre> <pre><code class="zsh">nohup cmd &amp;
</code></pre>
<small>where <code>cmd</code> is your command.</small> <small>where <code>cmd</code> is your command.</small>
</div> </div>

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Usages non dits de Git" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2009-10-untaught-git-usage/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Usages non dits de Git" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2009-10-untaught-git-usage/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -54,9 +57,9 @@
<div class="flush"></div> <div class="flush"></div>
<div id="afterheader"> <div id="afterheader">
<div class="corps"> <div class="corps">
<p><small> <em>I explain why I had so much difficulties to use Git. There is an &ldquo;untaught rule&rdquo; that make hard to work without. Until I read the good document. </em></small></p> <p><small> <em>I explain why I had so much difficulties to use Git. There is an “untaught rule” that make hard to work without. Until I read the good document. </em></small></p>
<p><small> <em> &ldquo;Cheap branches&rdquo; aren&rsquo;t designed to be totally isolated branches but rather should follow a &ldquo;Master Branch&rdquo;. There is a </em>Standard Workflow<em> to follow. If you don&rsquo;t follow it, you prepare yourself with some hard time with Git.</em> </small></p> <p><small> <em> “Cheap branches” arent designed to be totally isolated branches but rather should follow a “Master Branch”. There is a </em>Standard Workflow<em> to follow. If you dont follow it, you prepare yourself with some hard time with Git.</em> </small></p>
</div> </div>
@ -72,7 +75,7 @@
<p>I must say I was completely convinced. And the more you learn about <abbr title="Decentralized Concurrent Versioning System">DCVS</abbr> the more you see good reason to use them.</p> <p>I must say I was completely convinced. And the more you learn about <abbr title="Decentralized Concurrent Versioning System">DCVS</abbr> the more you see good reason to use them.</p>
<p>I then needed a versioning system for my team. As they were not used to open source versioning system except those heavy, with a GUI and with and administrator<sup><a href="#note1">&dagger;</a></sup></p> <p>I then needed a versioning system for my team. As they were not used to open source versioning system except those heavy, with a GUI and with and administrator<sup><a href="#note1"></a></sup></p>
<p>After some web searches, I founded three main choices:</p> <p>After some web searches, I founded three main choices:</p>
@ -82,7 +85,7 @@
<li><a href="http://selenic.com/mercurial">Mercurial</a></li> <li><a href="http://selenic.com/mercurial">Mercurial</a></li>
</ul> </ul>
<p>After trying each other I chosen Bazaar. It has the simplest User Interface<sup><a href="#note2">&#42;</a></sup>. My choice was done.</p> <p>After trying each other I chosen Bazaar. It has the simplest User Interface<sup><a href="#note2">*</a></sup>. My choice was done.</p>
<h3 id="from-bazaar-to-git">From Bazaar to Git</h3> <h3 id="from-bazaar-to-git">From Bazaar to Git</h3>
@ -91,21 +94,21 @@
<p>After some times, reading on many blogs, I realize Git is far more popular and by influent people. </p> <p>After some times, reading on many blogs, I realize Git is far more popular and by influent people. </p>
<p>I then decide to use Git in particular to <em>version</em> this current website. <p>I then decide to use Git in particular to <em>version</em> this current website.
But after trying it, I found it difficult and couter intuitive (I&rsquo;ll speak a work about it later).</p> But after trying it, I found it difficult and couter intuitive (Ill speak a work about it later).</p>
<p>After calling for some help, when I say Bazaar is much simpler to learn, some people answer me that Git:</p> <p>After calling for some help, when I say Bazaar is much simpler to learn, some people answer me that Git:</p>
<blockquote> <blockquote>
<p>&mdash; <em>SO-MUCH-EASY my 12 year old daughter uses it to version its school documents. She has no difficulties at all, creating branches, blah, blah, blah&hellip;</em></p> <p> <em>SO-MUCH-EASY my 12 year old daughter uses it to version its school documents. She has no difficulties at all, creating branches, blah, blah, blah</em></p>
</blockquote> </blockquote>
<p>If a 12 years old girl has no problem with Git and I (with my Computer Science Ph.D.) have difficulties to uses it like I want, it is frustrating and humiliating. But what makes Git natural for some people and confusing for me? </p> <p>If a 12 years old girl has no problem with Git and I (with my Computer Science Ph.D.) have difficulties to uses it like I want, it is frustrating and humiliating. But what makes Git natural for some people and confusing for me? </p>
<p>I finally understood why reading a document I didn&rsquo;t read before. It was the <em>untaught</em> part of the conception. The part every developer found so <em>natural</em> it is not necessary to say a word about it. But it was not <em>natural</em> for me.</p> <p>I finally understood why reading a document I didnt read before. It was the <em>untaught</em> part of the conception. The part every developer found so <em>natural</em> it is not necessary to say a word about it. But it was not <em>natural</em> for me.</p>
<p><small><a name="note1">&dagger;</a> - I speak about <em>ClearCase<small>&copy;</small></em>. I know there exists command line tools. But it was not the way my team used it.</small></p> <p><small><a name="note1"></a> - I speak about <em>ClearCase<small>&copy;</small></em>. I know there exists command line tools. But it was not the way my team used it.</small></p>
<p><small><a name="note2">&#42;</a> - I never really given its chance to Mercurial. The terminology they chosen was too far from the svn one. And I was used to it.</small></p> <p><small><a name="note2">*</a> - I never really given its chance to Mercurial. The terminology they chosen was too far from the svn one. And I was used to it.</small></p>
</div> </div>
@ -113,7 +116,7 @@ But after trying it, I found it difficult and couter intuitive (I&rsquo;ll speak
<div class="corps"> <div class="corps">
<p>When you see explanation about <em>branches</em> and <abbr title="Decentralized Concurrent Versioning System">DCVS</abbr> we imagine each branch is totally uncorrelated to each other, except when <em>merging</em>. Everything is magic. This is the &ldquo;<em>Parallel World</em>&rdquo; explanation. This way of seeing is explained more in depth in the <a href="http://betterexplained.com/articles/a-visual-guide-to-version-control/">real good article about branches</a> on betterexplained. </p> <p>When you see explanation about <em>branches</em> and <abbr title="Decentralized Concurrent Versioning System">DCVS</abbr> we imagine each branch is totally uncorrelated to each other, except when <em>merging</em>. Everything is magic. This is the <em>Parallel World</em> explanation. This way of seeing is explained more in depth in the <a href="http://betterexplained.com/articles/a-visual-guide-to-version-control/">real good article about branches</a> on betterexplained. </p>
<p>Git was designed to manage the Linux Kernel. Git was designed using the concept of <em>Patch</em> instead of <em>Parallel Worlds</em>.</p> <p>Git was designed to manage the Linux Kernel. Git was designed using the concept of <em>Patch</em> instead of <em>Parallel Worlds</em>.</p>
@ -124,11 +127,11 @@ But after trying it, I found it difficult and couter intuitive (I&rsquo;ll speak
<li>While Git seem base on the <em>Patch</em> model which will implie the creation of <em>Parallel Worlds</em>.</li> <li>While Git seem base on the <em>Patch</em> model which will implie the creation of <em>Parallel Worlds</em>.</li>
</ul> </ul>
<p>I will not argument about which is the best. Just tell my vision of DCVS come from the <em>Parallel World</em> vision and Git was designed the other way<sup><a href="#note3">&Dagger;</a></sup>.</p> <p>I will not argument about which is the best. Just tell my vision of DCVS come from the <em>Parallel World</em> vision and Git was designed the other way<sup><a href="#note3"></a></sup>.</p>
<h2 id="from-theory-to-real-life-usage">From Theory to Real Life Usage</h2> <h2 id="from-theory-to-real-life-usage">From Theory to Real Life Usage</h2>
<p>I believe I understood conceptual mechanism under Git. But I had some difficulties with real usage. The worst point, the one I didn&rsquo;t get before long was because I didn&rsquo;t get really well the notion of <em>Cheap Branching</em>.</p> <p>I believe I understood conceptual mechanism under Git. But I had some difficulties with real usage. The worst point, the one I didnt get before long was because I didnt get really well the notion of <em>Cheap Branching</em>.</p>
<p>What is a <em>Cheap Branch</em>? If like me you come from Bazaar, it is a totally new notion. It is in fact the ability to create a branches all of them using the same directory.</p> <p>What is a <em>Cheap Branch</em>? If like me you come from Bazaar, it is a totally new notion. It is in fact the ability to create a branches all of them using the same directory.</p>
@ -136,10 +139,10 @@ But after trying it, I found it difficult and couter intuitive (I&rsquo;ll speak
<p>In theory, <em>Cheap Branches</em> are exactly like Bazaar branches. The word used is <em>Branch</em> and not <em>Cheap Branch</em>. But there is a slight difference between them. A slight difference between a <em>Cloned Branch</em> and a <em>Cheap Branch</em>.</p> <p>In theory, <em>Cheap Branches</em> are exactly like Bazaar branches. The word used is <em>Branch</em> and not <em>Cheap Branch</em>. But there is a slight difference between them. A slight difference between a <em>Cloned Branch</em> and a <em>Cheap Branch</em>.</p>
<p>A &ldquo;Standard branch&rdquo; is what is theoretically a kind of new <em>Parallel World</em>. <p>A “Standard branch” is what is theoretically a kind of new <em>Parallel World</em>.
But <em>Cheap branch</em> was designed to be future <em>Patch</em> for the main branch of the directory/Cloned branch.</p> But <em>Cheap branch</em> was designed to be future <em>Patch</em> for the main branch of the directory/Cloned branch.</p>
<p>Of course, I know anybody can state you can totally use <em>Cheap branches</em> as <em>Cloned branches</em>. But they weren&rsquo;t designed for that. On daily usage, it is a bit uneasy to use it like this.</p> <p>Of course, I know anybody can state you can totally use <em>Cheap branches</em> as <em>Cloned branches</em>. But they werent designed for that. On daily usage, it is a bit uneasy to use it like this.</p>
<p>Here how Git <em>cheap branches</em> should be used (for more details see <a href="http://hoth.entp.com/output/git_for_designers.html">Git for Designers</a>):</p> <p>Here how Git <em>cheap branches</em> should be used (for more details see <a href="http://hoth.entp.com/output/git_for_designers.html">Git for Designers</a>):</p>
@ -148,11 +151,11 @@ But <em>Cheap branch</em> was designed to be future <em>Patch</em> for the main
<li>creation of a <em>Cheap branch</em> containing differences which <strong>have</strong> to be patched somewhere in the future into <strong><span class="sc">The Great Repository</span></strong></li> <li>creation of a <em>Cheap branch</em> containing differences which <strong>have</strong> to be patched somewhere in the future into <strong><span class="sc">The Great Repository</span></strong></li>
</ul> </ul>
<p>Here&rsquo;s how you should <strong>not</strong> use Git:</p> <p>Heres how you should <strong>not</strong> use Git:</p>
<ul> <ul>
<li>Get or creation of a repository</li> <li>Get or creation of a repository</li>
<li>Create a <em>cheap branch</em> which will never push it&rsquo;s modification to the main repository.</li> <li>Create a <em>cheap branch</em> which will never push its modification to the main repository.</li>
</ul> </ul>
<p>This simple minor difference of point of view confused me a lot.</p> <p>This simple minor difference of point of view confused me a lot.</p>
@ -170,23 +173,35 @@ And I return exactly in branches Bazaar provided me.</p>
<p>For now, I prefer (from far) Bazaar terminology. They are cleaner and more understandable.</p> <p>For now, I prefer (from far) Bazaar terminology. They are cleaner and more understandable.</p>
<div><pre class="twilight">bzr revert <div>
</pre></div>
<pre><code class="zsh">bzr revert</code></pre>
</div>
<p>Is clearer than</p> <p>Is clearer than</p>
<div><pre class="twilight">git reset --hard HEAD <div>
</pre></div>
<pre><code class="zsh">git reset --hard HEAD</code></pre>
</div>
<p>We can tell the same thing about</p> <p>We can tell the same thing about</p>
<div><pre class="twilight">bzr revert -r -3 <div>
</pre></div>
<pre><code class="zsh">bzr revert -r -3</code></pre>
</div>
<p>which seems preferable to</p> <p>which seems preferable to</p>
<div><pre class="twilight">git reset --hard HEAD~3 <div>
</pre></div>
<pre><code class="zsh">git reset --hard HEAD~3</code></pre>
</div>
<p>Until now, it is not big business. But now, things will go worse. <p>Until now, it is not big business. But now, things will go worse.
If we want to revert time on all the tree we use the keyword <code>reset</code>.</p> If we want to revert time on all the tree we use the keyword <code>reset</code>.</p>
@ -195,34 +210,49 @@ If we want to revert time on all the tree we use the keyword <code>reset</code>.
<p>Now, if I want to revert time on on file. We should naturally imagine the command will be:</p> <p>Now, if I want to revert time on on file. We should naturally imagine the command will be:</p>
<div><pre class="twilight">git reset --hard FILE <div>
</pre></div>
<pre><code class="zsh">git reset --hard FILE</code></pre>
</div>
<center>**OF COURSE NOT!**</center> <center>**OF COURSE NOT!**</center>
<p>The solution is:</p> <p>The solution is:</p>
<div><pre class="twilight">git checkout FILE <div>
</pre></div>
<pre><code class="zsh">git checkout FILE</code></pre>
</div>
<p>What? <strong><code>checkout</code></strong>&nbsp;!? Well, ok. I accept. why not? <p>What? <strong><code>checkout</code></strong>&nbsp;!? Well, ok. I accept. why not?
With Bazaar it is:</p> With Bazaar it is:</p>
<div><pre class="twilight">git revert FILE <div>
</pre></div>
<pre><code class="zsh">git revert FILE</code></pre>
</div>
<p>What I personally found far more natural.</p> <p>What I personally found far more natural.</p>
<p>But the command to change the current <em>cheap branch</em> is really hard to be accepted (from the User Interface point of view). <p>But the command to change the current <em>cheap branch</em> is really hard to be accepted (from the User Interface point of view).
With Bazaar it is:</p> With Bazaar it is:</p>
<div><pre class="twilight">cd ../branch <div>
</pre></div>
<pre><code class="zsh">cd ../branch</code></pre>
</div>
<p>Well yes. With Bazaar you have to change your directory to change your branch. It needs more disk resources but it is really clear. Which is my current branch, is just a <code>pwd</code> away. For Git here is the command:</p> <p>Well yes. With Bazaar you have to change your directory to change your branch. It needs more disk resources but it is really clear. Which is my current branch, is just a <code>pwd</code> away. For Git here is the command:</p>
<div><pre class="twilight">git checkout branch <div>
</pre></div>
<pre><code class="zsh">git checkout branch</code></pre>
</div>
<p><strong>WTF?</strong> I believed <code>checkout</code> was the key to get a file in some state (not the entire tree).</p> <p><strong>WTF?</strong> I believed <code>checkout</code> was the key to get a file in some state (not the entire tree).</p>
@ -232,15 +262,15 @@ With Bazaar it is:</p>
<blockquote> <blockquote>
<ul> <ul>
<li>&mdash; Try to find the good keyword for this operation</li> <li> Try to find the good keyword for this operation</li>
<li>&mdash; Wrong! Try again!</li> <li> Wrong! Try again!</li>
<li>&mdash; False, it is not yet right!</li> <li> False, it is not yet right!</li>
</ul> </ul>
</blockquote> </blockquote>
<p>That were the Git bad side. But It has many advantages. Once you&rsquo;ve understood the <em>cheap branching</em> paradigm. All became clearer for me after. Even if there is also some difficulties with the edit of the <code>.git/config</code> files (not user friendly at all).</p> <p>That were the Git bad side. But It has many advantages. Once youve understood the <em>cheap branching</em> paradigm. All became clearer for me after. Even if there is also some difficulties with the edit of the <code>.git/config</code> files (not user friendly at all).</p>
<p><small><a name="note3">&Dagger;</a> I must precise that I worked a lot with multi-modal logic and particularly about &ldquo;Temporal Logics&rdquo; (linear or not). This is why I was more inclined to see things this way. &ldquo;Ah&nbsp;! Just to remember my firsts love with computer science&nbsp;!&rdquo;</small></p> <p><small><a name="note3"></a> I must precise that I worked a lot with multi-modal logic and particularly about “Temporal Logics” (linear or not). This is why I was more inclined to see things this way. “Ah&nbsp;! Just to remember my firsts love with computer science&nbsp;!”</small></p>
</div> </div>
@ -257,15 +287,15 @@ Such as working on a fix on a totally isolated branches.</p>
<h3 id="is-git-better-than-bazaar">Is Git better than Bazaar?</h3> <h3 id="is-git-better-than-bazaar">Is Git better than Bazaar?</h3>
<p>Speaking about <em>features</em> I&rsquo;ll tell Git is the best. <p>Speaking about <em>features</em> Ill tell Git is the best.
But Git was too much in my way. Is was exactly what I didn&rsquo;t want for my first DCVS.</p> But Git was too much in my way. Is was exactly what I didnt want for my first DCVS.</p>
<p>I shouldn&rsquo;t have had those difficulties about understanding <em>cheap branching which must be a patch</em>. In reality, Git make a difference between the Tree and the Branch. Which is obviously not the case for Bazaar. Conceptually, bazaar is simpler to understand.</p> <p>I shouldnt have had those difficulties about understanding <em>cheap branching which must be a patch</em>. In reality, Git make a difference between the Tree and the Branch. Which is obviously not the case for Bazaar. Conceptually, bazaar is simpler to understand.</p>
<h3 id="finally">Finally</h3> <h3 id="finally">Finally</h3>
<p>In conclusion, I use Git more often than Bazaar and I must say, that I have some preferences for Git. However, Git lack hardly clear commands name like <code>revert</code>. <p>In conclusion, I use Git more often than Bazaar and I must say, that I have some preferences for Git. However, Git lack hardly clear commands name like <code>revert</code>.
For now I don&rsquo;t made alias to correct that. But may be one day I should do that.</p> For now I dont made alias to correct that. But may be one day I should do that.</p>
</div> </div>

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Git pour les nuls" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2009-11-12-Git-for-n00b/Git-pour-quoi-faire/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Git pour les nuls" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2009-11-12-Git-for-n00b/Git-pour-quoi-faire/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -70,34 +73,40 @@
</div> </div>
<p><a href="http://git-scm.org" title="Git">Git</a> is a <abbr title="Decentralized Concurent Versions System">DCVS</abbr>, which means a Decentralized Concurrent Versions System. Let&rsquo;s analyze each part of this long term:</p> <p><a href="http://git-scm.org" title="Git">Git</a> is a <abbr title="Decentralized Concurent Versions System">DCVS</abbr>, which means a Decentralized Concurrent Versions System. Lets analyze each part of this long term:</p>
<h3 id="versions-system">Versions System</h3> <h3 id="versions-system">Versions System</h3>
<p>Firstly, versions system manage files. <p>Firstly, versions system manage files.
When somebody work with files without a versions system, the following happens frequently:</p> When somebody work with files without a versions system, the following happens frequently:</p>
<p>When you modify a somehow critical file you don&rsquo;t want to loose. You copy naturally this file with another name. For example:</p> <p>When you modify a somehow critical file you dont want to loose. You copy naturally this file with another name. For example:</p>
<div><pre class="twilight">$ cp fichier_important.c fichier_important.c.bak
</pre></div>
<p>In consequence of what, the new file, play the role of <em>backup</em>. If you break everything, you can always return in the last state by overwriting your modifications.
Of course, this method is not very professional and is a bit limited. If you make many modifications, you&rsquo;ll end with many files with strange names like:</p>
<div> <div>
<pre class="twilight">
fichier_important.c.bak <pre><code class="zsh">$ cp fichier_important.c fichier_important.c.bak</code></pre>
</div>
<p>In consequence of what, the new file, play the role of <em>backup</em>. If you break everything, you can always return in the last state by overwriting your modifications.
Of course, this method is not very professional and is a bit limited. If you make many modifications, youll end with many files with strange names like:</p>
<div>
<pre><code class="zsh">fichier_important.c.bak
fichier_important.c.old fichier_important.c.old
fichier_important.c.Bakcup fichier_important.c.Bakcup
fichier_important.c.BAK.2009-11-14 fichier_important.c.BAK.2009-11-14
fichier_important.c.2009.11.14 fichier_important.c.2009.11.14
fichier_important.c.12112009 fichier_important.c.12112009
old.fichier_important.c old.fichier_important.c
</pre> </code></pre>
</div> </div>
<p>If you want to make it works correctly, you&rsquo;ll have to use naming convention. Files take many place even if you modify most of time only some lines.</p> <p>If you want to make it works correctly, youll have to use naming convention. Files take many place even if you modify most of time only some lines.</p>
<p><em>Fortunately, versions system are here to help.</em></p> <p><em>Fortunately, versions system are here to help.</em></p>
@ -105,13 +114,13 @@ old.fichier_important.c
<p>Once upon a time versions were managed for each file separately. I think about CVS. Then it naturally appears projects are a coherent set of files. Recover each file separately was a tedious work. This is why versions number passed from files to the entire project.</p> <p>Once upon a time versions were managed for each file separately. I think about CVS. Then it naturally appears projects are a coherent set of files. Recover each file separately was a tedious work. This is why versions number passed from files to the entire project.</p>
<p>It is therefore possible to say, &ldquo;I want to get back three days earlier&rdquo;.</p> <p>It is therefore possible to say, “I want to get back three days earlier”.</p>
<div class="black"> <div class="black">
<p><em>What gives versions system?</em> (I didn&rsquo;t mention everything at all)</p> <p><em>What gives versions system?</em> (I didnt mention everything at all)</p>
<ul> <ul>
<li>automatic backups: <em>back in time</em>,</li> <li>automatic backups: <em>back in time</em>,</li>
@ -128,14 +137,17 @@ old.fichier_important.c
<p>Version Systems are already useful to manage its own projects. They help to organize and resolve partially backup problems. I say partially because you have to backup your repository on a decent file system. But versions system are really interesting is on projects done by many people.</p> <p>Version Systems are already useful to manage its own projects. They help to organize and resolve partially backup problems. I say partially because you have to backup your repository on a decent file system. But versions system are really interesting is on projects done by many people.</p>
<p>Let&rsquo;s begin by an example, a two person project&nbsp;; Alex and Beatrice. On a file containing a <em>Lovecraft</em>&rsquo;s gods list:</p> <p>Lets begin by an example, a two person project&nbsp;; Alex and Beatrice. On a file containing a <em>Lovecraft</em>s gods list:</p>
<div style="width: 10em; margin-left: auto; margin-right: auto"> <div style="width: 10em; margin-left: auto; margin-right: auto">
<pre class="twilight">
Cthulhu
<pre><code class="zsh">Cthulhu
Shubniggurath Shubniggurath
Yogsototh Yogsototh
</pre></div> </code></pre>
</div>
<p>Say Alex is home and modify the file: <p>Say Alex is home and modify the file:
&lt;div style="width: 10em; margin-left: auto; margin-right: auto"&gt; &lt;div style="width: 10em; margin-left: auto; margin-right: auto"&gt;
@ -187,7 +199,7 @@ Yogsototh
<ul> <ul>
<li>get without any problem others modifications,</li> <li>get without any problem others modifications,</li>
<li>send without any problem its own modifications to others,</li> <li>send without any problem its own modifications to others,</li>
<li>manage conflicts. I didn&rsquo;t speak about it, but sometimes a conflict can occur (when two different people modify the same line on a file for example). SVC help to resolve such problem. More on that later,</li> <li>manage conflicts. I didnt speak about it, but sometimes a conflict can occur (when two different people modify the same line on a file for example). SVC help to resolve such problem. More on that later,</li>
<li>help to know who done what and when.</li> <li>help to know who done what and when.</li>
</ul> </ul>
@ -199,7 +211,7 @@ Yogsototh
<p>This word became popular only recently about CVS. And it mainly means two things:</p> <p>This word became popular only recently about CVS. And it mainly means two things:</p>
<p>First, until really recently (SVN), you&rsquo;ll have to be connected to the distant server to get informations about a project. Like get the history. New decentralized systems work with a local <em>REPOSITORY</em> (directory containing backups and many informations linked to the versions system functionalities). Hence, one can view the history of a project without the need of being connected.</p> <p>First, until really recently (SVN), youll have to be connected to the distant server to get informations about a project. Like get the history. New decentralized systems work with a local <em>REPOSITORY</em> (directory containing backups and many informations linked to the versions system functionalities). Hence, one can view the history of a project without the need of being connected.</p>
<p>All instances of a project can live <em>independently</em>.</p> <p>All instances of a project can live <em>independently</em>.</p>
@ -212,7 +224,7 @@ Yogsototh
<p>Typical example:</p> <p>Typical example:</p>
<blockquote> <blockquote>
<p>I develop my project. I&rsquo;m ameliorating something. An urgent bug is reported.</p> <p>I develop my project. Im ameliorating something. An urgent bug is reported.</p>
<p>With a DCVS I can easily, get back to the version with the bug. Fix it. Send the fix. Get back to my feature work. And even, use the fix for the new version with my new feature.</p> <p>With a DCVS I can easily, get back to the version with the bug. Fix it. Send the fix. Get back to my feature work. And even, use the fix for the new version with my new feature.</p>
@ -237,7 +249,7 @@ Yogsototh
<h2 id="to-resume">To resume</h2> <h2 id="to-resume">To resume</h2>
<p>Let&rsquo;s resume what we can easily do with DCVS:</p> <p>Lets resume what we can easily do with DCVS:</p>
<p><strong>Versions Systems</strong></p> <p><strong>Versions Systems</strong></p>
@ -263,7 +275,7 @@ Yogsototh
<li>Easily manipulate branches</li> <li>Easily manipulate branches</li>
</ul> </ul>
<p>Now let&rsquo;s see how to obtain all these things easily with <a href="http://git-scm.org" title="Git">Git</a>.</p> <p>Now lets see how to obtain all these things easily with <a href="http://git-scm.org" title="Git">Git</a>.</p>
</div> </div>

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Git pour les nuls" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2009-11-12-Git-for-n00b/c-est-parti-pour-l-aventure/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Git pour les nuls" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2009-11-12-Git-for-n00b/c-est-parti-pour-l-aventure/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -84,16 +87,19 @@
<h3 id="conflicts-management">Conflicts management</h3> <h3 id="conflicts-management">Conflicts management</h3>
<p>Conflicts can arise when you change the same line of code on the same file from another branch you&rsquo;re merging. It can seems a bit intimidating, but with <a href="http://git-scm.org" title="Git">Git</a> this kind of thing is really simple to handle.</p> <p>Conflicts can arise when you change the same line of code on the same file from another branch youre merging. It can seems a bit intimidating, but with <a href="http://git-scm.org" title="Git">Git</a> this kind of thing is really simple to handle.</p>
<h4 id="example">example</h4> <h4 id="example">example</h4>
<p>You start from the following file</p> <p>You start from the following file</p>
<div style="width: 18em; margin-left: auto; margin-right: auto"> <div style="width: 18em; margin-left: auto; margin-right: auto">
<pre class="twilight">
Zoot
</pre> <pre><code class="zsh">Zoot
</code></pre>
</div> </div>
<p>and you modify one line</p> <p>and you modify one line</p>
@ -115,17 +121,20 @@ Zoot<span class="StringConstant"><strong>, just Zoot</strong></span>
<p>Now when you do a:</p> <p>Now when you do a:</p>
<div> <div>
<pre class="twilight">
$ git pull
remote: Counting objects: 5, <span class="Keyword">done</span>. <pre><code class="zsh">$ git pull
remote: Counting objects: 5, done.
remote: Total 3 (delta 0), reused 0 (delta 0) remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), <span class="Keyword">done</span>. Unpacking objects: 100% (3/3), done.
From /home/e640846/tmp/conflictTest From /home/e640846/tmp/conflictTest
d3ea395..2dc7ffb master -<span class="Keyword">&gt;</span> origin/master d3ea395..2dc7ffb master -&gt; origin/master
Auto-merging foo Auto-merging foo
CONFLICT (content): Merge conflict <span class="Keyword">in</span> foo CONFLICT (content): Merge conflict in foo
Automatic merge failed<span class="Keyword">;</span> fix conflicts and <span class="Keyword">then</span> commit the result. Automatic merge failed; fix conflicts and then commit the result.
</pre> </code></pre>
</div> </div>
<p>Our file <code>foo</code> now contains: </p> <p>Our file <code>foo</code> now contains: </p>
@ -153,13 +162,16 @@ Zoot <span class="Constant"><strong>the not so pure</strong></span>
<p>and to commit</p> <p>and to commit</p>
<div> <div>
<pre class="twilight">
git commit -a -m <span class="String"><span class="String">&quot;</span>conflict resolved<span class="String">&quot;</span></span>
</pre> <pre><code class="zsh">git commit -a -m "conflict resolved"
</code></pre>
</div> </div>
<p>Now you&rsquo;re ready to use <a href="http://git-scm.org" title="Git">Git</a>. <p>Now youre ready to use <a href="http://git-scm.org" title="Git">Git</a>.
<a href="http://git-scm.org" title="Git">Git</a> provide many other functionnalities. Now we&rsquo;ll see some <a href="http://git-scm.org" title="Git">Git</a> usages older CVS couldn&rsquo;t handle.</p> <a href="http://git-scm.org" title="Git">Git</a> provide many other functionnalities. Now well see some <a href="http://git-scm.org" title="Git">Git</a> usages older CVS couldnt handle.</p>
</div> </div>

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Git pour les nuls" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2009-11-12-Git-for-n00b/commandes-avancees/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Git pour les nuls" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2009-11-12-Git-for-n00b/commandes-avancees/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -78,114 +81,165 @@
<h3 id="get-others-modifications">get others modifications</h3> <h3 id="get-others-modifications">get others modifications</h3>
<div><pre class="twilight"> <div>
$ git pull
</pre></div> <pre><code class="zsh">$ git pull
</code></pre>
</div>
<h3 id="send-modifications-to-others">send modifications to others</h3> <h3 id="send-modifications-to-others">send modifications to others</h3>
<div><pre class="twilight"> <div>
$ git push
</pre></div> <pre><code class="zsh">$ git push
</code></pre>
</div>
<p>or more generally</p> <p>or more generally</p>
<div><pre class="twilight"> <div>
$ git pull
<pre><code class="zsh">$ git pull
$ git push $ git push
</pre></div> </code></pre>
</div>
<h3 id="get-back-in-time">get back in time</h3> <h3 id="get-back-in-time">get back in time</h3>
<h4 id="for-all-tree">For all tree</h4> <h4 id="for-all-tree">For all tree</h4>
<div><pre class="twilight"> <div>
$ git checkout
</pre></div>
<div><pre class="twilight"> <pre><code class="zsh">$ git checkout
$ git revert </code></pre>
</pre></div>
</div>
<div>
<pre><code class="zsh">$ git revert
</code></pre>
</div>
<p>revert three version before (see my <code>.gitconfig</code> file).</p> <p>revert three version before (see my <code>.gitconfig</code> file).</p>
<div><pre class="twilight"> <div>
$ git uncommit 3
</pre></div> <pre><code class="zsh">$ git uncommit 3
</code></pre>
</div>
<p>Undo the las merge (if something goes wrong)</p> <p>Undo the las merge (if something goes wrong)</p>
<div><pre class="twilight"> <div>
$ git revertbeforemerge
</pre></div> <pre><code class="zsh">$ git revertbeforemerge
</code></pre>
</div>
<h4 id="for-one-file">For one file</h4> <h4 id="for-one-file">For one file</h4>
<div><pre class="twilight"> <div>
$ git checkout file
<pre><code class="zsh">$ git checkout file
$ git checkout VersionHash file $ git checkout VersionHash file
$ git checkout HEAD~3 file $ git checkout HEAD~3 file
</pre></div> </code></pre>
</div>
<h3 id="list-differences-between-each-version">list differences between each version</h3> <h3 id="list-differences-between-each-version">list differences between each version</h3>
<p>list files being modified</p> <p>list files being modified</p>
<div><pre class="twilight"> <div>
$ git status
</pre></div> <pre><code class="zsh">$ git status
</code></pre>
</div>
<p>differences between last version files and local files</p> <p>differences between last version files and local files</p>
<div><pre class="twilight"> <div>
$ git diff
</pre></div> <pre><code class="zsh">$ git diff
</code></pre>
</div>
<p>differences between some version and local files</p> <p>differences between some version and local files</p>
<div><pre class="twilight"> <div>
$ git diff VersionHash fichier
</pre></div> <pre><code class="zsh">$ git diff VersionHash fichier
</code></pre>
</div>
<h3 id="name-some-version-to-refer-to-them-in-the-future">name some version to refer to them in the future</h3> <h3 id="name-some-version-to-refer-to-them-in-the-future">name some version to refer to them in the future</h3>
<div><pre class="twilight"> <div>
$ git tag <span class="String"><span class="String">'</span>toto<span class="String">'</span></span>
</pre></div> <pre><code class="zsh">$ git tag 'toto'
</code></pre>
</div>
<h3 id="show-historic-of-modifications">show historic of modifications</h3> <h3 id="show-historic-of-modifications">show historic of modifications</h3>
<div><pre class="twilight"> <div>
$ git log
<pre><code class="zsh">$ git log
$ git lg $ git lg
$ git logfull $ git logfull
</pre></div> </code></pre>
</div>
<h3 id="know-who-did-what-and-when">know who did what and when</h3> <h3 id="know-who-did-what-and-when">know who did what and when</h3>
<div><pre class="twilight"> <div>
$ git blame fichier
</pre></div> <pre><code class="zsh">$ git blame fichier
</code></pre>
</div>
<h3 id="handle-conflicts">handle conflicts</h3> <h3 id="handle-conflicts">handle conflicts</h3>
<div><pre class="twilight"> <div>
$ git conflict
</pre></div> <pre><code class="zsh">$ git conflict
</code></pre>
</div>
<h3 id="manage-branches">manage branches</h3> <h3 id="manage-branches">manage branches</h3>
<p>To create a branch: </p> <p>To create a branch: </p>
<div><pre class="twilight"> <div>
$ git branch branch_name
</pre></div> <pre><code class="zsh">$ git branch branch_name
</code></pre>
</div>
<p>To change the current branch: </p> <p>To change the current branch: </p>
<div><pre class="twilight"> <div>
$ git checkout branch_name
</pre></div> <pre><code class="zsh">$ git checkout branch_name
</code></pre>
</div>
</div> </div>

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Git pour les nuls" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2009-11-12-Git-for-n00b/comprendre/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Git pour les nuls" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2009-11-12-Git-for-n00b/comprendre/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -70,9 +73,9 @@
<p>All was done to code and decide how to organize your versions after. In other VCS it is not as natural as in <a href="http://git-scm.org" title="Git">Git</a>.</p> <p>All was done to code and decide how to organize your versions after. In other VCS it is not as natural as in <a href="http://git-scm.org" title="Git">Git</a>.</p>
<p>With <a href="http://git-scm.org" title="Git">Git</a> you can depend of many different sources. Then, there is not necessarily a &lsquo;master&rsquo; repository where everybody puts its modifications.</p> <p>With <a href="http://git-scm.org" title="Git">Git</a> you can depend of many different sources. Then, there is not necessarily a master repository where everybody puts its modifications.</p>
<p>What changes the most with <a href="http://git-scm.org" title="Git">Git</a> when you come from SVN, it&rsquo;s the idea of a centralized project on one server. With <a href="http://git-scm.org" title="Git">Git</a> many people could work on the same project but not necessarily on the same <em>repository</em> as main reference. One can easily fix a bug and send a patch to many different versions of a project.</p> <p>What changes the most with <a href="http://git-scm.org" title="Git">Git</a> when you come from SVN, its the idea of a centralized project on one server. With <a href="http://git-scm.org" title="Git">Git</a> many people could work on the same project but not necessarily on the same <em>repository</em> as main reference. One can easily fix a bug and send a patch to many different versions of a project.</p>
</div> </div>

View file

@ -1,4 +1,3 @@
[color] [color]
branch = auto branch = auto
diff = auto diff = auto

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Git pour les nuls" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2009-11-12-Git-for-n00b/conf-et-install/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Git pour les nuls" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2009-11-12-Git-for-n00b/conf-et-install/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -64,8 +67,11 @@
<p>Under Linux Ubuntu or Debian:</p> <p>Under Linux Ubuntu or Debian:</p>
<div><pre class="twilight">$ sudo apt-get install git <div>
</pre></div>
<pre><code class="zsh">$ sudo apt-get install git</code></pre>
</div>
<p>Under Mac OS X:</p> <p>Under Mac OS X:</p>
@ -74,19 +80,23 @@
<li>install <a href="http://git-scm.org" title="Git">Git</a></li> <li>install <a href="http://git-scm.org" title="Git">Git</a></li>
</ul> </ul>
<div><pre class="twilight"> <div>
$ sudo port selfupdate
<pre><code class="zsh">$ sudo port selfupdate
$ sudo port install git-core $ sudo port install git-core
</pre></div> </code></pre>
</div>
<h2 id="global-configuration">Global configuration</h2> <h2 id="global-configuration">Global configuration</h2>
<p>Save the following file as your <code>~/.gitconfig</code>.</p> <p>Save the following file as your <code>~/.gitconfig</code>.</p>
<div><div class="code"><div class="file"><a href="/Scratch/en/blog/2009-11-12-Git-for-n00b/conf-et-install/code/gitconfig"> &#x27A5; gitconfig </a></div><div class="withfile"> <div><div class="codefile"><a href="/Scratch/en/blog/2009-11-12-Git-for-n00b/conf-et-install/code/gitconfig">&#x27A5; gitconfig</a></div>
<pre class="twilight">
[color]
<pre><code class="zsh">[color]
branch = auto branch = auto
diff = auto diff = auto
status = auto status = auto
@ -97,24 +107,28 @@ $ sudo port install git-core
lg = log --pretty=oneline --graph lg = log --pretty=oneline --graph
logfull = log --pretty=fuller --graph --stat -p logfull = log --pretty=fuller --graph --stat -p
unstage = reset HEAD unstage = reset HEAD
<span class="Comment"><span class="Comment">#</span> there should be an article on what this command do</span> # there should be an article on what this command do
uncommit = <span class="Keyword">!</span>zsh -c <span class="String"><span class="String">'</span>&quot;if (($0)); then nb=$(( $0 - 1 )); else nb=0; fi; i=0; while ((i&lt;=nb)); do git revert -n --no-edit HEAD~$i; ((i++)); done; git commit -m \&quot;revert to $0 version(s) back\&quot;&quot;<span class="String">'</span></span> uncommit = !zsh -c '"if (($0)); then nb=$(( $0 - 1 )); else nb=0; fi; i=0; while ((i&lt;=nb)); do git revert -n --no-edit HEAD~$i; ((i++)); done; git commit -m \"revert to $0 version(s) back\""'
undomerge = reset --hard ORIG_HEAD undomerge = reset --hard ORIG_HEAD
conflict = <span class="Keyword">!</span>gitk --left-right HEAD...MERGE_HEAD conflict = !gitk --left-right HEAD...MERGE_HEAD
<span class="Comment"><span class="Comment">#</span> under Mac OS X, you should use gitx instead</span> # under Mac OS X, you should use gitx instead
<span class="Comment"><span class="Comment">#</span> conflict = !gitx --left-right HEAD...MERGE_HEAD</span> # conflict = !gitx --left-right HEAD...MERGE_HEAD
[branch] [branch]
autosetupmerge = true autosetupmerge = true
</pre> </code></pre>
</div></div></div>
</div>
<p>You can achieve the same result using for each entry the command: <code>git config --global</code>. Next, configure your name and your email. For example, if your name is John Doe and your email is <code>john.doe@email.com</code>. Launch the following commands:</p> <p>You can achieve the same result using for each entry the command: <code>git config --global</code>. Next, configure your name and your email. For example, if your name is John Doe and your email is <code>john.doe@email.com</code>. Launch the following commands:</p>
<div><pre class="twilight"> <div>
$ git config --global user.name John Doe
<pre><code class="zsh">$ git config --global user.name John Doe
$ git config --global user.email john.doe@email.com $ git config --global user.email john.doe@email.com
</pre></div> </code></pre>
</div>
<p>Here it is. Base configuration is over. The file containing alias will help to type shorter commands.</p> <p>Here it is. Base configuration is over. The file containing alias will help to type shorter commands.</p>
@ -122,69 +136,93 @@ $ git config --global user.email john.doe@email.com
<p>If a project is already versionned with <a href="http://git-scm.org" title="Git">Git</a> you should have an <code>URL</code> of the sources. Then use the following command:</p> <p>If a project is already versionned with <a href="http://git-scm.org" title="Git">Git</a> you should have an <code>URL</code> of the sources. Then use the following command:</p>
<div><pre class="twilight"> <div>
$ cd <span class="Keyword">~</span>/Projets
<pre><code class="zsh">$ cd ~/Projets
$ git clone git://main.server/path/to/file $ git clone git://main.server/path/to/file
</pre></div> </code></pre>
<p>If there is no git server but you&rsquo;ve got an <code>ssh</code> access. Just replace the <code>git://host</code> by <code>ssh://user@host</code>. In order not to type your password each time, use:</p> </div>
<div><pre class="twilight"> <p>If there is no git server but youve got an <code>ssh</code> access. Just replace the <code>git://host</code> by <code>ssh://user@host</code>. In order not to type your password each time, use:</p>
$ ssh-keygen -t rsa
</pre></div> <div>
<pre><code class="zsh">$ ssh-keygen -t rsa
</code></pre>
</div>
<p>Reply to question and <em>*do not enter</em> a password. Then copy your keys to the distant server. This is not the safest way to do this. The safest being, using <code>ssh-agent</code>.</p> <p>Reply to question and <em>*do not enter</em> a password. Then copy your keys to the distant server. This is not the safest way to do this. The safest being, using <code>ssh-agent</code>.</p>
<p>The easiest way if you have <code>ssh-copy-id</code>:</p> <p>The easiest way if you have <code>ssh-copy-id</code>:</p>
<div><pre class="twilight"> <div>
me@locahost$ ssh-copy-id <span class="Keyword">~</span>/.ssh/id_rsa.pub me@main.server
</pre></div> <pre><code class="zsh">me@locahost$ ssh-copy-id ~/.ssh/id_rsa.pub me@main.server
</code></pre>
</div>
<p>or manually</p> <p>or manually</p>
<div><pre class="twilight"> <div>
me@locahost$ scp <span class="Keyword">~</span>/.ssh/id_rsa.pub me@main.server:
<pre><code class="zsh">me@locahost$ scp ~/.ssh/id_rsa.pub me@main.server:
me@locahost$ ssh me@main.server me@locahost$ ssh me@main.server
password: password:
me@main.server$ cat id_rsa.pub <span class="Keyword">&gt;&gt;</span> <span class="Keyword">~</span>/.ssh/authorized_keys me@main.server$ cat id_rsa.pub &gt;&gt; ~/.ssh/authorized_keys
me@main.server$ rm id_rsa.pub me@main.server$ rm id_rsa.pub
me@main.server$ logout me@main.server$ logout
</pre></div> </code></pre>
<p>Now you don&rsquo;t need to write your password to access the <code>main.server</code>.</p> </div>
<p>Now you dont need to write your password to access the <code>main.server</code>.</p>
<h2 id="creating-a-new-project">Creating a new project</h2> <h2 id="creating-a-new-project">Creating a new project</h2>
<p>Suppose you already have a project with files. Then it is really easy to version it.</p> <p>Suppose you already have a project with files. Then it is really easy to version it.</p>
<div><pre class="twilight"> <div>
$ cd /path/to/project
<pre><code class="zsh">$ cd /path/to/project
$ git init $ git init
$ git add . $ git add .
$ git commit -m <span class="String"><span class="String">&quot;</span>Initial commit<span class="String">&quot;</span></span> $ git commit -m "Initial commit"
</pre></div> </code></pre>
<p>Let do a small remark. If you don&rsquo;t want to <em>version</em> every file. Typically intermediate compilation file, swap files&hellip; Then you need to exclude them. Just before launching the <code>git add .</code> command. You need to create a <code>.gitignore</code> file in the root directory of your project. This file will contain all exclude <em>pattern</em>. For example:</p> </div>
<div><pre class="twilight"> <p>Let do a small remark. If you dont want to <em>version</em> every file. Typically intermediate compilation file, swap files… Then you need to exclude them. Just before launching the <code>git add .</code> command. You need to create a <code>.gitignore</code> file in the root directory of your project. This file will contain all exclude <em>pattern</em>. For example:</p>
*.o
<div>
<pre><code class="zsh">*.o
*.bak *.bak
*.swp *.swp
*~ *~
</pre></div> </code></pre>
</div>
<p>Now, if you want to create a repository on a distant server, it <em>must</em> not be in <code>bare</code> mode. The repository will contain only versionning informations, but not the files of the project. To achieve that:</p> <p>Now, if you want to create a repository on a distant server, it <em>must</em> not be in <code>bare</code> mode. The repository will contain only versionning informations, but not the files of the project. To achieve that:</p>
<div><pre class="twilight"> <div>
$ cd /path/to/local/project
<pre><code class="zsh">$ cd /path/to/local/project
$ git clone --bare . ssh://server/path/to/project $ git clone --bare . ssh://server/path/to/project
</pre></div> </code></pre>
</div>
<p>Others will be able to get your modifications.</p> <p>Others will be able to get your modifications.</p>
<div><pre class="twilight"> <div>
git clone ssh://server/path/to/project
</pre></div> <pre><code class="zsh">git clone ssh://server/path/to/project
</code></pre>
</div>
<h2 id="abstract-of-the-second-step">Abstract of the second step</h2> <h2 id="abstract-of-the-second-step">Abstract of the second step</h2>

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Git pour les nuls" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2009-11-12-Git-for-n00b/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Git pour les nuls" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2009-11-12-Git-for-n00b/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -62,7 +65,7 @@
<div class="intro"> <div class="intro">
<p>A detailed tutorial of <a href="http://git-scm.org">Git</a> for people knowing very few about versions systems. You&rsquo;ll understand utility of such program and how we use modern version control system. I try to stay as pragmatic as possible.</p> <p>A detailed tutorial of <a href="http://git-scm.org">Git</a> for people knowing very few about versions systems. Youll understand utility of such program and how we use modern version control system. I try to stay as pragmatic as possible.</p>
</div> </div>
@ -80,37 +83,43 @@
<p>Get a project from the web: </p> <p>Get a project from the web: </p>
<div><pre class="twilight"> <div>
git clone ssh://server/path/to/project
</pre></div> <pre><code class="zsh">git clone ssh://server/path/to/project
</code></pre>
</div>
<p>Everyday <a href="http://git-scm.org" title="Git">Git</a> usage: </p> <p>Everyday <a href="http://git-scm.org" title="Git">Git</a> usage: </p>
<div><pre class="twilight"> <div>
<span class="Comment"><span class="Comment">#</span> get modifications from other</span>
<pre><code class="zsh"># get modifications from other
git pull git pull
<span class="Comment"><span class="Comment">#</span> read what was done</span> # read what was done
git log git log
<span class="Comment"><span class="Comment">#</span> Make local changes to files </span> # Make local changes to files
hack, hack, hack... hack, hack, hack...
<span class="Comment"><span class="Comment">#</span> list the modified files</span> # list the modified files
git status git status
<span class="Comment"><span class="Comment">#</span> show what I've done</span> # show what I've done
git diff git diff
<span class="Comment"><span class="Comment">#</span> tell git to version a new file</span> # tell git to version a new file
git add new/file git add new/file
<span class="Comment"><span class="Comment">#</span> commit its own modifications </span> # commit its own modifications
<span class="Comment"><span class="Comment">#</span> to its local branch</span> # to its local branch
git commit -a -m <span class="String"><span class="String">&quot;</span>Fix bug #321<span class="String">&quot;</span></span> git commit -a -m "Fix bug #321"
<span class="Comment"><span class="Comment">#</span> send local modifications to other</span> # send local modifications to other
git push git push
</pre></div> </code></pre>
<p>This article is written for people knowing very few about versionning systems. It is also written for those who had didn&rsquo;t followed progress since CVS or subversion (SVN). This is why, in a first time I&rsquo;ll explain quickly which are the goal of such systems. Secondly, I&rsquo;ll explain how to install and configure <a href="http://git-scm.org" title="Git">Git</a>. Then, I give the command for each feature a <abbr title="Decentralized Concurent Versions System">DCVS</abbr> must have.</p> </div>
<p>This article is written for people knowing very few about versionning systems. It is also written for those who had didnt followed progress since CVS or subversion (SVN). This is why, in a first time Ill explain quickly which are the goal of such systems. Secondly, Ill explain how to install and configure <a href="http://git-scm.org" title="Git">Git</a>. Then, I give the command for each feature a <abbr title="Decentralized Concurent Versions System">DCVS</abbr> must have.</p>
</div> </div>

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Filtrage d'appel avec l'iPhone" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2009-12-06-iphone-call-filter/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Filtrage d'appel avec l'iPhone" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2009-12-06-iphone-call-filter/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -56,7 +59,7 @@
<div class="corps"> <div class="corps">
<p>It is unbelievable you cannot filter your call with an iPhone! The only reason I see for that is a negotiation with phone operator to force users to get phone advertising. It is simple unacceptable.</p> <p>It is unbelievable you cannot filter your call with an iPhone! The only reason I see for that is a negotiation with phone operator to force users to get phone advertising. It is simple unacceptable.</p>
<p>I&rsquo;m a λ iPhone&rsquo;s user. The only way to filter your call and to manage blacklist is to <em>jailbreak</em> your iPhone. And I don&rsquo;t want to do that. Then, if like me you find it unacceptable, just write a line to Apple: <a href="http://www.apple.com/feedback/iphone.html">http://www.apple.com/feedback/iphone.html</a></p> <p>Im a λ iPhones user. The only way to filter your call and to manage blacklist is to <em>jailbreak</em> your iPhone. And I dont want to do that. Then, if like me you find it unacceptable, just write a line to Apple: <a href="http://www.apple.com/feedback/iphone.html">http://www.apple.com/feedback/iphone.html</a></p>
</div> </div>

View file

@ -1,3 +1,2 @@
[alias] [alias]
uncommit = !zsh -c '"if (($0)); then nb=$(( $0 - 1 )); else nb=0; fi; i=0; while ((i<=nb)); do git revert -n --no-edit HEAD~$i; ((i++)); done; git commit -m \"revert to $0 version(s) back\""' uncommit = !zsh -c '"if (($0)); then nb=$(( $0 - 1 )); else nb=0; fi; i=0; while ((i<=nb)); do git revert -n --no-edit HEAD~$i; ((i++)); done; git commit -m \"revert to $0 version(s) back\""'

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Git ou Bazaar ?" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2009-12-14-Git-vs--Bzr/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Git ou Bazaar ?" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2009-12-14-Git-vs--Bzr/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -62,7 +65,7 @@
<div class="intro"> <div class="intro">
<p>Why even if I believe <code>git</code> has many bad point I believe it is the best DCVS around to work with. This is why I first tell why I prefer <a href="http://bazaar-vcs.org">Bazaar</a> over <a href="http://git-scm.org">Git</a>. Secondly I&rsquo;ll talk about the only advantage of git against Bazaar which lead me to prefer it.</p> <p>Why even if I believe <code>git</code> has many bad point I believe it is the best DCVS around to work with. This is why I first tell why I prefer <a href="http://bazaar-vcs.org">Bazaar</a> over <a href="http://git-scm.org">Git</a>. Secondly Ill talk about the only advantage of git against Bazaar which lead me to prefer it.</p>
</div> </div>
@ -74,7 +77,7 @@
<p>There is two way of perceive version control system. Either you think in term of branches (see the really good article on <a href="http://betterexplained.com/articles/a-visual-guide-to-version-control/">betterexplained</a>) or think in term of patches. Another way to say that, is weather you concentrate on vertices or on transitions of the graph of possible states of your project.</p> <p>There is two way of perceive version control system. Either you think in term of branches (see the really good article on <a href="http://betterexplained.com/articles/a-visual-guide-to-version-control/">betterexplained</a>) or think in term of patches. Another way to say that, is weather you concentrate on vertices or on transitions of the graph of possible states of your project.</p>
<p>This is the second approach who was behind <code>git</code> and this is the first behind Bazaar. <code>git</code> was created by Linus Torvald in order to close some gap in the version system used to develop the Linux kernel. And patches is a term which is more present than &lsquo;state&rsquo; in the development community.</p> <p>This is the second approach who was behind <code>git</code> and this is the first behind Bazaar. <code>git</code> was created by Linus Torvald in order to close some gap in the version system used to develop the Linux kernel. And patches is a term which is more present than state in the development community.</p>
<p>I first was convinced by Bazaar. Why? Argument in favor of Bazaar were: user friendly, terminology close to the subversion one. And I tried a bit the two, and it was clearly more natural for me to use Bazaar. But after seeing so many people using <code>git</code> I decided to give it a serious try.</p> <p>I first was convinced by Bazaar. Why? Argument in favor of Bazaar were: user friendly, terminology close to the subversion one. And I tried a bit the two, and it was clearly more natural for me to use Bazaar. But after seeing so many people using <code>git</code> I decided to give it a serious try.</p>
@ -84,45 +87,63 @@
<p>The first example, <code>checkout</code> is used to make only one thing from the technical point of vue. But from the user perspective, you make many <em>different</em> things with this word. Example:</p> <p>The first example, <code>checkout</code> is used to make only one thing from the technical point of vue. But from the user perspective, you make many <em>different</em> things with this word. Example:</p>
<div><pre class="twilight"> <div>
git checkout pipo
</pre></div> <pre><code class="zsh">git checkout pipo
</code></pre>
</div>
<p>undo the current modification of the file <code>pipo</code></p> <p>undo the current modification of the file <code>pipo</code></p>
<div><pre class="twilight"> <div>
git checkout pipo
</pre></div> <pre><code class="zsh">git checkout pipo
</code></pre>
</div>
<p>change the current branch to the branch <code>pipo</code></p> <p>change the current branch to the branch <code>pipo</code></p>
<p>And, like me, you remark, it is exactly the same command to make two completely different things. What occur when you have a <code>pipo</code> branch and a <code>pipo</code> file? By default, it change the current branch. In order to leave the ambiguity you have to use the following syntax:</p> <p>And, like me, you remark, it is exactly the same command to make two completely different things. What occur when you have a <code>pipo</code> branch and a <code>pipo</code> file? By default, it change the current branch. In order to leave the ambiguity you have to use the following syntax:</p>
<div><pre class="twilight"> <div>
git checkout ./pipo
</pre></div>
<p>Yes, hum&hellip;</p> <pre><code class="zsh">git checkout ./pipo
</code></pre>
</div>
<p>Yes, hum…</p>
<p>It works, but it is clearly not really user friendly. Furthermore, checkout had a complete different signification in older CSV like <code>cvs</code> et <code>svn</code>. <code>checkout</code> was used to get a distant project locally.</p> <p>It works, but it is clearly not really user friendly. Furthermore, checkout had a complete different signification in older CSV like <code>cvs</code> et <code>svn</code>. <code>checkout</code> was used to get a distant project locally.</p>
<p>Bazaar terminology is far more natural, because there is no command to change the current branch as there is only one branch per directory. Changing a branch in Bazaar is changing the current directory. I also believe it is the biggest problem of Bazaar, I&rsquo;ll tell you why. And to undo things in Bazaar:</p> <p>Bazaar terminology is far more natural, because there is no command to change the current branch as there is only one branch per directory. Changing a branch in Bazaar is changing the current directory. I also believe it is the biggest problem of Bazaar, Ill tell you why. And to undo things in Bazaar:</p>
<div><pre class="twilight"> <div>
bzr revert pipo
</pre></div> <pre><code class="zsh">bzr revert pipo
</code></pre>
</div>
<p>Furthermore, most Bazaar command take a revision number in parameter. For example, to get back 3 versions earlier, it is enough to write:</p> <p>Furthermore, most Bazaar command take a revision number in parameter. For example, to get back 3 versions earlier, it is enough to write:</p>
<div><pre class="twilight"> <div>
bzr revert -r -3 pipo
</pre></div> <pre><code class="zsh">bzr revert -r -3 pipo
</code></pre>
</div>
<p>The <code>git</code> equivalent is far more cryptic:</p> <p>The <code>git</code> equivalent is far more cryptic:</p>
<div><pre class="twilight"> <div>
bzr checkout HEAD~3 pipo
</pre></div> <pre><code class="zsh">bzr checkout HEAD~3 pipo
</code></pre>
</div>
<p>One more time, Bazaar is far more readable.</p> <p>One more time, Bazaar is far more readable.</p>
@ -130,65 +151,82 @@ bzr checkout HEAD~3 pipo
<p>with Bazaar: </p> <p>with Bazaar: </p>
<div><pre class="twilight"> <div>
bzr revert -r -3 pipo
</pre></div> <pre><code class="zsh">bzr revert -r -3 pipo
</code></pre>
</div>
<p>and with <code>git</code>? <code>git checkout</code>? Of course not! It would be too simple. What we find in the documentation (<code>man</code>) and everywhere on the net:</p> <p>and with <code>git</code>? <code>git checkout</code>? Of course not! It would be too simple. What we find in the documentation (<code>man</code>) and everywhere on the net:</p>
<div><pre class="twilight"> <div>
git reset --hard HEAD~3
</pre></div> <pre><code class="zsh">git reset --hard HEAD~3
</code></pre>
</div>
<p>Except that this command is horrible. It forget revisions! Then you must use it with prudence. And you cannot tell other people working on the project you discard some changes. If someone had pulled the <em>bad</em> version, you are <em>doomed</em>. This is why you can also use:</p> <p>Except that this command is horrible. It forget revisions! Then you must use it with prudence. And you cannot tell other people working on the project you discard some changes. If someone had pulled the <em>bad</em> version, you are <em>doomed</em>. This is why you can also use:</p>
<div><pre class="twilight"> <div>
git checkout HEAD~3 -- . <span class="Keyword">&amp;&amp;</span> git commit -m <span class="String"><span class="String">'</span>back in time<span class="String">'</span></span>
</pre></div> <pre><code class="zsh">git checkout HEAD~3 -- . &amp;&amp; git commit -m 'back in time'
</code></pre>
</div>
<p>Just to keep a backup branch. Without it we can definitively loose the current version HEAD. But some error may rest when there were some addition and deletion of files. <em>The unique way to be really clean without any risk is to use the following command:</em></p> <p>Just to keep a backup branch. Without it we can definitively loose the current version HEAD. But some error may rest when there were some addition and deletion of files. <em>The unique way to be really clean without any risk is to use the following command:</em></p>
<div><pre class="twilight"> <div>
<span class="Keyword">for</span> i <span class="Keyword">in</span> <span class="String"><span class="String">$(</span>seq 0 2<span class="String">)</span></span><span class="Keyword">;</span> <span class="Keyword">do</span>
git revert -n --no-edit head~<span class="Variable"><span class="Variable">$</span>i</span><span class="Keyword">;</span> <pre><code class="zsh">for i in $(seq 0 2); do
<span class="Keyword">done</span> git revert -n --no-edit head~$i;
git commit -m <span class="String"><span class="String">&quot;</span>reverted 3 versions back<span class="String">&quot;</span></span> done
</pre></div> git commit -m "reverted 3 versions back"
</code></pre>
</div>
<p>And with this command this is the only good way to undo things in a project and tell other contributor you reverted something. You simply revert version in backward order.</p> <p>And with this command this is the only good way to undo things in a project and tell other contributor you reverted something. You simply revert version in backward order.</p>
<p>The rule is simple: <em>NEVER use the <code>git reset</code> command on a version somebody else could have <code>fetched</code></em></p> <p>The rule is simple: <em>NEVER use the <code>git reset</code> command on a version somebody else could have <code>fetched</code></em></p>
<p>It was said. Discover the best method took me some time. I&rsquo;d made many different tries. The safer and best way of reverting back your tree is to use this method. If you want to make it automatic just had the following alias in your <code>~/.gitconfig</code>. Of course this alias will work only on environment having <code>zsh</code> installed. Which is the cas for most UNIX (Ubuntu, Mac OS X&hellip;).</p> <p>It was said. Discover the best method took me some time. Id made many different tries. The safer and best way of reverting back your tree is to use this method. If you want to make it automatic just had the following alias in your <code>~/.gitconfig</code>. Of course this alias will work only on environment having <code>zsh</code> installed. Which is the cas for most UNIX (Ubuntu, Mac OS X).</p>
<div><div class="code"><div class="file"><a href="/Scratch/en/blog/2009-12-14-Git-vs--Bzr/code/gitconfig"> &#x27A5; gitconfig </a></div><div class="withfile"> <div><div class="codefile"><a href="/Scratch/en/blog/2009-12-14-Git-vs--Bzr/code/gitconfig">&#x27A5; gitconfig</a></div>
<pre class="twilight">
[alias]
uncommit = <span class="Keyword">!</span>zsh -c <span class="String"><span class="String">'</span>&quot;if (($0)); then nb=$(( $0 - 1 )); else nb=0; fi; i=0; while ((i&lt;=nb)); do git revert -n --no-edit HEAD~$i; ((i++)); done; git commit -m \&quot;revert to $0 version(s) back\&quot;&quot;<span class="String">'</span></span> <pre><code class="zsh">[alias]
</pre> uncommit = !zsh -c '"if (($0)); then nb=$(( $0 - 1 )); else nb=0; fi; i=0; while ((i&lt;=nb)); do git revert -n --no-edit HEAD~$i; ((i++)); done; git commit -m \"revert to $0 version(s) back\""'
</div></div></div> </code></pre>
</div>
<h1 id="what-make-git-by-far-the-best-dcvs-today">What make <code>git</code> by far the best DCVS today</h1> <h1 id="what-make-git-by-far-the-best-dcvs-today">What make <code>git</code> by far the best DCVS today</h1>
<p>After talking about the negatives points of <code>git</code>, now it&rsquo;s time to speak about the very positive feature that make <code>git</code> the best DCVS in my humble opinion.</p> <p>After talking about the negatives points of <code>git</code>, now its time to speak about the very positive feature that make <code>git</code> the best DCVS in my humble opinion.</p>
<h2 id="cheap-branching">Cheap branching</h2> <h2 id="cheap-branching">Cheap branching</h2>
<p>You always work into the same main directory. For example, you can work on two fix in the same time. Say <code>fix1</code> require you to work on <code>file1</code> and <code>fix2</code> to work on <code>file2</code>. You can work in any order on <code>file1</code> and <code>file2</code> in the <code>master</code> branch. And then go to branch <code>fix1</code>, commit <code>file1</code> into it. Then go to branch <code>fix2</code> and commit <code>file2</code> into it. And finally merge the two branches <code>fix1</code> and <code>fix2</code> into <code>master</code>.</p> <p>You always work into the same main directory. For example, you can work on two fix in the same time. Say <code>fix1</code> require you to work on <code>file1</code> and <code>fix2</code> to work on <code>file2</code>. You can work in any order on <code>file1</code> and <code>file2</code> in the <code>master</code> branch. And then go to branch <code>fix1</code>, commit <code>file1</code> into it. Then go to branch <code>fix2</code> and commit <code>file2</code> into it. And finally merge the two branches <code>fix1</code> and <code>fix2</code> into <code>master</code>.</p>
<div><pre class="twilight"> <div>
<span class="Keyword">&gt;</span> vim file1
<span class="Keyword">&gt;</span> vim file2 <pre><code class="zsh">&gt; vim file1
<span class="Keyword">&gt;</span> git br fix1 &gt; vim file2
<span class="Keyword">&gt;</span> git add file1 &gt; git br fix1
<span class="Keyword">&gt;</span> git commit -m <span class="String"><span class="String">'</span>fix1<span class="String">'</span></span> &gt; git add file1
<span class="Keyword">&gt;</span> git br fix2 &gt; git commit -m 'fix1'
<span class="Keyword">&gt;</span> git add file2 &gt; git br fix2
<span class="Keyword">&gt;</span> git commit -m <span class="String"><span class="String">'</span>fix2<span class="String">'</span></span> &gt; git add file2
<span class="Keyword">&gt;</span> git commit master &gt; git commit -m 'fix2'
<span class="Keyword">&gt;</span> git merge fix1 &gt; git commit master
<span class="Keyword">&gt;</span> git merge fix2 &gt; git merge fix1
</pre></div> &gt; git merge fix2
</code></pre>
</div>
<p>And this is great not to worry about working in the <em>good</em> branch and coding in the same time. You just worry about your code and then about the versionning system.</p> <p>And this is great not to worry about working in the <em>good</em> branch and coding in the same time. You just worry about your code and then about the versionning system.</p>

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Changer le shell par défaut sous Mac OS X" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-01-04-Change-default-shell-on-Mac-OS-X/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Changer le shell par défaut sous Mac OS X" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-01-04-Change-default-shell-on-Mac-OS-X/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -56,9 +59,12 @@
<div class="corps"> <div class="corps">
<p>I just found a way to change the default shell on Mac OS X. This note is mostly for me, but somebody else should find it useful. Just launch the following command: </p> <p>I just found a way to change the default shell on Mac OS X. This note is mostly for me, but somebody else should find it useful. Just launch the following command: </p>
<div><pre class="twilight"> <div>
<span class="Keyword">&gt;</span> chsh
</pre></div> <pre><code class="zsh">&gt; chsh
</code></pre>
</div>
</div> </div>

View file

@ -1,5 +1,4 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig> <fontconfig>

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Fontes adoucies sous Ubuntu Firefox" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-01-12-antialias-font-in-Firefox-under-Ubuntu/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Fontes adoucies sous Ubuntu Firefox" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-01-12-antialias-font-in-Firefox-under-Ubuntu/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -59,64 +62,66 @@
<p>Just modify the <code>/etc/fonts/local.conf</code> with the following code: </p> <p>Just modify the <code>/etc/fonts/local.conf</code> with the following code: </p>
<div> <div>
<div class="code"><div class="file"><a href="/Scratch/en/blog/2010-01-12-antialias-font-in-Firefox-under-Ubuntu/code/local.conf"> &#x27A5; local.conf </a></div><div class="withfile"> <div class="codefile"><a href="/Scratch/en/blog/2010-01-12-antialias-font-in-Firefox-under-Ubuntu/code/local.conf">&#x27A5; local.conf</a></div>
<pre class="twilight">
<span class="DoctypeXmlProcessing"><span class="DoctypeXmlProcessing">&lt;?</span><span class="DoctypeXmlProcessing">xml</span><span class="DoctypeXmlProcessing"> version</span>=<span class="DoctypeXmlProcessing"><span class="DoctypeXmlProcessing">&quot;</span>1.0<span class="DoctypeXmlProcessing">&quot;</span></span><span class="DoctypeXmlProcessing">?&gt;</span></span>
<span class="DoctypeXmlProcessing"><span class="DoctypeXmlProcessing">&lt;!</span><span class="DoctypeXmlProcessing">DOCTYPE</span> fontconfig SYSTEM &quot;fonts.dtd&quot;<span class="DoctypeXmlProcessing">&gt;</span></span>
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">fontconfig</span><span class="MetaTagAll">&gt;</span></span>
<span class="Comment"><span class="Comment">&lt;!--</span> Miscellaneous settings <span class="Comment">--&gt;</span></span> <pre><code class="xml">
&lt;?xml version="1.0"?&gt;
&lt;!DOCTYPE fontconfig SYSTEM "fonts.dtd"&gt;
&lt;fontconfig&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">include</span> <span class="MetaTagAll">ignore_missing</span>=<span class="String"><span class="String">&quot;</span>yes<span class="String">&quot;</span></span><span class="MetaTagAll">&gt;</span></span>misc.conf<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">include</span><span class="MetaTagAll">&gt;</span></span> &lt;!-- Miscellaneous settings --&gt;
<span class="Comment"><span class="Comment">&lt;!--</span> Define alias <span class="Comment">--&gt;</span></span> &lt;include ignore_missing="yes"&gt;misc.conf&lt;/include&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">include</span> <span class="MetaTagAll">ignore_missing</span>=<span class="String"><span class="String">&quot;</span>yes<span class="String">&quot;</span></span><span class="MetaTagAll">&gt;</span></span>alias.conf<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">include</span><span class="MetaTagAll">&gt;</span></span> &lt;!-- Define alias --&gt;
<span class="Comment"><span class="Comment">&lt;!--</span> Rules for Microsoft fonts <span class="Comment">--&gt;</span></span> &lt;include ignore_missing="yes"&gt;alias.conf&lt;/include&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">include</span> <span class="MetaTagAll">ignore_missing</span>=<span class="String"><span class="String">&quot;</span>yes<span class="String">&quot;</span></span><span class="MetaTagAll">&gt;</span></span>msfonts-rules.conf<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">include</span><span class="MetaTagAll">&gt;</span></span> &lt;!-- Rules for Microsoft fonts --&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">match</span> <span class="MetaTagAll">target</span>=<span class="String"><span class="String">&quot;</span>pattern<span class="String">&quot;</span></span> <span class="MetaTagAll">name</span>=<span class="String"><span class="String">&quot;</span>family<span class="String">&quot;</span></span> <span class="MetaTagAll">&gt;</span></span> &lt;include ignore_missing="yes"&gt;msfonts-rules.conf&lt;/include&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">test</span> <span class="MetaTagAll">name</span>=<span class="String"><span class="String">&quot;</span>family<span class="String">&quot;</span></span> <span class="MetaTagAll">qual</span>=<span class="String"><span class="String">&quot;</span>any<span class="String">&quot;</span></span> <span class="MetaTagAll">&gt;</span></span>
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">string</span><span class="MetaTagAll">&gt;</span></span>Tahoma<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">string</span><span class="MetaTagAll">&gt;</span></span> &lt;match target="pattern" name="family" &gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">test</span><span class="MetaTagAll">&gt;</span></span> &lt;test name="family" qual="any" &gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">edit</span> <span class="MetaTagAll">mode</span>=<span class="String"><span class="String">&quot;</span>assign<span class="String">&quot;</span></span> <span class="MetaTagAll">name</span>=<span class="String"><span class="String">&quot;</span>family<span class="String">&quot;</span></span> <span class="MetaTagAll">&gt;</span></span> &lt;string&gt;Tahoma&lt;/string&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">string</span><span class="MetaTagAll">&gt;</span></span>Verdana<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">string</span><span class="MetaTagAll">&gt;</span></span> &lt;/test&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">edit</span><span class="MetaTagAll">&gt;</span></span> &lt;edit mode="assign" name="family" &gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">match</span><span class="MetaTagAll">&gt;</span></span> &lt;string&gt;Verdana&lt;/string&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">selectfont</span><span class="MetaTagAll">&gt;</span></span> &lt;/edit&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">acceptfont</span><span class="MetaTagAll">&gt;</span></span> &lt;/match&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">pattern</span><span class="MetaTagAll">&gt;</span></span> &lt;selectfont&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">patelt</span> <span class="MetaTagAll">name</span>=<span class="String"><span class="String">&quot;</span>family<span class="String">&quot;</span></span><span class="MetaTagAll">&gt;</span></span> &lt;acceptfont&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">string</span><span class="MetaTagAll">&gt;</span></span>Lucida Grande<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">string</span><span class="MetaTagAll">&gt;</span></span> &lt;pattern&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">patelt</span><span class="MetaTagAll">&gt;</span></span> &lt;patelt name="family"&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">pattern</span><span class="MetaTagAll">&gt;</span></span> &lt;string&gt;Lucida Grande&lt;/string&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">acceptfont</span><span class="MetaTagAll">&gt;</span></span> &lt;/patelt&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">selectfont</span><span class="MetaTagAll">&gt;</span></span> &lt;/pattern&gt;
&lt;/acceptfont&gt;
&lt;/selectfont&gt;
&lt;match target="pattern" name="family" &gt;
&lt;test name="family" qual="any" &gt;
&lt;string&gt;Georgia&lt;/string&gt;
&lt;/test&gt;
&lt;edit mode="assign" name="family" &gt;
&lt;string&gt;Georgia&lt;/string&gt;
&lt;/edit&gt;
&lt;/match&gt;
&lt;selectfont&gt;
&lt;acceptfont&gt;
&lt;pattern&gt;
&lt;patelt name="family"&gt;
&lt;string&gt;Century Schoolbook L&lt;/string&gt;
&lt;/patelt&gt;
&lt;/pattern&gt;
&lt;/acceptfont&gt;
&lt;/selectfont&gt;
&lt;/fontconfig&gt;
</code></pre>
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">match</span> <span class="MetaTagAll">target</span>=<span class="String"><span class="String">&quot;</span>pattern<span class="String">&quot;</span></span> <span class="MetaTagAll">name</span>=<span class="String"><span class="String">&quot;</span>family<span class="String">&quot;</span></span> <span class="MetaTagAll">&gt;</span></span>
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">test</span> <span class="MetaTagAll">name</span>=<span class="String"><span class="String">&quot;</span>family<span class="String">&quot;</span></span> <span class="MetaTagAll">qual</span>=<span class="String"><span class="String">&quot;</span>any<span class="String">&quot;</span></span> <span class="MetaTagAll">&gt;</span></span>
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">string</span><span class="MetaTagAll">&gt;</span></span>Georgia<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">string</span><span class="MetaTagAll">&gt;</span></span>
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">test</span><span class="MetaTagAll">&gt;</span></span>
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">edit</span> <span class="MetaTagAll">mode</span>=<span class="String"><span class="String">&quot;</span>assign<span class="String">&quot;</span></span> <span class="MetaTagAll">name</span>=<span class="String"><span class="String">&quot;</span>family<span class="String">&quot;</span></span> <span class="MetaTagAll">&gt;</span></span>
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">string</span><span class="MetaTagAll">&gt;</span></span>Georgia<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">string</span><span class="MetaTagAll">&gt;</span></span>
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">edit</span><span class="MetaTagAll">&gt;</span></span>
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">match</span><span class="MetaTagAll">&gt;</span></span>
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">selectfont</span><span class="MetaTagAll">&gt;</span></span>
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">acceptfont</span><span class="MetaTagAll">&gt;</span></span>
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">pattern</span><span class="MetaTagAll">&gt;</span></span>
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">patelt</span> <span class="MetaTagAll">name</span>=<span class="String"><span class="String">&quot;</span>family<span class="String">&quot;</span></span><span class="MetaTagAll">&gt;</span></span>
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">string</span><span class="MetaTagAll">&gt;</span></span>Century Schoolbook L<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">string</span><span class="MetaTagAll">&gt;</span></span>
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">patelt</span><span class="MetaTagAll">&gt;</span></span>
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">pattern</span><span class="MetaTagAll">&gt;</span></span>
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">acceptfont</span><span class="MetaTagAll">&gt;</span></span>
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">selectfont</span><span class="MetaTagAll">&gt;</span></span>
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">fontconfig</span><span class="MetaTagAll">&gt;</span></span>
</pre>
</div></div>
</div> </div>
<p>Hope it helped someone who like me had his eyes crying in face of such ugly fonts.</p> <p>Hope it helped someone who like me had his eyes crying in face of such ugly fonts.</p>

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Expression régulière pour tout sauf quelquechose" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-02-15-All-but-something-regexp/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Expression régulière pour tout sauf quelquechose" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-02-15-All-but-something-regexp/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -56,31 +59,37 @@
<div class="corps"> <div class="corps">
<p>Sometimes you cannot simply write:</p> <p>Sometimes you cannot simply write:</p>
<div><pre class="twilight"> <div>
<span class="Keyword">if</span> str.<span class="Entity">match</span>(regexp) <span class="Keyword">and</span>
<span class="Keyword">not</span> str.<span class="Entity">match</span>(other_regexp) <pre><code class="ruby">if str.match(regexp) and
not str.match(other_regexp)
do_something do_something
</pre></div> </code></pre>
</div>
<p>and you have to make this behaviour with only one regular expression. <p>and you have to make this behaviour with only one regular expression.
But, there exists a major problem: the complementary of a regular language might not be regular. But, there exists a major problem: the complementary of a regular language might not be regular.
Then, for some expression it is absolutely impossible to negate a regular expression.</p> Then, for some expression it is absolutely impossible to negate a regular expression.</p>
<p>But sometimes with some simple regular expression it should be possible<sup><a href="#note1">&dagger;</a></sup>. Say you want to match everything containing the some word say <code>bull</code> but don&rsquo;t want to match <code>bullshit</code>. Here is a nice way to do that:</p> <p>But sometimes with some simple regular expression it should be possible<sup><a href="#note1"></a></sup>. Say you want to match everything containing the some word say <code>bull</code> but dont want to match <code>bullshit</code>. Here is a nice way to do that:</p>
<div><pre class="twilight"> <div>
<span class="Comment"><span class="Comment">#</span> match all string containing 'bull' (bullshit comprised)</span>
<span class="StringRegexp"><span class="StringRegexp">/</span></span><span class="StringRegexp">bull</span><span class="StringRegexp"><span class="StringRegexp">/</span></span>
<span class="Comment"><span class="Comment">#</span> match all string containing 'bull' except 'bullshit'</span> <pre><code class="ruby"># match all string containing 'bull' (bullshit comprised)
<span class="StringRegexp"><span class="StringRegexp">/</span></span><span class="StringRegexp">bull<span class="StringRegexp"><span class="StringRegexp">(</span><span class="StringRegexp"><span class="StringRegexp">[</span>^s<span class="StringRegexp">]</span></span>|$<span class="StringRegexp">)</span></span>|</span> /bull/
<span class="StringRegexp">bulls<span class="StringRegexp"><span class="StringRegexp">(</span><span class="StringRegexp"><span class="StringRegexp">[</span>^h<span class="StringRegexp">]</span></span>|$<span class="StringRegexp">)</span></span>|</span>
<span class="StringRegexp">bullsh<span class="StringRegexp"><span class="StringRegexp">(</span><span class="StringRegexp"><span class="StringRegexp">[</span>^i<span class="StringRegexp">]</span></span>|$<span class="StringRegexp">)</span></span>|</span>
<span class="StringRegexp">bullshi<span class="StringRegexp"><span class="StringRegexp">(</span><span class="StringRegexp"><span class="StringRegexp">[</span>^t<span class="StringRegexp">]</span></span>|$<span class="StringRegexp">)</span></span></span><span class="StringRegexp"><span class="StringRegexp">/</span></span>
<span class="Comment"><span class="Comment">#</span> another way to write it would be</span> # match all string containing 'bull' except 'bullshit'
<span class="StringRegexp"><span class="StringRegexp">/</span></span><span class="StringRegexp">bull<span class="StringRegexp"><span class="StringRegexp">(</span><span class="StringRegexp"><span class="StringRegexp">[</span>^s<span class="StringRegexp">]</span></span>|$|s<span class="StringRegexp"><span class="StringRegexp">(</span><span class="StringRegexp"><span class="StringRegexp">[</span>^h<span class="StringRegexp">]</span></span>|$<span class="StringRegexp">)</span></span>|sh<span class="StringRegexp"><span class="StringRegexp">(</span><span class="StringRegexp"><span class="StringRegexp">[</span>^i<span class="StringRegexp">]</span></span>|$<span class="StringRegexp">)</span></span>|shi<span class="StringRegexp"><span class="StringRegexp">(</span><span class="StringRegexp"><span class="StringRegexp">[</span>^t<span class="StringRegexp">]</span></span>|$<span class="StringRegexp">)</span></span><span class="StringRegexp">)</span></span></span><span class="StringRegexp"><span class="StringRegexp">/</span></span> /bull([^s]|$)|
</pre></div> bulls([^h]|$)|
bullsh([^i]|$)|
bullshi([^t]|$)/
# another way to write it would be
/bull([^s]|$|s([^h]|$)|sh([^i]|$)|shi([^t]|$))/
</code></pre>
</div>
<p>Let look closer. In the first line the expression is: <p>Let look closer. In the first line the expression is:
<code>bull([^s]|$)</code>, why does the <code>$</code> is needed? <code>bull([^s]|$)</code>, why does the <code>$</code> is needed?
@ -95,34 +104,40 @@ contains <code>bull</code> followed by a letter different from <code>s</code>. <
<p>And this is it. I hope it could help you.</p> <p>And this is it. I hope it could help you.</p>
<p>Notice this method is not always the best. For example try to write a regular expression equivalent to the following conditional expression:</p> <p>Notice this method is not always the best. For example try to write a regular expression equivalent to the following conditional expression:</p>
<div><pre class="twilight"> <div>
<span class="Comment"><span class="Comment">#</span> Begin with 'a': ^a</span>
<span class="Comment"><span class="Comment">#</span> End with 'a': c$</span> <pre><code class="ruby"># Begin with 'a': ^a
<span class="Comment"><span class="Comment">#</span> Contain 'b': .*b.*</span> # End with 'a': c$
<span class="Comment"><span class="Comment">#</span> But isn't 'axbxc'</span> # Contain 'b': .*b.*
<span class="Keyword">if</span> str.<span class="Entity">match</span>(<span class="StringRegexp"><span class="StringRegexp">/</span></span><span class="StringRegexp">^a.*b.*c$</span><span class="StringRegexp"><span class="StringRegexp">/</span></span>) <span class="Keyword">and</span> # But isn't 'axbxc'
<span class="Keyword">not</span> str.<span class="Entity">match</span>(<span class="StringRegexp"><span class="StringRegexp">/</span></span><span class="StringRegexp">^axbxc$</span><span class="StringRegexp"><span class="StringRegexp">/</span></span>) if str.match(/^a.*b.*c$/) and
not str.match(/^axbxc$/)
do_something do_something
<span class="Keyword">end</span> end
</pre></div> </code></pre>
</div>
<p>A nice solution is:</p> <p>A nice solution is:</p>
<div><pre class="twilight"> <div>
<span class="StringRegexp"><span class="StringRegexp">/</span></span><span class="StringRegexp">abc| <span class="Comment"><span class="Comment">#</span> length 3</span></span>
<span class="StringRegexp">a.bc| <span class="Comment"><span class="Comment">#</span> length 4</span></span> <pre><code class="ruby">/abc| # length 3
<span class="StringRegexp">ab.c|</span> a.bc| # length 4
<span class="StringRegexp">a<span class="StringRegexp"><span class="StringRegexp">[</span>^x<span class="StringRegexp">]</span></span>b<span class="StringRegexp"><span class="StringRegexp">[</span>^x<span class="StringRegexp">]</span></span>c| <span class="Comment"><span class="Comment">#</span> length 5</span></span> ab.c|
<span class="StringRegexp">a...*b.*c| # length &gt;5</span> a[^x]b[^x]c| # length 5
<span class="StringRegexp">a.*b...*c</span><span class="StringRegexp"><span class="StringRegexp">/</span></span> a...*b.*c| # length &gt;5
</pre></div> a.*b...*c/
</code></pre>
</div>
<p>This solution uses the maximal length of the string not to be matched. <p>This solution uses the maximal length of the string not to be matched.
There certainly exists many other methods. But the important lesson is There certainly exists many other methods. But the important lesson is
it is not straightforward to exclude something of a regular expression.</p> it is not straightforward to exclude something of a regular expression.</p>
<hr /> <hr />
<p><small><a name="note1">&dagger;</a> <p><small><a name="note1"></a>
It can be proved that any regular set minus a finite set is also regular. It can be proved that any regular set minus a finite set is also regular.
</small></p> </small></p>

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Tout sauf quelquechose en expression régulière." type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-02-16-All-but-something-regexp--2-/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Tout sauf quelquechose en expression régulière." type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-02-16-All-but-something-regexp--2-/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -54,7 +57,7 @@
<div class="flush"></div> <div class="flush"></div>
<div id="afterheader"> <div id="afterheader">
<div class="corps"> <div class="corps">
<p>In my <a href="previouspost">previous post</a> I had given some trick to match all except something. On the same idea, the trick to match the smallest possible string. Say you want to match the string between &lsquo;a&rsquo; and &lsquo;b&rsquo;, for example, you want to match:</p> <p>In my <a href="previouspost">previous post</a> I had given some trick to match all except something. On the same idea, the trick to match the smallest possible string. Say you want to match the string between a and b, for example, you want to match:</p>
<pre class="twilight"> <pre class="twilight">
a.....<span class="Constant"><strong>a......b</strong></span>..b..a....<span class="Constant"><strong>a....b</strong></span>... a.....<span class="Constant"><strong>a......b</strong></span>..b..a....<span class="Constant"><strong>a....b</strong></span>...
@ -75,7 +78,7 @@ a.....<span class="Constant"><strong>a......b</strong></span>..b..a....<span cla
</pre> </pre>
<p>The next natural way, is to change the <em>greediness</em>. But it is not enough as you will match from the first <code>a</code> to the first <code>b</code>. <p>The next natural way, is to change the <em>greediness</em>. But it is not enough as you will match from the first <code>a</code> to the first <code>b</code>.
Then a simple constatation is that our matching string shouldn&rsquo;t contain any <code>a</code> nor <code>b</code>. Which lead to the last elegant solution.</p> Then a simple constatation is that our matching string shouldnt contain any <code>a</code> nor <code>b</code>. Which lead to the last elegant solution.</p>
<pre class="twilight"> <pre class="twilight">
/a[^ab]*b/ /a[^ab]*b/
@ -85,64 +88,82 @@ a.....<span class="Constant"><strong>a......b</strong></span>..b..a....<span cla
<p>Until now, that was, easy. <p>Until now, that was, easy.
Now, just pass at the case you need to match not between <code>a</code> and <code>b</code>, but between strings. Now, just pass at the case you need to match not between <code>a</code> and <code>b</code>, but between strings.
For example:</p> For example:</p>
<div><pre class="twilight"> <div>
&lt;li&gt;...&lt;li&gt;
</pre></div> <pre><code class="perl">&lt;li&gt;...&lt;li&gt;
</code></pre>
</div>
<p>This is a bit difficult. You need to match </p> <p>This is a bit difficult. You need to match </p>
<div><pre class="twilight"> <div>
&lt;li&gt;[anything not containing &lt;li&gt;]&lt;/li&gt;
</pre></div> <pre><code class="perl">&lt;li&gt;[anything not containing &lt;li&gt;]&lt;/li&gt;
</code></pre>
</div>
<p>The first method would be to use the same reasoning as in my <a href="previouspost">previous post</a>. Here is a first try:</p> <p>The first method would be to use the same reasoning as in my <a href="previouspost">previous post</a>. Here is a first try:</p>
<div><pre class="twilight"> <div>
&lt;li&gt;([^&lt;]|&lt;[^l]|&lt;l[^i]|&lt;li[^&gt;])*&lt;/li&gt;
</pre></div> <pre><code class="perl">&lt;li&gt;([^&lt;]|&lt;[^l]|&lt;l[^i]|&lt;li[^&gt;])*&lt;/li&gt;
</code></pre>
</div>
<p>But what about the following string: </p> <p>But what about the following string: </p>
<div><pre class="twilight"> <div>
&lt;li&gt;...&lt;li&lt;/li&gt;
</pre></div>
<p>That string should not match. This is why if we really want to match it correctly<sup><a href="#note1">&dagger;</a></sup> we need to add:</p> <pre><code class="perl">&lt;li&gt;...&lt;li&lt;/li&gt;
<div><pre class="twilight"> </code></pre>
&lt;li&gt;([^&lt;]|&lt;[^l]|&lt;l[^i]|&lt;li[^&gt;])*(|&lt;|&lt;l|&lt;li)&lt;/li&gt;
</pre></div> </div>
<p>That string should not match. This is why if we really want to match it correctly<sup><a href="#note1"></a></sup> we need to add:</p>
<div>
<pre><code class="perl">&lt;li&gt;([^&lt;]|&lt;[^l]|&lt;l[^i]|&lt;li[^&gt;])*(|&lt;|&lt;l|&lt;li)&lt;/li&gt;
</code></pre>
</div>
<p>Yes a bit complicated. But what if the string I wanted to match was even longer?</p> <p>Yes a bit complicated. But what if the string I wanted to match was even longer?</p>
<p>Here is the algorithm way to handle this easily. You reduce the problem to the first one letter matching:</p> <p>Here is the algorithm way to handle this easily. You reduce the problem to the first one letter matching:</p>
<div><pre class="twilight"> <div>
<span class="Comment"><span class="Comment">#</span> transform a simple randomly choosen character</span>
<span class="Comment"><span class="Comment">#</span> to an unique ID </span>
<span class="Comment"><span class="Comment">#</span> (you should verify the identifier is REALLY unique)</span>
<span class="Comment"><span class="Comment">#</span> beware the unique ID must not contain the </span>
<span class="Comment"><span class="Comment">#</span> choosen character</span>
<span class="StringRegexp"><span class="StringRegexp"><span class="SupportFunction">s</span>/</span>X</span><span class="StringRegexp"><span class="StringRegexp">/</span>_was_x_<span class="StringRegexp">/</span></span><span class="StringRegexp"><span class="StringRegexp"><span class="Keyword">g</span></span></span>
<span class="StringRegexp"><span class="StringRegexp"><span class="SupportFunction">s</span>/</span>Y</span><span class="StringRegexp"><span class="StringRegexp">/</span>_was_y_<span class="StringRegexp">/</span></span><span class="StringRegexp"><span class="StringRegexp"><span class="Keyword">g</span></span></span>
<span class="Comment"><span class="Comment">#</span> transform the long string in this simple character</span> <pre><code class="perl"># transform a simple randomly choosen character
<span class="StringRegexp"><span class="StringRegexp"><span class="SupportFunction">s</span>/</span>&lt;li&gt;</span><span class="StringRegexp"><span class="StringRegexp">/</span>X<span class="StringRegexp">/</span></span><span class="StringRegexp"><span class="StringRegexp"><span class="Keyword">g</span></span></span> # to an unique ID
<span class="StringRegexp"><span class="StringRegexp"><span class="SupportFunction">s</span>/</span>&lt;<span class="StringRegexpSpecial">\/</span>li&gt;</span><span class="StringRegexp"><span class="StringRegexp">/</span>Y<span class="StringRegexp">/</span></span><span class="StringRegexp"><span class="StringRegexp"><span class="Keyword">g</span></span></span> # (you should verify the identifier is REALLY unique)
# beware the unique ID must not contain the
# choosen character
s/X/_was_x_/g
s/Y/_was_y_/g
<span class="Comment"><span class="Comment">#</span> use the first method</span> # transform the long string in this simple character
<span class="StringRegexp"><span class="StringRegexp"><span class="SupportFunction">s</span>/</span>X([^X]*)Y</span><span class="StringRegexp"><span class="StringRegexp">/</span><span class="StringRegexp">/</span></span><span class="StringRegexp"><span class="StringRegexp"><span class="Keyword">g</span></span></span> s/&lt;li&gt;/X/g
s/&lt;\/li&gt;/Y/g
<span class="Comment"><span class="Comment">#</span> retransform choosen letter by string</span> # use the first method
<span class="StringRegexp"><span class="StringRegexp"><span class="SupportFunction">s</span>/</span>X</span><span class="StringRegexp"><span class="StringRegexp">/</span>&lt;li&gt;<span class="StringRegexp">/</span></span><span class="StringRegexp"><span class="StringRegexp"><span class="Keyword">g</span></span></span> s/X([^X]*)Y//g
<span class="StringRegexp"><span class="StringRegexp"><span class="SupportFunction">s</span>/</span>Y</span><span class="StringRegexp"><span class="StringRegexp">/</span>&lt;<span class="StringRegexpSpecial">\/</span>li&gt;<span class="StringRegexp">/</span></span><span class="StringRegexp"><span class="StringRegexp"><span class="Keyword">g</span></span></span>
<span class="Comment"><span class="Comment">#</span> retransform the choosen character back</span> # retransform choosen letter by string
<span class="StringRegexp"><span class="StringRegexp"><span class="SupportFunction">s</span>/</span>_was_x_</span><span class="StringRegexp"><span class="StringRegexp">/</span>X<span class="StringRegexp">/</span></span><span class="StringRegexp"><span class="StringRegexp"><span class="Keyword">g</span></span></span> s/X/&lt;li&gt;/g
<span class="StringRegexp"><span class="StringRegexp"><span class="SupportFunction">s</span>/</span>_was_y_</span><span class="StringRegexp"><span class="StringRegexp">/</span>Y<span class="StringRegexp">/</span></span><span class="StringRegexp"><span class="StringRegexp"><span class="Keyword">g</span></span></span> s/Y/&lt;\/li&gt;/g
</pre></div>
# retransform the choosen character back
s/_was_x_/X/g
s/_was_y_/Y/g
</code></pre>
</div>
<p>And it works in only 9 lines for any beginning and ending string. This solution should look less <em>I AM THE GREAT REGEXP M45T3R, URAN00B</em>, but is more convenient in my humble opinion. Further more, using this last solution prove you master regexp, because you know it is difficult to manage such problems with only a regexp.</p> <p>And it works in only 9 lines for any beginning and ending string. This solution should look less <em>I AM THE GREAT REGEXP M45T3R, URAN00B</em>, but is more convenient in my humble opinion. Further more, using this last solution prove you master regexp, because you know it is difficult to manage such problems with only a regexp.</p>
<hr /> <hr />
<p><small><a name="note1"><sup>&dagger;</sup></a> I know I used an HTML syntax example, but in my real life usage, I needed to match between <code>en:</code> and <code>::</code>. And sometimes the string could finish with <code>e::</code>.</small></p> <p><small><a name="note1"><sup></sup></a> I know I used an HTML syntax example, but in my real life usage, I needed to match between <code>en:</code> and <code>::</code>. And sometimes the string could finish with <code>e::</code>.</small></p>
</div> </div>

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="découper un fichier par mots clés" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-02-18-split-a-file-by-keyword/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="découper un fichier par mots clés" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-02-18-split-a-file-by-keyword/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -54,18 +57,21 @@
<div class="flush"></div> <div class="flush"></div>
<div id="afterheader"> <div id="afterheader">
<div class="corps"> <div class="corps">
<p>Strangely enough, I didn&rsquo;t find any built-in tool to split a file by keyword. I made one myself in <code>awk</code>. I put it here mostly for myself. But it could also helps someone else. <p>Strangely enough, I didnt find any built-in tool to split a file by keyword. I made one myself in <code>awk</code>. I put it here mostly for myself. But it could also helps someone else.
The following code split a file for each line containing the word <code>UTC</code>.</p> The following code split a file for each line containing the word <code>UTC</code>.</p>
<div><pre class="twilight"> <div>
<span class="Comment"><span class="Comment">#</span>!/usr/bin/env awk</span>
<span class="Entity">BEGIN</span>{i=0;} <pre><code class="perl">#!/usr/bin/env awk
<span class="StringRegexp"><span class="StringRegexp">/</span>UTC<span class="StringRegexp">/</span></span> { BEGIN{i=0;}
/UTC/ {
i+=1; i+=1;
FIC=<span class="SupportFunction">sprintf</span>(<span class="String"><span class="String">&quot;</span>fic.%03d<span class="String">&quot;</span></span>,i); FIC=sprintf("fic.%03d",i);
} }
{<span class="SupportFunction">print</span> <span class="Variable"><span class="Variable">$</span>0</span>&gt;&gt;FIC} {print $0&gt;&gt;FIC}
</pre></div> </code></pre>
</div>
<p>In my real world example, I wanted one file per day, each line containing UTC being in the following format:</p> <p>In my real world example, I wanted one file per day, each line containing UTC being in the following format:</p>
@ -75,19 +81,22 @@ Mon Dec 7 10:32:30 UTC 2009
<p>I then finished with the following code:</p> <p>I then finished with the following code:</p>
<div><pre class="twilight"> <div>
<span class="Comment"><span class="Comment">#</span>!/usr/bin/env awk</span>
<span class="Entity">BEGIN</span>{i=0;} <pre><code class="perl">#!/usr/bin/env awk
<span class="StringRegexp"><span class="StringRegexp">/</span>UTC<span class="StringRegexp">/</span></span> { BEGIN{i=0;}
date=<span class="Variable"><span class="Variable">$</span>1</span><span class="Variable"><span class="Variable">$</span>2</span><span class="Variable"><span class="Variable">$</span>3</span>; /UTC/ {
<span class="Keyword">if</span> ( date != olddate ) { date=$1$2$3;
if ( date != olddate ) {
olddate=date; olddate=date;
i+=1; i+=1;
FIC=<span class="SupportFunction">sprintf</span>(<span class="String"><span class="String">&quot;</span>fic.%03d<span class="String">&quot;</span></span>,i); FIC=sprintf("fic.%03d",i);
} }
} }
{<span class="SupportFunction">print</span> <span class="Variable"><span class="Variable">$</span>0</span>&gt;&gt;FIC} {print $0&gt;&gt;FIC}
</pre></div> </code></pre>
</div>
</div> </div>

View file

@ -1,4 +1,3 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
require 'benchmark' require 'benchmark'
n=80000 n=80000

View file

@ -1,4 +1,3 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
require 'benchmark' require 'benchmark'
n=80000 n=80000

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Quand se passer des expressions régulières ?" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-02-23-When-regexp-is-not-the-best-solution/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Quand se passer des expressions régulières ?" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-02-23-When-regexp-is-not-the-best-solution/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -59,50 +62,55 @@ Particularly when transformations you want to make are easy.</p>
<p>I wanted to know how to get file extension from filename the fastest way possible. There is 3 natural way of doing this:</p> <p>I wanted to know how to get file extension from filename the fastest way possible. There is 3 natural way of doing this:</p>
<div><pre class="twilight"> <div>
<span class="Comment"><span class="Comment">#</span> regexp</span>
str.<span class="Entity">match</span>(<span class="StringRegexp"><span class="StringRegexp">/</span></span><span class="StringRegexp"><span class="StringRegexp"><span class="StringRegexp">[</span>^.<span class="StringRegexp">]</span></span>*$</span><span class="StringRegexp"><span class="StringRegexp">/</span></span>);
ext<span class="Keyword">=</span><span class="Variable"><span class="Variable">$</span>&amp;</span>
<span class="Comment"><span class="Comment">#</span> split</span> <pre><code class="ruby"># regexp
ext<span class="Keyword">=</span>str.<span class="Entity">split</span>(<span class="String"><span class="String">'</span>.<span class="String">'</span></span>)[<span class="Keyword">-</span><span class="Constant">1</span>] str.match(/[^.]*$/);
ext=$&amp;
<span class="Comment"><span class="Comment">#</span> File module</span> # split
ext<span class="Keyword">=</span><span class="Support">File</span>.<span class="Entity">extname</span>(str) ext=str.split('.')[-1]
</pre></div>
# File module
ext=File.extname(str)
</code></pre>
</div>
<p>At first sight I believed that the regexp should be faster than the split because it could be many <code>.</code> in a filename. But in reality, most of time there is only one dot and I realized the split will be faster. But not the fastest way. There is a function dedicated to this work in the <code>File</code> module.</p> <p>At first sight I believed that the regexp should be faster than the split because it could be many <code>.</code> in a filename. But in reality, most of time there is only one dot and I realized the split will be faster. But not the fastest way. There is a function dedicated to this work in the <code>File</code> module.</p>
<p>Here is the Benchmark ruby code:</p> <p>Here is the Benchmark ruby code:</p>
<div><div class="code"><div class="file"><a href="/Scratch/en/blog/2010-02-23-When-regexp-is-not-the-best-solution/code/regex_benchmark_ext.rb"> &#x27A5; regex_benchmark_ext.rb </a></div><div class="withfile"> <div><div class="codefile"><a href="/Scratch/en/blog/2010-02-23-When-regexp-is-not-the-best-solution/code/regex_benchmark_ext.rb">&#x27A5; regex_benchmark_ext.rb</a></div>
<pre class="twilight">
<span class="Comment"><span class="Comment">#</span>!/usr/bin/env ruby</span>
<span class="Keyword">require</span> <span class="String"><span class="String">'</span>benchmark<span class="String">'</span></span>
n<span class="Keyword">=</span><span class="Constant">80000</span>
tab<span class="Keyword">=</span>[ <span class="String"><span class="String">'</span>/accounts/user.json<span class="String">'</span></span>,
<span class="String"><span class="String">'</span>/accounts/user.xml<span class="String">'</span></span>,
<span class="String"><span class="String">'</span>/user/titi/blog/toto.json<span class="String">'</span></span>,
<span class="String"><span class="String">'</span>/user/titi/blog/toto.xml<span class="String">'</span></span> ]
puts <span class="String"><span class="String">&quot;</span>Get extname<span class="String">&quot;</span></span>
<span class="Support">Benchmark</span>.<span class="Entity">bm</span> <span class="Keyword">do </span>|<span class="Variable">x</span>| <pre><code class="ruby">#!/usr/bin/env ruby
x.<span class="Entity">report</span>(<span class="String"><span class="String">&quot;</span>regexp:<span class="String">&quot;</span></span>) { n.<span class="Entity">times</span> <span class="Keyword">do </span> require 'benchmark'
str<span class="Keyword">=</span>tab[<span class="Entity">rand</span>(<span class="Constant">4</span>)]; n=80000
str.<span class="Entity">match</span>(<span class="StringRegexp"><span class="StringRegexp">/</span></span><span class="StringRegexp"><span class="StringRegexp"><span class="StringRegexp">[</span>^.<span class="StringRegexp">]</span></span>*$</span><span class="StringRegexp"><span class="StringRegexp">/</span></span>); tab=[ '/accounts/user.json',
ext<span class="Keyword">=</span><span class="Variable"><span class="Variable">$</span>&amp;</span>; '/accounts/user.xml',
<span class="Keyword">end</span> } '/user/titi/blog/toto.json',
x.<span class="Entity">report</span>(<span class="String"><span class="String">&quot;</span> split:<span class="String">&quot;</span></span>) { n.<span class="Entity">times</span> <span class="Keyword">do </span> '/user/titi/blog/toto.xml' ]
str<span class="Keyword">=</span>tab[<span class="Entity">rand</span>(<span class="Constant">4</span>)];
ext<span class="Keyword">=</span>str.<span class="Entity">split</span>(<span class="String"><span class="String">'</span>.<span class="String">'</span></span>)[<span class="Keyword">-</span><span class="Constant">1</span>] ; puts "Get extname"
<span class="Keyword">end</span> } Benchmark.bm do |x|
x.<span class="Entity">report</span>(<span class="String"><span class="String">&quot;</span> File:<span class="String">&quot;</span></span>) { n.<span class="Entity">times</span> <span class="Keyword">do </span> x.report("regexp:") { n.times do
str<span class="Keyword">=</span>tab[<span class="Entity">rand</span>(<span class="Constant">4</span>)]; str=tab[rand(4)];
ext<span class="Keyword">=</span><span class="Support">File</span>.<span class="Entity">extname</span>(str); str.match(/[^.]*$/);
<span class="Keyword">end</span> } ext=$&amp;;
<span class="Keyword">end</span> end }
</pre> x.report(" split:") { n.times do
</div></div></div> str=tab[rand(4)];
ext=str.split('.')[-1] ;
end }
x.report(" File:") { n.times do
str=tab[rand(4)];
ext=File.extname(str);
end }
end
</code></pre>
</div>
<p>And here is the result</p> <p>And here is the result</p>
@ -118,30 +126,32 @@ regexp: 2.550000 0.020000 2.570000 ( 2.693407)
<h2 id="file-path-without-the-extension">file path without the extension.</h2> <h2 id="file-path-without-the-extension">file path without the extension.</h2>
<div><div class="code"><div class="file"><a href="/Scratch/en/blog/2010-02-23-When-regexp-is-not-the-best-solution/code/regex_benchmark_strip.rb"> &#x27A5; regex_benchmark_strip.rb </a></div><div class="withfile"> <div><div class="codefile"><a href="/Scratch/en/blog/2010-02-23-When-regexp-is-not-the-best-solution/code/regex_benchmark_strip.rb">&#x27A5; regex_benchmark_strip.rb</a></div>
<pre class="twilight">
<span class="Comment"><span class="Comment">#</span>!/usr/bin/env ruby</span>
<span class="Keyword">require</span> <span class="String"><span class="String">'</span>benchmark<span class="String">'</span></span>
n<span class="Keyword">=</span><span class="Constant">80000</span>
tab<span class="Keyword">=</span>[ <span class="String"><span class="String">'</span>/accounts/user.json<span class="String">'</span></span>,
<span class="String"><span class="String">'</span>/accounts/user.xml<span class="String">'</span></span>,
<span class="String"><span class="String">'</span>/user/titi/blog/toto.json<span class="String">'</span></span>,
<span class="String"><span class="String">'</span>/user/titi/blog/toto.xml<span class="String">'</span></span> ]
puts <span class="String"><span class="String">&quot;</span>remove extension<span class="String">&quot;</span></span>
<span class="Support">Benchmark</span>.<span class="Entity">bm</span> <span class="Keyword">do </span>|<span class="Variable">x</span>| <pre><code class="ruby">#!/usr/bin/env ruby
x.<span class="Entity">report</span>(<span class="String"><span class="String">&quot;</span> File:<span class="String">&quot;</span></span>) { n.<span class="Entity">times</span> <span class="Keyword">do </span> require 'benchmark'
str<span class="Keyword">=</span>tab[<span class="Entity">rand</span>(<span class="Constant">4</span>)]; n=80000
path<span class="Keyword">=</span><span class="Support">File</span>.<span class="Entity">expand_path</span>(str,<span class="Support">File</span>.<span class="Entity">basename</span>(str,<span class="Support">File</span>.<span class="Entity">extname</span>(str))); tab=[ '/accounts/user.json',
<span class="Keyword">end</span> } '/accounts/user.xml',
x.<span class="Entity">report</span>(<span class="String"><span class="String">&quot;</span>chomp:<span class="String">&quot;</span></span>) { n.<span class="Entity">times</span> <span class="Keyword">do </span> '/user/titi/blog/toto.json',
str<span class="Keyword">=</span>tab[<span class="Entity">rand</span>(<span class="Constant">4</span>)]; '/user/titi/blog/toto.xml' ]
ext<span class="Keyword">=</span><span class="Support">File</span>.<span class="Entity">extname</span>(str);
path<span class="Keyword">=</span>str.<span class="Entity">chomp</span>(ext); puts "remove extension"
<span class="Keyword">end</span> } Benchmark.bm do |x|
<span class="Keyword">end</span> x.report(" File:") { n.times do
</pre> str=tab[rand(4)];
</div></div></div> path=File.expand_path(str,File.basename(str,File.extname(str)));
end }
x.report("chomp:") { n.times do
str=tab[rand(4)];
ext=File.extname(str);
path=str.chomp(ext);
end }
end
</code></pre>
</div>
<p>and here is the result:</p> <p>and here is the result:</p>

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Astuces Git" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-03-22-Git-Tips/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Astuces Git" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-03-22-Git-Tips/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -58,60 +61,75 @@
<p>Standard:</p> <p>Standard:</p>
<div><pre class="twilight"> <div>
git clone git@github.com:yogsototh/project.git
</pre></div> <pre><code class="zsh">git clone git@github.com:yogsototh/project.git
</code></pre>
</div>
<p>Using HTTPS port:</p> <p>Using HTTPS port:</p>
<div><pre class="twilight"> <div>
git clone git+ssh://git@github.com:443/yogsototh/project.git
</pre></div> <pre><code class="zsh">git clone git+ssh://git@github.com:443/yogsototh/project.git
</code></pre>
</div>
<h2 id="clone-all-branches">clone all branches</h2> <h2 id="clone-all-branches">clone all branches</h2>
<p><code>git clone</code> can only fetch the master branch.</p> <p><code>git clone</code> can only fetch the master branch.</p>
<p>If you don&rsquo;t have much branches, you can simply use clone your project and then use the following command:</p> <p>If you dont have much branches, you can simply use clone your project and then use the following command:</p>
<div><pre class="twilight"> <div>
git branch --track local_branch remote_branch
</pre></div> <pre><code class="zsh">git branch --track local_branch remote_branch
</code></pre>
</div>
<p>for example:</p> <p>for example:</p>
<div><pre class="twilight"> <div>
$ git clone git@github:yogsototh/example.git
<pre><code class="zsh">$ git clone git@github:yogsototh/example.git
$ git branch $ git branch
master * master *
$ git branch -a $ git branch -a
master * master *
remotes/origin/HEAD -<span class="Keyword">&gt;</span> origin/master remotes/origin/HEAD -&gt; origin/master
remotes/origin/experimental remotes/origin/experimental
$ git branch --track experimental remotes/origin/experimental $ git branch --track experimental remotes/origin/experimental
$ git branch $ git branch
master * master *
experimental experimental
</pre></div> </code></pre>
</div>
<p>If you have many branches it can be useful to use the following <em>script</em>/<em>long command line</em>.</p> <p>If you have many branches it can be useful to use the following <em>script</em>/<em>long command line</em>.</p>
<div><pre class="twilight"> <div>
<span class="Comment"><span class="Comment">#</span> first clone your project</span>
<pre><code class="zsh"># first clone your project
$ git clone git@github.com:yogsototh/project.git $ git clone git@github.com:yogsototh/project.git
<span class="Comment"><span class="Comment">#</span> copy all branches</span> # copy all branches
$ zsh $ zsh
$ cd project $ cd project
$ <span class="Keyword">for</span> br <span class="Keyword">in</span> <span class="String"><span class="String">$(</span> git br -a <span class="String">)</span></span><span class="Keyword">;</span> <span class="Keyword">do</span> $ for br in $( git br -a ); do
<span class="Keyword">case</span> <span class="Variable"><span class="Variable">$</span>br</span> <span class="Keyword">in</span> case $br in
remotes/*) print <span class="Variable"><span class="Variable">$</span>br</span> <span class="Keyword">;</span> remotes/*) print $br ;
<span class="Keyword">case</span> <span class="Variable"><span class="Variable">${</span>br:t<span class="Variable">}</span></span> <span class="Keyword">in</span> case ${br:t} in
master<span class="Keyword">|</span>HEAD) <span class="Keyword">continue</span> <span class="Keyword">;</span><span class="Keyword">;</span> master|HEAD) continue ;;
*) git branch --track <span class="Variable"><span class="Variable">${</span>br:t<span class="Variable">}</span></span> <span class="Variable"><span class="Variable">$</span>br</span> <span class="Keyword">;</span><span class="Keyword">;</span> *) git branch --track ${br:t} $br ;;
<span class="Keyword">esac</span> <span class="Keyword">;</span><span class="Keyword">;</span> esac ;;
<span class="Keyword">esac</span> esac
<span class="Keyword">done</span> done
</pre></div> </code></pre>
</div>
</div> </div>

View file

@ -1,4 +1,3 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
# encoding: utf-8 # encoding: utf-8

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Encapsuler git" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-03-23-Encapsulate-git/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Encapsuler git" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-03-23-Encapsulate-git/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -82,12 +85,15 @@ clientB: project adapted for client B</p>
<p>An arrow from A to B means, you can merge A in B. If there is no arrow from A to B that means it is <em>forbidden</em> to merge A in B. Here is the corresponding rubycode:</p> <p>An arrow from A to B means, you can merge A in B. If there is no arrow from A to B that means it is <em>forbidden</em> to merge A in B. Here is the corresponding rubycode:</p>
<div><pre class="twilight"> <div>
<span class="Variable"><span class="Variable">$</span>architecture</span><span class="Keyword">=</span>{
<span class="Constant"><span class="Constant">:</span>master</span> =&gt; [ <span class="Constant"><span class="Constant">:</span>dev</span>, <span class="Constant"><span class="Constant">:</span>client</span> ], <pre><code class="ruby">$architecture={
<span class="Constant"><span class="Constant">:</span>dev</span> =&gt; [ <span class="Constant"><span class="Constant">:</span>master</span> ], :master =&gt; [ :dev, :client ],
<span class="Constant"><span class="Constant">:</span>client</span> =&gt; [ <span class="Constant"><span class="Constant">:</span>clientA</span>, <span class="Constant"><span class="Constant">:</span>clientB</span> ] } :dev =&gt; [ :master ],
</pre></div> :client =&gt; [ :clientA, :clientB ] }
</code></pre>
</div>
<p>Having a <code>:master =&gt; [ :dev, :client ]</code> means you can merge <code>master</code> branch into <code>dev</code> and <code>client</code>.</p> <p>Having a <code>:master =&gt; [ :dev, :client ]</code> means you can merge <code>master</code> branch into <code>dev</code> and <code>client</code>.</p>
@ -95,123 +101,128 @@ clientB: project adapted for client B</p>
<p>But this script do far more than that. It also merge from top to down. The action <code>allmerges</code> will do:</p> <p>But this script do far more than that. It also merge from top to down. The action <code>allmerges</code> will do:</p>
<div><pre class="twilight"> <div>
git co dev <span class="Keyword">&amp;&amp;</span> git merge master
git co client <span class="Keyword">&amp;&amp;</span> git merge master <pre><code class="zsh">git co dev &amp;&amp; git merge master
git co clientA <span class="Keyword">&amp;&amp;</span> git merge client git co client &amp;&amp; git merge master
git co clientB <span class="Keyword">&amp;&amp;</span> git merge client git co clientA &amp;&amp; git merge client
</pre></div> git co clientB &amp;&amp; git merge client
</code></pre>
</div>
<p>That means, I can update all branches. The algorithm will not make loop even if there is a cycle in the branch hierarchy.</p> <p>That means, I can update all branches. The algorithm will not make loop even if there is a cycle in the branch hierarchy.</p>
<p>Here it is:</p> <p>Here it is:</p>
<div class="small"><div class="code"><div class="file"><a href="/Scratch/en/blog/2010-03-23-Encapsulate-git/code/eng"> &#x27A5; eng </a></div><div class="withfile"> <div class="small"><div class="codefile"><a href="/Scratch/en/blog/2010-03-23-Encapsulate-git/code/eng">&#x27A5; eng</a></div>
<pre class="twilight">
<span class="Comment"><span class="Comment">#</span>!/usr/bin/env ruby</span>
<span class="Comment"><span class="Comment">#</span> encoding: utf-8</span>
<span class="Comment"><span class="Comment">#</span> architecture</span>
<span class="Comment"><span class="Comment">#</span></span>
<span class="Comment"><span class="Comment">#</span> master &lt;-&gt; dev</span>
<span class="Comment"><span class="Comment">#</span> master -&gt; client</span>
<span class="Comment"><span class="Comment">#</span> clien -&gt; clientA | clientB</span>
<span class="Comment"><span class="Comment">#</span></span>
<span class="Comment"><span class="Comment">#</span> merge using two of these branches should be </span>
<span class="Comment"><span class="Comment">#</span> restricted to these rules</span>
<span class="Comment"><span class="Comment">#</span> merge to one of these branch and an unknown one should</span>
<span class="Comment"><span class="Comment">#</span> raise a warning, and may the option to add this new branch</span>
<span class="Comment"><span class="Comment">#</span> to the hierarchy</span>
<span class="Variable"><span class="Variable">$</span>architecture</span><span class="Keyword">=</span>{ <pre><code class="ruby">#!/usr/bin/env ruby
<span class="Constant"><span class="Constant">:</span>master</span> =&gt; [ <span class="Constant"><span class="Constant">:</span>dev</span>, <span class="Constant"><span class="Constant">:</span>client</span> ], # encoding: utf-8
<span class="Constant"><span class="Constant">:</span>dev</span> =&gt; [ <span class="Constant"><span class="Constant">:</span>master</span> ],
<span class="Constant"><span class="Constant">:</span>client</span> =&gt; [ <span class="Constant"><span class="Constant">:</span>clientA</span>, <span class="Constant"><span class="Constant">:</span>clientB</span> ] }
<span class="Keyword">def</span> <span class="Entity">get_current_branch</span>(<span class="Variable"></span>) # architecture
(<span class="String"><span class="String">`</span>git branch --no-color | awk '$1 == &quot;*&quot; {print $2}'<span class="String">`</span></span>).<span class="Entity">chop</span>.<span class="Entity">intern</span> #
<span class="Keyword">end</span> # master &lt;-&gt; dev
# master -&gt; client
# clien -&gt; clientA | clientB
#
# merge using two of these branches should be
# restricted to these rules
# merge to one of these branch and an unknown one should
# raise a warning, and may the option to add this new branch
# to the hierarchy
<span class="Keyword">if</span> <span class="Variable">ARGV</span>.<span class="Entity">length</span> <span class="Keyword">==</span> <span class="Constant">0</span> $architecture={
puts <span class="String"><span class="String">%{</span>usage: $0:t [git_command or local_command]</span> :master =&gt; [ :dev, :client ],
<span class="String"> </span> :dev =&gt; [ :master ],
<span class="String">local commands:</span> :client =&gt; [ :clientA, :clientB ] }
<span class="String"> allmerges: merge from top to down<span class="String">}</span></span>
exit <span class="Constant">0</span>
<span class="Keyword">end</span>
<span class="Keyword">require</span> <span class="String"><span class="String">'</span>set<span class="String">'</span></span> def get_current_branch()
<span class="Variable"><span class="Variable">$</span>known_branches</span><span class="Keyword">=</span><span class="Support">Set</span>.<span class="Entity">new</span> (`git branch --no-color | awk '$1 == "*" {print $2}'`).chop.intern
<span class="Variable"><span class="Variable">$</span>architecture</span>.<span class="Entity">each</span> <span class="Keyword">do </span>|<span class="Variable">k</span>,<span class="Variable">v</span>| end
<span class="Variable"><span class="Variable">$</span>known_branches</span>.<span class="Entity">add</span>(k)
v.<span class="Entity">each</span> { |<span class="Variable">b</span>| <span class="Variable"><span class="Variable">$</span>known_branches</span>.<span class="Entity">add</span>(b) }
<span class="Keyword">end</span>
<span class="Keyword">def</span> <span class="Entity">rec_merge</span>(<span class="Variable">branch</span>) if ARGV.length == 0
<span class="Keyword">if</span> <span class="Variable"><span class="Variable">$</span>architecture</span>[branch].<span class="Entity">nil?</span> puts %{usage: $0:t [git_command or local_command]
<span class="Keyword">return</span>
<span class="Keyword">end</span> local commands:
<span class="Variable"><span class="Variable">$</span>architecture</span>[branch].<span class="Entity">each</span> <span class="Keyword">do </span>|<span class="Variable">b</span>| allmerges: merge from top to down}
<span class="Keyword">if</span> <span class="Variable"><span class="Variable">$</span>flag</span>.<span class="Entity">has_key?</span>(b.<span class="Entity">to_s</span> <span class="Keyword">+</span> branch.<span class="Entity">to_s</span>) exit 0
<span class="Keyword">next</span> end
<span class="Keyword">end</span>
flagname<span class="Keyword">=</span>branch.<span class="Entity">to_s</span> <span class="Keyword">+</span> b.<span class="Entity">to_s</span>
<span class="Keyword">if</span> <span class="Variable"><span class="Variable">$</span>flag</span>.<span class="Entity">has_key?</span>(flagname)
<span class="Keyword">next</span>
<span class="Keyword">end</span>
<span class="Keyword">if</span> system <span class="String"><span class="String">%{</span>eng checkout <span class="StringEmbeddedSource"><span class="StringEmbeddedSource">#{</span>b<span class="StringEmbeddedSource">}</span></span><span class="String">}</span></span>
<span class="Keyword">if</span> get_current_branch <span class="Keyword">!=</span> b
puts <span class="String"><span class="String">&quot;</span>Can't checkout to <span class="StringEmbeddedSource"><span class="StringEmbeddedSource">#{</span>b<span class="StringEmbeddedSource">}</span></span><span class="String">&quot;</span></span>
exit <span class="Constant">2</span>
<span class="Keyword">end</span>
<span class="Keyword">if</span> system <span class="String"><span class="String">%{</span>eng merge <span class="StringEmbeddedSource"><span class="StringEmbeddedSource">#{</span>branch<span class="StringEmbeddedSource">}</span></span><span class="String">}</span></span>
<span class="Variable"><span class="Variable">$</span>flag</span>[flagname]<span class="Keyword">=</span><span class="Constant">true</span>
<span class="Entity">rec_merge</span>(b)
<span class="Keyword">else</span>
exit <span class="Constant">1</span>
<span class="Keyword">end</span>
<span class="Keyword">else</span>
exit <span class="Constant">1</span>
<span class="Keyword">end</span>
<span class="Keyword">end</span>
<span class="Keyword">end</span>
<span class="Keyword">def</span> <span class="Entity">do_all_merges</span> require 'set'
puts <span class="String"><span class="String">'</span>Will merge from father to sons<span class="String">'</span></span> $known_branches=Set.new
current_branch<span class="Keyword">=</span>get_current_branch $architecture.each do |k,v|
<span class="Variable"><span class="Variable">$</span>flag</span><span class="Keyword">=</span>{} $known_branches.add(k)
<span class="Entity">rec_merge</span>(<span class="Constant"><span class="Constant">:</span>master</span>) v.each { |b| $known_branches.add(b) }
system <span class="String"><span class="String">%{</span>git co <span class="StringEmbeddedSource"><span class="StringEmbeddedSource">#{</span>current_branch<span class="StringEmbeddedSource">}</span></span><span class="String">}</span></span> end
<span class="Keyword">end</span>
<span class="Keyword">def</span> <span class="Entity">do_merge</span> def rec_merge(branch)
current_branch<span class="Keyword">=</span>get_current_branch if $architecture[branch].nil?
src_branch<span class="Keyword">=</span><span class="Variable">ARGV</span>[<span class="Constant">1</span>].<span class="Entity">intern</span> return
puts <span class="String"><span class="String">%{</span>do_merge: <span class="StringEmbeddedSource"><span class="StringEmbeddedSource">#{</span>src_branch<span class="StringEmbeddedSource">}</span></span> =&gt; <span class="StringEmbeddedSource"><span class="StringEmbeddedSource">#{</span>current_branch<span class="StringEmbeddedSource">}</span></span><span class="String">}</span></span> end
<span class="Keyword">if</span> <span class="Variable"><span class="Variable">$</span>known_branches</span>.<span class="Entity">include?</span>(current_branch) $architecture[branch].each do |b|
<span class="Keyword">if</span> <span class="Variable"><span class="Variable">$</span>known_branches</span>.<span class="Entity">include?</span>(src_branch) if $flag.has_key?(b.to_s + branch.to_s)
<span class="Keyword">if</span> <span class="Variable"><span class="Variable">$</span>architecture</span>.<span class="Entity">has_key?</span>(src_branch) <span class="Keyword">and</span> next
<span class="Variable"><span class="Variable">$</span>architecture</span>[src_branch].<span class="Entity">include?</span>(current_branch) end
system <span class="String"><span class="String">%{</span>git merge <span class="StringEmbeddedSource"><span class="StringEmbeddedSource">#{</span>src_branch<span class="StringEmbeddedSource">}</span></span><span class="String">}</span></span> flagname=branch.to_s + b.to_s
<span class="Keyword">else</span> if $flag.has_key?(flagname)
puts <span class="String"><span class="String">%{</span>Forbidden merge: <span class="StringEmbeddedSource"><span class="StringEmbeddedSource">#{</span>src_branch<span class="StringEmbeddedSource">}</span></span> =&gt; <span class="StringEmbeddedSource"><span class="StringEmbeddedSource">#{</span>current_branch<span class="StringEmbeddedSource">}</span></span><span class="String">}</span></span> next
<span class="Keyword">end</span> end
<span class="Keyword">else</span> if system %{eng checkout #{b}}
puts <span class="String"><span class="String">%{</span>Warning! <span class="StringEmbeddedSource"><span class="StringEmbeddedSource">#{</span>src_branch<span class="StringEmbeddedSource">}</span></span> not mentionned in rb configuration<span class="String">}</span></span> if get_current_branch != b
sleep <span class="Constant">2</span> puts "Can't checkout to #{b}"
system <span class="String"><span class="String">%{</span>git merge <span class="StringEmbeddedSource"><span class="StringEmbeddedSource">#{</span>src_branch<span class="StringEmbeddedSource">}</span></span><span class="String">}</span></span> exit 2
puts <span class="String"><span class="String">%{</span>Warning! <span class="StringEmbeddedSource"><span class="StringEmbeddedSource">#{</span>src_branch<span class="StringEmbeddedSource">}</span></span> not mentionned in rb configuration<span class="String">}</span></span> end
<span class="Keyword">end</span> if system %{eng merge #{branch}}
<span class="Keyword">end</span> $flag[flagname]=true
<span class="Keyword">end</span> rec_merge(b)
else
exit 1
end
else
exit 1
end
end
end
<span class="Keyword">case</span> <span class="Variable">ARGV</span>[<span class="Constant">0</span>] def do_all_merges
<span class="Keyword">when</span> <span class="String"><span class="String">'</span>allmerges<span class="String">'</span></span> <span class="Keyword">then</span> do_all_merges puts 'Will merge from father to sons'
<span class="Keyword">when</span> <span class="String"><span class="String">'</span>merge<span class="String">'</span></span> <span class="Keyword">then</span> do_merge current_branch=get_current_branch
<span class="Keyword">else</span> system <span class="String"><span class="String">%{</span>git <span class="StringEmbeddedSource"><span class="StringEmbeddedSource">#{</span><span class="StringVariable">ARGV</span><span class="StringEmbeddedSource"><span class="StringEmbeddedSource">.</span><span class="Entity">join</span></span><span class="StringEmbeddedSource">(</span><span class="String"><span class="String">'</span> <span class="String">'</span></span><span class="StringEmbeddedSource">)</span><span class="StringEmbeddedSource">}</span></span><span class="String">}</span></span> $flag={}
<span class="Keyword">end</span> rec_merge(:master)
</pre> system %{git co #{current_branch}}
</div></div></div> end
def do_merge
current_branch=get_current_branch
src_branch=ARGV[1].intern
puts %{do_merge: #{src_branch} =&gt; #{current_branch}}
if $known_branches.include?(current_branch)
if $known_branches.include?(src_branch)
if $architecture.has_key?(src_branch) and
$architecture[src_branch].include?(current_branch)
system %{git merge #{src_branch}}
else
puts %{Forbidden merge: #{src_branch} =&gt; #{current_branch}}
end
else
puts %{Warning! #{src_branch} not mentionned in rb configuration}
sleep 2
system %{git merge #{src_branch}}
puts %{Warning! #{src_branch} not mentionned in rb configuration}
end
end
end
case ARGV[0]
when 'allmerges' then do_all_merges
when 'merge' then do_merge
else system %{git #{ARGV.join(' ')}}
end
</code></pre>
</div>
<p>All you need to do to make it work is simply to copy eng in a directory contained in your PATH.</p> <p>All you need to do to make it work is simply to copy eng in a directory contained in your PATH.</p>
@ -332,7 +343,7 @@ git co clientB <span class="Keyword">&amp;&amp;</span> git merge client
</div> </div>
<div id="lastmod"> <div id="lastmod">
Created: 03/23/2010 Created: 03/23/2010
Modified: 05/09/2010 Modified: 04/26/2012
</div> </div>
<div> <div>
Entirely done with Entirely done with

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Je reviens à la vie !" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-05-17-at-least-this-blog-revive/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Je reviens à la vie !" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-05-17-at-least-this-blog-revive/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -60,14 +63,14 @@
<p>The more you wait to do something, the more difficult it is to start doing it.</p> <p>The more you wait to do something, the more difficult it is to start doing it.</p>
</blockquote> </blockquote>
<p>I had to write another post for this blog. I had added many article idea in my todolist. But, I made many other things, and I&rsquo;ve always said (until now), I&rsquo;ll do this later. What changed my mind is the haunt of this simple remark about how to be productive in programming. <p>I had to write another post for this blog. I had added many article idea in my todolist. But, I made many other things, and Ive always said (until now), Ill do this later. What changed my mind is the haunt of this simple remark about how to be productive in programming.
&gt; Stop write <code>TODO</code> in your code and make it now!<br /> &gt; Stop write <code>TODO</code> in your code and make it now!<br />
&gt; You&rsquo;ll be surprised by the results.</p> &gt; Youll be surprised by the results.</p>
<p>In short: <p>In short:
&gt; <strong>Just do it!</strong> ou <strong>Juste fait le</strong> comme auraient dit les nuls.</p> &gt; <strong>Just do it!</strong> ou <strong>Juste fait le</strong> comme auraient dit les nuls.</p>
<p>Finally I&rsquo;ll certainly write blog post more often for a short period of time.</p> <p>Finally Ill certainly write blog post more often for a short period of time.</p>
<h3 id="what-did-i-do">What did I do?</h3> <h3 id="what-did-i-do">What did I do?</h3>
@ -77,7 +80,7 @@
<p>I also have a <em>real</em> life. I enjoyed some vacancies with my family. </p> <p>I also have a <em>real</em> life. I enjoyed some vacancies with my family. </p>
<p>I work with <a href="http://www.lucarea.net">Luc</a> on a simple ruby REST/JSON/API oriented framework. It works fairly well, with really few bug until now. We planify to make a simple todolist tutorial. May be in two to three blog posts. This framework is not public for now. It will certainly be after we&rsquo;ll create some simple web service with it and made a nice website for it.</p> <p>I work with <a href="http://www.lucarea.net">Luc</a> on a simple ruby REST/JSON/API oriented framework. It works fairly well, with really few bug until now. We planify to make a simple todolist tutorial. May be in two to three blog posts. This framework is not public for now. It will certainly be after well create some simple web service with it and made a nice website for it.</p>
<p>Then what I plan to do from now:</p> <p>Then what I plan to do from now:</p>
@ -89,7 +92,7 @@
<li>provide the sources of this website on <a href="http://github.com">github</a></li> <li>provide the sources of this website on <a href="http://github.com">github</a></li>
</ul> </ul>
<p>There is some random in some of these achivement mostly because they don&rsquo;t depend totally on me.</p> <p>There is some random in some of these achivement mostly because they dont depend totally on me.</p>
</div> </div>

View file

@ -1,4 +1,3 @@
# repair cutted XML code by closing the tags # repair cutted XML code by closing the tags
# work even if the XML is cut into a tag. # work even if the XML is cut into a tag.
# example: # example:

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Comment réparer un XML coupé ?" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-05-19-How-to-cut-HTML-and-repair-it/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Comment réparer un XML coupé ?" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-05-19-How-to-cut-HTML-and-repair-it/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -62,104 +65,100 @@
<p>Here is an example:</p> <p>Here is an example:</p>
<pre class="twilight"> <pre><code class="html">&lt;div class="corps"&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">div</span> <span class="MetaTagAll">class</span>=<span class="String"><span class="String">&quot;</span>corps<span class="String">&quot;</span></span><span class="MetaTagAll">&gt;</span></span> &lt;div class="intro"&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">div</span> <span class="MetaTagAll">class</span>=<span class="String"><span class="String">&quot;</span>intro<span class="String">&quot;</span></span><span class="MetaTagAll">&gt;</span></span> &lt;p&gt;Introduction&lt;/p&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">p</span><span class="MetaTagAll">&gt;</span></span>Introduction<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">p</span><span class="MetaTagAll">&gt;</span></span> &lt;/div&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">div</span><span class="MetaTagAll">&gt;</span></span> &lt;p&gt;The first paragraph&lt;/p&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">p</span><span class="MetaTagAll">&gt;</span></span>The first paragraph<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">p</span><span class="MetaTagAll">&gt;</span></span> &lt;img src="/img/img.png" alt="an image"/&gt;
<span class="MetaTagInline"><span class="MetaTagInline">&lt;</span><span class="MetaTagInline">img</span> <span class="MetaTagInline">src</span>=<span class="String"><span class="String">&quot;</span>/img/img.png<span class="String">&quot;</span></span> <span class="MetaTagInline">alt</span>=<span class="String"><span class="String">&quot;</span>an image<span class="String">&quot;</span></span>/<span class="MetaTagInline">&gt;</span></span> &lt;p&gt;Another long paragraph&lt;/p&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">p</span><span class="MetaTagAll">&gt;</span></span>Another long paragraph<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">p</span><span class="MetaTagAll">&gt;</span></span> &lt;/div&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">div</span><span class="MetaTagAll">&gt;</span></span> </code></pre>
</pre>
<p>After the cut, I obtain:</p> <p>After the cut, I obtain:</p>
<pre class="twilight"> <pre><code class="html">&lt;div class="corps"&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">div</span> <span class="MetaTagAll">class</span>=<span class="String"><span class="String">&quot;</span>corps<span class="String">&quot;</span></span><span class="MetaTagAll">&gt;</span></span> &lt;div class="intro"&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">div</span> <span class="MetaTagAll">class</span>=<span class="String"><span class="String">&quot;</span>intro<span class="String">&quot;</span></span><span class="MetaTagAll">&gt;</span></span> &lt;p&gt;Introduction&lt;/p&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">p</span><span class="MetaTagAll">&gt;</span></span>Introduction<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">p</span><span class="MetaTagAll">&gt;</span></span> &lt;/div&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">div</span><span class="MetaTagAll">&gt;</span></span> &lt;p&gt;The first paragraph&lt;/p&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">p</span><span class="MetaTagAll">&gt;</span></span>The first paragraph<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">p</span><span class="MetaTagAll">&gt;</span></span> &lt;img src="/img/im
<span class="MetaTagInline"><span class="MetaTagInline">&lt;</span><span class="MetaTagInline">img</span> <span class="MetaTagInline">src</span>=<span class="String"><span class="String">&quot;</span>/img/im</span></span> </code></pre>
</pre>
<p>Argh! In the middle of an <code>&lt;img&gt;</code> tag.</p> <p>Argh! In the middle of an <code>&lt;img&gt;</code> tag.</p>
<p>In fact, it is not as difficult as it should sound first. The secret is, you don&rsquo;t need to keep the complete tree structure to repair it, but only the list of not closed parents.</p> <p>In fact, it is not as difficult as it should sound first. The secret is, you dont need to keep the complete tree structure to repair it, but only the list of not closed parents.</p>
<p>Given with our example, when we are after the first paragraph. we only have to close the <code>div</code> for class <code>corps</code> and the XML is repaired. Of course, when you cut inside a tag, you sould go back, as if you where just before it. Delete this tag and all is ok.</p> <p>Given with our example, when we are after the first paragraph. we only have to close the <code>div</code> for class <code>corps</code> and the XML is repaired. Of course, when you cut inside a tag, you sould go back, as if you where just before it. Delete this tag and all is ok.</p>
<p>Then, all you have to do, is not remember all the XML tree, but only the heap containing your parents. Suppose we treat the complete first example, the stack will pass through the following state, in order:</p> <p>Then, all you have to do, is not remember all the XML tree, but only the heap containing your parents. Suppose we treat the complete first example, the stack will pass through the following state, in order:</p>
<pre class="twilight"> <pre><code class="html">[]
[] [div] &lt;div class="corps"&gt;
[div] <span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">div</span> <span class="MetaTagAll">class</span>=<span class="String"><span class="String">&quot;</span>corps<span class="String">&quot;</span></span><span class="MetaTagAll">&gt;</span></span> [div, div] &lt;div class="intro"&gt;
[div, div] <span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">div</span> <span class="MetaTagAll">class</span>=<span class="String"><span class="String">&quot;</span>intro<span class="String">&quot;</span></span><span class="MetaTagAll">&gt;</span></span> [div, div, p] &lt;p&gt;
[div, div, p] <span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">p</span><span class="MetaTagAll">&gt;</span></span>
Introduction Introduction
[div, div] <span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">p</span><span class="MetaTagAll">&gt;</span></span> [div, div] &lt;/p&gt;
[div] <span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">div</span><span class="MetaTagAll">&gt;</span></span> [div] &lt;/div&gt;
[div, p] <span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">p</span><span class="MetaTagAll">&gt;</span></span> [div, p] &lt;p&gt;
The first paragraph The first paragraph
[div] <span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">p</span><span class="MetaTagAll">&gt;</span></span> [div] &lt;/p&gt;
[div] <span class="MetaTagInline"><span class="MetaTagInline">&lt;</span><span class="MetaTagInline">img</span> <span class="MetaTagInline">src</span>=<span class="String"><span class="String">&quot;</span>/img/img.png<span class="String">&quot;</span></span> <span class="MetaTagInline">alt</span>=<span class="String"><span class="String">&quot;</span>an image<span class="String">&quot;</span></span>/<span class="MetaTagInline">&gt;</span></span> [div] &lt;img src="/img/img.png" alt="an image"/&gt;
[div, p] <span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">p</span><span class="MetaTagAll">&gt;</span></span> [div, p] &lt;p&gt;
Another long paragraph Another long paragraph
[div] <span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">p</span><span class="MetaTagAll">&gt;</span></span> [div] &lt;/p&gt;
[] <span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">div</span><span class="MetaTagAll">&gt;</span></span> [] &lt;/div&gt;
</pre> </code></pre>
<p>The algorihm, is then really simple: <p>The algorihm, is then really simple: </p>
&lt;pre class="twilight"&gt;
let res be the XML as a string&nbsp;; <pre><code class="html">let res be the XML as a string ;
read res and each time you encouter a tag: read res and each time you encouter a tag:
if it is an opening one: if it is an opening one:
push it to the stack push it to the stack
else if it is a closing one: else if it is a closing one:
pop the stack.</p> pop the stack.
<p>remove any malformed/cutted tag in the end of res remove any malformed/cutted tag in the end of res
for each tag in the stack, pop it, and write: for each tag in the stack, pop it, and write:
res = res + closed tag</p> res = res + closed tag
<p>return res return res
&lt;/pre&gt;</p> </code></pre>
<p>And <code>res</code> contain the repaired XML.</p> <p>And <code>res</code> contain the repaired XML.</p>
<p>Finally, this is the code in ruby I use. The <code>xml</code> variable contain the cutted XML.</p> <p>Finally, this is the code in ruby I use. The <code>xml</code> variable contain the cutted XML.</p>
<div class="code"><div class="file"><a href="/Scratch/en/blog/2010-05-19-How-to-cut-HTML-and-repair-it/code/repair_xml.rb"> &#x27A5; repair_xml.rb </a></div><div class="withfile"> <div class="codefile"><a href="/Scratch/en/blog/2010-05-19-How-to-cut-HTML-and-repair-it/code/repair_xml.rb">&#x27A5; repair_xml.rb</a></div>
<pre class="twilight">
<span class="Comment"><span class="Comment">#</span> repair cutted XML code by closing the tags</span>
<span class="Comment"><span class="Comment">#</span> work even if the XML is cut into a tag.</span>
<span class="Comment"><span class="Comment">#</span> example:</span>
<span class="Comment"><span class="Comment">#</span> transform '&lt;div&gt; &lt;span&gt; toto &lt;/span&gt; &lt;p&gt; hello &lt;a href=&quot;http://tur'</span>
<span class="Comment"><span class="Comment">#</span> into '&lt;div&gt; &lt;span&gt; toto &lt;/span&gt; &lt;p&gt; hello &lt;/p&gt;&lt;/div&gt;'</span>
<span class="Keyword">def</span> <span class="Entity">repair_xml</span>(<span class="Variable"> xml </span>)
parents<span class="Keyword">=</span>[]
depth<span class="Keyword">=</span><span class="Constant">0</span>
xml.<span class="Entity">scan</span>( <span class="StringRegexp"><span class="StringRegexp">%r{</span>&lt;<span class="StringRegexp"><span class="StringRegexp">(</span>/?<span class="StringRegexp">)</span></span><span class="StringRegexp"><span class="StringRegexp">(</span><span class="StringRegexpSpecial">\w</span>*<span class="StringRegexp">)</span></span><span class="StringRegexp"><span class="StringRegexp">[</span>^&gt;<span class="StringRegexp">]</span></span>*<span class="StringRegexp"><span class="StringRegexp">(</span>/?<span class="StringRegexp">)</span></span>&gt;<span class="StringRegexp">}</span></span> ).<span class="Entity">each</span> <span class="Keyword">do </span>|<span class="Variable">m</span>|
<span class="Keyword">if</span> m[<span class="Constant">2</span>] <span class="Keyword">==</span> <span class="String"><span class="String">&quot;</span>/<span class="String">&quot;</span></span>
<span class="Keyword">next</span>
<span class="Keyword">end</span>
<span class="Keyword">if</span> m[<span class="Constant">0</span>] <span class="Keyword">==</span> <span class="String"><span class="String">&quot;</span><span class="String">&quot;</span></span>
parents[depth]<span class="Keyword">=</span>m[<span class="Constant">1</span>]
depth<span class="Keyword">+=</span><span class="Constant">1</span>
<span class="Keyword">else</span>
depth<span class="Keyword">-=</span><span class="Constant">1</span>
<span class="Keyword">end</span>
<span class="Keyword">end</span>
res<span class="Keyword">=</span>xml.<span class="Entity">sub</span>(<span class="StringRegexp"><span class="StringRegexp">/</span></span><span class="StringRegexp">&lt;<span class="StringRegexp"><span class="StringRegexp">[</span>^&gt;<span class="StringRegexp">]</span></span>*$</span><span class="StringRegexp"><span class="StringRegexp">/m</span></span>,<span class="String"><span class="String">'</span><span class="String">'</span></span>)
depth<span class="Keyword">-=</span><span class="Constant">1</span>
depth.<span class="Entity">downto</span>(<span class="Constant">0</span>).<span class="Entity">each</span> { |<span class="Variable">x</span>| res<span class="Keyword">&lt;&lt;=</span> <span class="String"><span class="String">%{</span>&lt;/<span class="StringEmbeddedSource"><span class="StringEmbeddedSource">#{</span>parents<span class="StringEmbeddedSource">[</span>x<span class="StringEmbeddedSource">]</span><span class="StringEmbeddedSource">}</span></span>&gt;<span class="String">}</span></span> }
res
<span class="Keyword">end</span>
</pre>
</div></div>
<p>I don&rsquo;t know if the code can help you, but the raisonning should definitively be known.</p> <pre><code class="ruby"># repair cutted XML code by closing the tags
# work even if the XML is cut into a tag.
# example:
# transform '&lt;div&gt; &lt;span&gt; toto &lt;/span&gt; &lt;p&gt; hello &lt;a href="http://tur'
# into '&lt;div&gt; &lt;span&gt; toto &lt;/span&gt; &lt;p&gt; hello &lt;/p&gt;&lt;/div&gt;'
def repair_xml( xml )
parents=[]
depth=0
xml.scan( %r{&lt;(/?)(\w*)[^&gt;]*(/?)&gt;} ).each do |m|
if m[2] == "/"
next
end
if m[0] == ""
parents[depth]=m[1]
depth+=1
else
depth-=1
end
end
res=xml.sub(/&lt;[^&gt;]*$/m,'')
depth-=1
depth.downto(0).each { |x| res&lt;&lt;= %{&lt;/#{parents[x]}&gt;} }
res
end
</code></pre>
<p>I dont know if the code can help you, but the raisonning should definitively be known.</p>
</div> </div>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Arbres ; Pragmatisme et Formalisme" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-05-24-Trees--Pragmatism-and-Formalism/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Arbres ; Pragmatisme et Formalisme" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-05-24-Trees--Pragmatism-and-Formalism/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -71,7 +74,7 @@
<li>Used a pen and a sheet of paper</li> <li>Used a pen and a sheet of paper</li>
<li>Made some math.</li> <li>Made some math.</li>
<li>Crushed the problem in 10 minutes</li> <li>Crushed the problem in 10 minutes</li>
<li>Conclusion: The pragmatism shouldn&rsquo;t mean &ldquo;never use theory&rdquo;.</li> <li>Conclusion: The pragmatism shouldnt mean “never use theory”.</li>
</ul> </ul>
@ -86,10 +89,10 @@ I entered in the <em>infernal</em>: <em>try &amp; repair loop</em>.
Each step was like:</p> Each step was like:</p>
<blockquote> <blockquote>
<p>&ndash; Just this thing to repair and that should be done.<br /> <p> Just this thing to repair and that should be done.<br />
&ndash; OK, now that should just work.<br /> OK, now that should just work.<br />
&ndash; Yeah!!!<br /> Yeah!!!<br />
&ndash; Oops! I forgotten that&hellip;<br /> Oops! I forgotten that…<br />
<code>repeat until death</code></p> <code>repeat until death</code></p>
</blockquote> </blockquote>
@ -117,52 +120,50 @@ I had to face a problem of the same kind at my job. The problem was simple to th
<p>The source <span class="sc">xml</span> was in the following general format:</p> <p>The source <span class="sc">xml</span> was in the following general format:</p>
<pre class="twilight"> <pre><code class="xml">&lt;rubrique&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">rubrique</span><span class="MetaTagAll">&gt;</span></span> &lt;contenu&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">contenu</span><span class="MetaTagAll">&gt;</span></span> &lt;tag1&gt;value1&lt;/tag1&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">tag1</span><span class="MetaTagAll">&gt;</span></span>value1<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">tag1</span><span class="MetaTagAll">&gt;</span></span> &lt;tag2&gt;value2&lt;/tag2&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">tag2</span><span class="MetaTagAll">&gt;</span></span>value2<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">tag2</span><span class="MetaTagAll">&gt;</span></span>
... ...
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">contenu</span><span class="MetaTagAll">&gt;</span></span> &lt;/contenu&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">enfant</span><span class="MetaTagAll">&gt;</span></span> &lt;enfant&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">rubrique</span><span class="MetaTagAll">&gt;</span></span> &lt;rubrique&gt;
... ...
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">rubrique</span><span class="MetaTagAll">&gt;</span></span> &lt;/rubrique&gt;
... ...
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">rubrique</span><span class="MetaTagAll">&gt;</span></span> &lt;rubrique&gt;
... ...
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">rubrique</span><span class="MetaTagAll">&gt;</span></span> &lt;/rubrique&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">enfant</span><span class="MetaTagAll">&gt;</span></span> &lt;/enfant&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">menu</span><span class="MetaTagAll">&gt;</span></span> &lt;/menu&gt;
</pre> </code></pre>
<p>and the destination format was in the following general format:</p> <p>and the destination format was in the following general format:</p>
<pre class="twilight"> <pre><code class="xml">&lt;item name="Menu0"&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">item</span> <span class="MetaTagAll">name</span>=<span class="String"><span class="String">&quot;</span>Menu0<span class="String">&quot;</span></span><span class="MetaTagAll">&gt;</span></span> &lt;value&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">value</span><span class="MetaTagAll">&gt;</span></span> &lt;item name="menu"&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">item</span> <span class="MetaTagAll">name</span>=<span class="String"><span class="String">&quot;</span>menu<span class="String">&quot;</span></span><span class="MetaTagAll">&gt;</span></span> &lt;value&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">value</span><span class="MetaTagAll">&gt;</span></span> &lt;item name="tag1"&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">item</span> <span class="MetaTagAll">name</span>=<span class="String"><span class="String">&quot;</span>tag1<span class="String">&quot;</span></span><span class="MetaTagAll">&gt;</span></span> &lt;value&gt;value1&lt;/value&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">value</span><span class="MetaTagAll">&gt;</span></span>value1<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">value</span><span class="MetaTagAll">&gt;</span></span> &lt;/item&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">item</span><span class="MetaTagAll">&gt;</span></span> &lt;item name="tag2"&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">item</span> <span class="MetaTagAll">name</span>=<span class="String"><span class="String">&quot;</span>tag2<span class="String">&quot;</span></span><span class="MetaTagAll">&gt;</span></span> &lt;value&gt;value2&lt;/value&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">value</span><span class="MetaTagAll">&gt;</span></span>value2<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">value</span><span class="MetaTagAll">&gt;</span></span> &lt;/item&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">item</span><span class="MetaTagAll">&gt;</span></span>
... ...
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">item</span> <span class="MetaTagAll">name</span>=<span class="String"><span class="String">&quot;</span>menu<span class="String">&quot;</span></span><span class="MetaTagAll">&gt;</span></span> &lt;item name="menu"&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">value</span><span class="MetaTagAll">&gt;</span></span> &lt;value&gt;
... ...
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">value</span><span class="MetaTagAll">&gt;</span></span> &lt;/value&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">value</span><span class="MetaTagAll">&gt;</span></span> &lt;value&gt;
... ...
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">value</span><span class="MetaTagAll">&gt;</span></span> &lt;/value&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">item</span><span class="MetaTagAll">&gt;</span></span> &lt;/item&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">value</span><span class="MetaTagAll">&gt;</span></span> &lt;/value&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">item</span><span class="MetaTagAll">&gt;</span></span> &lt;/item&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">value</span><span class="MetaTagAll">&gt;</span></span> &lt;/value&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">item</span><span class="MetaTagAll">&gt;</span></span> &lt;/item&gt;
</pre> </code></pre>
<p>At first sight I believed it will be easy. I was so certain it will be easy that I fixed to myself the following rules:</p> <p>At first sight I believed it will be easy. I was so certain it will be easy that I fixed to myself the following rules:</p>
@ -173,7 +174,7 @@ I had to face a problem of the same kind at my job. The problem was simple to th
</ol> </ol>
<p>You can try if you want. If you attack the problem directly opening an editor, I assure you, it will certainly be not so simple. <p>You can try if you want. If you attack the problem directly opening an editor, I assure you, it will certainly be not so simple.
I can tell that, because it&rsquo;s what I&rsquo;ve done. And I must say I lost almost a complete day at work trying to resolve this. There was also, many small problems around that make me lose more than two days for this problem.</p> I can tell that, because its what Ive done. And I must say I lost almost a complete day at work trying to resolve this. There was also, many small problems around that make me lose more than two days for this problem.</p>
<p>Why after two days did I was unable to resolve this problem which seems so simple?</p> <p>Why after two days did I was unable to resolve this problem which seems so simple?</p>
@ -194,14 +195,14 @@ I thought about how to resolve the problem but with the eyes of a <em>pragmatic
<blockquote> <blockquote>
<p>That should be a simple perl search and replace program.<br /> <p>That should be a simple perl search and replace program.<br />
Let&rsquo;s begin to write code</p> Lets begin to write code</p>
</blockquote> </blockquote>
<p>This is the second sentence that was plainly wrong. I started in the wrong direction. And the workflow did not work from this entry point.</p> <p>This is the second sentence that was plainly wrong. I started in the wrong direction. And the workflow did not work from this entry point.</p>
<h2 id="think">Think</h2> <h2 id="think">Think</h2>
<p>After some times, I just stopped to work. Tell myself <em>&ldquo;it is enough, now, I must finish it!&rdquo;</em>. <p>After some times, I just stopped to work. Tell myself <em>“it is enough, now, I must finish it!”</em>.
I took a sheet of paper, a pen and began to draw some trees.</p> I took a sheet of paper, a pen and began to draw some trees.</p>
<p>I began by make by removing most of the verbosity. <p>I began by make by removing most of the verbosity.
@ -248,23 +249,21 @@ r - b
<p>And look at what it implies when you write it in <span class="sc">xml</span>:</p> <p>And look at what it implies when you write it in <span class="sc">xml</span>:</p>
<pre class="twilight"> <pre><code class="xml">&lt;r&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">r</span><span class="MetaTagAll">&gt;</span></span> &lt;x&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">x</span><span class="MetaTagAll">&gt;</span></span> &lt;a&gt;value for a&lt;/a&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">a</span><span class="MetaTagAll">&gt;</span></span>value for a<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">a</span><span class="MetaTagAll">&gt;</span></span> &lt;b&gt;value for b&lt;/b&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">b</span><span class="MetaTagAll">&gt;</span></span>value for b<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">b</span><span class="MetaTagAll">&gt;</span></span> &lt;/x&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">x</span><span class="MetaTagAll">&gt;</span></span> &lt;y&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">y</span><span class="MetaTagAll">&gt;</span></span> &lt;c&gt;value for c&lt;/c&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">c</span><span class="MetaTagAll">&gt;</span></span>value for c<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">c</span><span class="MetaTagAll">&gt;</span></span> &lt;/y&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">y</span><span class="MetaTagAll">&gt;</span></span> &lt;/r&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">r</span><span class="MetaTagAll">&gt;</span></span> </code></pre>
</pre>
<p>Then deleting all <code>x</code> nodes is equivalent to pass the <span class="sc">xml</span> via the following search and replace script:</p> <p>Then deleting all <code>x</code> nodes is equivalent to pass the <span class="sc">xml</span> via the following search and replace script:</p>
<pre class="twilight"> <pre><code class="perl">s/&lt;\/?x&gt;//g
<span class="StringRegexp"><span class="StringRegexp"><span class="SupportFunction">s</span>/</span>&lt;<span class="StringRegexpSpecial">\/</span>?x&gt;</span><span class="StringRegexp"><span class="StringRegexp">/</span><span class="StringRegexp">/</span></span><span class="StringRegexp"><span class="StringRegexp"><span class="Keyword">g</span></span></span> </code></pre>
</pre>
<p>Therefore, if there exists a one state deterministic transducer which transform my trees&nbsp;; <p>Therefore, if there exists a one state deterministic transducer which transform my trees&nbsp;;
I can transform the <span class="sc">xml</span> from one format to another with just a simple list of search and replace directives.</p> I can transform the <span class="sc">xml</span> from one format to another with just a simple list of search and replace directives.</p>
@ -307,28 +306,26 @@ M - V - M - V - tag2 tag1
<p>can be done using the following one state deterministic tree transducer:</p> <p>can be done using the following one state deterministic tree transducer:</p>
<blockquote> <blockquote>
<p>C &rarr; &epsilon;<br /> <p>C &rarr; ε<br />
E &rarr; M<br /> E &rarr; M<br />
R &rarr; V </p> R &rarr; V </p>
</blockquote> </blockquote>
<p>Wich can be traduced by the following simple search and replace directives: </p> <p>Wich can be traduced by the following simple search and replace directives: </p>
<pre class="twilight"> <pre><code class="perl">s/C//g
<span class="StringRegexp"><span class="StringRegexp"><span class="SupportFunction">s</span>/</span>C</span><span class="StringRegexp"><span class="StringRegexp">/</span><span class="StringRegexp">/</span></span><span class="StringRegexp"><span class="StringRegexp"><span class="Keyword">g</span></span></span> s/E/M/g
<span class="StringRegexp"><span class="StringRegexp"><span class="SupportFunction">s</span>/</span>E</span><span class="StringRegexp"><span class="StringRegexp">/</span>M<span class="StringRegexp">/</span></span><span class="StringRegexp"><span class="StringRegexp"><span class="Keyword">g</span></span></span> s/R/V/g
<span class="StringRegexp"><span class="StringRegexp"><span class="SupportFunction">s</span>/</span>R</span><span class="StringRegexp"><span class="StringRegexp">/</span>V<span class="StringRegexp">/</span></span><span class="StringRegexp"><span class="StringRegexp"><span class="Keyword">g</span></span></span> </code></pre>
</pre>
<p>Once adapted to <span class="sc">xml</span> it becomes:</p> <p>Once adapted to <span class="sc">xml</span> it becomes:</p>
<pre class="twilight"> <pre><code class="perl">s%&lt;/?contenu&gt;%%g
<span class="StringRegexp"><span class="StringRegexp"><span class="SupportFunction">s</span>%</span>&lt;/?contenu&gt;</span><span class="StringRegexp"><span class="StringRegexp">%</span><span class="StringRegexp">%</span></span><span class="StringRegexp"><span class="StringRegexp"><span class="Keyword">g</span></span></span> s%&lt;enfant&gt;%&lt;item name="menu"&gt;%g
<span class="StringRegexp"><span class="StringRegexp"><span class="SupportFunction">s</span>%</span>&lt;enfant&gt;</span><span class="StringRegexp"><span class="StringRegexp">%</span>&lt;item name=&quot;menu&quot;&gt;<span class="StringRegexp">%</span></span><span class="StringRegexp"><span class="StringRegexp"><span class="Keyword">g</span></span></span> s%&lt;/enfant&gt;%&lt;/item&gt;%g
<span class="StringRegexp"><span class="StringRegexp"><span class="SupportFunction">s</span>%</span>&lt;/enfant&gt;</span><span class="StringRegexp"><span class="StringRegexp">%</span>&lt;/item&gt;<span class="StringRegexp">%</span></span><span class="StringRegexp"><span class="StringRegexp"><span class="Keyword">g</span></span></span> s%&lt;rubrique&gt;%&lt;value&gt;%g
<span class="StringRegexp"><span class="StringRegexp"><span class="SupportFunction">s</span>%</span>&lt;rubrique&gt;</span><span class="StringRegexp"><span class="StringRegexp">%</span>&lt;value&gt;<span class="StringRegexp">%</span></span><span class="StringRegexp"><span class="StringRegexp"><span class="Keyword">g</span></span></span> s%&lt;/rubrique&gt;%&lt;/value&gt;%g
<span class="StringRegexp"><span class="StringRegexp"><span class="SupportFunction">s</span>%</span>&lt;/rubrique&gt;</span><span class="StringRegexp"><span class="StringRegexp">%</span>&lt;/value&gt;<span class="StringRegexp">%</span></span><span class="StringRegexp"><span class="StringRegexp"><span class="Keyword">g</span></span></span> </code></pre>
</pre>
<p>That is all.</p> <p>That is all.</p>

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="choix liés à l'écriture dans plusieurs langues" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-06-14-multi-language-choices/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="choix liés à l'écriture dans plusieurs langues" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-06-14-multi-language-choices/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -73,7 +76,7 @@ here is an example of english text.
<p>This way of handling translations force you to write completely an article in one language, copy it, and translate it.</p> <p>This way of handling translations force you to write completely an article in one language, copy it, and translate it.</p>
<p>However, most of time, there are common parts like images, source code, etc&hellip; <p>However, most of time, there are common parts like images, source code, etc
When I want to correct some mistake on these parts, I have to make twice the work. With sometimes adding another mistake in only one language.</p> When I want to correct some mistake on these parts, I have to make twice the work. With sometimes adding another mistake in only one language.</p>
<p>This is why I preferred to handle it differently. <p>This is why I preferred to handle it differently.
@ -89,7 +92,7 @@ Finally my files looks like:</p>
[image](url) [image](url)
</pre> </pre>
<p>As I edit my files with <a href="http://vim.org">vim</a>, it is really easy to add <code>fr:</code> or <code>en:</code> at some line&rsquo;s beginning using the useful <code>C-v</code>. <p>As I edit my files with <a href="http://vim.org">vim</a>, it is really easy to add <code>fr:</code> or <code>en:</code> at some lines beginning using the useful <code>C-v</code>.
However <a href="http://nanoc.stoneship.org">nanoc</a> was conceived to be used for one language only. Or to be used with the first method. I tried to adapt nanoc to my usage. But after a while, I found it easier to pre-filter the nanoc work by a simple script. My script transform my file into two new files. And all work like a charm.</p> However <a href="http://nanoc.stoneship.org">nanoc</a> was conceived to be used for one language only. Or to be used with the first method. I tried to adapt nanoc to my usage. But after a while, I found it easier to pre-filter the nanoc work by a simple script. My script transform my file into two new files. And all work like a charm.</p>
<p>You can get my blog code source (without most of articles) at <a href="http://github.com/yogsototh/Scratch">github.com/yogsototh/Scratch</a>.</p> <p>You can get my blog code source (without most of articles) at <a href="http://github.com/yogsototh/Scratch">github.com/yogsototh/Scratch</a>.</p>

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Récupérez mon système de blog" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-06-15-Get-my-blog-engine/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Récupérez mon système de blog" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-06-15-Get-my-blog-engine/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -66,7 +69,7 @@ You can get it on <a href="http://github.com/yogsototh/nanoc3_blog">github.com</
<li><a href="http://intensedebate.org">intenseDebate</a> comments integration (asynchronous)&nbsp;;</li> <li><a href="http://intensedebate.org">intenseDebate</a> comments integration (asynchronous)&nbsp;;</li>
<li>Portable with and without javascript, XHTML Strict 1.0 / CSS3,</li> <li>Portable with and without javascript, XHTML Strict 1.0 / CSS3,</li>
<li>Write in markdown format (no HTML editing needed),</li> <li>Write in markdown format (no HTML editing needed),</li>
<li>Typographic ameliorations (no &lsquo;:&rsquo; starting a line in French for example),</li> <li>Typographic ameliorations (no : starting a line in French for example),</li>
<li><a href="http://graphviz.org">Graphviz</a> graph generation integration.</li> <li><a href="http://graphviz.org">Graphviz</a> graph generation integration.</li>
</ul> </ul>
@ -82,12 +85,11 @@ You can get it on <a href="http://github.com/yogsototh/nanoc3_blog">github.com</
<p>Once installed (follow the README.md instructions).</p> <p>Once installed (follow the README.md instructions).</p>
<pre class="twilight"> <pre><code class="zsh">$ cd /root/of/nanoc3_blog
$ cd /root/of/nanoc3_blog
$ ./task/new_blog_entry Title of the blog $ ./task/new_blog_entry Title of the blog
$ vi latest.md $ vi latest.md
$ ./task/recompile $ ./task/recompile
</pre> </code></pre>
<p>Now your website reside into the <code>output</code> directory.</p> <p>Now your website reside into the <code>output</code> directory.</p>
@ -104,9 +106,9 @@ $ ./task/recompile
<h3 id="multi-language">Multi-language</h3> <h3 id="multi-language">Multi-language</h3>
<p>All files in <code>multi</code> are processed and copied in the <code>content</code> directory. <p>All files in <code>multi</code> are processed and copied in the <code>content</code> directory.
For each file in multi, each line starting by &lsquo;<code>fr: </code>&rsquo; are copied (without the <code>fr: </code> into the <code>content/html/fr/</code> tree, but not into the <code>content/html/en</code> tree. File not starting by <code>fr: </code> or <code>en: </code> are copied in each destinations.</p> For each file in multi, each line starting by <code>fr: </code> are copied (without the <code>fr: </code> into the <code>content/html/fr/</code> tree, but not into the <code>content/html/en</code> tree. File not starting by <code>fr: </code> or <code>en: </code> are copied in each destinations.</p>
<p>If you want to add another language, you&rsquo;ll have to modify <code>tasks/config</code>, and <code>config.yaml</code>, create a <code>content/html/xx</code> where <code>xx</code> is the language code.</p> <p>If you want to add another language, youll have to modify <code>tasks/config</code>, and <code>config.yaml</code>, create a <code>content/html/xx</code> where <code>xx</code> is the language code.</p>
<h3 id="edition--rendering">Edition &amp; Rendering</h3> <h3 id="edition--rendering">Edition &amp; Rendering</h3>
@ -120,7 +122,7 @@ For each file in multi, each line starting by &lsquo;<code>fr: </code>&rsquo; ar
<h4 id="typography">Typography</h4> <h4 id="typography">Typography</h4>
<p>In French all &lsquo;:&rsquo;, &lsquo;;&rsquo;, &lsquo;!&rsquo; and &lsquo;?&rsquo; are preceded automatically by <code>&amp;nbsp</code>. This enable not to have a line starting by a single special character.</p> <p>In French all :, ;, ! and ? are preceded automatically by <code>&amp;nbsp</code>. This enable not to have a line starting by a single special character.</p>
<p>You can use small caps using <code>&lt;sc&gt;</code> tags. </p> <p>You can use small caps using <code>&lt;sc&gt;</code> tags. </p>
@ -135,11 +137,10 @@ For each file in multi, each line starting by &lsquo;<code>fr: </code>&rsquo; ar
<p>To write source code you should use the following format:</p> <p>To write source code you should use the following format:</p>
<pre class="twilight"> <pre><code class="html">&lt;code class="ruby" file="filename.rb"&gt;
<span class="MetaTagInline"><span class="MetaTagInline">&lt;</span><span class="MetaTagInline">code</span> <span class="MetaTagInline">class</span>=<span class="String"><span class="String">&quot;</span>ruby<span class="String">&quot;</span></span> <span class="MetaTagInline">file</span>=<span class="String"><span class="String">&quot;</span>filename.rb<span class="String">&quot;</span></span><span class="MetaTagInline">&gt;</span></span>
The code The code
<span class="MetaTagInline"><span class="MetaTagInline">&lt;/</span><span class="MetaTagInline">cOde</span><span class="MetaTagInline">&gt;</span></span> &lt;/cOde&gt;
</pre> </code></pre>
<p>The <code>file</code> attribute is not required.</p> <p>The <code>file</code> attribute is not required.</p>

View file

@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

View file

@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Se cacher de ses statistiques web" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-06-17-hide-yourself-to-analytics/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Se cacher de ses statistiques web" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-06-17-hide-yourself-to-analytics/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -61,68 +64,65 @@ First you should look on how <a href="/Scratch/en/blog/2010-06-17-track-events-w
<p>I check if the key <code>admin</code> is not set in the cookie before adding the visit.</p> <p>I check if the key <code>admin</code> is not set in the cookie before adding the visit.</p>
<pre class="twilight"> <pre><code class="javascript"> var admin = $.cookie('admin');
<span class="Storage">var</span> admin <span class="Keyword">=</span> <span class="Keyword">$</span>.<span class="SupportConstant">cookie</span>(<span class="String"><span class="String">'</span>admin<span class="String">'</span></span>); if (! admin) {
<span class="Keyword">if</span> (<span class="Keyword">!</span> admin) { // put your analytics code here
<span class="Comment"><span class="Comment">//</span> put your analytics code here</span> } else {
} <span class="Keyword">else</span> { console.log("[WARNING] you're HIDDEN to analytics");
<span class="Entity">console</span><span class="SupportFunction">.log</span>(<span class="String"><span class="String">&quot;</span>[WARNING] you're HIDDEN to analytics<span class="String">&quot;</span></span>);
} }
</pre> </code></pre>
<p>then create two <span class="sc">html</span> files. One to hide:</p> <p>then create two <span class="sc">html</span> files. One to hide:</p>
<div class="code"><div class="file"><a href="/Scratch/en/blog/2010-06-17-hide-yourself-to-analytics/code/become_hidden.html"> &#x27A5; become_hidden.html </a></div><div class="withfile"> <div class="codefile"><a href="/Scratch/en/blog/2010-06-17-hide-yourself-to-analytics/code/become_hidden.html">&#x27A5; become_hidden.html</a></div>
<pre class="twilight">
<span class="DoctypeXmlProcessing"><span class="DoctypeXmlProcessing">&lt;?</span><span class="DoctypeXmlProcessing">xml</span> <span class="DoctypeXmlProcessing">version</span>=<span class="DoctypeXmlProcessing"><span class="DoctypeXmlProcessing">&quot;</span>1.0<span class="DoctypeXmlProcessing">&quot;</span></span> <span class="DoctypeXmlProcessing">encoding</span>=<span class="DoctypeXmlProcessing"><span class="DoctypeXmlProcessing">&quot;</span>utf-8<span class="DoctypeXmlProcessing">&quot;</span></span><span class="DoctypeXmlProcessing">?&gt;</span></span> <pre><code class="html">&lt;?xml version="1.0" encoding="utf-8"?&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;!</span><span class="DoctypeXmlProcessing"><span class="DoctypeXmlProcessing">DOCTYPE</span> html PUBLIC <span class="DoctypeXmlProcessing">&quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;</span></span></span> &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<span class="MetaTagAll"><span class="DoctypeXmlProcessing"> <span class="DoctypeXmlProcessing">&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;</span></span><span class="MetaTagAll">&gt;</span></span> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">html</span> <span class="MetaTagAll">xmlns</span>=<span class="String"><span class="String">&quot;</span>http://www.w3.org/1999/xhtml<span class="String">&quot;</span></span> <span class="MetaTagAll">lang</span>=<span class="String"><span class="String">&quot;</span>fr<span class="String">&quot;</span></span> <span class="MetaTagAll">xml:lang</span>=<span class="String"><span class="String">&quot;</span>fr<span class="String">&quot;</span></span><span class="MetaTagAll">&gt;</span></span> &lt;html xmlns="http://www.w3.org/1999/xhtml" lang="fr" xml:lang="fr"&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">head</span><span class="MetaTagAll">&gt;</span></span> &lt;head&gt;
<span class="MetaTagInline"><span class="MetaTagInline">&lt;</span><span class="MetaTagInline">meta</span> <span class="MetaTagInline">http-equiv</span>=<span class="String"><span class="String">&quot;</span>Content-Type<span class="String">&quot;</span></span> <span class="MetaTagInline">content</span>=<span class="String"><span class="String">&quot;</span>text/html; charset=UTF-8<span class="String">&quot;</span></span> /<span class="MetaTagInline">&gt;</span></span> &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
<span class="EmbeddedSource"> <span class="EmbeddedSource">&lt;</span><span class="MetaTagInline">script</span> <span class="MetaTagInline">type</span>=<span class="String"><span class="String">&quot;</span>text/javascript<span class="String">&quot;</span></span> <span class="MetaTagInline">src</span>=<span class="String"><span class="String">&quot;</span>jquery.js<span class="String">&quot;</span></span><span class="EmbeddedSource">&gt;</span><span class="EmbeddedSource">&lt;/</span><span class="MetaTagInline">script</span><span class="EmbeddedSource">&gt;</span></span> &lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt;
<span class="EmbeddedSource"> <span class="EmbeddedSource">&lt;</span><span class="MetaTagInline">script</span> <span class="MetaTagInline">type</span>=<span class="String"><span class="String">&quot;</span>text/javascript<span class="String">&quot;</span></span> <span class="MetaTagInline">src</span>=<span class="String"><span class="String">&quot;</span>jquery.cookie.js<span class="String">&quot;</span></span><span class="EmbeddedSource">&gt;</span><span class="EmbeddedSource">&lt;/</span><span class="MetaTagInline">script</span><span class="EmbeddedSource">&gt;</span></span> &lt;script type="text/javascript" src="jquery.cookie.js"&gt;&lt;/script&gt;
<span class="EmbeddedSource"> <span class="EmbeddedSource">&lt;</span><span class="MetaTagInline">script</span><span class="EmbeddedSource">&gt;</span></span> &lt;script&gt;
<span class="EmbeddedSource"> <span class="Keyword">$</span><span class="EmbeddedSource">(</span><span class="Support">document</span><span class="EmbeddedSource">)</span><span class="EmbeddedSource">.</span>ready<span class="EmbeddedSource">(</span><span class="Storage">function</span><span class="EmbeddedSource">(</span><span class="EmbeddedSource">)</span><span class="EmbeddedSource">{</span></span> $(document).ready(function(){
<span class="EmbeddedSource"> <span class="Keyword">$</span><span class="EmbeddedSource">.</span><span class="SupportConstant">cookie</span><span class="EmbeddedSource">(</span><span class="String"><span class="String">'</span>admin<span class="String">'</span></span><span class="EmbeddedSource">,</span><span class="Constant">1</span><span class="EmbeddedSource">)</span><span class="EmbeddedSource">;</span></span> $.cookie('admin',1);
<span class="EmbeddedSource"> <span class="Keyword">$</span><span class="EmbeddedSource">(</span><span class="String"><span class="String">'</span>#info<span class="String">'</span></span><span class="EmbeddedSource">)</span><span class="EmbeddedSource">.</span>html<span class="EmbeddedSource">(</span><span class="String"><span class="String">'</span>Analytics can no more see you.<span class="String">'</span></span><span class="EmbeddedSource">)</span></span> $('#info').html('Analytics can no more see you.')
<span class="EmbeddedSource"> <span class="EmbeddedSource">}</span><span class="EmbeddedSource">)</span><span class="EmbeddedSource">;</span></span> });
<span class="EmbeddedSource"> <span class="EmbeddedSource">&lt;/</span><span class="MetaTagInline">script</span><span class="EmbeddedSource">&gt;</span></span> &lt;/script&gt;
<span class="MetaTagInline"><span class="MetaTagInline">&lt;</span><span class="MetaTagInline">title</span><span class="MetaTagInline">&gt;</span></span>Hide to analytics<span class="MetaTagInline"><span class="MetaTagInline">&lt;/</span><span class="MetaTagInline">title</span><span class="MetaTagInline">&gt;</span></span> &lt;title&gt;Hide to analytics&lt;/title&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">head</span><span class="MetaTagAll">&gt;</span></span> &lt;/head&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">body</span><span class="MetaTagAll">&gt;</span></span> &lt;body&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">div</span> <span class="MetaTagAll"><span class="MetaTagAll">id</span><span class="MetaTagAll">=</span><span class="String"><span class="String">&quot;</span><span class="String">info</span><span class="String">&quot;</span></span></span><span class="MetaTagAll">&gt;<span class="MetaTagAll">&lt;</span>/</span><span class="MetaTagAll">div</span><span class="MetaTagAll">&gt;</span></span> &lt;div id="info"&gt;&lt;/div&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">body</span><span class="MetaTagAll">&gt;</span></span> &lt;/body&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">html</span><span class="MetaTagAll">&gt;</span></span> &lt;/html&gt;
</pre> </code></pre>
</div></div>
<p>the other to be visible again (it can be useful):</p> <p>the other to be visible again (it can be useful):</p>
<div class="code"><div class="file"><a href="/Scratch/en/blog/2010-06-17-hide-yourself-to-analytics/code/become_visible.html"> &#x27A5; become_visible.html </a></div><div class="withfile"> <div class="codefile"><a href="/Scratch/en/blog/2010-06-17-hide-yourself-to-analytics/code/become_visible.html">&#x27A5; become_visible.html</a></div>
<pre class="twilight">
<span class="DoctypeXmlProcessing"><span class="DoctypeXmlProcessing">&lt;?</span><span class="DoctypeXmlProcessing">xml</span> <span class="DoctypeXmlProcessing">version</span>=<span class="DoctypeXmlProcessing"><span class="DoctypeXmlProcessing">&quot;</span>1.0<span class="DoctypeXmlProcessing">&quot;</span></span> <span class="DoctypeXmlProcessing">encoding</span>=<span class="DoctypeXmlProcessing"><span class="DoctypeXmlProcessing">&quot;</span>utf-8<span class="DoctypeXmlProcessing">&quot;</span></span><span class="DoctypeXmlProcessing">?&gt;</span></span> <pre><code class="html">&lt;?xml version="1.0" encoding="utf-8"?&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;!</span><span class="DoctypeXmlProcessing"><span class="DoctypeXmlProcessing">DOCTYPE</span> html PUBLIC <span class="DoctypeXmlProcessing">&quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;</span></span></span> &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<span class="MetaTagAll"><span class="DoctypeXmlProcessing"> <span class="DoctypeXmlProcessing">&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;</span></span><span class="MetaTagAll">&gt;</span></span> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">html</span> <span class="MetaTagAll">xmlns</span>=<span class="String"><span class="String">&quot;</span>http://www.w3.org/1999/xhtml<span class="String">&quot;</span></span> <span class="MetaTagAll">lang</span>=<span class="String"><span class="String">&quot;</span>fr<span class="String">&quot;</span></span> <span class="MetaTagAll">xml:lang</span>=<span class="String"><span class="String">&quot;</span>fr<span class="String">&quot;</span></span><span class="MetaTagAll">&gt;</span></span> &lt;html xmlns="http://www.w3.org/1999/xhtml" lang="fr" xml:lang="fr"&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">head</span><span class="MetaTagAll">&gt;</span></span> &lt;head&gt;
<span class="MetaTagInline"><span class="MetaTagInline">&lt;</span><span class="MetaTagInline">meta</span> <span class="MetaTagInline">http-equiv</span>=<span class="String"><span class="String">&quot;</span>Content-Type<span class="String">&quot;</span></span> <span class="MetaTagInline">content</span>=<span class="String"><span class="String">&quot;</span>text/html; charset=UTF-8<span class="String">&quot;</span></span> /<span class="MetaTagInline">&gt;</span></span> &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
<span class="EmbeddedSource"> <span class="EmbeddedSource">&lt;</span><span class="MetaTagInline">script</span> <span class="MetaTagInline">type</span>=<span class="String"><span class="String">&quot;</span>text/javascript<span class="String">&quot;</span></span> <span class="MetaTagInline">src</span>=<span class="String"><span class="String">&quot;</span>jquery.js<span class="String">&quot;</span></span><span class="EmbeddedSource">&gt;</span><span class="EmbeddedSource">&lt;/</span><span class="MetaTagInline">script</span><span class="EmbeddedSource">&gt;</span></span> &lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt;
<span class="EmbeddedSource"> <span class="EmbeddedSource">&lt;</span><span class="MetaTagInline">script</span> <span class="MetaTagInline">type</span>=<span class="String"><span class="String">&quot;</span>text/javascript<span class="String">&quot;</span></span> <span class="MetaTagInline">src</span>=<span class="String"><span class="String">&quot;</span>jquery.cookie.js<span class="String">&quot;</span></span><span class="EmbeddedSource">&gt;</span><span class="EmbeddedSource">&lt;/</span><span class="MetaTagInline">script</span><span class="EmbeddedSource">&gt;</span></span> &lt;script type="text/javascript" src="jquery.cookie.js"&gt;&lt;/script&gt;
<span class="EmbeddedSource"> <span class="EmbeddedSource">&lt;</span><span class="MetaTagInline">script</span><span class="EmbeddedSource">&gt;</span></span> &lt;script&gt;
<span class="EmbeddedSource"> <span class="Keyword">$</span><span class="EmbeddedSource">(</span><span class="Support">document</span><span class="EmbeddedSource">)</span><span class="EmbeddedSource">.</span>ready<span class="EmbeddedSource">(</span><span class="Storage">function</span><span class="EmbeddedSource">(</span><span class="EmbeddedSource">)</span><span class="EmbeddedSource">{</span></span> $(document).ready(function(){
<span class="EmbeddedSource"> <span class="Keyword">$</span><span class="EmbeddedSource">.</span><span class="SupportConstant">cookie</span><span class="EmbeddedSource">(</span><span class="String"><span class="String">'</span>admin<span class="String">'</span></span><span class="EmbeddedSource">,</span><span class="Constant">null</span><span class="EmbeddedSource">)</span><span class="EmbeddedSource">;</span></span> $.cookie('admin',null);
<span class="EmbeddedSource"> <span class="Keyword">$</span><span class="EmbeddedSource">(</span><span class="String"><span class="String">'</span>#info<span class="String">'</span></span><span class="EmbeddedSource">)</span><span class="EmbeddedSource">.</span>html<span class="EmbeddedSource">(</span><span class="String"><span class="String">'</span>Analytics can see you.<span class="String">'</span></span><span class="EmbeddedSource">)</span></span> $('#info').html('Analytics can see you.')
<span class="EmbeddedSource"> <span class="EmbeddedSource">}</span><span class="EmbeddedSource">)</span><span class="EmbeddedSource">;</span></span> });
<span class="EmbeddedSource"> <span class="EmbeddedSource">&lt;/</span><span class="MetaTagInline">script</span><span class="EmbeddedSource">&gt;</span></span> &lt;/script&gt;
<span class="MetaTagInline"><span class="MetaTagInline">&lt;</span><span class="MetaTagInline">title</span><span class="MetaTagInline">&gt;</span></span>Hide to analytics<span class="MetaTagInline"><span class="MetaTagInline">&lt;/</span><span class="MetaTagInline">title</span><span class="MetaTagInline">&gt;</span></span> &lt;title&gt;Hide to analytics&lt;/title&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">head</span><span class="MetaTagAll">&gt;</span></span> &lt;/head&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">body</span><span class="MetaTagAll">&gt;</span></span> &lt;body&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;</span><span class="MetaTagAll">div</span> <span class="MetaTagAll"><span class="MetaTagAll">id</span><span class="MetaTagAll">=</span><span class="String"><span class="String">&quot;</span><span class="String">info</span><span class="String">&quot;</span></span></span><span class="MetaTagAll">&gt;<span class="MetaTagAll">&lt;</span>/</span><span class="MetaTagAll">div</span><span class="MetaTagAll">&gt;</span></span> &lt;div id="info"&gt;&lt;/div&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">body</span><span class="MetaTagAll">&gt;</span></span> &lt;/body&gt;
<span class="MetaTagAll"><span class="MetaTagAll">&lt;/</span><span class="MetaTagAll">html</span><span class="MetaTagAll">&gt;</span></span> &lt;/html&gt;
</pre> </code></pre>
</div></div>
<p>Now accessing these files with you browser you can <em>hide</em> or <em>appear</em> in your statistics. You just have to think to access these file from all you browser.</p> <p>Now accessing these files with you browser you can <em>hide</em> or <em>appear</em> in your statistics. You just have to think to access these file from all you browser.</p>

View file

@ -1,4 +1,3 @@
$(document).ready( function() { $(document).ready( function() {
// add an event to all link for google analytics // add an event to all link for google analytics
$('a').click(function () { $('a').click(function () {

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Analyser les clicks sur votre Site" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-06-17-track-events-with-google-analytics/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Analyser les clicks sur votre Site" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-06-17-track-events-with-google-analytics/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -62,64 +65,62 @@
<p>First in your <span class="sc">html</span> you need to use <a href="http://jquery.com">jQuery</a> and a javscript file I named <code>yga.js</code>:</p> <p>First in your <span class="sc">html</span> you need to use <a href="http://jquery.com">jQuery</a> and a javscript file I named <code>yga.js</code>:</p>
<pre class="twilight"> <pre><code class="html"> &lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt;
<span class="EmbeddedSource"> <span class="EmbeddedSource">&lt;</span><span class="MetaTagInline">script</span> <span class="MetaTagInline">type</span>=<span class="String"><span class="String">&quot;</span>text/javascript<span class="String">&quot;</span></span> <span class="MetaTagInline">src</span>=<span class="String"><span class="String">&quot;</span>jquery.js<span class="String">&quot;</span></span><span class="EmbeddedSource">&gt;</span><span class="EmbeddedSource">&lt;/</span><span class="MetaTagInline">script</span><span class="EmbeddedSource">&gt;</span></span> &lt;script type="text/javascript" src="yga.js"&gt;&lt;/script&gt;
<span class="EmbeddedSource"> <span class="EmbeddedSource">&lt;</span><span class="MetaTagInline">script</span> <span class="MetaTagInline">type</span>=<span class="String"><span class="String">&quot;</span>text/javascript<span class="String">&quot;</span></span> <span class="MetaTagInline">src</span>=<span class="String"><span class="String">&quot;</span>yga.js<span class="String">&quot;</span></span><span class="EmbeddedSource">&gt;</span><span class="EmbeddedSource">&lt;/</span><span class="MetaTagInline">script</span><span class="EmbeddedSource">&gt;</span></span> </code></pre>
</pre>
<p>And here is the <code>yga.js</code> file:</p> <p>And here is the <code>yga.js</code> file:</p>
<div class="code"><div class="file"><a href="/Scratch/en/blog/2010-06-17-track-events-with-google-analytics/code/yga.js"> &#x27A5; yga.js </a></div><div class="withfile"> <div class="codefile"><a href="/Scratch/en/blog/2010-06-17-track-events-with-google-analytics/code/yga.js">&#x27A5; yga.js</a></div>
<pre class="twilight">
<span class="Keyword">$</span>(<span class="Support">document</span>).ready( <span class="Storage">function</span>() { <pre><code class="javascript">$(document).ready( function() {
<span class="Comment"><span class="Comment">//</span> add an event to all link for google analytics</span> // add an event to all link for google analytics
<span class="Keyword">$</span>(<span class="String"><span class="String">'</span>a<span class="String">'</span></span>).<span class="SupportFunction">click</span>(<span class="Storage">function</span> () { $('a').click(function () {
<span class="Comment"><span class="Comment">//</span> tell analytics to save event</span> // tell analytics to save event
<span class="Keyword">try</span> { try {
<span class="Storage">var</span> identifier<span class="Keyword">=</span><span class="Keyword">$</span>(<span class="Variable">this</span>).attr(<span class="String"><span class="String">'</span>id<span class="String">'</span></span>) ; var identifier=$(this).attr('id') ;
<span class="Storage">var</span> href<span class="Keyword">=</span><span class="Keyword">$</span>(<span class="Variable">this</span>).attr(<span class="String"><span class="String">'</span>href<span class="String">'</span></span>) var href=$(this).attr('href')
<span class="Storage">var</span> label<span class="Keyword">=</span><span class="String"><span class="String">&quot;</span><span class="String">&quot;</span></span>; var label="";
<span class="Keyword">if</span> ( <span class="Keyword">typeof</span>( identifier ) <span class="Keyword">!</span><span class="Keyword">=</span> <span class="String"><span class="String">'</span>undefined<span class="String">'</span></span> ) { if ( typeof( identifier ) != 'undefined' ) {
label<span class="Keyword">=</span>label<span class="Keyword">+</span><span class="String"><span class="String">'</span>[id]:<span class="String">'</span></span><span class="Keyword">+</span>identifier label=label+'[id]:'+identifier
category<span class="Keyword">=</span><span class="String"><span class="String">'</span>JSLink<span class="String">'</span></span> category='JSLink'
} }
<span class="Keyword">if</span> ( <span class="Keyword">typeof</span>( href ) <span class="Keyword">!</span><span class="Keyword">=</span> <span class="String"><span class="String">'</span>undefined<span class="String">'</span></span> ) { if ( typeof( href ) != 'undefined' ) {
label<span class="Keyword">=</span>label<span class="Keyword">+</span><span class="String"><span class="String">'</span> [href]:<span class="String">'</span></span><span class="Keyword">+</span>href label=label+' [href]:'+href
<span class="Keyword">if</span> ( href[<span class="Constant">0</span>] <span class="Keyword">==</span> <span class="String"><span class="String">'</span>#<span class="String">'</span></span> ) { if ( href[0] == '#' ) {
category<span class="Keyword">=</span><span class="String"><span class="String">'</span>Anchor<span class="String">'</span></span>; category='Anchor';
} <span class="Keyword">else</span> { } else {
category<span class="Keyword">=</span><span class="String"><span class="String">'</span>Link<span class="String">'</span></span>; category='Link';
} }
} }
_gaq.<span class="SupportFunction">push</span>([<span class="String"><span class="String">'</span>_trackEvent<span class="String">'</span></span>, category, <span class="String"><span class="String">'</span>clicked<span class="String">'</span></span>, label]); _gaq.push(['_trackEvent', category, 'clicked', label]);
<span class="Comment"><span class="Comment">//</span> console.log('[tracked]: ' + category + ' ; clicked ; ' + label );</span> // console.log('[tracked]: ' + category + ' ; clicked ; ' + label );
} }
<span class="Keyword">catch</span> (err) { catch (err) {
<span class="Entity">console</span><span class="SupportFunction">.log</span>(err); console.log(err);
} }
<span class="Comment"><span class="Comment">//</span> pause to allow google script to run</span> // pause to allow google script to run
<span class="Storage">var</span> date <span class="Keyword">=</span> <span class="Keyword">new</span> <span class="Entity">Date</span>(); var date = new Date();
<span class="Storage">var</span> curDate <span class="Keyword">=</span> <span class="Constant">null</span>; var curDate = null;
<span class="Keyword">do</span> { do {
curDate <span class="Keyword">=</span> <span class="Keyword">new</span> <span class="Entity">Date</span>(); curDate = new Date();
} <span class="Keyword">while</span>(curDate<span class="Keyword">-</span>date <span class="Keyword">&lt;</span> <span class="Constant">300</span>); } while(curDate-date &lt; 300);
}); });
}); });
<span class="Storage">var</span> _gaq <span class="Keyword">=</span> _gaq <span class="Keyword">||</span> []; var _gaq = _gaq || [];
_gaq.<span class="SupportFunction">push</span>([<span class="String"><span class="String">'</span>_setAccount<span class="String">'</span></span>, <span class="String"><span class="String">'</span>UA-XXXXXXXX-1<span class="String">'</span></span>]); _gaq.push(['_setAccount', 'UA-XXXXXXXX-1']);
_gaq.<span class="SupportFunction">push</span>([<span class="String"><span class="String">'</span>_trackPageview<span class="String">'</span></span>]); _gaq.push(['_trackPageview']);
(<span class="Storage">function</span>() { (function() {
<span class="Storage">var</span> ga <span class="Keyword">=</span> <span class="Support">document</span>.<span class="SupportFunction">createElement</span>(<span class="String"><span class="String">'</span>script<span class="String">'</span></span>); ga.<span class="SupportConstant">type</span> <span class="Keyword">=</span> <span class="String"><span class="String">'</span>text/javascript<span class="String">'</span></span>; ga.async <span class="Keyword">=</span> <span class="Constant">true</span>; var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.<span class="SupportConstant">src</span> <span class="Keyword">=</span> (<span class="String"><span class="String">'</span>https:<span class="String">'</span></span> <span class="Keyword">==</span> <span class="Support">document</span>.<span class="SupportConstant">location</span>.<span class="SupportConstant">protocol</span> ? <span class="String"><span class="String">'</span>https://ssl<span class="String">'</span></span> : <span class="String"><span class="String">'</span>http://www<span class="String">'</span></span>) <span class="Keyword">+</span> <span class="String"><span class="String">'</span>.google-analytics.com/ga.js<span class="String">'</span></span>; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
<span class="Storage">var</span> s <span class="Keyword">=</span> <span class="Support">document</span>.<span class="SupportFunction">getElementsByTagName</span>(<span class="String"><span class="String">'</span>script<span class="String">'</span></span>)[<span class="Constant">0</span>]; s.<span class="SupportConstant">parentNode</span>.<span class="SupportFunction">insertBefore</span>(ga, s); var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})(); })();
</pre> </code></pre>
</div></div>
<p>Replace the: <code>UA-XXXXXXXX-1</code> by your google analytics code and you&rsquo;re done.</p> <p>Replace the: <code>UA-XXXXXXXX-1</code> by your google analytics code and youre done.</p>
<p>To see what occurs, simply go in <code>Content</code> and <code>Event Tracking</code> as shown in the following screenshot:</p> <p>To see what occurs, simply go in <code>Content</code> and <code>Event Tracking</code> as shown in the following screenshot:</p>
@ -242,7 +243,7 @@ _gaq.<span class="SupportFunction">push</span>([<span class="String"><span class
</div> </div>
<div id="lastmod"> <div id="lastmod">
Created: 06/17/2010 Created: 06/17/2010
Modified: 06/17/2010 Modified: 04/26/2012
</div> </div>
<div> <div>
Entirely done with Entirely done with

View file

@ -1,4 +1,3 @@
// --- code popup --- // --- code popup ---
function openPopup() { function openPopup() {
$(this).clone(false).appendTo($("#_code")); $(this).clone(false).appendTo($("#_code"));

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Comment faire des popups en jQuery rapidement" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-06-19-jQuery-popup-the-easy-way/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Comment faire des popups en jQuery rapidement" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-06-19-jQuery-popup-the-easy-way/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -56,32 +59,31 @@
<div class="corps"> <div class="corps">
<p>Here is a fast and easy way to create jQuery popup.</p> <p>Here is a fast and easy way to create jQuery popup.</p>
<div class="code"><div class="file"><a href="/Scratch/en/blog/2010-06-19-jQuery-popup-the-easy-way/code/essai.js"> &#x27A5; essai.js </a></div><div class="withfile"> <div class="codefile"><a href="/Scratch/en/blog/2010-06-19-jQuery-popup-the-easy-way/code/essai.js">&#x27A5; essai.js</a></div>
<pre class="twilight">
<span class="Comment"><span class="Comment">//</span> --- code popup ---</span> <pre><code class="javascript">// --- code popup ---
<span class="Storage">function</span> <span class="Entity">openPopup</span>() { function openPopup() {
<span class="Keyword">$</span>(<span class="Variable">this</span>).clone(<span class="Constant">false</span>).appendTo(<span class="Keyword">$</span>(<span class="String"><span class="String">&quot;</span>#_code<span class="String">&quot;</span></span>)); $(this).clone(false).appendTo($("#_code"));
<span class="Keyword">$</span>(<span class="String"><span class="String">&quot;</span>#_code<span class="String">&quot;</span></span>).show(); $("#_code").show();
} }
<span class="Storage">function</span> <span class="Entity">closePopup</span>() { function closePopup() {
<span class="Keyword">$</span>(<span class="String"><span class="String">&quot;</span>#_code<span class="String">&quot;</span></span>).html(<span class="String"><span class="String">&quot;</span><span class="String">&quot;</span></span>); $("#_code").html("");
<span class="Keyword">$</span>(<span class="String"><span class="String">&quot;</span>#_code<span class="String">&quot;</span></span>).hide(); $("#_code").hide();
} }
<span class="Storage">function</span> <span class="Entity">initCode</span>() { function initCode() {
<span class="Keyword">$</span>(<span class="String"><span class="String">&quot;</span>.code<span class="String">&quot;</span></span>).<span class="SupportFunction">click</span>(openPopup); $(".code").click(openPopup);
<span class="Keyword">$</span>(<span class="String"><span class="String">&quot;</span>.code<span class="String">&quot;</span></span>).css({cursor: <span class="String"><span class="String">&quot;</span>pointer<span class="String">&quot;</span></span>}); $(".code").css({cursor: "pointer"});
<span class="Keyword">$</span>(<span class="String"><span class="String">'</span>body<span class="String">'</span></span>).append(<span class="String"><span class="String">'</span>&lt;div id=&quot;_code&quot;&gt;&lt;/div&gt;<span class="String">'</span></span>); $('body').append('&lt;div id="_code"&gt;&lt;/div&gt;');
<span class="Keyword">$</span>(<span class="String"><span class="String">'</span>#_code<span class="String">'</span></span>).css( { <span class="String"><span class="String">'</span>text-align<span class="String">'</span></span>: <span class="String"><span class="String">&quot;</span>justify<span class="String">&quot;</span></span>, position: <span class="String"><span class="String">&quot;</span>fixed<span class="String">&quot;</span></span>, $('#_code').css( { 'text-align': "justify", position: "fixed",
left:<span class="Constant">0</span>, top:<span class="Constant">0</span>, width: <span class="String"><span class="String">&quot;</span>100%<span class="String">&quot;</span></span>, height: <span class="String"><span class="String">&quot;</span>100%<span class="String">&quot;</span></span>, left:0, top:0, width: "100%", height: "100%",
<span class="String"><span class="String">&quot;</span>background-color<span class="String">&quot;</span></span>: <span class="String"><span class="String">&quot;</span>rgba(0, 0, 0, 0.8)<span class="String">&quot;</span></span>, <span class="String"><span class="String">'</span>z-index<span class="String">'</span></span>:<span class="Constant">2000</span>, <span class="String"><span class="String">'</span>padding<span class="String">'</span></span>:<span class="String"><span class="String">'</span>3px<span class="String">'</span></span>} ); "background-color": "rgba(0, 0, 0, 0.8)", 'z-index':2000, 'padding':'3px'} );
<span class="Keyword">$</span>(<span class="String"><span class="String">'</span>#_code<span class="String">'</span></span>).hide(); $('#_code').hide();
<span class="Keyword">$</span>(<span class="String"><span class="String">'</span>#_code<span class="String">'</span></span>).<span class="SupportFunction">click</span>(closePopup); $('#_code').click(closePopup);
} }
<span class="Comment"><span class="Comment">//</span> --- end of code popup section ---</span> // --- end of code popup section ---
</pre> </code></pre>
</div></div>
<p>What does this code do?</p> <p>What does this code do?</p>

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Cappuccino ou jQuery ?" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-07-05-Cappuccino-and-Web-applications/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Cappuccino ou jQuery ?" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-07-05-Cappuccino-and-Web-applications/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -64,7 +67,7 @@
<li>Tried to make <a href="http://yannesposito.com/Softwares/YPassword.html">YPassword</a> in jQuery and with Cappuccino.</li> <li>Tried to make <a href="http://yannesposito.com/Softwares/YPassword.html">YPassword</a> in jQuery and with Cappuccino.</li>
<li>Cappuccino nice in desktop browser but 1.4MB, not compatible with iPhone.</li> <li>Cappuccino nice in desktop browser but 1.4MB, not compatible with iPhone.</li>
<li>jQuery not as nice as the Cappuccino version but 106KB. iPhone compatible.</li> <li>jQuery not as nice as the Cappuccino version but 106KB. iPhone compatible.</li>
<li>I&rsquo;ll give a try to Dashcode 3.</li> <li>Ill give a try to Dashcode 3.</li>
</ul> </ul>
@ -97,7 +100,7 @@ I then made a second version with the <a href="http://cappuccino.org">Cappuccino
<div class="intro"> <div class="intro">
<p>If you don&rsquo;t mind about what does my widget and just want to know how the two frameworkcompare, you should go <p>If you dont mind about what does my widget and just want to know how the two frameworkcompare, you should go
directly to the <a href="#cappuccino">next part</a>.</p> directly to the <a href="#cappuccino">next part</a>.</p>
@ -105,9 +108,9 @@ directly to the <a href="#cappuccino">next part</a>.</p>
<p>I manage my password on many site with a simple method. <p>I manage my password on many site with a simple method.
I remember a strong master password. And my password is mainly I remember a strong master password. And my password is mainly</p>
&lt;pre class="twilight"&gt;<span class="Entity">hash</span>(masterPassword<span class="Keyword">+</span>domainName)
&lt;/pre&gt;</p> <pre><code class="ruby">hash(masterPassword+domainName)</code></pre>
<p>In reality I need a bit more informations to create a password:</p> <p>In reality I need a bit more informations to create a password:</p>
@ -121,14 +124,13 @@ I remember a strong master password. And my password is mainly
<p>The result password is this:</p> <p>The result password is this:</p>
<pre class="twilight"> <pre><code class="ruby">domainName=domaine_Name_Of_URL(url)
domainName<span class="Keyword">=</span><span class="Entity">domaine_Name_Of_URL</span>(url) hash=sha1( masterPassword + leakedTimes + domainName )
hash<span class="Keyword">=</span><span class="Entity">sha1</span>( masterPassword <span class="Keyword">+</span> leakedTimes <span class="Keyword">+</span> domainName ) if ( kind == 'base64' )
<span class="Keyword">if</span> ( kind <span class="Keyword">==</span> <span class="String"><span class="String">'</span>base64<span class="String">'</span></span> ) hash=base64(hash)
hash<span class="Keyword">=</span><span class="Entity">base64</span>(hash) end
<span class="Keyword">end</span> return hash[0..maxlength]
<span class="Keyword">return</span> hash[<span class="Constant">0</span>..maxlength] </code></pre>
</pre>
<p>In fact depending of websites, some give some strange constraint to your password: </p> <p>In fact depending of websites, some give some strange constraint to your password: </p>
@ -137,7 +139,7 @@ hash<span class="Keyword">=</span><span class="Entity">sha1</span>( masterPasswo
<li>maximal length,</li> <li>maximal length,</li>
<li>must not contain a special character, </li> <li>must not contain a special character, </li>
<li>must contain a special character, </li> <li>must contain a special character, </li>
<li>etc&hellip;</li> <li>etc</li>
</ul> </ul>
<p>And if you want to change your password the <em>leak number</em> is here for that. <p>And if you want to change your password the <em>leak number</em> is here for that.
@ -153,14 +155,14 @@ All informations such as user name, maximal length can be stored in a public fil
<h2 id="cappuccino">Cappuccino</h2> <h2 id="cappuccino">Cappuccino</h2>
<p>First, I&rsquo;d like to say Cappuccino applications look simply awesome. <p>First, Id like to say Cappuccino applications look simply awesome.
It is like having a Cocoa application in your web browser. It is like having a Cocoa application in your web browser.
And this is <em>great</em>.</p> And this is <em>great</em>.</p>
<p>I also must admit I enjoyed making my application with Cappuccino. <p>I also must admit I enjoyed making my application with Cappuccino.
It is like programming for an iPhone application. It is like programming for an iPhone application.
If you are a bit familiar with Cocoa, you feel at home. If you are a bit familiar with Cocoa, you feel at home.
If you don&rsquo;t know anything about Cocoa, I suggest you to look at it. If you dont know anything about Cocoa, I suggest you to look at it.
This is a really <em>great</em> framework to make User Interface. This is a really <em>great</em> framework to make User Interface.
I am not a specialist, but I have done some MFC, java Swing<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup> and WXWindows User Interfaces (some years ago). I am not a specialist, but I have done some MFC, java Swing<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup> and WXWindows User Interfaces (some years ago).
And I must say, Cocoa is far better than those.</p> And I must say, Cocoa is far better than those.</p>
@ -177,37 +179,37 @@ But there was also some drawbacks</p>
<li>I could have done the User Interface using <a href="http://developer.apple.com/technologies/tools/xcode.html">Interface Builder</a>.</li> <li>I could have done the User Interface using <a href="http://developer.apple.com/technologies/tools/xcode.html">Interface Builder</a>.</li>
</ul> </ul>
<p>Some things I didn&rsquo;t like:</p> <p>Some things I didnt like:</p>
<ul> <ul>
<li>I made some time to understand how to handle the <code>onChange</code> on the text fields.</li> <li>I made some time to understand how to handle the <code>onChange</code> on the text fields.</li>
<li>Documentation lacked a bit of organisation.</li> <li>Documentation lacked a bit of organisation.</li>
<li>It doesn&rsquo;t work on iPhone.</li> <li>It doesnt work on iPhone.</li>
<li>It weighted 11MB to deploy.</li> <li>It weighted 11MB to deploy.</li>
<li>It weight 1.3MB to load.</li> <li>It weight 1.3MB to load.</li>
</ul> </ul>
<p>I didn&rsquo;t use bindings because I believe they are not ready by now.</p> <p>I didnt use bindings because I believe they are not ready by now.</p>
<h2 id="jquery">jQuery</h2> <h2 id="jquery">jQuery</h2>
<p>The jQuery version of YPassword is not as finished as the Cappuccino one. Because, there is no <em>slider</em> directly with jQuery. I&rsquo;d have to use jQueryUI. And I believe, using it will make the application weight far more than the today 106KB.</p> <p>The jQuery version of YPassword is not as finished as the Cappuccino one. Because, there is no <em>slider</em> directly with jQuery. Id have to use jQueryUI. And I believe, using it will make the application weight far more than the today 106KB.</p>
<p>To make this version I simply copied my widget source code and adapted it. It was straightforward. But jQuery is not an <em>application oriented framework</em>. It is more a &ldquo;<em>dark side</em> javascript animation framework&rdquo;<sup id="fnref:2"><a href="#fn:2" rel="footnote">2</a></sup>.</p> <p>To make this version I simply copied my widget source code and adapted it. It was straightforward. But jQuery is not an <em>application oriented framework</em>. It is more a <em>dark side</em> javascript animation framework<sup id="fnref:2"><a href="#fn:2" rel="footnote">2</a></sup>.</p>
<p>I don&rsquo;t have too much to say about the jQuery version. But this was way more <em>low level</em> programming than Cappuccino.</p> <p>I dont have too much to say about the jQuery version. But this was way more <em>low level</em> programming than Cappuccino.</p>
<h2 id="my-conclusion">My conclusion</h2> <h2 id="my-conclusion">My conclusion</h2>
<p>If you want to make an iPhone compatible web application just don&rsquo;t use Cappuccino yet. <p>If you want to make an iPhone compatible web application just dont use Cappuccino yet.
If you want to make <em>simple</em> application like mine, I also believe, Cappuccino is a bit too much.</p> If you want to make <em>simple</em> application like mine, I also believe, Cappuccino is a bit too much.</p>
<p>If you want to make a complex web oriented application, Cappuccino is a great choice. <p>If you want to make a complex web oriented application, Cappuccino is a great choice.
But you may have some difficulties to begin programming with it.</p> But you may have some difficulties to begin programming with it.</p>
<p>Finally, to terminate my web version of my widget, I&rsquo;ll give a try to Dashcode 3. <p>Finally, to terminate my web version of my widget, Ill give a try to Dashcode 3.
It seems to be a good alternative to create web widgets. It seems to be a good alternative to create web widgets.
I don&rsquo;t know if Dashcode 3 is portable on non webkit browser. I dont know if Dashcode 3 is portable on non webkit browser.
But if it is, it could be the end of projects like Cappuccino and Sproutcore.</p> But if it is, it could be the end of projects like Cappuccino and Sproutcore.</p>
<hr/><div class="footnotes"> <hr/><div class="footnotes">
<ol> <ol>
@ -215,7 +217,7 @@ But if it is, it could be the end of projects like Cappuccino and Sproutcore.</p
<p>If you are interested you can take a look at <a href="http://labh-curien.univ-st-etienne.fr/informatique/SEDiL/">SEDiL</a>. I am proud of the tree drawing view made from scratch.<a href="#fnref:1" rel="reference">&#8617;</a></p> <p>If you are interested you can take a look at <a href="http://labh-curien.univ-st-etienne.fr/informatique/SEDiL/">SEDiL</a>. I am proud of the tree drawing view made from scratch.<a href="#fnref:1" rel="reference">&#8617;</a></p>
</li> </li>
<li id="fn:2"> <li id="fn:2">
<p>I don&rsquo;t want to feel like a <em>troll</em> I use jQuery to make some <em>dark side</em> animation on this blog. But the javascript on my blog is not needed except for commenting.<a href="#fnref:2" rel="reference">&#8617;</a></p> <p>I dont want to feel like a <em>troll</em> I use jQuery to make some <em>dark side</em> animation on this blog. But the javascript on my blog is not needed except for commenting.<a href="#fnref:2" rel="reference">&#8617;</a></p>
</li> </li>
</ol> </ol>
</div> </div>

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="N'utilisez pas de gradients avec Chrome" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-07-07-CSS-rendering-problems-by-navigator/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="N'utilisez pas de gradients avec Chrome" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-07-07-CSS-rendering-problems-by-navigator/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -55,7 +58,7 @@
<div id="afterheader"> <div id="afterheader">
<div class="corps"> <div class="corps">
<p>Some <a href="http://reddit.com">Reddit</a> users reported my website was really long to load and to scroll. <p>Some <a href="http://reddit.com">Reddit</a> users reported my website was really long to load and to scroll.
They thinks it was because of the &lsquo;1px shadow&rsquo; I apply on all the text. They thinks it was because of the 1px shadow I apply on all the text.
I was a bit surprised, because I make some test into a really <em>slow</em> virtual machine. And all have always worked fine. In fact, what slow down so much are by order of importance:</p> I was a bit surprised, because I make some test into a really <em>slow</em> virtual machine. And all have always worked fine. In fact, what slow down so much are by order of importance:</p>
<ol> <ol>
@ -69,7 +72,7 @@ I was a bit surprised, because I make some test into a really <em>slow</em> virt
<p>Safari and Chrome use webkit, when you access my website with javascript enabled, an additionnal browser specific CSS is loaded. Until now I switched only between: IE, Mozilla and Webkit. Now I added one more special case for Chrome. Now I continue to use gradient for Safari but no more on Chrome.</p> <p>Safari and Chrome use webkit, when you access my website with javascript enabled, an additionnal browser specific CSS is loaded. Until now I switched only between: IE, Mozilla and Webkit. Now I added one more special case for Chrome. Now I continue to use gradient for Safari but no more on Chrome.</p>
<p>I didn&rsquo;t tried to verify the efficiency of all new CSS 3 features. But I advise you not to use <strong><code>-webkit-gradient</code></strong> on Chrome. At least when the host is a Linux.</p> <p>I didnt tried to verify the efficiency of all new CSS 3 features. But I advise you not to use <strong><code>-webkit-gradient</code></strong> on Chrome. At least when the host is a Linux.</p>
<h2 id="box-shadows">Box Shadows</h2> <h2 id="box-shadows">Box Shadows</h2>
@ -77,7 +80,7 @@ I was a bit surprised, because I make some test into a really <em>slow</em> virt
<h2 id="text-shadows">Text Shadows</h2> <h2 id="text-shadows">Text Shadows</h2>
<p>Many tell me to use text-shadows sparingly. But I believe it was not the real reason of the slow down. This is why I&rsquo;ll get them back.</p> <p>Many tell me to use text-shadows sparingly. But I believe it was not the real reason of the slow down. This is why Ill get them back.</p>
<h2 id="conclusion">Conclusion</h2> <h2 id="conclusion">Conclusion</h2>

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Indécidabilités (partie 1)" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-07-09-Indecidabilities/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Indécidabilités (partie 1)" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-07-09-Indecidabilities/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -81,10 +84,10 @@
<p>If a demiurge made our world, he certainly had a great sense of humor. <p>If a demiurge made our world, he certainly had a great sense of humor.
After this read, you should be convinced. After this read, you should be convinced.
I&rsquo;ll pretend to be him. Ill pretend to be him.
I&rsquo;ll create a simplified world. Ill create a simplified world.
A world that obey to simple mathematical rules. A world that obey to simple mathematical rules.
And I&rsquo;ll tell you about one of the curse on this world: the <em>undecidability</em>. And Ill tell you about one of the curse on this world: the <em>undecidability</em>.
The inability to know if we had find the <em>truth</em>. The inability to know if we had find the <em>truth</em>.
The inability to predict many things that should be natural. The inability to predict many things that should be natural.
Here begin the story.</p> Here begin the story.</p>
@ -93,14 +96,14 @@ Here begin the story.</p>
</div> </div>
<p><img alt="no name" src="/Scratch/img/blog/2010-07-09-Indecidabilities/genesis.png" class="left" /></p> <p>leftblogimage(“genesis.png”)</p>
<p>In the beginning there was only void. <p>In the beginning there was only void.
Then a blog post beginning to be written. Then a blog post beginning to be written.
I breath profoundly to feel the weight of the act I will accomplish. I breath profoundly to feel the weight of the act I will accomplish.
A last tense moment and&hellip; I <em>create</em> the <em>Universe</em>. A last tense moment and I <em>create</em> the <em>Universe</em>.
An incredible <em>Universe</em> which will exists only the time of this read. An incredible <em>Universe</em> which will exists only the time of this read.
I&rsquo;m the <em>demiurge</em> of this universe and you are its observer.</p> Im the <em>demiurge</em> of this universe and you are its observer.</p>
<p>I construct this world using only simples rules. <p>I construct this world using only simples rules.
I decide that <em>real</em> rules of this world will be the one we believe are <em>true</em> for our world. I decide that <em>real</em> rules of this world will be the one we believe are <em>true</em> for our world.
@ -109,7 +112,7 @@ For their world, everything we <em>believe</em> today is <em>true</em> for them.
Their world is then probably <em>simpler</em> than our. Their world is then probably <em>simpler</em> than our.
Particularly, we can describe this world with axioms and mathematic rules. Particularly, we can describe this world with axioms and mathematic rules.
It is not so sure for our Universe. It is not so sure for our Universe.
But we&rsquo;ll talk about that later.</p> But well talk about that later.</p>
<p>Lets the work begin. <p>Lets the work begin.
I create an <em>Earth</em>. I create an <em>Earth</em>.
@ -119,14 +122,14 @@ In particular they try to understand their world.
They believe that if they know the rules of their world they will be able to predict the consequences of most of their acts. They believe that if they know the rules of their world they will be able to predict the consequences of most of their acts.
They are so naive. They are so naive.
If only they knew. If only they knew.
But I&rsquo;m here to help them.</p> But Im here to help them.</p>
<p>I am a God who likes jokes. <p>I am a God who likes jokes.
The first joke I make to Ys is to make their sense imperfect. The first joke I make to Ys is to make their sense imperfect.
Furthermore it is not possible to make perfect precise measure in my world. Furthermore it is not possible to make perfect precise measure in my world.
I let Ys ameliorate their technology but there is a theoretical limit to the best precision they can reach.</p> I let Ys ameliorate their technology but there is a theoretical limit to the best precision they can reach.</p>
<p>I&rsquo;d like to precise that these people believe their world is flat. <p>Id like to precise that these people believe their world is flat.
Some believe it is possible to find the rules of their Universe. Some believe it is possible to find the rules of their Universe.
Now, let the game begins.</p> Now, let the game begins.</p>
@ -143,7 +146,7 @@ It is certainly a rule of my Universe.
But how to be certain all triangle in my Universe share this property?</p> But how to be certain all triangle in my Universe share this property?</p>
</blockquote> </blockquote>
<p><img alt="no name" src="/Scratch/img/blog/2010-07-09-Indecidabilities/triangle_3_angles.png" class="left" /></p> <p><img alt="three triangles" src="/Scratch/img/blog/2010-07-09-Indecidabilities/triangle_3_angles.png" class=" left" /></p>
<p>Some began to formalize the problem. <p>Some began to formalize the problem.
They end by writing a mathematical proof. They end by writing a mathematical proof.
@ -153,14 +156,14 @@ The proof is based on rules and axioms.
How to be certain these rules and axioms are right in their world? How to be certain these rules and axioms are right in their world?
They will try to measure again and again the sum of the angles of triangles. They will try to measure again and again the sum of the angles of triangles.
The measure will never fail. The measure will never fail.
But they&rsquo;ll never be certain the rules and axioms are right. But theyll never be certain the rules and axioms are right.
Because then only way to verify all axioms depends of observation. Because then only way to verify all axioms depends of observation.
And as a facetious god, I forbid perfect measure in observation.</p> And as a facetious god, I forbid perfect measure in observation.</p>
<p>Of course, they prey, they call me to help. <p>Of course, they prey, they call me to help.
And as any respectful god, I don&rsquo;t answer. And as any respectful god, I dont answer.
Ah ah ah! I&rsquo;ve always loved to make these kind of thing. Ah ah ah! Ive always loved to make these kind of thing.
Let&rsquo;s act as if I don&rsquo;t exists. Lets act as if I dont exists.
What a good joke!</p> What a good joke!</p>
<p>They feel sad. But they have some hope:</p> <p>They feel sad. But they have some hope:</p>
@ -173,10 +176,10 @@ What a good joke!</p>
<h2 id="growing-errors-undecidability">Growing errors Undecidability</h2> <h2 id="growing-errors-undecidability">Growing errors Undecidability</h2>
<p><img alt="no name" src="/Scratch/img/blog/2010-07-09-Indecidabilities/3_corps.png" class="left" /></p> <p><img alt="Three bodies" src="/Scratch/img/blog/2010-07-09-Indecidabilities/3_corps.png" class=" left" /></p>
<p>Unfortunately, the three bodies problem will crush this <em>hope</em>. <p>Unfortunately, the three bodies problem will crush this <em>hope</em>.
Using Newton&rsquo;s Universal Law of gravitation with two bodies, we can predict with precision what will be their position and speed in the future. Using Newtons Universal Law of gravitation with two bodies, we can predict with precision what will be their position and speed in the future.
Until there all seems OK. Until there all seems OK.
But now, add another body. But now, add another body.
All errors will grow. All errors will grow.
@ -195,25 +198,25 @@ And we should at least determine what we can predict and what we cannot.</p>
<p>Consider the following question:</p> <p>Consider the following question:</p>
<p><img alt="no name" src="/Scratch/img/blog/2010-07-09-Indecidabilities/mandelbrot.png" class="left" /></p> <p><img alt="Mandelbrot set" src="/Scratch/img/blog/2010-07-09-Indecidabilities/mandelbrot.png" class=" left" /></p>
<p>Consider some GPS coordinates on a point around the cost of the &ldquo;Bretagne&rdquo; in France. <p>Consider some GPS coordinates on a point around the cost of the “Bretagne” in France.
The coordinates are 3 feet precise. The coordinates are 3 feet precise.
Is the point in the water or on Earth?</p> Is the point in the water or on Earth?</p>
<p>For some coordinates it is not possible to know. <p>For some coordinates it is not possible to know.
Even if we are authorize to move a bit to dodge the borders. Even if we are authorize to move a bit to dodge the borders.
Because there are some zone in which all point could be a &ldquo;border&rdquo; for any size of the zone.</p> Because there are some zone in which all point could be a “border” for any size of the zone.</p>
<p>We can even imagine some mathematical structure where <em>all</em> points are at the border<sup id="fnref:2"><a href="#fn:2" rel="footnote">1</a></sup>. </p> <p>We can even imagine some mathematical structure where <em>all</em> points are at the border<sup id="fnref:2"><a href="#fn:2" rel="footnote">1</a></sup>. </p>
<h2 id="logical-undecidability">Logical Undecidability</h2> <h2 id="logical-undecidability">Logical Undecidability</h2>
<p><img alt="no name" src="/Scratch/img/blog/2010-07-09-Indecidabilities/stackOverflow.png" class="left" /></p> <p><img alt="recursive stack overflow" src="/Scratch/img/blog/2010-07-09-Indecidabilities/stackOverflow.png" class=" left" /></p>
<p>Until there all problem were undecidable because of measure <em>errors</em>. <p>Until there all problem were undecidable because of measure <em>errors</em>.
May be in a controlled world without any <em>error</em> we should be able to predict anything.<br /> May be in a controlled world without any <em>error</em> we should be able to predict anything.<br />
I&rsquo;m sorry to say no. Im sorry to say no.
Even in a self-contained mathematical world it can be possible to create object with an unpredictable behaviour.</p> Even in a self-contained mathematical world it can be possible to create object with an unpredictable behaviour.</p>
<p>It is the <em>halting problem</em>.</p> <p>It is the <em>halting problem</em>.</p>
@ -229,8 +232,8 @@ More precisely:</p>
<p>Hypothesis: there exists a program <code>P</code> such that:</p> <p>Hypothesis: there exists a program <code>P</code> such that:</p>
<ul> <ul>
<li><code>P(x,y)</code> return &ldquo;stop&rdquo; in a finite amount of time if <code>x(y)</code><sup id="fnref:1"><a href="#fn:1" rel="footnote">2</a></sup> will stop running.</li> <li><code>P(x,y)</code> return “stop” in a finite amount of time if <code>x(y)</code><sup id="fnref:1"><a href="#fn:1" rel="footnote">2</a></sup> will stop running.</li>
<li><code>P(x,y)</code> return &ldquo;loop&rdquo; in a finite amount of time if <code>x(y)</code> will never stop running.</li> <li><code>P(x,y)</code> return “loop” in a finite amount of time if <code>x(y)</code> will never stop running.</li>
</ul> </ul>
<p>Remark: Any program can be represented as a string. Therefore, a program can be used as the input of another program. <p>Remark: Any program can be represented as a string. Therefore, a program can be used as the input of another program.
@ -247,8 +250,8 @@ Q(x) :
<p>Now, what is the value of <code>P(Q,Q)</code>?</p> <p>Now, what is the value of <code>P(Q,Q)</code>?</p>
<ul> <ul>
<li>if <code>P(Q,Q)</code> returns &ldquo;stop&rdquo; that imply by construction of <code>Q</code> that <code>P(Q,Q)</code> returns &ldquo;loop&rdquo;.</li> <li>if <code>P(Q,Q)</code> returns “stop” that imply by construction of <code>Q</code> that <code>P(Q,Q)</code> returns “loop”.</li>
<li>if <code>P(Q,Q)</code> returns &ldquo;loop&rdquo; that means by construction of <code>Q</code> that <code>P(Q,Q)</code> return &ldquo;stop&rdquo;.</li> <li>if <code>P(Q,Q)</code> returns “loop” that means by construction of <code>Q</code> that <code>P(Q,Q)</code> return “stop”.</li>
</ul> </ul>
<p>Therefore there is a contradiction the only way to handle is by the non existence of the program <code>P</code>.</p> <p>Therefore there is a contradiction the only way to handle is by the non existence of the program <code>P</code>.</p>
@ -256,7 +259,7 @@ Q(x) :
<p>I am the demiurge of this imaginary world. <p>I am the demiurge of this imaginary world.
And I cannot know the future of this world. And I cannot know the future of this world.
Therefore, creative power isn&rsquo;t equivalent to omnipotence.</p> Therefore, creative power isnt equivalent to omnipotence.</p>
</div> </div>
@ -266,7 +269,7 @@ Therefore, creative power isn&rsquo;t equivalent to omnipotence.</p>
<p>After all this, it becomes difficult to know what we can believe. <p>After all this, it becomes difficult to know what we can believe.
But it would be another error to throw away all our knowledge. But it would be another error to throw away all our knowledge.
In a future next part, I&rsquo;ll explain what we can hope and what attitude we should have once we&rsquo;ve realized most of truth are unaccessible.</p> In a future next part, Ill explain what we can hope and what attitude we should have once weve realized most of truth are unaccessible.</p>
<hr/><div class="footnotes"> <hr/><div class="footnotes">
<ol> <ol>
<li id="fn:2"> <li id="fn:2">
@ -393,7 +396,7 @@ In a future next part, I&rsquo;ll explain what we can hope and what attitude we
</div> </div>
<div id="lastmod"> <div id="lastmod">
Created: 08/11/2010 Created: 08/11/2010
Modified: 04/11/2012 Modified: 04/26/2012
</div> </div>
<div> <div>
Entirely done with Entirely done with

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Nouveau style après les vacances" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-07-31-New-style-after-holidays/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Nouveau style après les vacances" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-07-31-New-style-after-holidays/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->

View file

@ -1,4 +1,3 @@
rack rack
rack-rewrite rack-rewrite
rack-contrib rack-contrib

View file

@ -1,4 +1,3 @@
require 'rubygems' require 'rubygems'
require 'rack' require 'rack'
require 'rack/contrib' require 'rack/contrib'

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Maintenant sur Heroku" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-08-23-Now-heberged-on-heroku/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Maintenant sur Heroku" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-08-23-Now-heberged-on-heroku/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -69,73 +72,70 @@ But here is the conf to make it work on heroku.</p>
<p>The root of my files is <code>/output</code>. You only need to create a <code>config.ru</code><sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup> file:</p> <p>The root of my files is <code>/output</code>. You only need to create a <code>config.ru</code><sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup> file:</p>
<div class="code"><div class="file"><a href="/Scratch/en/blog/2010-08-23-Now-heberged-on-heroku/code/config.ru"> &#x27A5; config.ru </a></div><div class="withfile"> <div class="codefile"><a href="/Scratch/en/blog/2010-08-23-Now-heberged-on-heroku/code/config.ru">&#x27A5; config.ru</a></div>
<pre class="twilight">
<span class="Keyword">require</span> <span class="String"><span class="String">'</span>rubygems<span class="String">'</span></span>
<span class="Keyword">require</span> <span class="String"><span class="String">'</span>rack<span class="String">'</span></span>
<span class="Keyword">require</span> <span class="String"><span class="String">'</span>rack/contrib<span class="String">'</span></span>
<span class="Keyword">require</span> <span class="String"><span class="String">'</span>rack-rewrite<span class="String">'</span></span>
<span class="Keyword">require</span> <span class="String"><span class="String">'</span>mime/types<span class="String">'</span></span>
use <span class="Support">Rack</span>::<span class="Entity">ETag</span> <pre><code class="ruby">require 'rubygems'
<span class="Keyword">module</span> ::<span class="Entity">Rack</span> require 'rack'
<span class="Keyword">class</span> <span class="Entity">TryStatic<span class="EntityInheritedClass"> <span class="EntityInheritedClass">&lt;</span> Static</span></span> require 'rack/contrib'
require 'rack-rewrite'
require 'mime/types'
<span class="Keyword">def</span> <span class="Entity">initialize</span>(<span class="Variable">app<span class="Variable">,</span> options</span>) use Rack::ETag
<span class="Keyword">super</span> module ::Rack
<span class="Variable"><span class="Variable">@</span>try</span> <span class="Keyword">=</span> ([<span class="String"><span class="String">'</span><span class="String">'</span></span>] <span class="Keyword">+</span> <span class="Variable">Array</span>(options.<span class="Entity">delete</span>(<span class="Constant"><span class="Constant">:</span>try</span>)) <span class="Keyword">+</span> [<span class="String"><span class="String">'</span><span class="String">'</span></span>]) class TryStatic &lt; Static
<span class="Keyword">end</span>
<span class="Keyword">def</span> <span class="Entity">call</span>(<span class="Variable">env</span>) def initialize(app, options)
<span class="Variable"><span class="Variable">@</span>next</span> <span class="Keyword">=</span> <span class="Constant">0</span> super
<span class="Keyword">while</span> <span class="Variable"><span class="Variable">@</span>next</span> <span class="Keyword">&lt;</span> <span class="Variable"><span class="Variable">@</span>try</span>.<span class="Entity">size</span> <span class="Keyword">&amp;&amp;</span> <span class="Constant">404</span> <span class="Keyword">==</span> (resp <span class="Keyword">=</span> <span class="Keyword">super</span>(<span class="Entity">try_next</span>(env)))[<span class="Constant">0</span>] @try = ([''] + Array(options.delete(:try)) + [''])
<span class="Variable"><span class="Variable">@</span>next</span> <span class="Keyword">+=</span> <span class="Constant">1</span> end
<span class="Keyword">end</span>
<span class="Constant">404</span> <span class="Keyword">==</span> resp[<span class="Constant">0</span>] <span class="Keyword">?</span> <span class="Variable"><span class="Variable">@</span>app</span>.<span class="Entity">call</span> : resp
<span class="Keyword">end</span>
<span class="Keyword">private</span> def call(env)
<span class="Keyword">def</span> <span class="Entity">try_next</span>(<span class="Variable">env</span>) @next = 0
env.<span class="Entity">merge</span>(<span class="String"><span class="String">'</span>PATH_INFO<span class="String">'</span></span> =&gt; env[<span class="String"><span class="String">'</span>PATH_INFO<span class="String">'</span></span>] <span class="Keyword">+</span> <span class="Variable"><span class="Variable">@</span>try</span>[<span class="Variable"><span class="Variable">@</span>next</span>]) while @next &lt; @try.size &amp;&amp; 404 == (resp = super(try_next(env)))[0]
<span class="Keyword">end</span> @next += 1
end
404 == resp[0] ? @app.call : resp
end
<span class="Keyword">end</span> private
<span class="Keyword">end</span> def try_next(env)
env.merge('PATH_INFO' =&gt; env['PATH_INFO'] + @try[@next])
end
use <span class="Support">Rack</span>::<span class="Entity">TryStatic</span>, end
<span class="Constant"><span class="Constant">:</span>root</span> =&gt; <span class="String"><span class="String">&quot;</span>output<span class="String">&quot;</span></span>, <span class="Comment"><span class="Comment">#</span> static files root dir</span> end
<span class="Constant"><span class="Constant">:</span>urls</span> =&gt; <span class="String"><span class="String">%w[</span>/<span class="String">]</span></span>, <span class="Comment"><span class="Comment">#</span> match all requests </span>
<span class="Constant"><span class="Constant">:</span>try</span> =&gt; [<span class="String"><span class="String">'</span>.html<span class="String">'</span></span>, <span class="String"><span class="String">'</span>index.html<span class="String">'</span></span>, <span class="String"><span class="String">'</span>/index.html<span class="String">'</span></span>] <span class="Comment"><span class="Comment">#</span> try these postfixes sequentially</span>
errorFile<span class="Keyword">=</span><span class="String"><span class="String">'</span>output/Scratch/en/error/404-not_found/index.html<span class="String">'</span></span> use Rack::TryStatic,
run lambda { [<span class="Constant">404</span>, { :root =&gt; "output", # static files root dir
<span class="String"><span class="String">&quot;</span>Last-Modified<span class="String">&quot;</span></span> =&gt; <span class="Support">File</span>.<span class="Entity">mtime</span>(errorFile).<span class="Entity">httpdate</span>, :urls =&gt; %w[/], # match all requests
<span class="String"><span class="String">&quot;</span>Content-Type<span class="String">&quot;</span></span> =&gt; <span class="String"><span class="String">&quot;</span>text/html<span class="String">&quot;</span></span>, :try =&gt; ['.html', 'index.html', '/index.html'] # try these postfixes sequentially
<span class="String"><span class="String">&quot;</span>Content-Length<span class="String">&quot;</span></span> =&gt; <span class="Support">File</span>.<span class="Entity">size</span>(errorFile).<span class="Entity">to_s</span>
}, <span class="Support">File</span>.<span class="Entity">read</span>(errorFile)] } errorFile='output/Scratch/en/error/404-not_found/index.html'
</pre> run lambda { [404, {
</div></div> "Last-Modified" =&gt; File.mtime(errorFile).httpdate,
"Content-Type" =&gt; "text/html",
"Content-Length" =&gt; File.size(errorFile).to_s
}, File.read(errorFile)] }
</code></pre>
<p>and the <code>.gems</code> file needed to install <code>rack</code> middlewares.</p> <p>and the <code>.gems</code> file needed to install <code>rack</code> middlewares.</p>
<div class="code"><div class="file"><a href="/Scratch/en/blog/2010-08-23-Now-heberged-on-heroku/code/.gems"> &#x27A5; .gems </a></div><div class="withfile"> <div class="codefile"><a href="/Scratch/en/blog/2010-08-23-Now-heberged-on-heroku/code/.gems">&#x27A5; .gems</a></div>
<pre class="twilight">
rack <pre><code class="ruby">rack
rack<span class="Keyword">-</span>rewrite rack-rewrite
rack<span class="Keyword">-</span>contrib rack-contrib
</pre> </code></pre>
</div></div>
<p>Now, just follow the heroku tutorial to create an application&nbsp;:</p> <p>Now, just follow the heroku tutorial to create an application&nbsp;:</p>
<pre class="twilight"> <pre><code class="zsh">git init
git init
git add . git add .
heroku create heroku create
git push heroku master git push heroku master
</pre> </code></pre>
<p>Now I&rsquo;ll should be able to redirect properly to my own 404 page for example. <p>Now Ill should be able to redirect properly to my own 404 page for example.
I hope it is helpful.</p> I hope it is helpful.</p>
<hr/><div class="footnotes"> <hr/><div class="footnotes">
<ol> <ol>

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Envoyer un mail en ligne de commande avec un fichier attaché" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-08-31-send-mail-from-command-line-with-attached-file/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Envoyer un mail en ligne de commande avec un fichier attaché" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-08-31-send-mail-from-command-line-with-attached-file/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -55,19 +58,18 @@
<div id="afterheader"> <div id="afterheader">
<div class="corps"> <div class="corps">
<p>I had to send a mail using only command line. <p>I had to send a mail using only command line.
I was surprised it isn&rsquo;t straightforward at all. I was surprised it isnt straightforward at all.
I didn&rsquo;t had <code>pine</code> nor <code>mutt</code> or anything like that. I didnt had <code>pine</code> nor <code>mutt</code> or anything like that.
Just <code>mail</code> and <code>mailx</code>.</p> Just <code>mail</code> and <code>mailx</code>.</p>
<p>What Internet say (via google) is</p> <p>What Internet say (via google) is</p>
<pre class="twilight"> <pre><code class="zsh">uuencode fic.jpg fic.jpg | mail -s 'Subject'
uuencode fic.jpg fic.jpg <span class="Keyword">|</span> mail -s <span class="String"><span class="String">'</span>Subject<span class="String">'</span></span> </code></pre>
</pre>
<p>I tried it. <p>I tried it.
And it works almost each times. And it works almost each times.
But for my file, it didn&rsquo;t worked. But for my file, it didnt worked.
I compressed it to <code>.gz</code>, <code>.bz2</code> and <code>.zip</code>. I compressed it to <code>.gz</code>, <code>.bz2</code> and <code>.zip</code>.
Using <code>.bz2</code> format it worked nicely, but not with other formats. Using <code>.bz2</code> format it worked nicely, but not with other formats.
Instead of having an attached file I saw this in my email.</p> Instead of having an attached file I saw this in my email.</p>
@ -87,12 +89,11 @@ After some research I found the solution.
Use MIME instead of <code>uuencode</code>.</p> Use MIME instead of <code>uuencode</code>.</p>
<p>Finally I made it manually using <code>sendmail</code>. <p>Finally I made it manually using <code>sendmail</code>.
I didn&rsquo;t dare to use <code>telnet</code>. I didnt dare to use <code>telnet</code>.
The command to use is:</p> The command to use is:</p>
<pre class="twilight"> <pre><code class="zsh">sendmail -t -oi &lt; mailcontent.txt
sendmail -t -oi <span class="Keyword">&lt;</span> mailcontent.txt </code></pre>
</pre>
<p>Of course you need to create the <code>mailcontent.txt</code> file. <p>Of course you need to create the <code>mailcontent.txt</code> file.
It should contains:</p> It should contains:</p>
@ -118,7 +119,7 @@ H4sICB6Ke0wAA2Rjcl93aXRob3V0X2tleXdvcmQuY3N2ANSdW5ubOJPH7/e7
... ...
</pre> </pre>
<p>And to obtain the &ldquo;encoded&rdquo; file in base64 I used:</p> <p>And to obtain the “encoded” file in base64 I used:</p>
<p><code classs="zsh"> <p><code classs="zsh">
uuencode -m fic.jpg fic.jpg uuencode -m fic.jpg fic.jpg

View file

@ -1,4 +1,3 @@
def gitmtime def gitmtime
filepath=@item.path.sub('/Scratch/','content/html/').sub(/\/$/,'') filepath=@item.path.sub('/Scratch/','content/html/').sub(/\/$/,'')
ext=%{.#{@item[:extension]}} ext=%{.#{@item[:extension]}}

View file

@ -12,6 +12,7 @@
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" /> <link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/> <link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Utilisation de git pour calculer les mtimes" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-09-02-Use-git-to-calculate-trusted-mtimes/" /> <link rel="alternate" lang="fr" xml:lang="fr" title="Utilisation de git pour calculer les mtimes" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-09-02-Use-git-to-calculate-trusted-mtimes/" />
@ -19,6 +20,8 @@
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script> <script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script> <script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script> <script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script> <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]--> <![endif]-->
@ -57,30 +60,29 @@
<p>You can remark at the bottom of each page I provide a last modification date. <p>You can remark at the bottom of each page I provide a last modification date.
This label was first calculated using the <code>mtime</code> of the file on the file system. This label was first calculated using the <code>mtime</code> of the file on the file system.
But many times I modify this date just to force some recompilation. But many times I modify this date just to force some recompilation.
Therefore the date wasn&rsquo;t a date of <em>real</em> modification.</p> Therefore the date wasnt a date of <em>real</em> modification.</p>
<p>I use <a href="http://git-scm.org">git</a> to version my website. <p>I use <a href="http://git-scm.org">git</a> to version my website.
And fortunately I can know the last date of <em>real</em> change of a file. And fortunately I can know the last date of <em>real</em> change of a file.
This is how I do this with <a href="http://nanoc.stoneship.org">nanoc</a>:</p> This is how I do this with <a href="http://nanoc.stoneship.org">nanoc</a>:</p>
<div class="code"><div class="file"><a href="/Scratch/en/blog/2010-09-02-Use-git-to-calculate-trusted-mtimes/code/gitmtime.rb"> &#x27A5; gitmtime.rb </a></div><div class="withfile"> <div class="codefile"><a href="/Scratch/en/blog/2010-09-02-Use-git-to-calculate-trusted-mtimes/code/gitmtime.rb">&#x27A5; gitmtime.rb</a></div>
<pre class="twilight">
<span class="Keyword">def</span> <span class="Entity">gitmtime</span> <pre><code class="ruby">def gitmtime
filepath<span class="Keyword">=</span><span class="Variable"><span class="Variable">@</span>item</span>.<span class="Entity">path</span>.<span class="Entity">sub</span>(<span class="String"><span class="String">'</span>/Scratch/<span class="String">'</span></span>,<span class="String"><span class="String">'</span>content/html/<span class="String">'</span></span>).<span class="Entity">sub</span>(<span class="StringRegexp"><span class="StringRegexp">/</span></span><span class="StringRegexp"><span class="StringRegexpSpecial">\/</span>$</span><span class="StringRegexp"><span class="StringRegexp">/</span></span>,<span class="String"><span class="String">'</span><span class="String">'</span></span>) filepath=@item.path.sub('/Scratch/','content/html/').sub(/\/$/,'')
ext<span class="Keyword">=</span><span class="String"><span class="String">%{</span>.<span class="StringEmbeddedSource"><span class="StringEmbeddedSource">#{</span><span class="StringVariable"><span class="StringVariable">@</span>item</span><span class="StringEmbeddedSource">[</span><span class="StringConstant"><span class="StringConstant">:</span>extension</span><span class="StringEmbeddedSource">]</span><span class="StringEmbeddedSource">}</span></span><span class="String">}</span></span> ext=%{.#{@item[:extension]}}
filepath<span class="Keyword">&lt;&lt;=</span>ext filepath&lt;&lt;=ext
<span class="Keyword">if</span> <span class="Keyword">not</span> <span class="Support">FileTest</span>.<span class="Entity">exists?</span>(filepath) if not FileTest.exists?(filepath)
filepath.<span class="Entity">sub!</span>(ext,<span class="String"><span class="String">%{</span><span class="StringEmbeddedSource"><span class="StringEmbeddedSource">#{</span><span class="StringVariable"><span class="StringVariable">@</span>item</span><span class="StringEmbeddedSource"><span class="StringEmbeddedSource">.</span><span class="Entity">raw_filename</span></span><span class="StringEmbeddedSource">}</span></span><span class="StringEmbeddedSource"><span class="StringEmbeddedSource">#{</span>ext<span class="StringEmbeddedSource">}</span></span><span class="String">}</span></span>) filepath.sub!(ext,%{#{@item.raw_filename}#{ext}})
<span class="Keyword">end</span> end
str<span class="Keyword">=</span><span class="String"><span class="String">`</span>git log -1 --format='%ci' -- <span class="StringEmbeddedSource"><span class="StringEmbeddedSource">#{</span>filepath<span class="StringEmbeddedSource">}</span></span><span class="String">`</span></span> str=`git log -1 --format='%ci' -- #{filepath}`
<span class="Keyword">if</span> str.<span class="Entity">nil?</span> <span class="Keyword">or</span> str.<span class="Entity">empty?</span> if str.nil? or str.empty?
<span class="Keyword">return</span> <span class="Support">Time</span>.<span class="Entity">now</span> return Time.now
<span class="Keyword">else</span> else
<span class="Keyword">return</span> <span class="Support">DateTime</span>.<span class="Entity">parse</span>( str ) return DateTime.parse( str )
<span class="Keyword">end</span> end
<span class="Keyword">end</span> end
</pre> </code></pre>
</div></div>
<p>Of course I know it is really slow and absolutely not optimized. <p>Of course I know it is really slow and absolutely not optimized.
But it works as expected. But it works as expected.

View file

@ -1,5 +1,4 @@
- (unsigned char *)sha1:(NSString *)baseString result:(unsigned char *)result { - (unsigned char *)sha1:(NSString *)baseString result:(unsigned char *)result {
char *c_baseString=(char *)[baseString UTF8String]; char *c_baseString=(char *)[baseString UTF8String];
CC_SHA1(c_baseString, strlen(c_baseString), result); CC_SHA1(c_baseString, strlen(c_baseString), result);

Some files were not shown because too many files have changed in this diff Show more