initial commit

This commit is contained in:
Yann Esposito (Yogsototh) 2013-03-04 11:54:08 +01:00
commit 94e92ff8a3
545 changed files with 68778 additions and 0 deletions

97
404.html Normal file
View file

@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - 404 Error</title>
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="404.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>404 Error</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<p>The page youre looking for is not there. If you want to help me fix this, send me the following content:</p>
<blockquote>
404 on
<script>document.write('“'+document.URL+'”');</script>
from
<script>if (document.referrer) { document.write('“' + document.referrer + '”.'); } else {document.write('unknown referrer.');}</script>
</blockquote>
<p>using one of the following method</p>
<ul>
<li>twitter: <a href="http://twitter.com/yogsototh">@yogsototh</a></li>
<li>Google+: <a href="https://plus.google.com/117858550730178181663">+yogsotoh</a></li>
<li>email: <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></li>
</ul>
<p>Thanks!</p>
</div>
<div id="bottom">
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

1
CNAME Normal file
View file

@ -0,0 +1 @@
yannesposito.com

1
Scratch/css/cmu.css Normal file
View file

@ -0,0 +1 @@
pre, code, a.cut{font-family:"cmuntt", Incosolata, Monaco, monospace}body{font-family:"ComputerModern", Georgia, Palatino, "Century Schoolbook L", "Times New Roman", Times, serif}

View file

@ -0,0 +1 @@
@font-face{font-family:"cmuntt";src:url("fonts/cmuntt.eot");src:local("☺"), url("fonts/cmuntt.svg") format("svg"), url("fonts/cmuntt.ttf") format("truetype");font-weight:normal;font-style:normal}@font-face{font-family:"ComputerModern";src:url("fonts/cmunrb.eot");src:local("☺"), url("fonts/cmunrb.svg") format("svg"), url("fonts/cmunrb.ttf") format("truetype");font-weight:bold}@font-face{font-family:"ComputerModern";src:url("fonts/cmunsl.eot");src:local("☺"), url("fonts/cmunsl.svg") format("svg"), url("fonts/cmunsl.ttf") format("truetype");font-style:italic, oblique}@font-face{font-family:"ComputerModern";src:url("fonts/cmunrm.eot");src:local("☺"), url("fonts/cmunrm.svg") format("svg"), url("fonts/cmunrm.ttf") format("truetype");font-weight:normal;font-style:normal}

File diff suppressed because one or more lines are too long

1
Scratch/css/dynamic.css Normal file
View file

@ -0,0 +1 @@
*{transition-property:all;transition-duration:0.5s;-moz-transition-property:all;-moz-transition-duration:0.5s;-webkit-transition-property:all;-webkit-transition-duration:0.5s;-o-transition-property:all;-o-transition-duration:0.5s}#social *, #comment *{transition-property:all;transition-duration:0s;-moz-transition-property:all;-moz-transition-duration:0s;-webkit-transition-property:all;-webkit-transition-duration:0s;-o-transition-property:all;-o-transition-duration:0s}

BIN
Scratch/css/fonts/cmunorm.eot Executable file

Binary file not shown.

Binary file not shown.

BIN
Scratch/css/fonts/cmunorm.svg Executable file

Binary file not shown.

BIN
Scratch/css/fonts/cmunorm.ttf Executable file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Scratch/css/fonts/cmunrm.eot Executable file

Binary file not shown.

Binary file not shown.

BIN
Scratch/css/fonts/cmunrm.svg Executable file

Binary file not shown.

BIN
Scratch/css/fonts/cmunrm.ttf Executable file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

1
Scratch/css/modern.css Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
pre{padding:0.8em;background:#f3f4f5;color:#657b83;color:#839496;display:block}pre .high0{color:#586e75}pre .high, pre .high1{color:#073642}pre .high2{color:#002b36}pre .DiffInserted, pre .DiffChanged, pre .DiffHeader, pre .DiffDeleted, pre .EmbeddedSource, pre .EmbeddedSourceBright{color:#839496}pre .DiffHeader{font-style:italic}pre .EmbeddedSource, pre .EmbeddedSourceBright{background-color:#073642}pre .low, pre .line-numbers, pre .DoctypeXmlProcessing{color:#586e75}pre .Comment{color:#586e75;font-style:italic}pre .yellow, pre .CssClass, pre .CssPropertyName, pre .Entity, pre .MarkupList{color:#b58900}pre .EntityInheritedClass{color:#b58900;font-style:italic}pre .orange, pre .String, pre .StringRegexp, pre .StringEmbeddedSource, pre .StringConstant, pre .MetaTagAll{color:#cb4b16}pre .red, pre .InvalidIllegal, pre .CssAtRule, pre .InvalidDeprecated{color:#dc322f;font-style:italic}pre .magenta, pre .CCCPreprocessorLine, pre .CCCPreprocessorDirective{color:#d33682}pre .violet, pre .Constant{color:#6c71c4}pre .blue, pre .Storage, pre .Variable, pre .CssId, pre .SupportFunction, pre .MetaTagInline, pre .StringRegexpSpecial, pre .CssTagName, pre .StringVariable, pre .Support{color:#268bd2}pre .cyan, pre .MarkupHeading, pre .CssAdditionalConstants, pre .CssPropertyValue, pre .SupportConstant{color:#2aa198}pre .green, pre .CssPseudoClass, pre .Keyword, pre .CssConstructorArgument{color:#859900}pre code{color:#657b83;background-color:#f3f4f5}pre .comment, pre .template_comment, pre .diff .header, pre .doctype, pre .lisp .string, pre .javadoc{color:#93a1a1;font-style:italic}pre .keyword, pre .css .rule .keyword, pre .winutils, pre .javascript .title, pre .method, pre .addition, pre .css .tag, pre .lisp .title{color:#859900}pre .number, pre .command, pre .string, pre .tag .value, pre .phpdoc, pre .tex .formula, pre .regexp, pre .hexcolor{color:#2aa198}pre .title, pre .localvars, pre .function .title, pre .chunk, pre .decorator, pre .builtin, pre .built_in, pre .lisp .title, pre .identifier, pre .title .keymethods, pre .id{color:#268bd2}pre .attribute, pre .variable, pre .instancevar, pre .lisp .body, pre .smalltalk .number, pre .constant, pre .class .title, pre .parent, pre .haskell .label{color:#b58900}pre .preprocessor, pre .pi, pre .shebang, pre .symbol, pre .diff .change, pre .special, pre .keymethods, pre .attr_selector, pre .important, pre .subst, pre .cdata{color:#cb4b16}pre .deletion{color:#dc322f}pre .tex .formula{background:#eee8d5}

View file

@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - Contact</title>
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/about/contact/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>Contact</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<blockquote>
<ul>
<li><a href="/Scratch/en/about/contact/">contact</a></li>
<li><a href="/Scratch/en/about/old/">old</a></li>
<li><a href="/Scratch/en/about/technical_details/">technical details</a></li>
</ul>
</blockquote>
<h1 id="how-to-contact-me">How to contact me</h1>
<p><img src="/Scratch/img/about/avatar.png" alt="Avatar" class="clean 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;">yann.esposito@gmail.com</a><br /><a href="http://twitter.com/yogsototh">@yogsototh</a><br /><a href="https://plus.google.com/117858550730178181663">+yogsotoh</a><br />My web bookmarks <a href="http://pinboard.in/u:yogsototh">pinboard</a><br />My <a href="http://github.com/yogsototh">github</a><br /><a href="http://stackoverflow.com/users/40569/yogsototh">stackoverflow</a></p>
</div>
<div id="bottom">
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

135
Scratch/en/about/index.html Normal file
View file

@ -0,0 +1,135 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - About</title>
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/about/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>About</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<blockquote>
<ul>
<li><a href="/Scratch/en/about/contact/">contact</a></li>
<li><a href="/Scratch/en/about/old/">old</a></li>
<li><a href="/Scratch/en/about/technical_details/">technical details</a></li>
</ul>
</blockquote>
<div class="figure">
<img src="/Scratch/img/about/yann1.jpg" alt="I look like this" /><p class="caption">I look like this</p>
</div>
<table>
<tbody>
<tr class="odd">
<td align="left">Name</td>
<td align="left">Yann Esposito</td>
</tr>
<tr class="even">
<td align="left">Education</td>
<td align="left">Post Ph. D. in Computer Science</td>
</tr>
<tr class="odd">
<td align="left">School</td>
<td align="left">Université de Provence</td>
</tr>
<tr class="even">
<td align="left">Job</td>
<td align="left">IT at Sophia Antipolis (France)</td>
</tr>
</tbody>
</table>
<p>Books I like:</p>
<ul>
<li>Goëdel, Escher &amp; Bach <em>[Hofstadter]</em></li>
<li>On Numbers And Games <em>[Conway]</em></li>
<li>Baudolino <em>[Eco]</em></li>
</ul>
<p>Movies I like:</p>
<ul>
<li>Eraserhead <em>[Lynch]</em></li>
<li>Mullholland Drive <em>[Lynch]</em></li>
<li>Naked Lunch <em>[Cronenberg]</em></li>
<li>eXistenZ <em>[Cronenberg]</em></li>
</ul>
<p><a href="http://pinboard.in/u:yogsototh">My online bookmarks on pinboard</a></p>
<p><a href="http://resume.espozito.com">My resume</a></p>
<h2 id="shortly">Shortly</h2>
<p>Im a passionate guy. Passionate about</p>
<ul>
<li>Computer Science: <a href="http://yann.esposito.free.fr/recherche.php">Ive got a post Ph. D. degree in Computer Science</a>.</li>
<li>Programming: <a href="http://yann.esposito.free.fr/logiciels.php">I developed two scientific apps</a>, <a href="/Scratch/en/softwares">two Mac screen savers</a>, an <a href="http://ypassword.espozito.com">iOS app</a> and many other things; <a href="http://github.com/yogsototh">see my github</a></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 method to securely remember strong passwords, (<a href="/Scratch/en/softwares/ypassword/">programmed a dashboard widget</a> and a shell script to use this method).</li>
</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>, <code>Haskell</code></p>
</div>
<div id="bottom">
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,94 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - Other websites</title>
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/about/old/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>Other websites</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<blockquote>
<ul>
<li><a href="/Scratch/en/about/contact/">contact</a></li>
<li><a href="/Scratch/en/about/old/">old</a></li>
<li><a href="/Scratch/en/about/technical_details/">technical details</a></li>
</ul>
</blockquote>
<ul>
<li><a href="http://ypassword.espozito.com">Official YPassword website</a></li>
<li><a href="http://yann.esposito.free.fr/recherche.php?css=blue&amp;amp;lang=en">My research activities.</a></li>
<li><a href="http://yann.esposito.free.fr/">My student website. ✞ 2007</a></li>
</ul>
</div>
<div id="bottom">
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - Technical details</title>
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/about/technical_details/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>Technical details</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<blockquote>
<ul>
<li><a href="/Scratch/en/about/contact/">contact</a></li>
<li><a href="/Scratch/en/about/old/">old</a></li>
<li><a href="/Scratch/en/about/technical_details/">technical details</a></li>
</ul>
</blockquote>
<p>This website was completely made from scratch. Most is done using <a href="http://www.vim.org">Vim</a> and I generate pages using <a href="http://nanoc.stoneship.org">nanoc</a>.</p>
<p>Pictures were done with <a href="http://inkscape.org">Inkscape</a> and <a href="http://gimp.org">Gimp</a>. My website is versionned using the <a href="http://en.wikipedia.org/wiki/Distributed_Concurrent_Versions_System"> <acronym title="Distributed Concurrent Versions System">DCVS</acronym> </a> <a href="http://git-scm.com">Git</a>.</p>
<p>Blog comments are externalized to <del><a href="http://disqus.com">disqus</a></del> <a href="http://intensedebate.com">intense debate</a>. All I need is a static web server, no PHP, Java, ASP or CGI. Main advantages of this method concerns the load and the security of the server.</p>
<p>If you didnt understood anything, just remember I used only <a href="http://en.wikipedia.org/wiki/OpenSource">Opensource</a> and I mostly all done myself from scratch.</p>
</div>
<div id="bottom">
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,127 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - Nanoc</title>
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/01_nanoc/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>Nanoc</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<h1 id="what-is-nanoc">What is nanoc?</h1>
<p>It is not exactly a <abbr title="Content Management System">CMS</abbr>. But a Framework to generate static web pages.</p>
<p>You have to program yourself webpages, the code to generate the menu…</p>
<p>I added feature to make my website multilingual for example</p>
<p>Youll can find many informations on the <a href="http://nanoc.stoneship.org">official nanoc website</a>.</p>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2008-10-10
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,13 @@
#!/usr/bin/env zsh
(($#<1)) && { print 'usage: ack "regexp"' >&2; exit 1 }
listeFic=( **/*(.) )
autoload zargs
zargs -- $listeFic -- grep $1 | perl -ne 'use Term::ANSIColor;
if (m/([^:]*)(:.*)('$1')(.*)/) {
print color("green").$1;
print color("reset").$2;
print color("black","on_yellow").$3;
print color("reset").$4."\n";
} '

View file

@ -0,0 +1,142 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - Better than Grep</title>
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/02_ackgrep/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>Better than Grep</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<h1 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 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>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>
<hr />
<h1 id="better-than-grep">Better than grep</h1>
<p>One of the my main usage of <code>grep</code> is</p>
<div>
<code class="zsh"> grep pattern *<em>/</em>(.)</code>
</div>
<p>Most of time it is enough. But it is far better with colored output. <code>ack-grep</code> in Ubuntu does that. As I couldnt install it on my Evil Company Server, I had done one myself in very few lines:</p>
<div>
<p><code class="zsh" file="ack"> #!/usr/bin/env zsh (($#&lt;1)) &amp;&amp; { print usage: ack “regexp” &gt;&amp;2; exit 1 }</p>
listeFic=( <em><em>/</em>(.) ) autoload zargs zargs $listeFic grep $1 | perl -ne use Term::ANSIColor; if (m/([^:]<em>)(:.</em>)($1)(.</em>)/) { print color(“green”).$1; print color(“reset”).$2; print color(“black”,“on_yellow”).$3; print color(“reset”).$4.“”; } </code>
</div>
<p>For my team and I it is usable enough. I hope it could help.</p>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2009-07-22
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,199 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - A try to demystify 'Lost Highway'</title>
<meta name="keywords" content="movie, David Lynch, Lost Highway, alternate reality">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/03_losthighway/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>A try to demystify 'Lost Highway'</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<p><img src="/Scratch/img/blog/03_losthighway/intro.jpg" alt="Lost Highway"/></p>
<div class="small">
…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.<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…
</div>
<p>Lost Higway is a really good movie. You keep watching it event it seem totally obscure. This is one of the strength of David Lynch.</p>
<p>The first time I watched Lost Highway, I was a bit lost. Here some of explanations of Lost Highway I found on the Internet:</p>
<ul>
<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>Just the first part of the story is real. The rest is in the Freds imagination,</li>
</ul>
<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>
<ul>
<li>the first is <a href="http://www.mediacircus.net/lh.html">mediacircus</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>
<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>
<h2 id="the-rorschach-test">The Rorschach test</h2>
<p><img src="/Scratch/img/blog/03_losthighway/rorschach.gif" alt="test de Rorschach" class="left"/></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>
<li>If you are mystic, youll see in the mysterious man a devil,</li>
<li>If you are more psychanalytics, youll see an inconscient part of the protagonist…</li>
</ul>
<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="interprétation-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. There is certainly many coherent explanations.</p>
<p>I write this post because I believe I had found an interpretation which seems coherent for most of the movie.</p>
<h1 id="movies-keys">Movies keys</h1>
<div class="encadre" style="text-align: center">
<strong> All is in Freds memory </strong>
</div>
<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 Freds representation of reality. 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. Hell then create alternative realities.</p>
<ul>
<li>In a first time he kills his wife (Renee) because he believes she cheated at him.</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>
</ul>
<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 hes own a video camera:</p>
<blockquote>
<p>“Do you own a video camera?”<br />“No, Fred hates them.”<br />“I like to remember things my own way.”<br />“What do you mean by that?”<br />“How I remember them, not necessarily the way they happened.”</p>
</blockquote>
<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>
<h2 id="who-is-the-mysterious-man">Who is the mysterious man?</h2>
<p><img src="/Scratch/img/blog/03_losthighway/mysteryman.jpg" alt=" " class="left"/></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>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. As <em>Iago</em> of Shakespeare is imprisonned by its own jalousy. The Mysterious Man help Fred doing the acts of violence. 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 wifes face. In reality, its the same person for Fred. It should be her whos the origin of his interior badness.</p>
<h2 id="whos-at-the-origin-of-the-video-tapes">Whos at the origin of the video tapes?</h2>
<p>Certainly its the mysterious man (Fred himself) who makes them. Their reason should be:</p>
<ul>
<li>Remember the reality to Fred. From Fred point-of-view, video tapes are the reality. He tries to forget reality. But, finally, the video tapes go to the end: the murder of his wife.</li>
<li>It may also be a reference to pornographic video tapes, made by Renee.</li>
</ul>
<h2 id="what-really-happened">What really happened?</h2>
<p>There is many possibilities here. But we have many indices. Here is a supposition.</p>
<h3 id="hypothesis">#1 Hypothesis</h3>
<p>The protagonist is a garagist fallen in love with a porno actress. He believe the producer is the bad guy who go again his will. Then he kills Dick Laurent.</p>
<h3 id="hypothesis-1">#2 Hypothesis</h3>
<p>He was really married, he had killed his wife. The the remorse let him create an alternate self, which live in a kind of perfect world. But after the time pass, his obsession about the murder came again. And nobody could know if he had killed Andy or not.</p>
<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. 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>
<hr />
<h2 id="conclusion">Conclusion</h2>
<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 “test of Rorschach effet” when watching this movie.</p>
<p>Id like to know or opinion ; is my interpration wrong?</p>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2009-08-04
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,138 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - DRM are EVIL</title>
<meta name="keywords" content="drm, protection, iTunes, Apple">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/04_drm/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>DRM are EVIL</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<h1 id="drm-are-evil-1">DRM are EVIL (+1)</h1>
<p>My wife bought about 500€ (at least) of TV Shows on iTunes. She bought the first season of Battlestar Gallactica in english (she notified the language after the dowload). DRM make it impossible to play it with french sub-titles.</p>
<div class="encadre">
<p style="text-align: center; font-size: 5em">
<strong>WTF?</strong>
</p>
</div>
<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">
<p>Therefore far less money for you EVIL Copyrighter!!!!!</p>
</div>
<p>My wife wont see these episodes.<br/> This is a <strong>LOSE-LOSE</strong> cooperation.</p>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2009-08-15
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,13 @@
#!/usr/bin/env zsh
if (($#<1)); then
print -- "usage: $0:t branch_name" >&2
exit 1
fi
branch=$1
git br ${branch}
git co ${branch}
git config branch.${branch}.remote origin
git config branch.${branch}.merge refs/heads/${branch}

View file

@ -0,0 +1,134 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - Git remote branch creation</title>
<meta name="keywords" content="git, branch, local, remote">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/05_git_create_remote_branch/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>Git remote branch creation</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<h2 id="easiest-remote-git-branch-creation">easiest remote Git branch creation</h2>
<p>I use git simply to synchronize stuff for personnal projects. Therefore, when I create a local branch I want most of time this branch to be created remotely.</p>
<p>Here is the script I use to achieve that:</p>
<div>
<p><code class="zsh" file="git-create-new-branch.sh"> #!/usr/bin/env zsh</p>
<p>if (($#&lt;1)); then print “usage: $0:t branch_name” &gt;&amp;2 exit 1 fi</p>
branch=<span class="math">1<em>g</em><em>i</em><em>t</em><em>b</em><em>r</em></span>{branch} git co <span class="math"><em>b</em><em>r</em><em>a</em><em>n</em><em>c</em><em>h</em><em>g</em><em>i</em><em>t</em><em>c</em><em>o</em><em>n</em><em>f</em><em>i</em><em>g</em><em>b</em><em>r</em><em>a</em><em>n</em><em>c</em><em>h</em>.</span>{branch}.remote origin git config branch.<span class="math"><em>b</em><em>r</em><em>a</em><em>n</em><em>c</em><em>h</em>.<em>m</em><em>e</em><em>r</em><em>g</em><em>e</em><em>r</em><em>e</em><em>f</em><em>s</em>/<em>h</em><em>e</em><em>a</em><em>d</em><em>s</em>/</span>{branch} </code>
</div>
<p>Of course, I suppose <code>origin</code> is already configured.</p>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2009-08-17
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,12 @@
#!/usr/bin/env zsh
if (($#<1)); then
print -- "usage: $0:t branch_name" >&2
exit 1
fi
branch=$1
git br ${branch}
git co ${branch}
git config branch.${branch}.remote origin
git config branch.${branch}.merge refs/heads/${branch}

View file

@ -0,0 +1,13 @@
#!/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

View file

@ -0,0 +1,243 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - Git for self</title>
<meta name="keywords" content="git, svn, workflow">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/06_How_I_use_git/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>Git for self</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<p><img src="/Scratch/img/blog/06_How_I_use_git/central_architecture.png" alt="central architecture"/></p>
<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. 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>
<hr />
<h2 id="initialisation">Initialisation</h2>
<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>
<pre class="zsh"><code>cd to/project/directory/
git init
git add
git commit</code></pre>
</div>
<p>Now all files in the <code>to/project/directory/</code> are versionned. If you want not to follow some just edit the file <code>.gitignore</code></p>
<p>for example mine is:</p>
<div>
<pre class="zsh"><code>*.swp
.DS_Store
ikog.py.bak
output/Scratch/assets
output/Scratch/en
output/Scratch/fr
output/Scratch/multi</code></pre>
</div>
<p>Next, you want to put your project on a directory accessible from the web:</p>
<div>
<pre class="zsh"><code>git clone --bare . /path/to/repository</code></pre>
</div>
<p>Now on any computer you can do:</p>
<div>
<pre class="zsh"><code>git clone protocol://path/to/repository local_directory</code></pre>
</div>
<p>and <code>local_directory</code> will contain an up-to-date project.</p>
<div class="encadre">
<p><em> You should make this operation also on the computer used to create the repository. Just to verify all will be okay.</p>
</em>
</div>
<hr />
<h2 id="the-workflow">The workflow</h2>
<p>To resume you now have one repository on the Internet, and one or many computer associated with it. Now, what you want is to synchronize everything.</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>
<pre class="zsh"><code>git pull</code></pre>
</div>
<p>After that you can do (many times):</p>
<div>
<pre class="zsh"><code>hack, hack, hack...
git add some files
git commit</code></pre>
</div>
<p>When you want your local modification to be on the Internet just do a simple:</p>
<div>
<pre class="zsh"><code>git push</code></pre>
</div>
<p>All should be ok.</p>
<p>If you have some trouble with the <code>push</code> and <code>pull</code> verify your <code>.git/config</code> file ; it should contain the following lines:</p>
<div>
<pre class="zsh"><code>...
[remote &quot;origin&quot;]
url = protocol://url/of/the/repository
fetch = +refs/heads/*:refs/remotes/origin/*
[branch &quot;master&quot;]
remote = origin
merge = refs/heads/master
...</code></pre>
</div>
<h2 id="branches-synchronisation">Branches Synchronisation</h2>
<p>Well, now, all seems ok, but you have to worry about two little things. Git is all about decentralisation and branches. It is very easy to manage one branch, or many branches on the same host. But synchronize branches on many hosts is not a natural operation.</p>
<p>This is why I created two simple scripts to automate this. One for creating a branch locally and remotely. And one to get remotely created branched on your local host.</p>
<p>Then when you want to create a new branch (locally and remotely) ; you simply have to do a:</p>
<div>
<code class="zsh">git-create-new-branch branch_name</code>
</div>
<p>and when you are on another computer and want to get locally all the remote branches you execute:</p>
<div>
<code class="zsh">git-get-remote-branches</code>
</div>
<p>Here are the code of theese two scripts:</p>
<div>
<pre class="zsh"><code>#!/usr/bin/env zsh
if (($#&lt;1)); then
print -- &quot;usage: $0:t branch_name&quot; &gt;&amp;2
exit 1
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>
</div>
<div>
<pre class="zsh"><code>#!/usr/bin/env zsh
# recup branches not on local
localbranches=( $(git br | sed &#39;s/\*/ /&#39;) )
remoteMissingBranches=( $(git br -r | \
egrep -v &quot;origin/HEAD|(${(j:|:)localbranches})&quot; ) )
for br in $remoteMissingBranches; do
branch=${br#origin/}
print &quot;get remote branch $branch&quot;
git br ${branch}
git config branch.${branch}.remote origin
git config branch.${branch}.merge refs/heads/${branch}
done</code></pre>
</div>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2009-08-18
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,129 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - Screensaver compilation option for Snow Leopard<sub>&copy;</sub></title>
<meta name="keywords" content="screensaver, Apple, mac, Xcode">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/07_Screensaver_compilation_option_for_Snow_Leopard/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>Screensaver compilation option for Snow Leopard<sub>&copy;</sub></h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<h1 id="how-to-recompile-your-screensaver-to-be-snow-leopardc-compatible">How to recompile your screensaver to be Snow Leopard(c) compatible</h1>
<p>I upgraded to Mac OS X 10.6 Snow Leopard(c), 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 didnt work either. 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><img src="/Scratch/img/blog/07_Screensaver_compilation_option_for_Snow_Leopard/xcodeConfig.png" alt="XCode configuration"/></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>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2009-09-06
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,34 @@
<?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">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>Label</key>
<string>local.sshd</string>
<key>Program</key>
<string>/usr/libexec/sshd-keygen-wrapper</string>
<key>ProgramArguments</key>
<array>
<string>/usr/sbin/sshd</string>
<string>-i</string>
</array>
<key>Sockets</key>
<dict>
<key>Listeners</key>
<dict>
<key>SockServiceName</key>
<string>https</string>
</dict>
</dict>
<key>inetdCompatibility</key>
<dict>
<key>Wait</key>
<false/>
</dict>
<key>StandardErrorPath</key>
<string>/dev/null</string>
<key>SHAuthorizationRight</key>
<string>system.preferences</string>
</dict>
</plist>

View file

@ -0,0 +1,180 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - ssh to Listen 443 on Snow Leopard</title>
<meta name="keywords" content="Apple, mac, ssh, security">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/08_Configure_ssh_to_listen_the_port_443_on_Snow_Leopard/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>ssh to Listen 443 on Snow Leopard</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<h1 id="surf-everywhere-as-if-you-were-at-home">Surf everywhere as if you were at home</h1>
<p>In order to bypass <em>evil</em> company firewall and to surf safely on unsafe <sc>wifi</sc>. I keep an ssh server listening on the port 443.</p>
<p>Then from my laptop or my local computer I just have to launch the marvelous</p>
<div>
<pre class="zsh"><code>ssh -p 443 -D 9050 username@host</code></pre>
</div>
<p>and a local <sc>socks</sc> proxy listening on port 9050 is launched. The <sc>socks</sc> 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 <sc>wifi</sc> network to be <em>sniffed</em>. I simply need to configure my web browser to user the <sc>socks</sc> proxy on localhost and port 9050.</p>
<p>I get this information from <a href="http://dltj.org/article/ssh-as-socks-proxy/">this post</a>.</p>
<h1 id="ssh-and-snow-leopardc">Ssh and Snow Leopard(c)</h1>
<p>Here I dont want to talk about how great <sc>socks</sc> proxy via ssh tunneling is but how to configure my local server.</p>
<p>I have Mac with Snow Leopard(c) 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 posted the question on <a href="discussions.apple.com">Apple Discussions</a> in this <a href="http://discussions.apple.com/thread.jspa?messageID=10141032">discussion thread</a>. Thanks to all guys who helped me. And the solution is:</p>
<p>Create the file <tt>/Library/LaunchDaemons/ssh-443.plist</tt> containing:</p>
<div>
<pre class="sourceCode xml"><code class="sourceCode xml"><span class="kw">&lt;?xml</span> version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;<span class="kw">?&gt;</span>
<span class="dt">&lt;!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="dt">&gt;</span>
<span class="kw">&lt;plist</span><span class="ot"> version=</span><span class="st">&quot;1.0&quot;</span><span class="kw">&gt;</span>
<span class="kw">&lt;dict&gt;</span>
<span class="kw">&lt;key&gt;</span>Disabled<span class="kw">&lt;/key&gt;</span>
<span class="kw">&lt;false/&gt;</span>
<span class="kw">&lt;key&gt;</span>Label<span class="kw">&lt;/key&gt;</span>
<span class="kw">&lt;string&gt;</span>local.sshd<span class="kw">&lt;/string&gt;</span>
<span class="kw">&lt;key&gt;</span>Program<span class="kw">&lt;/key&gt;</span>
<span class="kw">&lt;string&gt;</span>/usr/libexec/sshd-keygen-wrapper<span class="kw">&lt;/string&gt;</span>
<span class="kw">&lt;key&gt;</span>ProgramArguments<span class="kw">&lt;/key&gt;</span>
<span class="kw">&lt;array&gt;</span>
<span class="kw">&lt;string&gt;</span>/usr/sbin/sshd<span class="kw">&lt;/string&gt;</span>
<span class="kw">&lt;string&gt;</span>-i<span class="kw">&lt;/string&gt;</span>
<span class="kw">&lt;/array&gt;</span>
<span class="kw">&lt;key&gt;</span>Sockets<span class="kw">&lt;/key&gt;</span>
<span class="kw">&lt;dict&gt;</span>
<span class="kw">&lt;key&gt;</span>Listeners<span class="kw">&lt;/key&gt;</span>
<span class="kw">&lt;dict&gt;</span>
<span class="kw">&lt;key&gt;</span>SockServiceName<span class="kw">&lt;/key&gt;</span>
<span class="kw">&lt;string&gt;</span>https<span class="kw">&lt;/string&gt;</span>
<span class="kw">&lt;/dict&gt;</span>
<span class="kw">&lt;/dict&gt;</span>
<span class="kw">&lt;key&gt;</span>inetdCompatibility<span class="kw">&lt;/key&gt;</span>
<span class="kw">&lt;dict&gt;</span>
<span class="kw">&lt;key&gt;</span>Wait<span class="kw">&lt;/key&gt;</span>
<span class="kw">&lt;false/&gt;</span>
<span class="kw">&lt;/dict&gt;</span>
<span class="kw">&lt;key&gt;</span>StandardErrorPath<span class="kw">&lt;/key&gt;</span>
<span class="kw">&lt;string&gt;</span>/dev/null<span class="kw">&lt;/string&gt;</span>
<span class="kw">&lt;key&gt;</span>SHAuthorizationRight<span class="kw">&lt;/key&gt;</span>
<span class="kw">&lt;string&gt;</span>system.preferences<span class="kw">&lt;/string&gt;</span>
<span class="kw">&lt;/dict&gt;</span>
<span class="kw">&lt;/plist&gt;</span></code></pre>
</div>
<p>It is a copy of <code>/System/Library/LaunchDaemons/ssh.plist</code> with some modifications:</p>
<ul>
<li>the <code>SockServiceName</code> from <code>ssh</code> to <code>https</code>.</li>
<li>the <code>Label</code> from <code>com.openssh.sshd</code> to something not existing as <code>local.sshd</code></li>
</ul>
<p>Tell me if it was helpfull or if you have any question.</p>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2009-09-07
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,134 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - Why I didn't keep whos.amung.us</title>
<meta name="keywords" content="analytics, web">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/09_Why_I_didn-t_keep_whosamung-us/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>Why I didn't keep whos.amung.us</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<p>I changed from <a href="http://whos.amung.us">whos.amung.us</a> to <a href="http://www.google.com/analytics">Google Analytics</a>.</p>
<p>Most of time I prefer not to use the same product as everybody and try some new. But this time I believe whosamung.us had too much ads on the page. I had to put their image on my website and they only give then number of user currently on the website, not the number of visits.</p>
<p>This is why I now use google analytics. The only problem, remains for pages with no javascript support.</p>
<p>Then for now:</p>
<div class="encadre">
Theorem:<br/>
<center>
Google Analytics <big><strong>&gt;</strong></big> Whos Amung Us
<center></div>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2009-09-11
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,101 @@
#!/usr/bin/env zsh
# Author: Yann Esposito
# Mail: yann.esposito@gmail.com
# Synchronize with "mobileMe" iDisk account.
mobileMeUser="firstname.lastname"
siteName="siteName"
# Depending of my hostname the
if [[ $(hostname) == 'ubuntu' ]]; then
iDisk='/mnt/iDisk'
else
iDisk="/Volumes/$mobileMeUser"
fi
root=$HOME/Sites/$siteName
destRep=$iDisk/Web/Sites/$siteName
[[ ! -d $root ]] && {
print -- "$root does not exist ; please verify the configuration ($0)" >&2;
exit 1
}
[[ ! -d $destRep ]] && {
print -- "$destRep does not exist, please mount the filesystem" >&2;
exit 1
}
if [[ $1 == '-h' ]]; then
print -- "usage: $0:h [-h|-a|-s]"
print -- " -a sychronize primary index"
print -- " -h show this help"
print -- " -s only swap directories"
fi
if [[ $1 == '-a' ]]; then
print -- "Index synchronisation (${destRep:h})"
rsync -av $root/index.html ${destRep:h}/index.html
fi
print -- "Root = $root"
print -- "Dest = $destRep"
if [[ ! $1 = '-s' ]]; then
[[ ! -d $destRep.tmp ]] && mkdir $destRep.tmp
print -P -- "%B[Sync => tmp]%b"
result=1
essai=1
while (( $result > 0 )); do
rsync -arv $root/Scratch/ $destRep.tmp
result=$?
if (( $result > 0 )); then
print -P -- "%Brsync failed%b (try n°$essai)" >&2
fi
((essai++))
done
fi
# SWAP
print -P -- "%B[Directory Swap (tmp <=> target)]%b"
essai=1
while [[ -e $destRep.old ]]; do
print -n -- "remove $destRep.old"
if ((essai>1)); then
print " (try n°$essai)"
else
print
fi
((essai++))
\rm -rf $destRep.old
done
print -- " renommage du repertoire sandard vers le .old"
essai=1
while [[ -e $destRep ]]; do
mv $destRep $destRep.old
(($?)) && print -- "Failed to rename (try n°$essai)" >&2
((essai++))
done
print -- " renaming folder tmp (new) to the standard one"
print -P -- " %BThe WebSite isn't working%b $(date)"
essai=1
while [[ ! -e $destRep ]]; do
mv $destRep.tmp $destRep
(($?)) && print -P -- "%B[WebSite not working]%b(try n°$essai) Failed to rename (mv $destRep.tmp $destRep)" >&2
((essai++))
done
print -P -- "\t===\t%BWEBSITE SHOULD WORK NOW%b\t==="
print -- " rename old folder to tmp folder"
essai=1
while [[ ! -e $destRep ]]; do
mv $destRep.old $destRep.tmp
(($?)) && print -P -- "Failed to rename n°$essai" >&2
((essai++))
done
print -P -- " Publish terminated"

View file

@ -0,0 +1,352 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - Synchronize Custom WebSite with mobileMe</title>
<meta name="keywords" content="Apple, mobileme, WebDav, synchronisation, zsh, script">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/10_Synchronize_Custom_WebSite_with_mobileMe/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>Synchronize Custom WebSite with mobileMe</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<h1 id="update-20120111">Update <small>(2012/01/11)</small></h1>
<p>iDisk should soon disapear. This entry is mainly obsolescent now.</p>
<h1 id="update-20091028">Update <small>(2009/10/28)</small></h1>
<p>I <a href="/Scratch/en/blog/2009-10-28-custom-website-synchronisation-with-mobileme--2-">updated my script</a> which is now incremental. Since the writing of this article, Apple(c) had made many efforts about the bandwith of its European servers.</p>
<hr />
<h1 id="webdav-terror">WebDav terror</h1>
<p>I live in France and iDisk upload is just terrible. Upload speed remind me the old 56k modem. Most operations such as list the content of a directory take at least 30 seconds (for 15 elements). Renaming a directory fail most of time.</p>
<p>Apple(c) use a WebDav server to host files. It works on port 80 (like http). I realized WebDav via https work better (2 to 3 times faster with far less errors). But even https is too slow.</p>
<p>I upload from my Mac and sometimes from an Ubuntu PC (iDisk mounted with webdavfs).</p>
<h1 id="synchronize-safely-the-website">Synchronize safely the website</h1>
<p>Here is the script I use in order to synchronize my website with maximum safety. It try each operations until it works.</p>
<p>The idea are:</p>
<ul>
<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>
</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>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>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">
<pre class="zsh"><code>#!/usr/bin/env zsh
# Script synchronisant le site sur me.com
# normalement, le site est indisponible le moins de temps possible
# le temps de deux renommages de répertoire
mobileMeUser=&quot;yann.esposito&quot;
siteName=&quot;siteName&quot;
# Depending of my hostname the
if [[ $(hostname) == &#39;ubuntu&#39; ]]; then
iDisk=&#39;/mnt/iDisk&#39;
else
iDisk=&quot;/Volumes/$mobileMeUser&quot;
fi
root=$HOME/Sites/$siteName
destRep=$iDisk/Web/Sites/$siteName
[[ ! -d $root ]] &amp;&amp; {
print -- &quot;$root n&#39;existe pas ; vérifiez la conf&quot; &gt;&amp;2;
exit 1
}
[[ ! -d $destRep ]] &amp;&amp; {
print -- &quot;$destRep n&#39;existe pas, veuillez remonter le FS&quot; &gt;&amp;2;
exit 1
}
if [[ $1 == &#39;-h&#39; ]]; then
print -- &quot;usage: $0:h [-h|-a|-s]&quot;
print -- &quot; -a sychronise aussi l&#39;index&quot;
print -- &quot; -h affiche l&#39;aide&quot;
print -- &quot; -s swappe simplement les répertoires&quot;
fi
if [[ $1 == &#39;-a&#39; ]]; then
print -- &quot;Synchronisation de l&#39;index (${destRep:h})&quot;
rsync -av $root/index.html ${destRep:h}/index.html
fi
print -- &quot;Root = $root&quot;
print -- &quot;Dest = $destRep&quot;
if [[ ! $1 = &#39;-s&#39; ]]; then
[[ ! -d $destRep.tmp ]] &amp;&amp; mkdir $destRep.tmp
print -P -- &quot;%B[Sync =&gt; tmp]%b&quot;
result=1
essai=1
while (( $result &gt; 0 )); do
rsync -arv $root/Scratch/ $destRep.tmp
result=$?
if (( $result &gt; 0 )); then
print -P -- &quot;%BEchec du rsync%b (essai n°$essai)&quot; &gt;&amp;2
fi
((essai++))
done
fi
# SWAP
print -P -- &quot;%B[Swap des Répertoires (tmp &lt;=&gt; target)]%b&quot;
essai=1
while [[ -e $destRep.old ]]; do
print -n -- &quot;suppression de $destRep.old&quot;
if ((essai&gt;1)); then
print &quot; (essai n°$essai)&quot;
else
print
fi
((essai++))
\rm -rf $destRep.old
done
print -- &quot; renommage du repertoire sandard vers le .old&quot;
essai=1
while [[ -e $destRep ]]; do
mv $destRep $destRep.old
(($?)) &amp;&amp; print -- &quot;Echec du renommage (essai n°$essai)&quot; &gt;&amp;2
((essai++))
done
print -- &quot; renommage du repertoire tmp (nouveau) vers le standard&quot;
print -P -- &quot; %BSite Indisponible%b $(date)&quot;
essai=1
while [[ ! -e $destRep ]]; do
mv $destRep.tmp $destRep
(($?)) &amp;&amp; print -P -- &quot;%B[Site Indisponible]%b(essai n°$essai) Echec du renommage (mv $destRep.tmp $destRep)&quot; &gt;&amp;2
((essai++))
done
print -P -- &quot;\t===\t%BSITE DISPONIBLE%b\t===&quot;
print -- &quot; renommage du repertoire old vers le tmp&quot;
essai=1
while [[ ! -e $destRep ]]; do
mv $destRep.old $destRep.tmp
(($?)) &amp;&amp; print -P -- &quot;Echec du renommage n°$essai&quot; &gt;&amp;2
((essai++))
done
print -P -- &quot; publication terminée&quot;</code></pre>
</div>
<div class="en">
<pre class="zsh"><code>#!/usr/bin/env zsh
# Author: Yann Esposito
# Mail: yann.esposito@gmail.com
# Synchronize with &quot;mobileMe&quot; iDisk account.
mobileMeUser=&quot;firstname.lastname&quot;
siteName=&quot;siteName&quot;
# Depending of my hostname the
if [[ $(hostname) == &#39;ubuntu&#39; ]]; then
iDisk=&#39;/mnt/iDisk&#39;
else
iDisk=&quot;/Volumes/$mobileMeUser&quot;
fi
root=$HOME/Sites/$siteName
destRep=$iDisk/Web/Sites/$siteName
[[ ! -d $root ]] &amp;&amp; {
print -- &quot;$root does not exist ; please verify the configuration ($0)&quot; &gt;&amp;2;
exit 1
}
[[ ! -d $destRep ]] &amp;&amp; {
print -- &quot;$destRep does not exist, please mount the filesystem&quot; &gt;&amp;2;
exit 1
}
if [[ $1 == &#39;-h&#39; ]]; then
print -- &quot;usage: $0:h [-h|-a|-s]&quot;
print -- &quot; -a sychronize primary index&quot;
print -- &quot; -h show this help&quot;
print -- &quot; -s only swap directories&quot;
fi
if [[ $1 == &#39;-a&#39; ]]; then
print -- &quot;Index synchronisation (${destRep:h})&quot;
rsync -av $root/index.html ${destRep:h}/index.html
fi
print -- &quot;Root = $root&quot;
print -- &quot;Dest = $destRep&quot;
if [[ ! $1 = &#39;-s&#39; ]]; then
[[ ! -d $destRep.tmp ]] &amp;&amp; mkdir $destRep.tmp
print -P -- &quot;%B[Sync =&gt; tmp]%b&quot;
result=1
essai=1
while (( $result &gt; 0 )); do
rsync -arv $root/Scratch/ $destRep.tmp
result=$?
if (( $result &gt; 0 )); then
print -P -- &quot;%Brsync failed%b (try n°$essai)&quot; &gt;&amp;2
fi
((essai++))
done
fi
# SWAP
print -P -- &quot;%B[Directory Swap (tmp &lt;=&gt; target)]%b&quot;
essai=1
while [[ -e $destRep.old ]]; do
print -n -- &quot;remove $destRep.old&quot;
if ((essai&gt;1)); then
print &quot; (try n°$essai)&quot;
else
print
fi
((essai++))
\rm -rf $destRep.old
done
print -- &quot; renommage du repertoire sandard vers le .old&quot;
essai=1
while [[ -e $destRep ]]; do
mv $destRep $destRep.old
(($?)) &amp;&amp; print -- &quot;Failed to rename (try n°$essai)&quot; &gt;&amp;2
((essai++))
done
print -- &quot; renaming folder tmp (new) to the standard one&quot;
print -P -- &quot; %BThe WebSite isn&#39;t working%b $(date)&quot;
essai=1
while [[ ! -e $destRep ]]; do
mv $destRep.tmp $destRep
(($?)) &amp;&amp; print -P -- &quot;%B[WebSite not working]%b(try n°$essai) Failed to rename (mv $destRep.tmp $destRep)&quot; &gt;&amp;2
((essai++))
done
print -P -- &quot;\t===\t%BWEBSITE SHOULD WORK NOW%b\t===&quot;
print -- &quot; rename old folder to tmp folder&quot;
essai=1
while [[ ! -e $destRep ]]; do
mv $destRep.old $destRep.tmp
(($?)) &amp;&amp; print -P -- &quot;Failed to rename n°$essai&quot; &gt;&amp;2
((essai++))
done
print -P -- &quot; Publish terminated&quot;</code></pre>
</div>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2009-09-11
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,160 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - Load Disqus Asynchronously</title>
<meta name="keywords" content="disqus, web, javascript, intense debate, comments">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/11_Load_Disqus_Asynchronously/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>Load Disqus Asynchronously</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<h1 id="update">Update</h1>
<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 didnt have any comment on my blog when I switched. Therefore my lack of influence was a good thing :-).</p>
<hr />
<p>Before begining, I must state that I <strong>love</strong> Disqus.</p>
<p>I know there is a similar blog entry at <a href="http://trephine.org/t/index.php?title=Site_improvements_-_fighting_with_Disqus">Trephine.org</a>. Here I just add a straight and easy way to load disqus asynchronously using jQuery.</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 lets begin.</em></p>
<hr />
<h1 id="why">Why?</h1>
<p>Why should I want to load the disqus javascript asynchronously?</p>
<ul>
<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>
</ul>
<hr />
<h1 id="how">How?</h1>
<p>I give a solution with jQuery, but Im certain it will work with many other js library.</p>
<h3 id="javascript">Javascript</h3>
<p>replace:</p>
<div>
<pre class="sourceCode javascript"><code class="sourceCode javascript">&lt;script type=<span class="st">&quot;text/javascript&quot;</span> src=<span class="st">&quot;http://disqus.com/forums/YOUR_DISQUS_ID/embed.js&quot;</span>&gt;&lt;/script&gt;</code></pre>
</div>
<p>by</p>
<div>
<pre class="sourceCode javascript"><code class="sourceCode javascript"><span class="kw">window</span>.<span class="fu">disqus</span>_<span class="fu">no</span>_<span class="fu">style</span>=<span class="kw">true</span>;
$(<span class="kw">document</span>).<span class="fu">ready</span>(<span class="kw">function</span>(){
$.<span class="fu">getScript</span>(<span class="st">&quot;http://disqus.com/forums/YOUR_DISQUS_ID/embed.js&quot;</span>);
});</code></pre>
</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>
<h3 id="css">CSS</h3>
<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 />
<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 id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2009-09-17
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,147 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - Disqus versus Intense Debate (Why I switched)</title>
<meta name="keywords" content="disqus, intense debate, web, blog">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/2009-09-Disqus-versus-Intense-Debate--Why-I-switched-/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>Disqus versus Intense Debate (Why I switched)</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<h1 id="disqus-vs.-intense-debate"><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 “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>I am a bit sad to quit <a href="http://disqus.com">Disqus</a> because I must confess <a href="http://giannii.com">giannii</a> had helped me has efficiently as he could. But the problem I had with disqus are inherent to some design choice not simply technical ones.</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, youve just to download their common js and replace the following line:</p>
<div>
<pre class="sourceCode javascript"><code class="sourceCode javascript"><span class="kw">document</span>.<span class="fu">getElementsByTagName</span>(<span class="st">&quot;head&quot;</span>)[<span class="dv">0</span>].<span class="fu">appendChild</span>(commentScript);</code></pre>
</div>
<p>by:</p>
<div>
<pre class="sourceCode javascript"><code class="sourceCode javascript">$(<span class="kw">document</span>).<span class="fu">ready</span>( <span class="kw">function</span>() {
<span class="kw">document</span>.<span class="fu">getElementsByTagName</span>(<span class="st">&quot;head&quot;</span>)[<span class="dv">0</span>].<span class="fu">appendChild</span>(commentScript);
});</code></pre>
</div>
<h2 id="and-the-winner-is-intense-debate">And the Winner is: <a href="http://intensedebate.com/">Intense Debate</a></h2>
<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>
<li>Load Asynchronously ; dont block my website</li>
<li>Add for free buttons like “share to any” and load them <strong>asynchronously</strong>.</li>
</ul>
<p>Voilà.</p>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2009-09-28
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,316 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - jQuery Tag Cloud</title>
<meta name="keywords" content="jQuery, javascript, web, ruby">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/2009-09-jQuery-Tag-Cloud/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>jQuery Tag Cloud</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<p>Here is how I done the tag cloud of my blog. It is done mostly in jQuery. All my site is static and pages are generated with <a href="nanoc.stoneship.org">nanoc</a>. It is (in my humble opinion) the modern geek way to make a website. The tagcloud should work for machine with and without javascript.</p>
<p>This is why Ill give only a Ruby Generator, not a full javascript generator. But you can easily translate from Ruby to Javascript.</p>
<p>Here is what you should obtain:</p>
<hr />
<div>
&lt;%= tagCloud %&gt;
</div>
<hr />
<h1 id="jquery">jQuery</h1>
<p>Here is the simple jQuery code:</p>
<div>
<pre class="sourceCode javascript"><code class="sourceCode javascript"> $(<span class="kw">document</span>).<span class="fu">ready</span>( <span class="kw">function</span>(){$(<span class="ch">&#39;.list&#39;</span>).<span class="fu">hide</span>();} );
<span class="kw">function</span> tagSelected(id) {
$(<span class="ch">&#39;.list&#39;</span>).<span class="fu">hide</span>();
$(<span class="ch">&#39;#&#39;</span>+id).<span class="fu">fadeIn</span>();
$(<span class="ch">&#39;.tag.selected&#39;</span>).<span class="fu">removeClass</span>(<span class="ch">&#39;selected&#39;</span>);
$(<span class="ch">&#39;#tag_&#39;</span>+id).<span class="fu">addClass</span>(<span class="ch">&#39;selected&#39;</span>);
}</code></pre>
</div>
<p>This code will hide all the div containing links to articles containing the tag. And create a function do show the div containing the tag.</p>
<p>For each tag I create a span element:</p>
<div>
<pre class="sourceCode html"><code class="sourceCode html"> <span class="kw">&lt;span</span><span class="ot"> style=</span><span class="st">&quot;font-size: 1.0em;&quot;</span>
<span class="ot"> class=</span><span class="st">&quot;tag&quot;</span>
<span class="ot"> onClick=</span><span class="st">&quot;tagSelected(&#39;[TAG]&#39;)&quot;</span>
<span class="ot"> id=</span><span class="st">&quot;tag_[TAG]&quot;</span><span class="kw">&gt;</span>
[TAG]
<span class="kw">&lt;/span&gt;</span> </code></pre>
</div>
<p>and a div containing links associtated to this tag:</p>
<div>
<pre class="sourceCode html"><code class="sourceCode html"> <span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">&quot;[TAG]&quot;</span><span class="kw">&gt;</span>
<span class="kw">&lt;h4&gt;</span>[TAG]<span class="kw">&lt;/h4&gt;</span>
<span class="kw">&lt;ul&gt;</span>
<span class="kw">&lt;li&gt;</span> LINK 1 <span class="kw">&lt;/li&gt;</span>
<span class="kw">&lt;li&gt;</span> LINK 2 <span class="kw">&lt;/li&gt;</span>
<span class="kw">&lt;/ul&gt;</span>
<span class="kw">&lt;/div&gt;</span> </code></pre>
</div>
<hr />
<h1 id="nanoc">nanoc</h1>
<p>Here is how I generate this using nanoc 2.</p>
<p>If you want to make it fully jQuery one, it shouldnt be too difficult, to use my ruby code and translate it into javascript.</p>
<p>In a first time <code>tags</code> correpond of the list of all tags.</p>
<div>
<pre class="sourceCode ruby"><code class="sourceCode ruby"><span class="kw">def</span> tags
<span class="kw">return</span> <span class="ot">@items</span>.tags.join(<span class="st">&#39;, &#39;</span>)
<span class="kw">end</span></code></pre>
</div>
<p>A function to create a data structure associating to each tag its occurence.</p>
<div>
<pre class="sourceCode ruby"><code class="sourceCode ruby"><span class="co"># generate an hash tag =&gt; number of occurence of tag</span>
<span class="kw">def</span> tagNumber
tags={}
<span class="ot">@items</span>.each <span class="kw">do</span> |p|
<span class="kw">if</span> p.tags.nil?
<span class="kw">next</span>
<span class="kw">end</span>
p.tags.each <span class="kw">do</span> |t|
<span class="kw">if</span> tags[t]
tags[t]+=<span class="dv">1</span>
<span class="kw">else</span>
tags[t]=<span class="dv">1</span>
<span class="kw">end</span>
<span class="kw">end</span>
<span class="kw">end</span>
<span class="kw">return</span> tags
<span class="kw">end</span></code></pre>
</div>
<p>I also need a data structure who associate to each tag a list of pages (at least url and title).</p>
<div>
<pre class="sourceCode ruby"><code class="sourceCode ruby"><span class="co"># generate an hash tag =&gt; [ page1, page2 ... ]</span>
<span class="kw">def</span> tagRefs
tagLinks={}
<span class="ot">@items</span>.each <span class="kw">do</span> |p|
<span class="kw">if</span> p.tags.nil?
<span class="kw">next</span>
<span class="kw">end</span>
p.tags.each <span class="kw">do</span> |t|
<span class="kw">if</span> tagLinks[t].nil?
tagLinks[t]=[ p ]
<span class="kw">else</span>
tagLinks[t] &lt;&lt;= p
<span class="kw">end</span>
<span class="kw">end</span>
<span class="kw">end</span>
<span class="kw">return</span> tagLinks
<span class="kw">end</span></code></pre>
</div>
<p>Calculate the real size of each tag to be displayed.</p>
<p>I choosen not to use the full range of size for all the tag. Because if no tag has more than <code>n</code> (here 10) occurences, then it doesnt deserve to be of the maximal size.</p>
<div>
<pre class="sourceCode ruby"><code class="sourceCode ruby"><span class="kw">def</span> tagRealSize
tags=tagNumber
max=tags.values.max
min=tags.values.min
<span class="co"># size in CSS em.</span>
minSize=<span class="fl">1.0</span>
maxSize=<span class="fl">2.5</span>
tagSize={}
tags.each <span class="kw">do</span> |t,n|
<span class="kw">if</span> ( max == min )
tagSize[t]=minSize
<span class="kw">else</span>
<span class="co"># normalized value between 0 and 1</span>
<span class="co"># if not tag appear more than 10 times, </span>
<span class="co"># then it cannot have the maximal size</span>
tagSize[t]=[ ( n - min + <span class="fl">0.0</span> ) / ( max - min ) ,
(n - min) / <span class="fl">10.0</span> ].min
<span class="co"># from normalized size to real size</span>
tagSize[t]=( tagSize[t] ) * (maxSize - minSize) + minSize
<span class="kw">end</span>
<span class="kw">end</span>
<span class="kw">return</span> tagSize
<span class="kw">end</span></code></pre>
</div>
<p>Finaly a function to generate the XHTML/jQuery code</p>
<div>
<pre class="sourceCode ruby"><code class="sourceCode ruby"><span class="co"># generate an XHTML/jQuery code for tag cloud</span>
<span class="kw">def</span> tagCloud
tagLinks=tagRefs
tagSize=tagRealSize
<span class="co"># begin to write the code</span>
tagCloud=<span class="ot">%{</span><span class="st">&lt;script type=&quot;text/javascript&quot;&gt;</span>
<span class="st"> $(document).ready( function(){$(&#39;.list&#39;).hide();} );</span>
<span class="st"> function tagSelected(id) {</span>
<span class="st"> $(&#39;.list&#39;).hide();</span>
<span class="st"> $(&#39;#&#39;+id).fadeIn();</span>
<span class="st"> $(&#39;.tag.selected&#39;).removeClass(&#39;selected&#39;);</span>
<span class="st"> $(&#39;#tag_&#39;+id).addClass(&#39;selected&#39;);</span>
<span class="st"> }</span>
<span class="st"> &lt;/script&gt;&lt;div id=&quot;tagcloud&quot;&gt;</span><span class="ot">}</span>
<span class="co"># Creation of the tags &lt;span&gt;</span>
tagSize.sort{|a,b| a[<span class="dv">0</span>].downcase &lt;=&gt; b[<span class="dv">0</span>].downcase}.each <span class="kw">do</span> |t,s|
tag_in_id=t.gsub(<span class="ot">/\W/</span>,<span class="st">&#39;_&#39;</span>)
<span class="co"># HTML protected version of the tag</span>
<span class="co"># for example, replace &#39; &#39; by &#39;&amp;nbsp;&#39;</span>
<span class="kw">protected</span>=t.gsub(<span class="ot">/&amp;/</span>,<span class="st">&#39;&amp;amp;&#39;</span>).gsub(<span class="ot">/ /</span>,<span class="st">&#39;&amp;nbsp;&#39;</span>).gsub(<span class="ot">/&lt;/</span>,<span class="st">&#39;&amp;lt;&#39;</span>).gsub(<span class="ot">/&gt;/</span>,<span class="st">&#39;&amp;gt;&#39;</span>)
tagCloud &lt;&lt;=<span class="ot"> %{</span>
<span class="st"> &lt;span style=&quot;font-size: </span><span class="ot">#{</span>s<span class="ot">}</span><span class="st">em;&quot; </span>
<span class="st"> class=&quot;tag&quot; </span>
<span class="st"> onClick=&quot;tagSelected(&#39;</span><span class="ot">#{</span>tag_in_id<span class="ot">}</span><span class="st">&#39;)&quot; </span>
<span class="st"> id=&quot;tag_</span><span class="ot">#{</span>tag_in_id<span class="ot">}</span><span class="st">&quot;&gt;</span>
<span class="st"> </span><span class="ot">#{</span><span class="kw">protected</span><span class="ot">}</span>
<span class="st"> &lt;/span&gt; </span><span class="ot">}</span>
<span class="kw">end</span>
tagCloud &lt;&lt;=<span class="ot"> %{</span><span class="st">&lt;/div&gt;&lt;div id=&quot;hiddenDivs&quot; &gt;</span><span class="ot">}</span>
<span class="co"># Creation of the divs containing links associated to a tag.</span>
tagLinks.each <span class="kw">do</span> |t,l|
tag_in_id=t.gsub(<span class="ot">/\W/</span>,<span class="st">&#39;_&#39;</span>)
tagCloud &lt;&lt;=<span class="ot"> %{</span>
<span class="st"> &lt;div id=&quot;</span><span class="ot">#{</span>tag_in_id<span class="ot">}</span><span class="st">&quot; class=&quot;list&quot;&gt;</span>
<span class="st"> &lt;h4&gt;</span><span class="ot">#{</span>t<span class="ot">}</span><span class="st">&lt;/h4&gt;&lt;ul&gt;</span><span class="ot">}</span>
<span class="co"># generate the link list</span>
l.each <span class="kw">do</span> |p|
tagCloud &lt;&lt;=<span class="ot"> %{</span><span class="st">&lt;li&gt;&lt;a href=&quot;</span><span class="ot">#{</span>p.path<span class="ot">}</span><span class="st">&quot;&gt;</span><span class="ot">#{</span>p.title<span class="ot">}</span><span class="st">&lt;/a&gt;&lt;/li&gt;</span><span class="ot">}</span>
<span class="kw">end</span>
tagCloud &lt;&lt;=<span class="ot"> %{</span><span class="st">&lt;/ul&gt;&lt;/div&gt;</span><span class="ot">}</span>
<span class="kw">end</span>
tagCloud &lt;&lt;=<span class="ot"> %{</span><span class="st">&lt;/div&gt;</span><span class="ot">}</span>
<span class="kw">return</span> tagCloud <span class="co"># yeah I know it is not necessary</span>
<span class="kw">end</span></code></pre>
</div>
<p>You can <a href="/Scratch/en/blog/2009-09-jQuery-Tag-Cloud/code/tag.rb">download the complete file</a> to put in your lib directory.</p>
<p>Of course to be nice you need the associated CSS</p>
<div>
<pre class="sourceCode css"><code class="sourceCode css">
// Change the color when mouse over
<span class="fl">.tag</span><span class="dv">:hover</span> <span class="kw">{</span>
<span class="kw">color:</span> <span class="dt">#cc0000</span><span class="kw">;</span> <span class="kw">}</span>
// Change the color when tag selected
<span class="fl">.tag.selected</span> <span class="kw">{</span>
<span class="kw">color:</span> <span class="dt">#6c0000</span><span class="kw">;</span> <span class="kw">}</span>
// a bit of space and pointer cursor
<span class="fl">.tag</span> <span class="kw">{</span>
<span class="kw">cursor:</span> <span class="dt">pointer</span><span class="kw">;</span>
<span class="kw">margin-left:</span> <span class="dt">.5em</span><span class="kw">;</span>
<span class="kw">margin-right:</span> <span class="dt">.5em</span><span class="kw">;</span> <span class="kw">}</span></code></pre>
</div>
<p>Thats all folks.</p>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2009-09-23
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,191 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - replace all except some part</title>
<meta name="keywords" content="ruby, regexp, regular expression">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/2009-09-replace-all-except-some-part/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>replace all except some part</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<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 dont want to be filtered. For example</p>
<div>
<pre class="sourceCode html"><code class="sourceCode html">...
text
...
BEGIN not to filter
...
text
...
END not to filter
...
text
...</code></pre>
</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>
<div>
<pre class="sourceCode ruby"><code class="sourceCode ruby"><span class="kw">def</span> allExceptCode( f, content )
<span class="co"># Beware the behaviour will change if you add</span>
<span class="co"># parenthesis (groups) to the regexp!</span>
regexp=<span class="ot">/&lt;code[^&gt;]*&gt;.*?&lt;\/code&gt;|&lt;pre[^&gt;]*&gt;.*?&lt;\/pre&gt;/m</span>
tmp=<span class="st">&quot;&quot;</span>
mem=[]
content.scan(regexp).each <span class="kw">do</span> |c|
mem &lt;&lt;= c
<span class="kw">end</span>
i=<span class="dv">0</span>
content.split(regexp).each <span class="kw">do</span> |x|
tmp &lt;&lt;= send(f,x)
<span class="kw">if</span> <span class="kw">not</span> mem[i].nil?
tmp &lt;&lt;= mem[i]
i+=<span class="dv">1</span>
<span class="kw">end</span>
<span class="kw">end</span>
tmp
<span class="kw">end</span></code></pre>
</div>
<p>An usage is:</p>
<div>
<pre class="sourceCode ruby"><code class="sourceCode ruby"><span class="kw">def</span> filter(content)
content.gsub(<span class="ot">/e/</span>,<span class="st">&#39;X&#39;</span>)
<span class="kw">end</span>
...
allExceptCode(<span class="st">:filter</span>, content)
...</code></pre>
</div>
<p>A better syntax would be:</p>
<div>
<pre class="sourceCode ruby"><code class="sourceCode ruby"><span class="co"># !!!!!!!!!! THIS SYNTAX DOES NOT WORK !!!!!!! #</span>
<span class="kw">def</span> allExceptCode( f, content )
regexp=<span class="ot">/&lt;code[^&gt;]*&gt;.*?&lt;\/code&gt;/m</span>
tmp=<span class="st">&quot;&quot;</span>
content.split(regexp).each <span class="kw">do</span> |x|
separator=<span class="dt">$&amp;</span>
tmp &lt;&lt;= send(f,x)
<span class="kw">if</span> <span class="kw">not</span> separator.nil?
tmp &lt;&lt;= separator
<span class="kw">end</span>
<span class="kw">end</span>
tmp
<span class="kw">end</span></code></pre>
</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>If someone know a nicer way to do that I will be happy to know how.</p>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2009-09-22
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,118 @@
#!/usr/bin/env zsh
# Script synchronisant le site sur me.com
# normalement, le site est indisponible le moins de temps possible
# le temps de deux renommages de répertoire
# get configuration
# mostly directories
source $0:h/config
# 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 {
local ydestRep=$destRep$suffix
localRef="$srcRep/map.yrf"
print -- "Creation du fichier de references"
create-reference-file.sh > $localRef
remoteRef="/tmp/remoteSiteMapRef.$$.yrf"
if [[ ! -e "$ydestRep/map.yrf" ]]; then
# pas de fichier de reference sur la cible
print -- "pas de fichier de reference sur la cible, passage en mode rsync"
rsyncPublish
swap
else
trycp "$ydestRep/map.yrf" "$remoteRef"
typeset -U filesToUpdate
filesToUpdate=( $(diff $localRef $remoteRef | awk '/^[<>]/ {print $2}' ) )
if ((${#filesToUpdate} == 1)); then
print -- "Seul le fichier ${filesToUpdate} sera téléversé"
elif ((${#filesToUpdate}<10)); then
print -- "${#filesToUpdate} fichiers seront téléversés :"
print -- "${filesToUpdate}"
else
print -- "${#filesToUpdate} fichiers seront téléversés"
fi
# copy all file with some differences
# except the map in case of error
for element in $filesToUpdate; do
if [[ $element == "/map.yrf" ]]; then
continue
fi
if [[ -e $srcRep$element ]]; then
trycp $srcRep$element $ydestRep$element
else
tryrm $ydestRep$element
fi
done
# if all went fine, copy the map file
trycp $srcRep/map.yrf $ydestRep/map.yrf
# remove the temporary file
\rm $remoteRef
# if we have used the tmp directory we swap
if [[ "$suffix" != "" ]]; then
swap
fi
fi
}
# publication via rsync
function rsyncPublish {
result=1
essai=1
while (( $result > 0 )); do
print -- rsync -arv $srcRep/ $destRep.tmp
if ((!testmode)); then
rsync -arv $srcRep/ $destRep.tmp
fi
result=$?
if (( $result > 0 )); then
print -P -- "%BEchec du rsync%b (essai n°$essai)" >&2
fi
((essai++))
done
}
# swap
function swap {
print -P -- "%B[Directory Swap (tmp <=> target)]%b"
[[ -e $destRep.old ]] && tryrm $destRep.old
print -- " renommage du repertoire sandard vers le .old"
tryrename $destRep $destRep.old
print -- " renommage du repertoire tmp (nouveau) vers le standard"
print -P -- "%B[Site Indisponible]%b $(date)"
tryrename $destRep.tmp $destRep
print -P -- "%B[Site Disponible]%b $(date)"
print -- " renommage du repertoire old vers le tmp"
tryrename $destRep.old $destRep.tmp
print -P -- " publication terminée"
}
print -- "Root = $webroot"
print -- "Dest = $destRep"
if [[ "$1" = "-s" ]]; then
swap
else
if [[ "$1" = "-d" ]]; then
suffix=""
else
suffix=".tmp"
fi
print -P -- "%BSync%b[${Root:t} => ${destRep:t}$suffix]"
incrementalPublish
fi

View file

@ -0,0 +1,108 @@
#!/usr/bin/env zsh
function samelineprint {
print -n -P -- "\r$*"
}
# avec 1 essai par seconde: 300 = 5 minutes
maxessais=300
# try to create a directory until success
function trymkdir {
target="$1"
print -- mkdir -p $target
local essai=1
while ! mkdir -p $target; do
samelineprint "Echec: essai n°$essai"
((essai++))
((essai>maxessais)) && exit 5
done
print
}
# try to copy until success
function trycp {
element="$1"
target="$2"
if [[ ! -d ${target:h} ]]; then
trymkdir ${target:h}
fi
local essai=1
print -- cp $element $target
while ! \cp $element $target; do
samelineprint "Echec: essai n°$essai"
((essai++))
((essai>maxessais)) && exit 5
done
print
}
# try to remove until success
function tryrm {
target="$1"
local essai=1
local options=''
[[ -d $target ]] && options='-rf'
print -- rm $options $target
while ! rm $options $target; do
samelineprint "Echec: essai n°$essai"
((essai++))
((essai>maxessais)) && exit 5
done
essai=1
while [[ -e $element ]]; do
samelineprint "rm reussi mais fichier source non disparu n°$essai"
sleep 1
((essai++))
((essai>maxessais)) && exit 5
done
print
}
# try to rename until success
function tryrename {
element="$1"
target="$2"
local essai=1
while [[ -e $target ]]; do
samelineprint "Echec n°$essai le fichier $target existe déjà"
((essai++))
((essai>maxessais)) && exit 5
sleep 1
done
print -- mv $element $target
while ! mv $element $target; do
samelineprint "Echec: essai n°$essai"
((essai++))
((essai>maxessais)) && exit 4
done
essai=1
while [[ -e $element ]]; do
samelineprint "mv reussi mais fichier source non disparu n°$essai"
sleep 1
((essai++))
((essai>maxessais)) && exit 5
done
print
}
# try to move until success
function trymv {
element="$1"
target="$2"
local essai=1
print -- mv $element $target
while ! mv $element $target; do
samelineprint "Echec: essai n°$essai"
((essai++))
((essai>maxessais)) && exit 5
done
essai=1
while [[ -e $element ]]; do
samelineprint "mv reussi mais fichier source non disparu n°$essai"
sleep 1
((essai++))
((essai>maxessais)) && exit 5
done
print
}

View file

@ -0,0 +1,196 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - custom website synchronisation with mobileme (2)</title>
<meta name="keywords" content="Apple, mobileme, WebDav, synchronisation, zsh, script">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/2009-10-28-custom-website-synchronisation-with-mobileme--2-/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>custom website synchronisation with mobileme (2)</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<p>I already talked about how <a href="/Scratch/en/blog/10_Synchronize_Custom_WebSite_with_mobileMe">I synchronized my website with mobileme</a>. I ameliorated this script in order to make it incremental.</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 webdav issues. For example, renaming a folder work really badly (on Linux at least). I use webdavfs. For example:</p>
<div>
<code class="zsh"> mv folder folder2 </code>
</div>
<p>It returns OK and Ive got:</p>
<div>
<code class="zsh"> $ ls folder folder2 </code>
</div>
<p>Booh….</p>
<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>
<div>
<p><code class="zsh" file="webdav-framework"> #!/usr/bin/env zsh</p>
<p>function samelineprint { print -n -P “$*” }</p>
<h1 id="avec-1-essai-par-seconde-300-5-minutes">avec 1 essai par seconde: 300 = 5 minutes</h1>
<p>maxessais=300</p>
<h1 id="try-to-create-a-directory-until-success">try to create a directory until success</h1>
<p>function trymkdir { target=“<span class="math">$1&quot; print -- mkdir -p $</span>target local essai=1 while ! mkdir -p <span class="math">$target; do samelineprint &quot;Echec: essai n°$</span>essai” ((essai++)) ((essai&gt;maxessais)) &amp;&amp; exit 5 done print }</p>
<h1 id="try-to-copy-until-success">try to copy until success</h1>
<p>function trycp { element=“$1” target=“<span class="math">$2&quot; if [[ ! -d $</span>{target:h} ]]; then trymkdir <span class="math"><em>t</em><em>a</em><em>r</em><em>g</em><em>e</em><em>t</em>:<em>h</em><em>f</em><em>i</em><em>l</em><em>o</em><em>c</em><em>a</em><em>l</em><em>e</em><em>s</em><em>s</em><em>a</em><em>i</em>=1<em>p</em><em>r</em><em>i</em><em>n</em><em>t</em><em>c</em><em>p</em></span>element <span class="math">$target while ! \cp $</span>element <span class="math">$target; do samelineprint &quot;Echec: essai n°$</span>essai” ((essai++)) ((essai&gt;maxessais)) &amp;&amp; exit 5 done print }</p>
<h1 id="try-to-remove-until-success">try to remove until success</h1>
<p>function tryrm { target=“<span class="math">$1&quot; local essai=1 local options='' [[ -d $</span>target ]] &amp;&amp; options=-rf print rm <span class="math"><em>o</em><em>p</em><em>t</em><em>i</em><em>o</em><em>n</em><em>s</em></span>target while ! rm <span class="math"><em>o</em><em>p</em><em>t</em><em>i</em><em>o</em><em>n</em><em>s</em></span>target; do samelineprint”Echec: essai n°<span class="math">$essai&quot; ((essai++)) ((essai&gt;maxessais)) &amp;&amp; exit 5 done essai=1 while [[ -e $</span>element ]]; do samelineprint “rm reussi mais fichier source non disparu n°$essai” sleep 1 ((essai++)) ((essai&gt;maxessais)) &amp;&amp; exit 5 done print }</p>
<h1 id="try-to-rename-until-success">try to rename until success</h1>
<p>function tryrename { element=“$1” target=“<span class="math">$2&quot; local essai=1 while [[ -e $</span>target ]]; do samelineprint”Echec n°<span class="math"><em>e</em><em>s</em><em>s</em><em>a</em><em>i</em><em>l</em><em>e</em><em>f</em><em>i</em><em>c</em><em>h</em><em>i</em><em>e</em><em>r</em></span>target existe déjà&quot; ((essai++)) ((essai&gt;maxessais)) &amp;&amp; exit 5 sleep 1 done print mv <span class="math"><em>e</em><em>l</em><em>e</em><em>m</em><em>e</em><em>n</em><em>t</em></span>target while ! mv <span class="math"><em>e</em><em>l</em><em>e</em><em>m</em><em>e</em><em>n</em><em>t</em></span>target; do samelineprint “Echec: essai n°<span class="math">$essai&quot; ((essai++)) ((essai&gt;maxessais)) &amp;&amp; exit 4 done essai=1 while [[ -e $</span>element ]]; do samelineprint”mv reussi mais fichier source non disparu n°$essai&quot; sleep 1 ((essai++)) ((essai&gt;maxessais)) &amp;&amp; exit 5 done print }</p>
<h1 id="try-to-move-until-success">try to move until success</h1>
function trymv { element=“$1” target=“<span class="math">$2&quot; local essai=1 print -- mv $</span>element <span class="math"><em>t</em><em>a</em><em>r</em><em>g</em><em>e</em><em>t</em><em>w</em><em>h</em><em>i</em><em>l</em><em>e</em>!<em>m</em><em>v</em></span>element <span class="math">$target; do samelineprint &quot;Echec: essai n°$</span>essai” ((essai++)) ((essai&gt;maxessais)) &amp;&amp; exit 5 done essai=1 while [[ -e $element ]]; do samelineprint “mv reussi mais fichier source non disparu n°$essai” sleep 1 ((essai++)) ((essai&gt;maxessais)) &amp;&amp; exit 5 done print } </code>
</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>
<div>
<p><code class="zsh" file="publish"> #!/usr/bin/env zsh</p>
<h1 id="script-synchronisant-le-site-sur-me.com">Script synchronisant le site sur me.com</h1>
<h1 id="normalement-le-site-est-indisponible-le-moins-de-temps-possible">normalement, le site est indisponible le moins de temps possible</h1>
<h1 id="le-temps-de-deux-renommages-de-répertoire">le temps de deux renommages de répertoire</h1>
<h1 id="get-configuration">get configuration</h1>
<h1 id="mostly-directories">mostly directories</h1>
<p>source $0:h/config</p>
<h1 id="get-trycp-function-copy-until-success">get trycp function (copy until success)</h1>
<p>source $0:h/webdav-framework</p>
<p>if [[ $1 == -h ]]; then print “usage : $0:h [-h|-s|-d]” print &quot; -a sychronise aussi lindex&quot; print &quot; -h affiche laide&quot; print &quot; -d modification directe (pas de swap)&quot; print &quot; -s swappe simplement les répertoires&quot; fi</p>
<h1 id="publication-incrementale">publication incrementale</h1>
<p>function incrementalPublish { local ydestRep=<span class="math"><em>d</em><em>e</em><em>s</em><em>t</em><em>R</em><em>e</em><em>p</em></span>suffix localRef=“<span class="math">$srcRep/map.yrf&quot; print -- &quot;Creation du fichier de references&quot; create-reference-file.sh &gt; $</span>localRef remoteRef=”/tmp/remoteSiteMapRef.<span class="math">$$.yrf&quot; if [[ ! -e &quot;$</span>ydestRep/map.yrf&quot; ]]; then # pas de fichier de reference sur la cible print “pas de fichier de reference sur la cible, passage en mode rsync” rsyncPublish swap else trycp “<span class="math">$ydestRep/map.yrf&quot; &quot;$</span>remoteRef” typeset -U filesToUpdate filesToUpdate=( <span class="math">(<em>d</em><em>i</em><em>f</em><em>f</em></span>localRef $remoteRef | awk /<sup><a href="#fn1" class="footnoteRef" id="fnref1">1</a></sup>/ {print <span class="math">$2}' ) ) if (($</span>{#filesToUpdate} == 1)); then print “Seul le fichier <span class="math">${filesToUpdate} sera téléversé&quot; elif (($</span>{#filesToUpdate}&lt;10)); then print –”<span class="math">${#filesToUpdate} fichiers seront téléversés :&quot; print -- &quot;$</span>{filesToUpdate}&quot; else print &quot;<span class="math">${#filesToUpdate} fichiers seront téléversés&quot; fi # copy all file with some differences # except the map in case of error for element in $</span>filesToUpdate; do if [[ $element == “/map.yrf” ]]; then continue fi if [[ -e <span class="math"><em>s</em><em>r</em><em>c</em><em>R</em><em>e</em><em>p</em></span>element ]]; then trycp <span class="math"><em>s</em><em>r</em><em>c</em><em>R</em><em>e</em><em>p</em></span>element <span class="math"><em>y</em><em>d</em><em>e</em><em>s</em><em>t</em><em>R</em><em>e</em><em>p</em></span>element else tryrm <span class="math"><em>y</em><em>d</em><em>e</em><em>s</em><em>t</em><em>R</em><em>e</em><em>p</em></span>element fi done # if all went fine, copy the map file trycp <span class="math"><em>s</em><em>r</em><em>c</em><em>R</em><em>e</em><em>p</em>/<em>m</em><em>a</em><em>p</em>.<em>y</em><em>r</em><em>f</em></span>ydestRep/map.yrf # remove the temporary file }</p>
<h1 id="publication-via-rsync">publication via rsync</h1>
<p>function rsyncPublish { result=1 essai=1 while (( <span class="math"><em>r</em><em>e</em><em>s</em><em>u</em><em>l</em><em>t</em>&gt;0));<em>d</em><em>o</em><em>p</em><em>r</em><em>i</em><em>n</em><em>t</em><em>r</em><em>s</em><em>y</em><em>n</em><em>c</em><em>a</em><em>r</em><em>v</em></span>srcRep/ <span class="math"><em>d</em><em>e</em><em>s</em><em>t</em><em>R</em><em>e</em><em>p</em>.<em>t</em><em>m</em><em>p</em><em>i</em><em>f</em>((!<em>t</em><em>e</em><em>s</em><em>t</em><em>m</em><em>o</em><em>d</em><em>e</em>));<em>t</em><em>h</em><em>e</em><em>n</em><em>r</em><em>s</em><em>y</em><em>n</em><em>c</em><em>a</em><em>r</em><em>v</em></span>srcRep/ <span class="math"><em>d</em><em>e</em><em>s</em><em>t</em><em>R</em><em>e</em><em>p</em>.<em>t</em><em>m</em><em>p</em><em>f</em><em>i</em><em>r</em><em>e</em><em>s</em><em>u</em><em>l</em><em>t</em>=</span>? if (( <span class="math">$result &gt; 0 )); then print -P -- &quot;%BEchec du rsync%b (essai n°$</span>essai)&quot; &gt;&amp;2 fi ((essai++)) done }</p>
<h1 id="swap">swap</h1>
<p>function swap { print -P “%B[Directory Swap (tmp &lt;=&gt; target)]%b” [[ -e $destRep.old ]] &amp;&amp; tryrm $destRep.old</p>
<pre><code>print -- &quot; renommage du repertoire sandard vers le .old&quot;
tryrename $destRep $destRep.old
print -- &quot; renommage du repertoire tmp (nouveau) vers le standard&quot;
print -P -- &quot;%B[Site Indisponible]%b $(date)&quot;
tryrename $destRep.tmp $destRep
print -P -- &quot;%B[Site Disponible]%b $(date)&quot;
print -- &quot; renommage du repertoire old vers le tmp&quot;
tryrename $destRep.old $destRep.tmp
print -P -- &quot; publication terminée&quot;</code></pre>
<p>}</p>
<p>print “Root = <span class="math">$webroot&quot; print -- &quot;Dest = $</span>destRep”</p>
if [[ “$1” = “-s” ]]; then swap else if [[ “$1” = “-d” ]]; then suffix=“&quot; else suffix=”.tmp&quot; fi print -P “%BSync%b[<span class="math"><em>R</em><em>o</em><em>o</em><em>t</em>:<em>t</em>=&gt;</span>{destRep:t}$suffix]” incrementalPublish fi </code>
</div>
<p>This is my way to replace <code>rsync</code> with filesystem not handling it. Hope it is usefull. Ill be happy to hear a way to handle the webdav rename folder problem. This is really annoying.</p>
<div class="footnotes">
<hr />
<ol>
<li id="fn1"><p>&lt;&gt;<a href="#fnref1"></a></p></li>
</ol>
</div>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2009-10-28
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,17 @@
// Remove all CSS I don't want to use on IE
$('link[rel=stylesheet]').each(function(i)
{
if (this.getAttribute('href') == '/css/layout.css')
this.disabled = true;
if (this.getAttribute('href') == '/css/shadows.css')
this.disabled = true;
if (this.getAttribute('href') == '/css/gen.css')
this.disabled = true;
}) ;
// Append the CSS for IE only
$('head').append('<link rel="stylesheet" type="text/css" href="/css/ie.css"/>');
// I also add a message on top of the page
$('body').prepend('<div id="iemessage"><p><span class="fr"><em>Avec <a href="http://www.firefox.com"> Firefox </a> et <a href="http://www.apple.com/safari">Safari</a> cette page est bien plus jolie !</em></span><span class="en"><em>This page is far nicer with <a href="http://www.firefox.com"> Firefox </a> and <a href="http://www.apple.com/safari">Safari</a>!</em></span></p>.</div>');

View file

@ -0,0 +1,144 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - How to handle evil IE</title>
<meta name="keywords" content="web, webdesign, jQuery">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/2009-10-30-How-to-handle-evil-IE/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>How to handle evil IE</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<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>
<div>
<code class="javascript"> <span class="math">$(document).ready( function() { if ($</span>.browser[“msie”]) { // include the ie.js file $(head).append(
<script type="text/javascript" src="/js/ie.js">
</scr' + 'ipt>); } }); </code>
</div>
<div>
<p><code class="javascript" file="ie.js"> // Remove all CSS I dont want to use on IE $(link[rel=stylesheet]).each(function(i) { if (this.getAttribute(href) == /css/layout.css) this.disabled = true; if (this.getAttribute(href) == /css/shadows.css) this.disabled = true; if (this.getAttribute(href) == /css/gen.css)<br /> this.disabled = true; }) ;</p>
<p>// Append the CSS for IE only $(head).append(<link rel="stylesheet" type="text/css" href="/css/ie.css"/>);</p>
// I also add a message on top of the page $(body).prepend(
<div id="iemessage"><p>
<span class="fr"><em>Avec <a href="http://www.firefox.com"> Firefox </a> et <a href="http://www.apple.com/safari">Safari</a> cette page est bien plus jolie !</em></span><span class="en"><em>This page is far nicer with <a href="http://www.firefox.com"> Firefox </a> and <a href="http://www.apple.com/safari">Safari</a>!</em></span>
</p>
.
</div>
<p>);</p>
</code>
</div>
<p>Thats it.</p>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2009-10-30
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,163 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - Focus &gt; Minimalism</title>
<meta name="keywords" content="jQuery, design, web">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/2009-10-Focus-vs-Minimalism/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>Focus &gt; Minimalism</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<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 Ill prefer to hide the menu only when you are on blog article. For now, I hide the menu everywhere on the website.</p>
<hr />
<h2 id="technical-details">technical details</h2>
<p>For those who want the technical details behind the show/hide menu, here is the simple jQuery code.</p>
<p>The HTML:</p>
<div>
<pre class="sourceCode html"><code class="sourceCode html"><span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">&quot;menuButton&quot;</span><span class="kw">&gt;&lt;/div&gt;</span>
<span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">&quot;entete&quot;</span><span class="kw">&gt;</span>#content of the menu<span class="kw">&lt;/div&gt;</span></code></pre>
</div>
<p>The CSS:</p>
<div>
<p><code class="css"> #menuButton { font-size: 2em; height: 2em; line-height: 1.8em; width: 2em; position: fixed; left: 0; top: 0; z-index: 9001 }</p>
<h1 id="menubuttonhover">menuButton:hover {</h1>
<p>cursor: pointer; }</p>
<h1 id="entete">entete {</h1>
top: 5em; left: 0; position: fixed; width: 10em; z-index: 9000; } ~~~~~~
</div>
<p>The javascript code (using jQuery)</p>
<div>
<pre class="sourceCode javascript"><code class="sourceCode javascript"><span class="kw">function</span> hideMenu() {
$(<span class="ch">&#39;#entete&#39;</span>).<span class="fu">animate</span>({<span class="dt">left</span>:<span class="st">&quot;-10em&quot;</span>}, <span class="dv">500</span> );
$(<span class="ch">&#39;#menuButton&#39;</span>).<span class="fu">html</span>(<span class="ch">&#39;&amp;rarr;&#39;</span>);
}
<span class="kw">function</span> showMenu() {
$(<span class="ch">&#39;#entete&#39;</span>).<span class="fu">animate</span>({<span class="dt">left</span>:<span class="st">&quot;0em&quot;</span>}, <span class="dv">500</span> );
$(<span class="ch">&#39;#menuButton&#39;</span>).<span class="fu">html</span>(<span class="ch">&#39;&amp;larr;&#39;</span>);
}
<span class="kw">function</span> toggleMenu() {
<span class="kw">if</span> ( $(<span class="ch">&#39;#entete&#39;</span>).<span class="fu">css</span>(<span class="ch">&#39;left&#39;</span>)==<span class="ch">&#39;-10em&#39;</span> ) {
showMenu();
} <span class="kw">else</span> {
hideMenu();
}
}</code></pre>
</div>
<p>And the result is shown in the top left corner of this website.</p>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2009-10-22
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,192 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - How to preload your site with style</title>
<meta name="keywords" content="web, jQuery, webdesign">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/2009-10-How-to-preload-your-site-with-style/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>How to preload your site with style</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<h2 id="example">Example</h2>
<p>Here is a live example of what appear while loading my pages.</p>
<div id="demo" style="width:45%; position: relative; height: 8em; background: #333; background-position: 50% 50%; color: #fff; text-align: center; padding-top: 1em; margin-left: auto; margin-right: auto; border: solid 10px rgba(255,255,255,0.7); -webkit-border-radius: 1em; -moz-border-radius: 1em; border-radius: 1em; cursor: pointer; ">
<p>
Hello! Ive finished loading!
</p>
<p>
Click me to see me disapear again.
</p>
<div id="todisapear" style="color: #000; position:absolute;top:0;left:0;text-align: center; padding-top: 1em; width: 100%; background-color: #eee; height: 8em;">
Loading… <img style="border: none; background-color: none; background: none" src="/Scratch/img/loading.gif" alt="loading logo"/>
</div>
<script>
function Rabbit(){
$('#todisapear')
.show()
.animate({opacity: 1.0},3000)
.fadeOut();
}
$(document).ready(function(){
$('#todisapear').animate({opacity: 1.0},3000).fadeOut();
$('#demo').click(Rabbit);
});
</script>
</div>
<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>In order to hide this small artefact, here is how I do that.</p>
<h2 id="code">Code</h2>
<p>In a first time, I added at the top of the body the div hiding all the content.</p>
<div>
<pre class="sourceCode html"><code class="sourceCode html">...
<span class="kw">&lt;body&gt;</span>
<span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">&quot;blackpage&quot;</span><span class="kw">&gt;</span>
content to display during the loading.
<span class="kw">&lt;/div&gt;</span>
...</code></pre>
</div>
<p>and here is the associated CSS to <code>#blackpage</code>:</p>
<div>
<pre class="sourceCode css"><code class="sourceCode css"><span class="fl">#blackpage</span>
top<span class="dv">:</span> 0
left<span class="dv">:</span> 0
width<span class="dv">:</span> 100%
height<span class="dv">:</span> 100%
margin-left<span class="dv">:</span> 0
margin-right<span class="dv">:</span> 0
margin-top<span class="dv">:</span> 0
margin-bottom<span class="dv">:</span> 0
position<span class="dv">:</span> absolute
text-align<span class="dv">:</span> center
color<span class="dv">:</span> <span class="fl">#666</span>
padding-top<span class="dv">:</span> 10em
background-color<span class="dv">:</span> <span class="fl">#eee</span>
z-index<span class="dv">:</span> 9000</code></pre>
</div>
<p>and the associated jQuery code:</p>
<div>
<pre class="sourceCode javascript"><code class="sourceCode javascript">$(<span class="kw">document</span>).<span class="fu">ready</span>(<span class="kw">function</span>(){
$(<span class="ch">&#39;#blackpage&#39;</span>).<span class="fu">fadeOut</span>();
});</code></pre>
</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>I hope it had helped you!</p>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2009-10-03
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,170 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - Menu waiting to hide himself</title>
<meta name="keywords" content="jQuery, web, javascript, design">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/2009-10-Wait-to-hide-a-menu-in-jQuery/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>Menu waiting to hide himself</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<p>I discussed <a href="/Scratch/en/blog/2009-10-Focus-vs-Minimalism">earlier why I prefer to hide my navigation menu</a>. I finally decided to hide it only after a short time. Just the time needed for a user to see it. But how make it disappear only when it is not used for some time?</p>
<p>Here is how to accomplish that easily.</p>
<p>HTML:</p>
<div>
<pre class="sourceCode html"><code class="sourceCode html"> <span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">&quot;menuButton&quot;</span><span class="kw">&gt;&lt;/div&gt;</span>
<span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">&quot;entete&quot;</span><span class="kw">&gt;</span>
<span class="kw">&lt;ul&gt;</span>
<span class="kw">&lt;li&gt;</span> menu item 1 <span class="kw">&lt;/li&gt;</span>
...
<span class="kw">&lt;li&gt;</span> menu item n <span class="kw">&lt;/li&gt;</span>
<span class="kw">&lt;/ul&gt;</span>
<span class="kw">&lt;/div&gt;</span></code></pre>
</div>
<p>CSS:</p>
<div>
<p><code class="css"> #entete { top: 1em; left: 0; position: fixed; width: 10em; z-index: 2000; }</p>
<pre><code>#entete {
top: 1em;
height: 22em;
left: 0;
position: fixed;
width: 10em; }</code></pre>
</code>
</div>
<p>Javascript:</p>
<div>
<p><code class="javascript"> var last=0;</p>
<p>// will hide the menu in 5 seconds // if the variable last has not changed its value function autoHideMenu(value) { setTimeout(function(){ if ( last == value ) { hideMenu(); } },5000); }</p>
<p><span class="math">$(document).ready( function() { // show the menu when the mouse is on // the good area $</span>(#menuButton).hover(showMenu);</p>
<pre><code>// If the mouse is on the menu change the
// value of &#39;last&#39;
// try to hide the menu when the mouse
// go out off the menu.
$(&#39;#entete&#39;).hover(
function(){last+=1;},
function(){autoHideMenu(last);} );
autoHideMenu(0);</code></pre>
<p>});</p>
<p>// show / hide menu functions details</p>
<p>// move to the left function hideMenu() { $(#entete).animate({left:“-10em”}, 500 ); }</p>
<p>// move to right and will try to hide in 5 sec. function showMenu() { $(#entete).animate({left:“0em”}, 500 ); last+=1; autoHideMenu(last); }</p>
</code>
</div>
<p>Simple and lightweight. No timer (almost), no memory leak, no Date…</p>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2009-10-26
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,130 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - launch daemon from command line</title>
<meta name="keywords" content="zsh, shell, script, tip">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/2009-10-launch-daemon-from-command-line/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>launch daemon from command line</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<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>
<div>
<code class="zsh"> nohup cmd &amp; ~~~~~~ <small>where <code>cmd</code> is your command.</small>
</div>
<p>I let this command here for me and I wish it could also help someone.</p>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2009-10-23
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,258 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - Untaught Git usage</title>
<meta name="keywords" content="git, dcvs, programming">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/2009-10-untaught-git-usage/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>Untaught Git usage</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<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> “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>
<hr />
<h1 id="my-way-to-decentralisation">My way to decentralisation</h1>
<h3 id="from-svn-to-bazaar">From SVN to Bazaar</h3>
<p>I was a huge user of <a href="http://subversion.tigris.org">subversion (svn)</a>. Until the day I saw this <a href="http://www.youtube.com/watch?v=4XpnKHJAok8">video of Linus Torvald</a>. Where he explain Git and all advantages of <em>Decentralized Concurrent Versioning System</em>(<abbr title="Decentralized Concurrent Versioning System">DCVS</abbr>)</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"></a></sup></p>
<p>After some web searches, I founded three main choices:</p>
<ul>
<li><a href="http://git-scm.com">Git</a></li>
<li><a href="http://bazaar-vcs.org">Bazaar</a></li>
<li><a href="http://selenic.com/mercurial">Mercurial</a></li>
</ul>
<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>
<p>It was really natural to learn when coming from <em>subversion</em>. The <code>pull</code> command corresponding to <code>update</code>, <code>push</code> command to <code>commit</code>. Commands like <code>commit</code> and <code>update</code> are still there if you want to use an SVN <em>workflow</em>.</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. 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>
<blockquote>
<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>
<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 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"></a> - I speak about <em>ClearCase(c)</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">*</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>
<hr />
<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>From one site <em>Parallel World</em> and <em>Patches</em> from the other. There is many equivalent notions in the two point of vue, but also some differences.</p>
<ul>
<li>Bazaar seems base on the <em>Parallel World</em> vision which implies <em>Patches</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>
<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>
<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>You just have to launch a Git command and the local directory reflect the state of the branch you selected.</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 “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>
<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>
<ul>
<li>get or creation of a main repositoy <strong><sc>The Great Repository</sc></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><sc>The Great Repository</sc></strong></li>
</ul>
<p>Heres how you should <strong>not</strong> use Git:</p>
<ul>
<li>Get or creation of a repository</li>
<li>Create a <em>cheap branch</em> which will never push its modification to the main repository.</li>
</ul>
<p>This simple minor difference of point of view confused me a lot.</p>
<h3 id="real-life-usage">Real Life Usage</h3>
<p>Now I have understood all that. I understand why Git has some many people claiming it is the best DCVS.</p>
<p>Cheap branching notion is essential in Git and is a really useful feature. Particularly for this website. But, there are not exactly, completely parallel line of development. Because they are designed to path the main branch. Of course, it is not an obligation, but there are slight messages which tell you this should be used like that.</p>
<p>If I want to separate in a better way some branches I just have to <em>Clone</em> them. And I return exactly in branches Bazaar provided me.</p>
<h3 id="examples">Examples</h3>
<p>For now, I prefer (from far) Bazaar terminology. They are cleaner and more understandable.</p>
<div>
<code class="zsh">bzr revert</code>
</div>
<p>Is clearer than</p>
<div>
<code class="zsh">git reset hard HEAD</code>
</div>
<p>We can tell the same thing about</p>
<div>
<code class="zsh">bzr revert -r -3</code>
</div>
<p>which seems preferable to</p>
<div>
<code class="zsh">git reset hard HEAD~3</code>
</div>
<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>
<center>
OK
</center>
<p>Now, if I want to revert time on on file. We should naturally imagine the command will be:</p>
<div>
<code class="zsh">git reset hard FILE</code>
</div>
<center>
<strong>OF COURSE NOT!</strong>
</center>
<p>The solution is:</p>
<div>
<code class="zsh">git checkout FILE</code>
</div>
<p>What? <strong><code>checkout</code></strong> !? Well, ok. I accept. why not? With Bazaar it is:</p>
<div>
<code class="zsh">git revert FILE</code>
</div>
<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). With Bazaar it is:</p>
<div>
<code class="zsh">cd ../branch</code>
</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>
<div>
<code class="zsh">git checkout branch</code>
</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>Then <code>checkout</code> is the same keyword used to get back in time on a file (BUT NOT ON ALL THE TREE where you have to use <code>reset --hard</code>) and to <strong>change current branch</strong>!</p>
<p>It is totally unnatural. Even if it is theoretically totally justified like you can see in the really good article <a href="http://eagain.net/articles/git-for-computer-scientists/">Git for Computer Scientist</a>. From the user point of vue, it is difficult to do worse than that. It is like somebody made it on purpose to make it the hardest possible to learn and understand.</p>
<blockquote>
<ul>
<li>— Try to find the good keyword for this operation</li>
<li>— Wrong! Try again!</li>
<li>— False, it is not yet right!</li>
</ul>
</blockquote>
<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"></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 ! Just to remember my firsts love with computer science !”</small></p>
<hr />
<h1 id="conclusion">Conclusion</h1>
<h3 id="dcvs-vs.cvs">DCVS vs. CVS ?</h3>
<p>Was it a good idea to change to a <em>decentralised</em> versionning system? Clearly yes. Decentralisation give far much great possibilities. 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>
<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 didnt want for my first DCVS.</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>
<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 dont made alias to correct that. But may be one day I should do that.</p>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2009-10-13
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,19 @@
[color]
branch = auto
diff = auto
status = auto
[alias]
st = status
co = checkout
br = branch
lg = log --pretty=oneline --graph
logfull = log --pretty=fuller --graph --stat -p
unstage = reset HEAD
# there should be an article on what this command do
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\""'
undomerge = reset --hard ORIG_HEAD
conflict = !gitk --left-right HEAD...MERGE_HEAD
# under Mac OS X, you should use gitx instead
# conflict = !gitx --left-right HEAD...MERGE_HEAD
[branch]
autosetupmerge = true

View file

@ -0,0 +1,505 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - Git for n00b</title>
<meta name="keywords" content="git">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/2009-11-12-Git-for-n00b/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>Git for n00b</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<div class="intro">
<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>
<hr />
<h1 id="begin-with-conclusion">Begin with conclusion</h1>
<p>Here is the list of sufficient and necessary command to use <a href="http://git-scm.org" title="Git">Git</a>. There is very few. It is normal not to understand immediately but it is to gives you an idea. Even if this article is long, 95% of <a href="http://git-scm.org" title="Git">Git</a> usage is in these 7 commands:</p>
<p>Get a project from the web:</p>
<pre class="zsh"><code>git clone ssh://server/path/to/project</code></pre>
<p>Everyday <a href="http://git-scm.org" title="Git">Git</a> usage:</p>
<pre class="zsh"><code># get modifications from other
git pull
# read what was done
git log
# Make local changes to files
hack, hack, hack...
# list the modified files
git status
# show what I&#39;ve done
git diff
# tell git to version a new file
git add new/file
# commit its own modifications
# to its local branch
git commit -a -m &quot;Fix bug #321&quot;
# send local modifications to other
git push</code></pre>
<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>
<h1 id="gitgit-for-what"><a href="http://git-scm.org" title="Git">Git</a> for what?</h1>
<div class="intro">
<p>If you just want to use <a href="http://git-scm.org" title="Git">Git</a> <strong>immediately</strong>, just read dark part. You read this part later to understand correctly foundations of version systems and not doing strange things.</p>
</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. Lets analyze each part of this long term:</p>
<h3 id="versions-system">Versions System</h3>
<p>Firstly, versions system manage files. When somebody work with files without a versions system, the following happens frequently:</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>
<pre class="zsh"><code>$ cp fichier_important.c fichier_important.c.bak</code></pre>
<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 class="zsh"><code>fichier_important.c.bak
fichier_important.c.old
fichier_important.c.Bakcup
fichier_important.c.BAK.2009-11-14
fichier_important.c.2009.11.14
fichier_important.c.12112009
old.fichier_important.c</code></pre>
</div>
<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>You only have to signal you want a new version of a file and the versions system will do the job for you. It will record the backup where it could be easily recovered. Generally, systems version do it better than you, making the backup only of the modified lines and not the total file.</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, “I want to get back three days earlier”.</p>
<div class="black">
<p><em>What gives versions system?</em> (I didnt mention everything at all)</p>
<ul>
<li>automatic backups: <em>back in time</em>,</li>
<li>gives the ability to see differences between each version,</li>
<li>put a <em>tag</em> on some version to be able to refer to them easily,</li>
<li>gives the ability to see an historic of all modifications. Generally the user must add a comment for each new version.</li>
</ul>
</div>
<h3 id="concurrent">concurrent:</h3>
<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>Lets begin by an example, a two person project ; 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">
<pre class="zsh"><code>Cthulhu
Shubniggurath
Yogsototh</code></pre>
</div>
Say Alex is home and modify the file:
<div style="width: 10em; margin-left: auto; margin-right: auto">
<pre class="twilight">
Cthulhu
Shubniggurath
<span class="StringConstant"><strong>Soggoth</strong></span>
Yogsototh
</pre>
</div>
<p>after that he send the file on the project server. Then on the server there is the Alex file:</p>
<p>A bit later, Beatrice who had not get the Alex file on the server make the modification:</p>
<div style="width: 10em; margin-left: auto; margin-right: auto">
<pre class="twilight">
Cthulhu
<span class="Constant"><strong>Dagon</strong></span>
Shubniggurath
Yogsototh
</pre>
</div>
<p>Beatrice send her file on the server</p>
<p>Alex modification is <em>lost</em>. One more time, versions system are here to help.</p>
<p>A version system would had <em>merge</em> the two files at the time Beatrice send the file on the server. And like by magic, on the server the file would be:</p>
<div style="width: 10em; margin-left: auto; margin-right: auto">
<pre class="twilight">
Cthulhu
<span class="Constant"><strong>Dagon</strong></span>
Shubniggurath
<span class="StringConstant"><strong>Soggoth</strong></span>
Yogsototh
</pre>
</div>
<p>In real life, at the moment Beatrice want to send her modifications, the versions system alert her a modification had occurred on the server. Then she uses a command which pull the modification from the server to her local computer. And this command update her file. After that, Beatrice send again the new file on the server.</p>
<div class="black">
<p><strong>In what Concurrent Versions System help?</strong></p>
<ul>
<li>get without any problem others modifications,</li>
<li>send without any problem its own modifications to others,</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>
</ul>
</div>
<h3 id="decentralized">decentralized</h3>
<p>This word became popular only recently about CVS. And it mainly means two things:</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>To be more precise, DCVS are base on the <em>branch</em> notion.</p>
<p>Practically, it has great importance. It means, everybody work separately, and the system help to glue all their work.</p>
<p>It is even more than just that. It help to code independently each feature and bug fixes. Under other system it was far more difficult.</p>
<p>Typical example:</p>
<blockquote>
<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>In a not decentralized version system, doing such a thing is possible but not natural. Decentralization means it become natural to use a branch for each separable work.</p>
</blockquote>
<div class="black">
<p><strong>Advantages given by DCVS:</strong></p>
<ul>
<li>Ability to work offline,</li>
<li>Ability to create many <em>atomic</em> patches,</li>
<li>Help the maintenance of many different versions of the same application.</li>
</ul>
</div>
<h2 id="to-resume">To resume</h2>
<p>Lets resume what we can easily do with DCVS:</p>
<p><strong>Versions Systems</strong></p>
<ul>
<li>back in time,</li>
<li>list differences between versions,</li>
<li>name some versions to refer to them easily</li>
<li>show history of modifications</li>
</ul>
<p><strong>Concurrent</strong></p>
<ul>
<li>get others modifications,</li>
<li>send its modifications to others,</li>
<li>know who done what and when,</li>
<li>conflicts management.</li>
</ul>
<p><strong>Decentralized</strong></p>
<ul>
<li>Easily manipulate branches</li>
</ul>
<p>Now lets see how to obtain all these things easily with <a href="http://git-scm.org" title="Git">Git</a>.</p>
<h1 id="before-usage-configuration">Before usage, configuration</h1>
<h2 id="install">install</h2>
<p>Under Linux Ubuntu or Debian:</p>
<pre class="zsh"><code>$ sudo apt-get install git</code></pre>
<p>Under Mac OS X:</p>
<ul>
<li>install <a href="http://macports.org/install.php">MacPorts</a></li>
<li>install <a href="http://git-scm.org" title="Git">Git</a></li>
</ul>
<pre class="zsh"><code>$ sudo port selfupdate
$ sudo port install git-core</code></pre>
<h2 id="global-configuration">Global configuration</h2>
<p>Save the following file as your <code>~/.gitconfig</code>.</p>
<pre><code>[color]
branch = auto
diff = auto
status = auto
[alias]
st = status
co = checkout
br = branch
lg = log --pretty=oneline --graph
logfull = log --pretty=fuller --graph --stat -p
unstage = reset HEAD
# there should be an article on what this command do
uncommit = !zsh -c &#39;&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;&#39;
undomerge = reset --hard ORIG_HEAD
conflict = !gitk --left-right HEAD...MERGE_HEAD
# under Mac OS X, you should use gitx instead
# conflict = !gitx --left-right HEAD...MERGE_HEAD
[branch]
autosetupmerge = true</code></pre>
<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>
<pre class="zsh"><code>$ git config --global user.name John Doe
$ git config --global user.email john.doe@email.com</code></pre>
<p>Here it is. Base configuration is over. The file containing alias will help to type shorter commands.</p>
<h2 id="get-a-project">Get a project</h2>
<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>
<pre class="zsh"><code>$ cd ~/Projets
$ git clone git://main.server/path/to/file</code></pre>
<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>
<pre class="zsh"><code>$ ssh-keygen -t rsa</code></pre>
<p>Reply to question and <strong>do not enter</strong> 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>
<pre class="zsh"><code>me@locahost$ ssh-copy-id ~/.ssh/id_rsa.pub me@main.server</code></pre>
<p>or manually</p>
<pre class="zsh"><code>me@locahost$ scp ~/.ssh/id_rsa.pub me@main.server:
me@locahost$ ssh me@main.server
password:
me@main.server$ cat id_rsa.pub &gt;&gt; ~/.ssh/authorized_keys
me@main.server$ rm id_rsa.pub
me@main.server$ logout</code></pre>
<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>
<p>Suppose you already have a project with files. Then it is really easy to version it.</p>
<pre class="zsh"><code>$ cd /path/to/project
$ git init
$ git add .
$ git commit -m &quot;Initial commit&quot;</code></pre>
<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>
<pre class="zsh"><code>*.o
*.bak
*.swp
*~</code></pre>
<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>
<pre class="zsh"><code>$ cd /path/to/local/project
$ git clone --bare . ssh://server/path/to/project</code></pre>
<p>Others will be able to get your modifications.</p>
<pre class="zsh"><code>git clone ssh://server/path/to/project</code></pre>
<h2 id="abstract-of-the-second-step">Abstract of the second step</h2>
<p>You now have a local directory on your computer. It is versionned and you can say it is, because there is a <code>.git</code> directory at the root (and the root only) of your project. This directory contain all necessary informations for <a href="http://git-scm.org" title="Git">Git</a> to version your project.</p>
<p>Now you only need to know how to use it.</p>
<h1 id="here-we-go">Here we go!</h1>
<p>Here is one from many way to use <a href="http://git-scm.org" title="Git">Git</a>. This method is sufficient to work on a project. Not there is many other <em>workflows</em>.</p>
<h2 id="basic-usage">Basic usage</h2>
<p>Work with <a href="http://git-scm.org" title="Git">Git</a> immediately:</p>
<ul>
<li>Get modification done by others <code>git pull</code>,</li>
<li>See details of these modifications <code>git log</code>,</li>
<li>Many times:</li>
<li><em>Make an atomic modification</em></li>
<li>Verify details of this modification: <code>git status</code> and <code>git diff</code>,</li>
<li>Add some file to be versionned if necessary:<br/><code>git add [file]</code>,</li>
<li>Save you modifications <br/><code>git commit -a -m &quot;message&quot;</code>,</li>
<li>Send your modifications to others: <code>git push</code> (redo a <code>git pull</code> if push return an error).</li>
</ul>
<p>With these few commands you can use <a href="http://git-scm.org" title="Git">Git</a>. Even if it is sufficient, you need to know one more thing before really begin ; How to manage <em>conflicts</em>.</p>
<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 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>
<p>You start from the following file</p>
<div style="width: 18em; margin-left: auto; margin-right: auto">
<pre class="zsh"><code>Zoot </code></pre>
</div>
<p>and you modify one line</p>
<div style="width: 18em; margin-left: auto; margin-right: auto">
<pre class="twilight">
Zoot <span class="Constant"><strong>the pure</strong></span>
</pre>
</div>
<p>except during this time, another user had also modified the same line and had done a <code>push</code>.</p>
<div style="width: 18em; margin-left: auto; margin-right: auto">
<pre class="twilight">
Zoot<span class="StringConstant"><strong>, just Zoot</strong></span>
</pre>
</div>
<p>Now when you do a:</p>
<div>
<pre class="zsh"><code>$ git pull
remote: Counting objects: 5, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From /home/yogsototh/tmp/conflictTest
d3ea395..2dc7ffb master -&gt; origin/master
Auto-merging foo
CONFLICT (content): Merge conflict in foo
Automatic merge failed; fix conflicts and then commit the result.</code></pre>
</div>
<p>Our file <code>foo</code> now contains:</p>
<div>
<pre class="twilight">
<<<<<<< HEAD:foo
Zoot <span class="Constant"><strong>the pure</strong></span>
=======
<span>Zoot<span class="StringConstant"><strong>, just Zoot</strong></span></span>
>>>>>>> 2dc7ffb0f186a407a1814d1a62684342cd54e7d6:foo
</pre>
</div>
<h4 id="conflict-resolution">Conflict resolution</h4>
<p>To resolve the conflict you only have to edit the file for example, writing:</p>
<div style="width: 18em; margin-left: auto; margin-right: auto">
<pre class="twilight">
Zoot <span class="Constant"><strong>the not so pure</strong></span>
</pre>
</div>
<p>and to commit</p>
<div>
<pre class="zsh"><code>git commit -a -m &quot;conflict resolved&quot;</code></pre>
</div>
<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 well see some <a href="http://git-scm.org" title="Git">Git</a> usages older CVS couldnt handle.</p>
<h1 id="why-git-is-cool">Why Git is cool?</h1>
<p>Because with <a href="http://git-scm.org" title="Git">Git</a> you can work on many part of some project totally independently. This is the true efficiency of decentralisation.</p>
<p>Each branch use the same directory. Then you can easily change your branch. You can also change branch when some files are modified. You can then dispatch your work on many different branches and merge them on one master branch at will.</p>
<p>Using the <code>git rebase</code> you can decide which modifications should be forget or merged into only one modification.</p>
<p>What does it mean for real usage? You can focus on coding. For example, you can code, a fix for bug b01 and for bug b02 and code a feature f03. Once finished you can create a branch by bug and by feature. And finally you can merge these modifications on a main branch.</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 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, 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>
<h1 id="command-list">Command List</h1>
<h2 id="command-for-each-functionality">Command for each functionality</h2>
<p>In the first part, we saw the list of resolved problem by <a href="http://git-scm.org" title="Git">Git</a>. To resume <a href="http://git-scm.org" title="Git">Git</a> should do:</p>
<ul>
<li>get others modifications,</li>
<li>send modifications to others,</li>
<li>get back in time,</li>
<li>list differences between each version,</li>
<li>name some versions in order to refer easily to them,</li>
<li>write an historic of modifications,</li>
<li>know who did what and when,</li>
<li>manage conflicts,</li>
<li>easily manage branches.</li>
</ul>
<h3 id="get-others-modifications">get others modifications</h3>
<pre class="zsh"><code>$ git pull</code></pre>
<h3 id="send-modifications-to-others">send modifications to others</h3>
<pre class="zsh"><code>$ git push</code></pre>
<p>or more generally</p>
<pre class="zsh"><code>$ git pull
$ git push</code></pre>
<h3 id="get-back-in-time">get back in time</h3>
<h4 id="for-all-tree">For all tree</h4>
<pre class="zsh"><code>$ git checkout</code></pre>
<pre class="zsh"><code>$ git revert</code></pre>
<p>revert three version before (see my <code>.gitconfig</code> file).</p>
<pre class="zsh"><code>$ git uncommit 3</code></pre>
<p>Undo the las merge (if something goes wrong)</p>
<pre class="zsh"><code>$ git revertbeforemerge</code></pre>
<h4 id="for-one-file">For one file</h4>
<pre class="zsh"><code>$ git checkout file
$ git checkout VersionHash file
$ git checkout HEAD~3 file</code></pre>
<h3 id="list-differences-between-each-version">list differences between each version</h3>
<p>list files being modified</p>
<pre class="zsh"><code>$ git status</code></pre>
<p>differences between last version files and local files</p>
<pre class="zsh"><code>$ git diff</code></pre>
<p>differences between some version and local files</p>
<pre class="zsh"><code>$ git diff VersionHash fichier</code></pre>
<h3 id="name-some-version-to-refer-to-them-in-the-future">name some version to refer to them in the future</h3>
<pre class="zsh"><code>$ git tag &#39;toto&#39;</code></pre>
<h3 id="show-historic-of-modifications">show historic of modifications</h3>
<pre class="zsh"><code>$ git log
$ git lg
$ git logfull</code></pre>
<h3 id="know-who-did-what-and-when">know who did what and when</h3>
<pre class="zsh"><code>$ git blame fichier</code></pre>
<h3 id="handle-conflicts">handle conflicts</h3>
<pre class="zsh"><code>$ git conflict</code></pre>
<h3 id="manage-branches">manage branches</h3>
<p>To create a branch:</p>
<pre class="zsh"><code>$ git branch branch_name</code></pre>
<p>To change the current branch:</p>
<pre class="zsh"><code>$ git checkout branch_name</code></pre>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2009-11-12
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,125 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - iphone call filter</title>
<meta name="keywords" content="iPhone, Apple, filter, blacklist">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/2009-12-06-iphone-call-filter/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>iphone call filter</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<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>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 id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2009-12-06
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,2 @@
[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\""'

View file

@ -0,0 +1,208 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - Git vs. Bzr</title>
<meta name="keywords" content="git, bzr, DCVS, Bazaar">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/2009-12-14-Git-vs--Bzr/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>Git vs. Bzr</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<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 Ill talk about the only advantage of git against Bazaar which lead me to prefer it.</p>
</div>
<h2 id="the-dcvs-discovery">The DCVS discovery</h2>
<p>Before beginning this article, you should know I come from <em>subversion</em>. I find subversion to be a really good CVS. But I was converted to the decentralized ones.</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 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>And it was so fastidious! The <code>git</code> terminology was <em>horrible</em>! And it is nothing to say it.</p>
<h2 id="where-bazaar-is-better-than-git">Where Bazaar is better than <code>git</code></h2>
<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>
<code class="zsh"> git checkout pipo </code>
</div>
<p>undo the current modification of the file <code>pipo</code></p>
<div>
<code class="zsh"> git checkout pipo </code>
</div>
<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>
<div>
<code class="zsh"> git checkout ./pipo </code>
</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>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>
<code class="zsh"> bzr revert pipo </code>
</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>
<div>
<code class="zsh"> bzr revert -r -3 pipo </code>
</div>
<p>The <code>git</code> equivalent is far more cryptic:</p>
<div>
<code class="zsh"> bzr checkout HEAD~3 pipo </code>
</div>
<p>One more time, Bazaar is far more readable.</p>
<p>Back in time for all the project:</p>
<p>with Bazaar:</p>
<div>
<code class="zsh"> bzr revert -r -3 pipo </code>
</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>
<div>
<code class="zsh"> git reset hard HEAD~3 </code>
</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>
<div>
<code class="zsh"> git checkout HEAD~3 . &amp;&amp; git commit -m back in time </code>
</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>
<div>
<code class="zsh"> for i in <span class="math">(<em>s</em><em>e</em><em>q</em>02);<em>d</em><em>o</em><em>g</em><em>i</em><em>t</em><em>r</em><em>e</em><em>v</em><em>e</em><em>r</em><em>t</em><em>n</em><em>n</em><em>o</em><em>e</em><em>d</em><em>i</em><em>t</em><em>h</em><em>e</em><em>a</em><em>d</em></span>i; done git commit -m “reverted 3 versions back” </code>
</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>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. 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>
<code class="zsh" file="gitconfig"> [alias] uncommit = !zsh -c “if ((<span class="math">0));<em>t</em><em>h</em><em>e</em><em>n</em><em>n</em><em>b</em>=</span>(( <span class="math">01));<em>e</em><em>l</em><em>s</em><em>e</em><em>n</em><em>b</em>=0;<em>f</em><em>i</em>;<em>i</em>=0;<em>w</em><em>h</em><em>i</em><em>l</em><em>e</em>((<em>i</em>&lt;=<em>n</em><em>b</em>));<em>d</em><em>o</em><em>g</em><em>i</em><em>t</em><em>r</em><em>e</em><em>v</em><em>e</em><em>r</em><em>t</em><em>n</em><em>n</em><em>o</em><em>e</em><em>d</em><em>i</em><em>t</em><em>H</em><em>E</em><em>A</em><em>D</em></span>i; ((i++)); done; git commit -m &quot;revert to $0 version(s) back&quot;”’ </code>
</div>
<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 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>
<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>
<code class="zsh"> &gt; vim file1 &gt; vim file2 &gt; git br fix1 &gt; git add file1 &gt; git commit -m fix1 &gt; git br fix2 &gt; git add file2 &gt; git commit -m fix2 &gt; git commit master &gt; git merge fix1 &gt; git merge fix2 </code>
</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 I use this possibilities <em>a lot</em>. Working with bazaar, I often made the error to begin a change in the bad branch. then I have to copy my modifications, then revert. In short it was tiedous.</p>
<p>This is why I prefer using <code>git</code> on an every day usage. If Bazaar implement the same way of cheap branching than git. I should switch again.</p>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2009-12-14
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,129 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - Change default shell on Mac OS X</title>
<meta name="keywords" content="Apple, Mac, OS X">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/2010-01-04-Change-default-shell-on-Mac-OS-X/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>Change default shell on Mac OS X</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<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>
<div>
<code class="zsh"> &gt; chsh </code>
</div>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2010-01-04
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,54 @@
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<!-- Miscellaneous settings -->
<include ignore_missing="yes">misc.conf</include>
<!-- Define alias -->
<include ignore_missing="yes">alias.conf</include>
<!-- Rules for Microsoft fonts -->
<include ignore_missing="yes">msfonts-rules.conf</include>
<match target="pattern" name="family" >
<test name="family" qual="any" >
<string>Tahoma</string>
</test>
<edit mode="assign" name="family" >
<string>Verdana</string>
</edit>
</match>
<selectfont>
<acceptfont>
<pattern>
<patelt name="family">
<string>Lucida Grande</string>
</patelt>
</pattern>
</acceptfont>
</selectfont>
<match target="pattern" name="family" >
<test name="family" qual="any" >
<string>Georgia</string>
</test>
<edit mode="assign" name="family" >
<string>Georgia</string>
</edit>
</match>
<selectfont>
<acceptfont>
<pattern>
<patelt name="family">
<string>Century Schoolbook L</string>
</patelt>
</pattern>
</acceptfont>
</selectfont>
</fontconfig>

View file

@ -0,0 +1,183 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - antialias font in Firefox under Ubuntu</title>
<meta name="keywords" content="Linux, Ubuntu, Fonts">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/2010-01-12-antialias-font-in-Firefox-under-Ubuntu/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>antialias font in Firefox under Ubuntu</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<p>How to stop using bad Microsoft© font under Ubuntu Linux in order to user nice anti aliased font under Firefox.</p>
<p>Just modify the <code>/etc/fonts/local.conf</code> with the following code:</p>
<div>
<pre class="sourceCode xml"><code class="sourceCode xml">
<span class="kw">&lt;?xml</span> version=&quot;1.0&quot;<span class="kw">?&gt;</span>
<span class="dt">&lt;!DOCTYPE </span>fontconfig SYSTEM &quot;fonts.dtd&quot;<span class="dt">&gt;</span>
<span class="kw">&lt;fontconfig&gt;</span>
<span class="co">&lt;!-- Miscellaneous settings --&gt;</span>
<span class="kw">&lt;include</span><span class="ot"> ignore_missing=</span><span class="st">&quot;yes&quot;</span><span class="kw">&gt;</span>misc.conf<span class="kw">&lt;/include&gt;</span>
<span class="co">&lt;!-- Define alias --&gt;</span>
<span class="kw">&lt;include</span><span class="ot"> ignore_missing=</span><span class="st">&quot;yes&quot;</span><span class="kw">&gt;</span>alias.conf<span class="kw">&lt;/include&gt;</span>
<span class="co">&lt;!-- Rules for Microsoft fonts --&gt;</span>
<span class="kw">&lt;include</span><span class="ot"> ignore_missing=</span><span class="st">&quot;yes&quot;</span><span class="kw">&gt;</span>msfonts-rules.conf<span class="kw">&lt;/include&gt;</span>
<span class="kw">&lt;match</span><span class="ot"> target=</span><span class="st">&quot;pattern&quot;</span><span class="ot"> name=</span><span class="st">&quot;family&quot;</span> <span class="kw">&gt;</span>
<span class="kw">&lt;test</span><span class="ot"> name=</span><span class="st">&quot;family&quot;</span><span class="ot"> qual=</span><span class="st">&quot;any&quot;</span> <span class="kw">&gt;</span>
<span class="kw">&lt;string&gt;</span>Tahoma<span class="kw">&lt;/string&gt;</span>
<span class="kw">&lt;/test&gt;</span>
<span class="kw">&lt;edit</span><span class="ot"> mode=</span><span class="st">&quot;assign&quot;</span><span class="ot"> name=</span><span class="st">&quot;family&quot;</span> <span class="kw">&gt;</span>
<span class="kw">&lt;string&gt;</span>Verdana<span class="kw">&lt;/string&gt;</span>
<span class="kw">&lt;/edit&gt;</span>
<span class="kw">&lt;/match&gt;</span>
<span class="kw">&lt;selectfont&gt;</span>
<span class="kw">&lt;acceptfont&gt;</span>
<span class="kw">&lt;pattern&gt;</span>
<span class="kw">&lt;patelt</span><span class="ot"> name=</span><span class="st">&quot;family&quot;</span><span class="kw">&gt;</span>
<span class="kw">&lt;string&gt;</span>Lucida Grande<span class="kw">&lt;/string&gt;</span>
<span class="kw">&lt;/patelt&gt;</span>
<span class="kw">&lt;/pattern&gt;</span>
<span class="kw">&lt;/acceptfont&gt;</span>
<span class="kw">&lt;/selectfont&gt;</span>
<span class="kw">&lt;match</span><span class="ot"> target=</span><span class="st">&quot;pattern&quot;</span><span class="ot"> name=</span><span class="st">&quot;family&quot;</span> <span class="kw">&gt;</span>
<span class="kw">&lt;test</span><span class="ot"> name=</span><span class="st">&quot;family&quot;</span><span class="ot"> qual=</span><span class="st">&quot;any&quot;</span> <span class="kw">&gt;</span>
<span class="kw">&lt;string&gt;</span>Georgia<span class="kw">&lt;/string&gt;</span>
<span class="kw">&lt;/test&gt;</span>
<span class="kw">&lt;edit</span><span class="ot"> mode=</span><span class="st">&quot;assign&quot;</span><span class="ot"> name=</span><span class="st">&quot;family&quot;</span> <span class="kw">&gt;</span>
<span class="kw">&lt;string&gt;</span>Georgia<span class="kw">&lt;/string&gt;</span>
<span class="kw">&lt;/edit&gt;</span>
<span class="kw">&lt;/match&gt;</span>
<span class="kw">&lt;selectfont&gt;</span>
<span class="kw">&lt;acceptfont&gt;</span>
<span class="kw">&lt;pattern&gt;</span>
<span class="kw">&lt;patelt</span><span class="ot"> name=</span><span class="st">&quot;family&quot;</span><span class="kw">&gt;</span>
<span class="kw">&lt;string&gt;</span>Century Schoolbook L<span class="kw">&lt;/string&gt;</span>
<span class="kw">&lt;/patelt&gt;</span>
<span class="kw">&lt;/pattern&gt;</span>
<span class="kw">&lt;/acceptfont&gt;</span>
<span class="kw">&lt;/selectfont&gt;</span>
<span class="kw">&lt;/fontconfig&gt;</span></code></pre>
</div>
<p>Hope it helped someone who like me had his eyes crying in face of such ugly fonts.</p>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2010-01-12
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,156 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - Pragmatic Regular Expression Exclude</title>
<meta name="keywords" content="regex, regexp, regular expression, negate">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/2010-02-15-All-but-something-regexp/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>Pragmatic Regular Expression Exclude</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<p>Sometimes you cannot simply write:</p>
<div>
<code class="ruby"> if str.match(regexp) and not str.match(other_regexp) do_something </code>
</div>
<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. 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"></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>
<p><code class="ruby"> # match all string containing bull (bullshit comprised) /bull/</p>
<h1 id="match-all-string-containing-bull-except-bullshit">match all string containing bull except bullshit</h1>
<p>/bull([^s]|<span class="math">)<em>b</em><em>u</em><em>l</em><em>l</em><em>s</em>([<sup><em>h</em></sup>]</span>)| bullsh([^i]|<span class="math">)<em>b</em><em>u</em><em>l</em><em>l</em><em>s</em><em>h</em><em>i</em>([<sup><em>t</em></sup>]</span>)/</p>
<h1 id="another-way-to-write-it-would-be">another way to write it would be</h1>
/bull([^s]|<span class="math"><em>s</em>([<sup><em>h</em></sup>]</span>)|sh([^i]|<span class="math">)<em>s</em><em>h</em><em>i</em>([<sup><em>t</em></sup>]</span>))/ </code>
</div>
<p>Let look closer. In the first line the expression is: <code>bull([^s]|$)</code>, why does the <code>$</code> is needed? Because, without it the word <code>bull</code> would be no more matched. This expression means:</p>
<blockquote>
<p>The string finish by <code>bull</code><br />or,<br />contains <code>bull</code> followed by a letter different from <code>s</code>.</p>
</blockquote>
<p>And this is it. I hope it could help you.</p>
Notice this method is not always the best. For example try to write a regular expression equivalent to the following conditional expression:
<div>
<code class="ruby"> # Begin with a: ^a # End with a: c$ # Contain b: .<em>b.</em> # But isnt axbxc if str.match(/^a.<em>b.</em>c<span class="math">/)<em>a</em><em>n</em><em>d</em><em>n</em><em>o</em><em>t</em><em>s</em><em>t</em><em>r</em>.<em>m</em><em>a</em><em>t</em><em>c</em><em>h</em>(/<sup><em>a</em></sup><em>x</em><em>b</em><em>x</em><em>c</em></span>/) do_something end </code>
</div>
<p>A nice solution is:</p>
<div>
<code class="ruby"> /abc| # length 3 a.bc| # length 4 ab.c| a[^x]b[^x]c| # length 5 a…<em>b.</em>c| # length &gt;5 a.<em>b…</em>c/ </code>
</div>
<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 it is not straightforward to exclude something of a regular expression.</p>
<hr />
<p><small><a name="note1"></a> It can be proved that any regular set minus a finite set is also regular. </small></p>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2010-02-15
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,208 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - Pragmatic Regular Expression Exclude (2)</title>
<meta name="keywords" content="regexp, regular expression">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/2010-02-16-All-but-something-regexp--2-/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>Pragmatic Regular Expression Exclude (2)</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<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 a and b, for example, you want to match:</p>
<pre class="twilight">
a.....<span class="Constant"><strong>a......b</strong></span>..b..a....<span class="Constant"><strong>a....b</strong></span>...
</pre>
<p>Here are two common errors and a solution:</p>
<pre class="twilight">
/a.*b/
<span class="Constant"><strong>a.....a......b..b..a....a....b</strong></span>...
</pre>
<p>The first error is to use the <em>evil</em> <code>.*</code>. Because you will match from the first to the last.</p>
<pre class="twilight">
/a.*?b/
<span class="Constant"><strong>a.....a......b</strong></span>..b..<span class="Constant"><strong>a....a....b</strong></span>...
</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>. 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">
/a[^ab]*b/
a.....<span class="Constant"><strong>a......b</strong></span>..b..a....<span class="Constant"><strong>a....b</strong></span>...
</pre>
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. For example:
<div>
<code class="perl">
<li>
<li>
</code>
</div>
This is a bit difficult. You need to match
<div>
<code class="perl">
<li>
[anything not containing ]
</li>
</code>
</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>
<div>
<code class="perl">
<li>
([^&lt;]|&lt;[^l]|<l[^i]|<li[^>])*
</li>
</code>
</div>
But what about the following string:
<div>
<code class="perl">
<li>
<li</li> </code>
</div>
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:
<div>
<code class="perl">
<li>
([^&lt;]|&lt;[^l]|<l[^i]|<li[^>])*(|&lt;|<l|<li)</li> </code>
</div>
<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>
<div>
<p><code class="perl"> # transform a simple randomly choosen character # to an unique ID # (you should verify the identifier is REALLY unique) # beware the unique ID must not contain the # choosen character s/X/<em>was_x</em>/g s/Y/<em>was_y</em>/g</p>
<h1 id="transform-the-long-string-in-this-simple-character">transform the long string in this simple character</h1>
s/
<li>
<p>/X/g s/&lt;/li&gt;/Y/g</p>
<h1 id="use-the-first-method">use the first method</h1>
<p>s/X([^X]*)Y//g</p>
<h1 id="retransform-choosen-letter-by-string">retransform choosen letter by string</h1>
s/X/
<li>
<p>/g s/Y/&lt;/li&gt;/g</p>
<h1 id="retransform-the-choosen-character-back">retransform the choosen character back</h1>
s/<em>was_x</em>/X/g s/<em>was_y</em>/Y/g </code>
</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>
<hr />
<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 id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2010-02-16
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,139 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - split a file by keyword</title>
<meta name="keywords" content="awk, shell, script">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/2010-02-18-split-a-file-by-keyword/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>split a file by keyword</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<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>
<div>
<code class="perl"> #!/usr/bin/env awk BEGIN{i=0;} /UTC/ { i+=1; FIC=sprintf(“fic.%03d”,i); } {print $0&gt;&gt;FIC} </code>
</div>
<p>In my real world example, I wanted one file per day, each line containing UTC being in the following format:</p>
<pre class="twilight">
Mon Dec 7 10:32:30 UTC 2009
</pre>
<p>I then finished with the following code:</p>
<div>
<code class="perl"> #!/usr/bin/env awk BEGIN{i=0;} /UTC/ { date=$1$2$3; if ( date != olddate ) { olddate=date; i+=1; FIC=sprintf(“fic.%03d”,i); } } {print $0&gt;&gt;FIC} </code>
</div>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2010-02-18
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,24 @@
#!/usr/bin/env ruby
require 'benchmark'
n=80000
tab=[ '/accounts/user.json',
'/accounts/user.xml',
'/user/titi/blog/toto.json',
'/user/titi/blog/toto.xml' ]
puts "Get extname"
Benchmark.bm do |x|
x.report("regexp:") { n.times do
str=tab[rand(4)];
str.match(/[^.]*$/);
ext=$&;
end }
x.report(" split:") { n.times do
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

View file

@ -0,0 +1,20 @@
#!/usr/bin/env ruby
require 'benchmark'
n=80000
tab=[ '/accounts/user.json',
'/accounts/user.xml',
'/user/titi/blog/toto.json',
'/user/titi/blog/toto.xml' ]
puts "remove extension"
Benchmark.bm do |x|
x.report(" File:") { n.times do
str=tab[rand(4)];
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

View file

@ -0,0 +1,165 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - When regexp is not the best solution</title>
<meta name="keywords" content="programming, regexp, regular expression, extension, file">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/2010-02-23-When-regexp-is-not-the-best-solution/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>When regexp is not the best solution</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<p>Regular expression are really useful. Unfortunately, they are not always the best way of doing things. 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>
<div>
<p><code class="ruby"> # regexp str.match(/[^.]*<span class="math">/);<em>e</em><em>x</em><em>t</em>=</span>&amp;</p>
<h1 id="split">split</h1>
<p>ext=str.split(.)[-1]</p>
<h1 id="file-module">File module</h1>
ext=File.extname(str) </code>
</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>Here is the Benchmark ruby code:</p>
<div>
<p><code class="ruby" file="regex_benchmark_ext.rb"> #!/usr/bin/env ruby require benchmark n=80000 tab=[ /accounts/user.json, /accounts/user.xml, /user/titi/blog/toto.json, /user/titi/blog/toto.xml ]</p>
puts “Get extname” Benchmark.bm do |x| x.report(“regexp:”) { n.times do str=tab[rand(4)]; str.match(/[^.]*<span class="math">/);<em>e</em><em>x</em><em>t</em>=</span>&amp;; end } x.report(&quot; split:“) { n.times do str=tab[rand(4)]; ext=str.split(.)[-1] ; end } x.report(” File:&quot;) { n.times do str=tab[rand(4)]; ext=File.extname(str); end } end </code>
</div>
<p>And here is the result</p>
<pre class="twilight">
Get extname
user system total real
regexp: 2.550000 0.020000 2.570000 ( 2.693407)
split: 1.080000 0.050000 1.130000 ( 1.190408)
File: 0.640000 0.030000 0.670000 ( 0.717748)
</pre>
<p>Conclusion of this benchmark, dedicated function are better than your way of doing stuff (most of time).</p>
<h2 id="file-path-without-the-extension.">file path without the extension.</h2>
<div>
<p><code class="ruby" file="regex_benchmark_strip.rb"> #!/usr/bin/env ruby require benchmark n=80000 tab=[ /accounts/user.json, /accounts/user.xml, /user/titi/blog/toto.json, /user/titi/blog/toto.xml ]</p>
puts “remove extension” Benchmark.bm do |x| x.report(&quot; File:“) { n.times do str=tab[rand(4)]; path=File.expand_path(str,File.basename(str,File.extname(str))); end } x.report(”chomp:&quot;) { n.times do str=tab[rand(4)]; ext=File.extname(str); path=str.chomp(ext); end } end </code>
</div>
<p>and here is the result:</p>
<pre class="twilight">
remove extension
user system total real
File: 0.970000 0.060000 1.030000 ( 1.081398)
chomp: 0.820000 0.040000 0.860000 ( 0.947432)
</pre>
<p>Conclusion of the second benchmark. One simple function is better than three dedicated functions. No surprise, but it is good to know.</p>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2010-02-23
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,154 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - Git Tips</title>
<meta name="keywords" content="git, tip">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/2010-03-22-Git-Tips/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>Git Tips</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<h2 id="clone-from-github-behind-an-evil-firewall">clone from github behind an evil firewall</h2>
<p>Standard:</p>
<div>
<code class="zsh"> git clone git@github.com:yogsototh/project.git </code>
</div>
<p>Using HTTPS port:</p>
<div>
<code class="zsh"> git clone git+ssh://git@github.com:443/yogsototh/project.git </code>
</div>
<h2 id="clone-all-branches">clone all branches</h2>
<p><code>git clone</code> can only fetch the master branch.</p>
<p>If you dont have much branches, you can simply use clone your project and then use the following command:</p>
<div>
<code class="zsh"> git branch track local_branch remote_branch </code>
</div>
for example:
<div>
<code class="zsh"> $ git clone git@github:yogsototh/example.git $ git branch master * $ git branch -a master * remotes/origin/HEAD -&gt; origin/master remotes/origin/experimental $ git branch track experimental remotes/origin/experimental $ git branch master * experimental </code>
</div>
<p>If you have many branches it can be useful to use the following <em>script</em>/<em>long command line</em>.</p>
<div>
<p><code class="zsh"> # first clone your project $ git clone git@github.com:yogsototh/project.git</p>
<h1 id="copy-all-branches">copy all branches</h1>
$ zsh $ cd project $ for br in <span class="math">(<em>g</em><em>i</em><em>t</em><em>b</em><em>r</em><em>a</em>);<em>d</em><em>o</em><em>c</em><em>a</em><em>s</em><em>e</em></span>br in remotes/*) print <span class="math"><em>b</em><em>r</em>;<em>c</em><em>a</em><em>s</em><em>e</em></span>{br:t} in master|HEAD) continue ;; *) git branch track <span class="math"><em>b</em><em>r</em>:<em>t</em></span>br ;; esac ;; esac done </code>
</div>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2010-03-22
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,102 @@
#!/usr/bin/env ruby
# encoding: utf-8
# architecture
#
# master <-> dev
# master -> client
# clien -> 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
$architecture={
:master => [ :dev, :client ],
:dev => [ :master ],
:client => [ :clientA, :clientB ] }
def get_current_branch()
(`git branch --no-color | awk '$1 == "*" {print $2}'`).chop.intern
end
if ARGV.length == 0
puts %{usage: $0:t [git_command or local_command]
local commands:
allmerges: merge from top to down}
exit 0
end
require 'set'
$known_branches=Set.new
$architecture.each do |k,v|
$known_branches.add(k)
v.each { |b| $known_branches.add(b) }
end
def rec_merge(branch)
if $architecture[branch].nil?
return
end
$architecture[branch].each do |b|
if $flag.has_key?(b.to_s + branch.to_s)
next
end
flagname=branch.to_s + b.to_s
if $flag.has_key?(flagname)
next
end
if system %{eng checkout #{b}}
if get_current_branch != b
puts "Can't checkout to #{b}"
exit 2
end
if system %{eng merge #{branch}}
$flag[flagname]=true
rec_merge(b)
else
exit 1
end
else
exit 1
end
end
end
def do_all_merges
puts 'Will merge from father to sons'
current_branch=get_current_branch
$flag={}
rec_merge(:master)
system %{git co #{current_branch}}
end
def do_merge
current_branch=get_current_branch
src_branch=ARGV[1].intern
puts %{do_merge: #{src_branch} => #{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} => #{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

View file

@ -0,0 +1,176 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - Encapsulate git</title>
<meta name="keywords" content="git, protection, branches, diverged">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/2010-03-23-Encapsulate-git/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>Encapsulate git</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<div class="intro">
Here is a solution to maintain divergent branches in git. Because it is easy to merge by mistake. I give a script that encapsulate git in order to forbid some merge and warn you some merge should be dangerous.
</div>
<h2 id="how-to-protect-against-your-own-dumb">how to protect against your own dumb</h2>
<p>I work on a project in which some of my git branches should remain divergent. And divergences should grow.</p>
<p>I also use some branch to contain what is common between projects.</p>
<p>Say I have some branches:</p>
<p>master: common to all branches dev: branch devoted to unstable development client: branch with features for all client but not general enough for master clientA: project adapted for client A clientB: project adapted for client B</p>
<p>Here how I want to work:</p>
<p><img src="/Scratch/img/blog/2010-03-23-Encapsulate-git/dynamic_branching.png" alt="Dynamic branching"/></p>
<p>And more precisely the branch hierarchy:</p>
<p><img src="/Scratch/img/blog/2010-03-23-Encapsulate-git/branch_hierarchy.png" alt="Branch hierarchy"/></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>
<code class="ruby"> $architecture={ :master =&gt; [ :dev, :client ], :dev =&gt; [ :master ], :client =&gt; [ :clientA, :clientB ] } </code>
</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>If by mistake I make a <code>git checkout master &amp;&amp; git merge clientA</code>, I made a mistake. This is why I made a script which encapsulate the git behaviour to dodge this kind of mistake.</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>
<code class="zsh"> git co dev &amp;&amp; git merge master git co client &amp;&amp; git merge master git co clientA &amp;&amp; git merge client git co clientB &amp;&amp; git merge client </code>
</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>Here it is:</p>
<div class="small">
<p><code class="ruby" file="eng"> #!/usr/bin/env ruby # encoding: utf-8</p>
<h1 id="architecture">architecture</h1>
<h1 id="section"></h1>
<h1 id="master---dev">master &lt;-&gt; dev</h1>
<h1 id="master---client">master -&gt; client</h1>
<h1 id="clien---clienta-clientb">clien -&gt; clientA | clientB</h1>
<h1 id="section-1"></h1>
<h1 id="merge-using-two-of-these-branches-should-be">merge using two of these branches should be</h1>
<h1 id="restricted-to-these-rules">restricted to these rules</h1>
<h1 id="merge-to-one-of-these-branch-and-an-unknown-one-should">merge to one of these branch and an unknown one should</h1>
<h1 id="raise-a-warning-and-may-the-option-to-add-this-new-branch">raise a warning, and may the option to add this new branch</h1>
<h1 id="to-the-hierarchy">to the hierarchy</h1>
<p>$architecture={ :master =&gt; [ :dev, :client ], :dev =&gt; [ :master ], :client =&gt; [ :clientA, :clientB ] }</p>
<p>def get_current_branch() (<code>git branch --no-color | awk '$1 == &quot;*&quot; {print $2}'</code>).chop.intern end</p>
<p>if ARGV.length == 0 puts %{usage: $0:t [git_command or local_command]</p>
<p>local commands: allmerges: merge from top to down} exit 0 end</p>
<p>require set <span class="math"><em>k</em><em>n</em><em>o</em><em>w</em><em>n</em><sub><em>b</em></sub><em>r</em><em>a</em><em>n</em><em>c</em><em>h</em><em>e</em><em>s</em>=<em>S</em><em>e</em><em>t</em>.<em>n</em><em>e</em><em>w</em></span>architecture.each do |k,v| <span class="math">$known_branches.add(k) v.each { |b| $</span>known_branches.add(b) } end</p>
<p>def rec_merge(branch) if <span class="math"><em>a</em><em>r</em><em>c</em><em>h</em><em>i</em><em>t</em><em>e</em><em>c</em><em>t</em><em>u</em><em>r</em><em>e</em>[<em>b</em><em>r</em><em>a</em><em>n</em><em>c</em><em>h</em>].<em>n</em><em>i</em><em>l</em>?<em>r</em><em>e</em><em>t</em><em>u</em><em>r</em><em>n</em><em>e</em><em>n</em><em>d</em></span>architecture[branch].each do |b| if <span class="math"><em>f</em><em>l</em><em>a</em><em>g</em>.<em>h</em><em>a</em><em>s</em><sub><em>k</em></sub><em>e</em><em>y</em>?(<em>b</em>.<em>t</em><em>o</em><sub><em>s</em></sub>+<em>b</em><em>r</em><em>a</em><em>n</em><em>c</em><em>h</em>.<em>t</em><em>o</em><sub><em>s</em></sub>)<em>n</em><em>e</em><em>x</em><em>t</em><em>e</em><em>n</em><em>d</em><em>f</em><em>l</em><em>a</em><em>g</em><em>n</em><em>a</em><em>m</em><em>e</em>=<em>b</em><em>r</em><em>a</em><em>n</em><em>c</em><em>h</em>.<em>t</em><em>o</em><sub><em>s</em></sub>+<em>b</em>.<em>t</em><em>o</em><sub><em>s</em></sub><em>i</em><em>f</em></span>flag.has_key?(flagname) next end if system %{eng checkout #{b}} if get_current_branch != b puts “Cant checkout to #{b}” exit 2 end if system %{eng merge #{branch}} $flag[flagname]=true rec_merge(b) else exit 1 end else exit 1 end end end</p>
<p>def do_all_merges puts Will merge from father to sons current_branch=get_current_branch $flag={} rec_merge(:master) system %{git co #{current_branch}} end</p>
<p>def do_merge current_branch=get_current_branch src_branch=ARGV[1].intern puts %{do_merge: #{src_branch} =&gt; #{current_branch}} if <span class="math"><em>k</em><em>n</em><em>o</em><em>w</em><em>n</em><sub><em>b</em></sub><em>r</em><em>a</em><em>n</em><em>c</em><em>h</em><em>e</em><em>s</em>.<em>i</em><em>n</em><em>c</em><em>l</em><em>u</em><em>d</em><em>e</em>?(<em>c</em><em>u</em><em>r</em><em>r</em><em>e</em><em>n</em><em>t</em><sub><em>b</em></sub><em>r</em><em>a</em><em>n</em><em>c</em><em>h</em>)<em>i</em><em>f</em></span>known_branches.include?(src_branch) if <span class="math"><em>a</em><em>r</em><em>c</em><em>h</em><em>i</em><em>t</em><em>e</em><em>c</em><em>t</em><em>u</em><em>r</em><em>e</em>.<em>h</em><em>a</em><em>s</em><sub><em>k</em></sub><em>e</em><em>y</em>?(<em>s</em><em>r</em><em>c</em><sub><em>b</em></sub><em>r</em><em>a</em><em>n</em><em>c</em><em>h</em>)<em>a</em><em>n</em><em>d</em></span>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</p>
case ARGV[0] when allmerges then do_all_merges when merge then do_merge else system %{git #{ARGV.join()}} end </code>
</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>Of course try to use as few as possible <code>cherry-pick</code> and <code>rebase</code>. This script was intended to work with workflow using <code>pull</code> and <code>merge</code>.</p>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2010-03-23
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,144 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - I live again!</title>
<meta name="keywords" content="blog">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/2010-05-17-at-least-this-blog-revive/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>I live again!</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<p>Hi all!</p>
<blockquote>
<p>The more you wait to do something, the more difficult it is to start doing it. {: cite=“http://www.madore.org/~david/weblog/2010-05.html#d.2010-05-12.1752” }</p>
</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 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; Youll be surprised by the results.</p>
<p>In short: &gt; <strong>Just do it!</strong> ou <strong>Juste fait le</strong> comme auraient dit les nuls.</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>
<p>I finished some web services/application for <a href="http://www.gridpocket.com">gridpocket(c)</a>.</p>
<p>I also finished to update my blog engine to nanoc3. The difficult part was to handle nicely multiple languages. But I should detail why in a future post.</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 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>
<ul>
<li>finish to make a public web service (I believe it can be popular)</li>
<li>finish to write the associated iPhone application for it</li>
<li>finish to publish our private framework to make web services</li>
<li>publish some articles about this blog (at least 3)</li>
<li>provide the sources of this website on <a href="http://github.com">github</a></li>
</ul>
<p>There is some random in some of these achivement mostly because they dont depend totally on me.</p>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2010-05-17
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,24 @@
# repair cutted XML code by closing the tags
# work even if the XML is cut into a tag.
# example:
# transform '<div> <span> toto </span> <p> hello <a href="http://tur'
# into '<div> <span> toto </span> <p> hello </p></div>'
def repair_xml( xml )
parents=[]
depth=0
xml.scan( %r{<(/?)(\w*)[^>]*(/?)>} ).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(/<[^>]*$/m,'')
depth-=1
depth.downto(0).each { |x| res<<= %{</#{parents[x]}>} }
res
end

View file

@ -0,0 +1,189 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - How to repair a cutted XML?</title>
<meta name="keywords" content="tree, HTML, script, ruby">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/2010-05-19-How-to-cut-HTML-and-repair-it/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>How to repair a cutted XML?</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<p>For my main page, you can see, a list of my latest blog entry. And you have the first part of each article. To accomplish that, I needed to include the begining of the entry and to cut it somewhere. But now, I had to repair this cutted HTML.</p>
<p>Here is an example:</p>
<pre class="sourceCode html"><code class="sourceCode html"><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">&quot;corps&quot;</span><span class="kw">&gt;</span>
<span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">&quot;intro&quot;</span><span class="kw">&gt;</span>
<span class="kw">&lt;p&gt;</span>Introduction<span class="kw">&lt;/p&gt;</span>
<span class="kw">&lt;/div&gt;</span>
<span class="kw">&lt;p&gt;</span>The first paragraph<span class="kw">&lt;/p&gt;</span>
<span class="kw">&lt;img</span><span class="ot"> src=</span><span class="st">&quot;/img/img.png&quot;</span><span class="ot"> alt=</span><span class="st">&quot;an image&quot;</span><span class="kw">/&gt;</span>
<span class="kw">&lt;p&gt;</span>Another long paragraph<span class="kw">&lt;/p&gt;</span>
<span class="kw">&lt;/div&gt;</span></code></pre>
<p>After the cut, I obtain:</p>
<pre class="sourceCode html"><code class="sourceCode html"><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">&quot;corps&quot;</span><span class="kw">&gt;</span>
<span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">&quot;intro&quot;</span><span class="kw">&gt;</span>
<span class="kw">&lt;p&gt;</span>Introduction<span class="kw">&lt;/p&gt;</span>
<span class="kw">&lt;/div&gt;</span>
<span class="kw">&lt;p&gt;</span>The first paragraph<span class="kw">&lt;/p&gt;</span>
<span class="kw">&lt;img</span><span class="ot"> src=</span><span class="st">&quot;/img/im</span></code></pre>
<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 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>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="sourceCode html"><code class="sourceCode html">[]
[div] <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">&quot;corps&quot;</span><span class="kw">&gt;</span>
[div, div] <span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">&quot;intro&quot;</span><span class="kw">&gt;</span>
[div, div, p] <span class="kw">&lt;p&gt;</span>
Introduction
[div, div] <span class="kw">&lt;/p&gt;</span>
[div] <span class="kw">&lt;/div&gt;</span>
[div, p] <span class="kw">&lt;p&gt;</span>
The first paragraph
[div] <span class="kw">&lt;/p&gt;</span>
[div] <span class="kw">&lt;img</span><span class="ot"> src=</span><span class="st">&quot;/img/img.png&quot;</span><span class="ot"> alt=</span><span class="st">&quot;an image&quot;</span><span class="kw">/&gt;</span>
[div, p] <span class="kw">&lt;p&gt;</span>
Another long paragraph
[div] <span class="kw">&lt;/p&gt;</span>
[] <span class="kw">&lt;/div&gt;</span></code></pre>
<p>The algorihm, is then really simple: ~~~~~~ {.html} let res be the XML as a string ; read res and each time you encouter a tag: if it is an opening one: push it to the stack else if it is a closing one: pop the stack.</p>
<p>remove any malformed/cutted tag in the end of res for each tag in the stack, pop it, and write: res = res + closed tag</p>
<p>return res ~~~~~~</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>
<pre class="sourceCode ruby"><code class="sourceCode ruby"><span class="co"># repair cutted XML code by closing the tags</span>
<span class="co"># work even if the XML is cut into a tag.</span>
<span class="co"># example:</span>
<span class="co"># transform &#39;&lt;div&gt; &lt;span&gt; toto &lt;/span&gt; &lt;p&gt; hello &lt;a href=&quot;http://tur&#39;</span>
<span class="co"># into &#39;&lt;div&gt; &lt;span&gt; toto &lt;/span&gt; &lt;p&gt; hello &lt;/p&gt;&lt;/div&gt;&#39;</span>
<span class="kw">def</span> repair_xml( xml )
parents=[]
depth=<span class="dv">0</span>
xml.scan(<span class="ot"> %r{&lt;(/?)(\w*)[^&gt;]*(/?)&gt;}</span> ).each <span class="kw">do</span> |m|
<span class="kw">if</span> m[<span class="dv">2</span>] == <span class="st">&quot;/&quot;</span>
<span class="kw">next</span>
<span class="kw">end</span>
<span class="kw">if</span> m[<span class="dv">0</span>] == <span class="st">&quot;&quot;</span>
parents[depth]=m[<span class="dv">1</span>]
depth+=<span class="dv">1</span>
<span class="kw">else</span>
depth-=<span class="dv">1</span>
<span class="kw">end</span>
<span class="kw">end</span>
res=xml.sub(<span class="ot">/&lt;[^&gt;]*$/m</span>,<span class="st">&#39;&#39;</span>)
depth-=<span class="dv">1</span>
depth.downto(<span class="dv">0</span>).each { |x| res&lt;&lt;=<span class="ot"> %{</span><span class="st">&lt;/</span><span class="ot">#{</span>parents[x]<span class="ot">}</span><span class="st">&gt;</span><span class="ot">}</span> }
res
<span class="kw">end</span></code></pre>
<p>I dont know if the code can help you, but the raisonning should definitively be known.</p>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2010-05-19
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

View file

@ -0,0 +1,313 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - Trees; Pragmatism and Formalism</title>
<meta name="keywords" content="XML, Perl, programming, tree, theory, mathematics, regexp, script">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/2010-05-24-Trees--Pragmatism-and-Formalism/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>Trees; Pragmatism and Formalism</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<div class="intro">
<p><span class="sc"><abbr title="Too long; didn't read">tl;dr</abbr>: </span>:</p>
<ul>
<li>I tried to program a simple filter</li>
<li>Was blocked 2 days</li>
<li>Then stopped working like an engineer monkey</li>
<li>Used a pen and a sheet of paper</li>
<li>Made some math.</li>
<li>Crushed the problem in 10 minutes</li>
<li>Conclusion: The pragmatism shouldnt mean “never use theory”.</li>
</ul>
</div>
<h2 id="abstract-longer-than-tldr">Abstract (longer than <span class="sc"><abbr title="Too long; didn't read">tl;dr</abbr>: </span>)</h2>
<p>For my job, I needed to resolve a problem. It first seems not too hard. Then I started working directly on my program. I entered in the <em>infernal</em>: <em>try &amp; repair loop</em>. Each step was like:</p>
<blockquote>
<p> Just this thing to repair and that should be done.<br /> OK, now that should just work.<br /> Yeah!!!<br /> Oops! I forgotten that…<br /> <code>repeat until death</code></p>
</blockquote>
<p>After two days of this <a href="http://fr.wikipedia.org/wiki/Sisyphe">Sisyphus</a> work, I finally just stopped to rethink the problem. I took a pen, a sheet of paper. I simplified the problem, reminded what I learned during my Ph.D. about trees. Finally, the problem was crushed in less than 20 minutes.</p>
<p>I believe the important lesson is to remember that the most efficient methodology to resolve this <em>pragmatic</em> problem was the <em>theoretical</em> one. And therefore, argues opposing science, theory to pragmatism and efficiency are fallacies.</p>
<hr />
<h1 id="first-my-experience">First: my experience</h1>
<p>Apparently 90% of programmer are unable to program a binary search without bug. The algorithm is well known and easy to understand. However it is difficult to program it without any flaw. I participated to <a href="http://reprog.wordpress.com/2010/04/19/are-you-one-of-the-10-percent/">this contest</a>. And you can see the <a href="http://reprog.wordpress.com/2010/04/21/binary-search-redux-part-1/">results here</a><sup><a href="#fn1" class="footnoteRef" id="fnref1">1</a></sup>. I had to face a problem of the same kind at my job. The problem was simple to the start. Simply transform an <sc>xml</sc> from one format to another.</p>
<p>The source <sc>xml</sc> was in the following general format:</p>
<pre class="sourceCode xml"><code class="sourceCode xml"><span class="kw">&lt;rubrique&gt;</span>
<span class="kw">&lt;contenu&gt;</span>
<span class="kw">&lt;tag1&gt;</span>value1<span class="kw">&lt;/tag1&gt;</span>
<span class="kw">&lt;tag2&gt;</span>value2<span class="kw">&lt;/tag2&gt;</span>
...
<span class="kw">&lt;/contenu&gt;</span>
<span class="kw">&lt;enfant&gt;</span>
<span class="kw">&lt;rubrique&gt;</span>
...
<span class="kw">&lt;/rubrique&gt;</span>
...
<span class="kw">&lt;rubrique&gt;</span>
...
<span class="kw">&lt;/rubrique&gt;</span>
<span class="kw">&lt;/enfant&gt;</span>
<span class="kw">&lt;/menu&gt;</span></code></pre>
<p>and the destination format was in the following general format:</p>
<pre class="sourceCode xml"><code class="sourceCode xml"><span class="kw">&lt;item</span><span class="ot"> name=</span><span class="st">&quot;Menu0&quot;</span><span class="kw">&gt;</span>
<span class="kw">&lt;value&gt;</span>
<span class="kw">&lt;item</span><span class="ot"> name=</span><span class="st">&quot;menu&quot;</span><span class="kw">&gt;</span>
<span class="kw">&lt;value&gt;</span>
<span class="kw">&lt;item</span><span class="ot"> name=</span><span class="st">&quot;tag1&quot;</span><span class="kw">&gt;</span>
<span class="kw">&lt;value&gt;</span>value1<span class="kw">&lt;/value&gt;</span>
<span class="kw">&lt;/item&gt;</span>
<span class="kw">&lt;item</span><span class="ot"> name=</span><span class="st">&quot;tag2&quot;</span><span class="kw">&gt;</span>
<span class="kw">&lt;value&gt;</span>value2<span class="kw">&lt;/value&gt;</span>
<span class="kw">&lt;/item&gt;</span>
...
<span class="kw">&lt;item</span><span class="ot"> name=</span><span class="st">&quot;menu&quot;</span><span class="kw">&gt;</span>
<span class="kw">&lt;value&gt;</span>
...
<span class="kw">&lt;/value&gt;</span>
<span class="kw">&lt;value&gt;</span>
...
<span class="kw">&lt;/value&gt;</span>
<span class="kw">&lt;/item&gt;</span>
<span class="kw">&lt;/value&gt;</span>
<span class="kw">&lt;/item&gt;</span>
<span class="kw">&lt;/value&gt;</span>
<span class="kw">&lt;/item&gt;</span></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>
<ol style="list-style-type: decimal">
<li>do not use <sc>xslt</sc></li>
<li>avoid the use of an <sc>xml</sc> parser</li>
<li>resolve the problem using a simple perl script[^2]</li>
</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. 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>What was my behaviour (workflow)?</p>
<ol style="list-style-type: decimal">
<li>Think</li>
<li>Write the program</li>
<li>Try the program</li>
<li>Verify the result</li>
<li>Found a bug</li>
<li>Resolve the bug</li>
<li>Go to step 3.</li>
</ol>
<p>This was a <em>standard</em> workflow for computer engineer. The flaw came from the first step. I thought about how to resolve the problem but with the eyes of a <em>pragmatic engineer</em>. I was saying:</p>
<blockquote>
<p>That should be a simple perl search and replace program.<br />Lets begin to write code</p>
</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>
<h2 id="think">Think</h2>
<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>
<p>I began by make by removing most of the verbosity. I first renamed <code>&lt;item name=&quot;Menu&quot;&gt;</code> by simpler name <code>M</code> for example. I obtained something like:</p>
<p><graph title="The source tree"> subgraph cluster_x { node [label=“C”] C_x ; node [label=“E”] E_x ; node [label=“a1”] tag1_x ; node [label=“a2”] tag2_x ; node [label=“R”, color=“#333333”, fillcolor=“#333333”, fontcolor=“white”] R_x ; R_x -&gt; C_x; C_x -&gt; tag1_x ; C_x -&gt; tag2_x ; R_x -&gt; E_x ; } subgraph cluster_y { node [label=“C”] C_y ; node [label=“E”] E_y ; node [label=“a1”] tag1_y ; node [label=“a2”] tag2_y ; node [label=“R”, color=“#333333”, fillcolor=“#333333”, fontcolor=“white”] R_y ; R_y -&gt; C_y; C_y -&gt; tag1_y ; C_y -&gt; tag2_y ; R_y -&gt; E_y ; } subgraph cluster_z { node [label=“C”] C_z ; node [label=“E”] E_z ; node [label=“a1”] tag1_z ; node [label=“a2”] tag2_z ; node [label=“R”, color=“#333333”, style=“filled”, fillcolor=“#333333”, fontcolor=“white”] R_z ; R_z -&gt; C_z; C_z -&gt; tag1_z ; C_z -&gt; tag2_z ; R_z -&gt; E_z ; } E_x -&gt; R_y ; E_x -&gt; R_z ;</p>
<p></graph></p>
<p>and</p>
<p><graph title="The destination tree"> subgraph cluster_x { node [label=“M”] E_x ; node [label=“a1”] tag1_x ; node [label=“V”] value_tag1_x ; node [label=“a2”] tag2_x ; node [label=“V”] value_tag2_x ; node [label=“V”, color=“#333333”, fillcolor=“#333333”, fontcolor=“white”] R_x ; R_x -&gt; value_tag1_x -&gt; tag1_x ; R_x -&gt; value_tag2_x -&gt; tag2_x ; R_x -&gt; E_x ; } subgraph cluster_y { node [label=“M”] E_y ; node [label=“a1”] tag1_y ; node [label=“V”] value_tag1_y ; node [label=“a2”] tag2_y ; node [label=“V”] value_tag2_y ; node [label=“V”, color=“#333333”, fillcolor=“#333333”, fontcolor=“white”] R_y ; R_y -&gt; value_tag1_y -&gt; tag1_y ; R_y -&gt; value_tag2_y -&gt; tag2_y ; R_y -&gt; E_y ; } subgraph cluster_z { node [label=“M”] E_z ; node [label=“a1”] tag1_z ; node [label=“V”] value_tag1_z ; node [label=“a2”] tag2_z ; node [label=“V”] value_tag2_z ; node [label=“V”, color=“#333333”, fillcolor=“#333333”, fontcolor=“white”] R_z ; R_z -&gt; value_tag1_z -&gt; tag1_z ; R_z -&gt; value_tag2_z -&gt; tag2_z ; R_z -&gt; E_z ; } E_x -&gt; R_y ; E_x -&gt; R_z ;</p>
<p></graph></p>
<p>Then I made myself the following reflexion:</p>
<p>Considering Tree Edit Distance, each unitary transformation of tree correspond to a simple search and replace on my <sc>xml</sc> source<sup><a href="#fn2" class="footnoteRef" id="fnref2">2</a></sup>. We consider three atomic transformations on trees:</p>
<ul>
<li><em>substitution</em>: renaming a node</li>
<li><em>insertion</em>: adding a node</li>
<li><em>deletion</em>: remove a node</li>
</ul>
<p>One of the particularity of atomic transformations on trees, is ; if you remove a node, all children of this node, became children of its father.</p>
<p>An example:</p>
<pre class="twilight">
r - x - a
\ \
\ b
y - c
</pre>
<p>If you delete the <code>x</code> node, you obtain</p>
<pre class="twilight">
a
/
r - b
\
y - c
</pre>
<p>And look at what it implies when you write it in <sc>xml</sc>:</p>
<pre class="sourceCode xml"><code class="sourceCode xml"><span class="kw">&lt;r&gt;</span>
<span class="kw">&lt;x&gt;</span>
<span class="kw">&lt;a&gt;</span>value for a<span class="kw">&lt;/a&gt;</span>
<span class="kw">&lt;b&gt;</span>value for b<span class="kw">&lt;/b&gt;</span>
<span class="kw">&lt;/x&gt;</span>
<span class="kw">&lt;y&gt;</span>
<span class="kw">&lt;c&gt;</span>value for c<span class="kw">&lt;/c&gt;</span>
<span class="kw">&lt;/y&gt;</span>
<span class="kw">&lt;/r&gt;</span></code></pre>
<p>Then deleting all <code>x</code> nodes is equivalent to pass the <sc>xml</sc> via the following search and replace script:</p>
<pre class="sourceCode perl"><code class="sourceCode perl"><span class="kw">s/</span><span class="ot">&lt;\/</span><span class="ch">?</span><span class="ot">x&gt;</span><span class="kw">//g</span></code></pre>
<p>Therefore, if there exists a one state deterministic transducer which transform my trees ; I can transform the <sc>xml</sc> from one format to another with just a simple list of search and replace directives.</p>
<h1 id="solution">Solution</h1>
<p>Transform this tree:</p>
<pre class="twilight">
R - C - tag1
\ \
\ tag2
E -- R - C - tag1
\ \ \
\ \ tag2
\ E ...
R - C - tag1
\ \
\ tag2
E ...
</pre>
<p>to this tree:</p>
<pre class="twilight">
tag1
/
M - V - M - V - tag2 tag1
\ /
M --- V - tag2
\ \
\ M
\ tag1
\ /
V - tag2
\
M
</pre>
<p>can be done using the following one state deterministic tree transducer:</p>
<blockquote>
<p>C -&gt; ε<br /> E -&gt; M<br /> R -&gt; V</p>
</blockquote>
<p>Wich can be traduced by the following simple search and replace directives:</p>
<pre class="sourceCode perl"><code class="sourceCode perl"><span class="kw">s/</span><span class="ot">C</span><span class="kw">//g</span>
<span class="kw">s/</span><span class="ot">E</span><span class="kw">/</span><span class="st">M</span><span class="kw">/g</span>
<span class="kw">s/</span><span class="ot">R</span><span class="kw">/</span><span class="st">V</span><span class="kw">/g</span></code></pre>
<p>Once adapted to <sc>xml</sc> it becomes:</p>
<pre class="sourceCode perl"><code class="sourceCode perl"><span class="kw">s%</span><span class="ot">&lt;/</span><span class="ch">?</span><span class="ot">contenu&gt;</span><span class="kw">%%g</span>
<span class="kw">s%</span><span class="ot">&lt;enfant&gt;</span><span class="kw">%</span><span class="st">&lt;item name=&quot;menu&quot;&gt;</span><span class="kw">%g</span>
<span class="kw">s%</span><span class="ot">&lt;/enfant&gt;</span><span class="kw">%</span><span class="st">&lt;/item&gt;</span><span class="kw">%g</span>
<span class="kw">s%</span><span class="ot">&lt;rubrique&gt;</span><span class="kw">%</span><span class="st">&lt;value&gt;</span><span class="kw">%g</span>
<span class="kw">s%</span><span class="ot">&lt;/rubrique&gt;</span><span class="kw">%</span><span class="st">&lt;/value&gt;</span><span class="kw">%g</span></code></pre>
<p>That is all.</p>
<h1 id="conclusion">Conclusion</h1>
<p>It should seems a bit paradoxal, but sometimes the most efficient approach to a pragmatic problem is to use the theoretical methodology.</p>
<div class="footnotes">
<hr />
<ol>
<li id="fn1"><p>Hopefully I am in the 10% who had given a bug free implementation.<a href="#fnref1"></a></p></li>
<li id="fn2"><p>I did a program which generate automatically the weight in a matrix of each edit distance from data.<a href="#fnref2"></a></p></li>
</ol>
</div>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2010-05-24
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,152 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - multi language choices</title>
<meta name="keywords" content="multilanguage, blog">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/2010-06-14-multi-language-choices/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>multi language choices</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<p>I translate most of my blog entries in French and English. Most people advice me to have one file per language. Generally it ends with:</p>
<pre class="twilight">
Bonjour,
voici un exemple de texte en français.
[image](url)
</pre>
<pre class="twilight">
Hello,
here is an example of english text.
[image](url)
</pre>
<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… 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. I use <em>tags</em> on a single file. Finally my files looks like:</p>
<pre class="twilight">
fr: Bonjour,
en: Hello,
en: here is an example of english text.
fr: voici un exemple de texte en français.
[image](url)
</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 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>
<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>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2010-06-14
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,185 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - Get my blog engine</title>
<meta name="keywords" content="blog, nanoc">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/2010-06-15-Get-my-blog-engine/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>Get my blog engine</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<p>I published a <em>light</em> version of my blog engine based on <a href="http://nanoc.stoneship.org">nanoc</a> yesterday night. By <em>light</em>, I mean a lighter, more portable CSS (without round border). You can get it on <a href="http://github.com/yogsototh/nanoc3_blog">github.com</a>.</p>
<p>What this system provide?</p>
<ul>
<li>All <a href="http://nanoc.stoneship.org">nanoc</a> advantages,</li>
<li>Easy multi-language handling,</li>
<li>Syntax Coloration for most languages,</li>
<li><a href="http://intensedebate.org">intenseDebate</a> comments integration (asynchronous) ;</li>
<li>Portable with and without javascript, XHTML Strict 1.0 / CSS3,</li>
<li>Write in markdown format (no HTML editing needed),</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>
</ul>
<hr />
<h1 id="main-documentation-page">Main Documentation Page</h1>
<h1 id="use-it-now">Use It NOW!</h1>
<p>Once installed (follow the README.md instructions).</p>
<pre class="zsh"><code>$ cd /root/of/nanoc3_blog
$ ./task/new_blog_entry Title of the blog
$ vi latest.md
$ ./task/recompile</code></pre>
<p>Now your website reside into the <code>output</code> directory.</p>
<hr />
<h1 id="documentation">Documentation</h1>
<h2 id="useful-things-to-know">Useful things to know</h2>
<h3 id="multi-language">Multi-language</h3>
<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 <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, 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>
<h4 id="additional-keywords">additional keywords</h4>
<p>You can separate multi content div using the: <code>n``ewcorps</code> directive (see examples).</p>
<p>You can create div using <code>b``egindiv(classname)</code>, <code>e``nddiv</code>. (See some existing blog entries for example). Use the class <code>intro</code> for the abstract part.</p>
<p>You can create nice description table using <code>&lt;``desc&gt;</code> (See source code for example).</p>
<h4 id="typography">Typography</h4>
<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>
<ul>
<li><code>(c``)</code> is replaced by (c).</li>
<li><code>(r``)</code> is replaced by (r).</li>
<li><code>&lt;``-</code> is replaced by &lt;-.</li>
<li><code>-``&gt;</code> is replaced by -&gt;.</li>
</ul>
<h4 id="source-code">source code</h4>
<p>To write source code you should use the following format:</p>
<p>~~~~~~ {.html} ~~~~~~ {.ruby} The code </cOde> ~~~~~~</p>
<p>The <code>file</code> attribute is not required.</p>
<h3 id="blog">blog</h3>
<p>If you want to make really long blog post, you can separate them into many files. To accomplish that, you simply have to make your files like:</p>
<pre class="twilight">
multi/blog/2010-06-01-the-title.md
multi/blog/2010-06-01-the-title/second_part.md
multi/blog/2010-06-01-the-title/third_part.md
</pre>
<h3 id="mobileme">mobileme</h3>
<p>All files are intended to be generated into the <code>output/Scratch</code> directory. This was made like that to work nicely with iWeb organisation of websites.</p>
<h3 id="menu">menu</h3>
<p>The order of post is done using the <code>menupriority</code> meta-data in the header of the files.</p>
<p>You can hide some file from the menu by setting: <code>isHidden: true</code> in the header.</p>
<h2 id="details">Details</h2>
<p>To know more about this blog engine, you should look at <a href="http://nanoc.stoneship.org">nanoc</a> project.</p>
<p>Then look at the files inside your project:</p>
<p><desc> README.md : readme for the project (used by github) :: latest.md : symbolic link to the last blog entry :: multi/ : Directory containing multi-language articles :: tasks/ : scripts for website live :: config.yaml : global configuration file :: Rules : generation rules :: content/ : content files processed by nanoc :: layouts/ : erb templates :: lib/ : ruby libraries used to process files :: output/ : website :: Rakefile : not mandatory for this blog :: </desc></p>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2010-06-15
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="fr" xml:lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.cookie.js"></script>
<script>
$(document).ready(function(){
$.cookie('admin',1);
$('#info').html('Analytics can no more see you.')
});
</script>
<title>Hide to analytics</title>
</head>
<body>
<div id="info"></div>
</body>
</html>

View file

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="fr" xml:lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.cookie.js"></script>
<script>
$(document).ready(function(){
$.cookie('admin',null);
$('#info').html('Analytics can see you.')
});
</script>
<title>Hide to analytics</title>
</head>
<body>
<div id="info"></div>
</body>
</html>

View file

@ -0,0 +1,175 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - Hide Yourself to your Analytics</title>
<meta name="keywords" content="analytics, statistics, hide, blog, jQuery, javascript">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/2010-06-17-hide-yourself-to-analytics/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>Hide Yourself to your Analytics</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<p>This is a way not to count your own visits to your blog. First you should look on how <a href="/Scratch/en/blog/2010-06-17-track-events-with-google-analytics">I handle analytics</a>. All analytics are handled in one javascript file, this make things really convenient.</p>
<p>Then you need to know my method use the <code>jquery-cookie</code>.</p>
<p>I check if the key <code>admin</code> is not set in the cookie before adding the visit.</p>
<pre class="sourceCode javascript"><code class="sourceCode javascript"> <span class="kw">var</span> admin = $.<span class="fu">cookie</span>(<span class="ch">&#39;admin&#39;</span>);
<span class="kw">if</span> (! admin) {
<span class="co">// put your analytics code here</span>
} <span class="kw">else</span> {
<span class="kw">console</span>.<span class="fu">log</span>(<span class="st">&quot;[WARNING] you&#39;re HIDDEN to analytics&quot;</span>);
}</code></pre>
<p>then create two <sc>html</sc> files. One to hide:</p>
<pre class="sourceCode html"><code class="sourceCode html"><span class="kw">&lt;?xml</span> version=&quot;1.0&quot; encoding=&quot;utf-8&quot;<span class="kw">?&gt;</span>
<span class="dt">&lt;!DOCTYPE </span>html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;
&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;<span class="dt">&gt;</span>
<span class="kw">&lt;html</span><span class="ot"> xmlns=</span><span class="st">&quot;http://www.w3.org/1999/xhtml&quot;</span><span class="ot"> lang=</span><span class="st">&quot;fr&quot;</span><span class="ot"> xml:lang=</span><span class="st">&quot;fr&quot;</span><span class="kw">&gt;</span>
<span class="kw">&lt;head&gt;</span>
<span class="kw">&lt;meta</span><span class="ot"> http-equiv=</span><span class="st">&quot;Content-Type&quot;</span><span class="ot"> content=</span><span class="st">&quot;text/html; charset=UTF-8&quot;</span> <span class="kw">/&gt;</span>
<span class="kw">&lt;script</span><span class="ot"> type=</span><span class="st">&quot;text/javascript&quot;</span><span class="ot"> src=</span><span class="st">&quot;jquery.js&quot;</span><span class="kw">&gt;&lt;/script&gt;</span>
<span class="kw">&lt;script</span><span class="ot"> type=</span><span class="st">&quot;text/javascript&quot;</span><span class="ot"> src=</span><span class="st">&quot;jquery.cookie.js&quot;</span><span class="kw">&gt;&lt;/script&gt;</span>
<span class="kw">&lt;script&gt;</span>
<span class="er"> $(document).ready(function(){</span>
$.<span class="fu">cookie</span>(<span class="ch">&#39;admin&#39;</span>,<span class="dv">1</span>);
$(<span class="ch">&#39;#info&#39;</span>).<span class="fu">html</span>(<span class="ch">&#39;Analytics can no more see you.&#39;</span>)
});
<span class="kw">&lt;/script&gt;</span>
<span class="kw">&lt;title&gt;</span>Hide to analytics<span class="kw">&lt;/title&gt;</span>
<span class="kw">&lt;/head&gt;</span>
<span class="kw">&lt;body&gt;</span>
<span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">&quot;info&quot;</span><span class="kw">&gt;&lt;/div&gt;</span>
<span class="kw">&lt;/body&gt;</span>
<span class="kw">&lt;/html&gt;</span></code></pre>
<p>the other to be visible again (it can be useful):</p>
<pre class="sourceCode html"><code class="sourceCode html"><span class="kw">&lt;?xml</span> version=&quot;1.0&quot; encoding=&quot;utf-8&quot;<span class="kw">?&gt;</span>
<span class="dt">&lt;!DOCTYPE </span>html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;
&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;<span class="dt">&gt;</span>
<span class="kw">&lt;html</span><span class="ot"> xmlns=</span><span class="st">&quot;http://www.w3.org/1999/xhtml&quot;</span><span class="ot"> lang=</span><span class="st">&quot;fr&quot;</span><span class="ot"> xml:lang=</span><span class="st">&quot;fr&quot;</span><span class="kw">&gt;</span>
<span class="kw">&lt;head&gt;</span>
<span class="kw">&lt;meta</span><span class="ot"> http-equiv=</span><span class="st">&quot;Content-Type&quot;</span><span class="ot"> content=</span><span class="st">&quot;text/html; charset=UTF-8&quot;</span> <span class="kw">/&gt;</span>
<span class="kw">&lt;script</span><span class="ot"> type=</span><span class="st">&quot;text/javascript&quot;</span><span class="ot"> src=</span><span class="st">&quot;jquery.js&quot;</span><span class="kw">&gt;&lt;/script&gt;</span>
<span class="kw">&lt;script</span><span class="ot"> type=</span><span class="st">&quot;text/javascript&quot;</span><span class="ot"> src=</span><span class="st">&quot;jquery.cookie.js&quot;</span><span class="kw">&gt;&lt;/script&gt;</span>
<span class="kw">&lt;script&gt;</span>
<span class="er"> $(document).ready(function(){</span>
$.<span class="fu">cookie</span>(<span class="ch">&#39;admin&#39;</span>,null);
$(<span class="ch">&#39;#info&#39;</span>).<span class="fu">html</span>(<span class="ch">&#39;Analytics can see you.&#39;</span>)
});
<span class="kw">&lt;/script&gt;</span>
<span class="kw">&lt;title&gt;</span>Hide to analytics<span class="kw">&lt;/title&gt;</span>
<span class="kw">&lt;/head&gt;</span>
<span class="kw">&lt;body&gt;</span>
<span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">&quot;info&quot;</span><span class="kw">&gt;&lt;/div&gt;</span>
<span class="kw">&lt;/body&gt;</span>
<span class="kw">&lt;/html&gt;</span></code></pre>
<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>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2010-06-17
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,45 @@
$(document).ready( function() {
// add an event to all link for google analytics
$('a').click(function () {
// tell analytics to save event
try {
var identifier=$(this).attr('id') ;
var href=$(this).attr('href')
var label="";
if ( typeof( identifier ) != 'undefined' ) {
label=label+'[id]:'+identifier
category='JSLink'
}
if ( typeof( href ) != 'undefined' ) {
label=label+' [href]:'+href
if ( href[0] == '#' ) {
category='Anchor';
} else {
category='Link';
}
}
_gaq.push(['_trackEvent', category, 'clicked', label]);
// console.log('[tracked]: ' + category + ' ; clicked ; ' + label );
}
catch (err) {
console.log(err);
}
// pause to allow google script to run
var date = new Date();
var curDate = null;
do {
curDate = new Date();
} while(curDate-date < 300);
});
});
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

View file

@ -0,0 +1,177 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - Track Events with Google Analytics</title>
<meta name="keywords" content="blog, javascript, jQuery, Google, analytics, analyser, User, Asynchronous">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/2010-06-17-track-events-with-google-analytics/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>Track Events with Google Analytics</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<p>Here is how to track all clicks on your website using google analytics asynchronously.</p>
<p>First in your <sc>html</sc> you need to use <a href="http://jquery.com">jQuery</a> and a javscript file I named <code>yga.js</code>:</p>
<pre class="sourceCode html"><code class="sourceCode html"> <span class="kw">&lt;script</span><span class="ot"> type=</span><span class="st">&quot;text/javascript&quot;</span><span class="ot"> src=</span><span class="st">&quot;jquery.js&quot;</span><span class="kw">&gt;&lt;/script&gt;</span>
<span class="kw">&lt;script</span><span class="ot"> type=</span><span class="st">&quot;text/javascript&quot;</span><span class="ot"> src=</span><span class="st">&quot;yga.js&quot;</span><span class="kw">&gt;&lt;/script&gt;</span></code></pre>
<p>And here is the <code>yga.js</code> file:</p>
<pre class="sourceCode javascript"><code class="sourceCode javascript">$(<span class="kw">document</span>).<span class="fu">ready</span>( <span class="kw">function</span>() {
<span class="co">// add an event to all link for google analytics</span>
$(<span class="ch">&#39;a&#39;</span>).<span class="fu">click</span>(<span class="kw">function</span> () {
<span class="co">// tell analytics to save event</span>
<span class="kw">try</span> {
<span class="kw">var</span> identifier=$(<span class="kw">this</span>).<span class="fu">attr</span>(<span class="ch">&#39;id&#39;</span>) ;
<span class="kw">var</span> href=$(<span class="kw">this</span>).<span class="fu">attr</span>(<span class="ch">&#39;href&#39;</span>)
<span class="kw">var</span> label=<span class="st">&quot;&quot;</span>;
<span class="kw">if</span> ( <span class="kw">typeof</span>( identifier ) != <span class="ch">&#39;undefined&#39;</span> ) {
label=label+<span class="ch">&#39;[id]:&#39;</span>+identifier
category=<span class="ch">&#39;JSLink&#39;</span>
}
<span class="kw">if</span> ( <span class="kw">typeof</span>( href ) != <span class="ch">&#39;undefined&#39;</span> ) {
label=label+<span class="ch">&#39; [href]:&#39;</span>+href
<span class="kw">if</span> ( href[<span class="dv">0</span>] == <span class="ch">&#39;#&#39;</span> ) {
category=<span class="ch">&#39;Anchor&#39;</span>;
} <span class="kw">else</span> {
category=<span class="ch">&#39;Link&#39;</span>;
}
}
<span class="kw">_gaq</span>.<span class="fu">push</span>([<span class="ch">&#39;_trackEvent&#39;</span>, category, <span class="ch">&#39;clicked&#39;</span>, label]);
<span class="co">// console.log(&#39;[tracked]: &#39; + category + &#39; ; clicked ; &#39; + label );</span>
}
<span class="kw">catch</span> (err) {
<span class="kw">console</span>.<span class="fu">log</span>(err);
}
<span class="co">// pause to allow google script to run</span>
<span class="kw">var</span> date = <span class="kw">new</span> <span class="kw">Date</span>();
<span class="kw">var</span> curDate = null;
<span class="kw">do</span> {
curDate = <span class="kw">new</span> <span class="kw">Date</span>();
} <span class="kw">while</span>(curDate-date &lt; <span class="dv">300</span>);
});
});
<span class="kw">var</span> _gaq = _gaq || [];
<span class="kw">_gaq</span>.<span class="fu">push</span>([<span class="ch">&#39;_setAccount&#39;</span>, <span class="ch">&#39;UA-XXXXXXXX-1&#39;</span>]);
<span class="kw">_gaq</span>.<span class="fu">push</span>([<span class="ch">&#39;_trackPageview&#39;</span>]);
(<span class="kw">function</span>() {
<span class="kw">var</span> ga = <span class="kw">document</span>.<span class="fu">createElement</span>(<span class="ch">&#39;script&#39;</span>); <span class="kw">ga</span>.<span class="fu">type</span> = <span class="ch">&#39;text/javascript&#39;</span>; <span class="kw">ga</span>.<span class="fu">async</span> = <span class="kw">true</span>;
<span class="kw">ga</span>.<span class="fu">src</span> = (<span class="ch">&#39;https:&#39;</span> == <span class="kw">document</span>.<span class="fu">location</span>.<span class="fu">protocol</span> ? <span class="ch">&#39;https://ssl&#39;</span> : <span class="ch">&#39;http://www&#39;</span>) + <span class="ch">&#39;.google-analytics.com/ga.js&#39;</span>;
<span class="kw">var</span> s = <span class="kw">document</span>.<span class="fu">getElementsByTagName</span>(<span class="ch">&#39;script&#39;</span>)[<span class="dv">0</span>]; <span class="kw">s.parentNode</span>.<span class="fu">insertBefore</span>(ga, s);
})();</code></pre>
<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><img src="/Scratch/img/blog/2010-06-17-track-events-with-google-analytics/GA_events.png" alt=""/></p>
<p>Happy tracking!</p>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2010-06-17
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,22 @@
// --- code popup ---
function openPopup() {
$(this).clone(false).appendTo($("#_code"));
$("#_code").show();
}
function closePopup() {
$("#_code").html("");
$("#_code").hide();
}
function initCode() {
$(".code").click(openPopup);
$(".code").css({cursor: "pointer"});
$('body').append('<div id="_code"></div>');
$('#_code').css( { 'text-align': "justify", position: "fixed",
left:0, top:0, width: "100%", height: "100%",
"background-color": "rgba(0, 0, 0, 0.8)", 'z-index':2000, 'padding':'3px'} );
$('#_code').hide();
$('#_code').click(closePopup);
}
// --- end of code popup section ---

View file

@ -0,0 +1,149 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - jQuery popup the easy way</title>
<meta name="keywords" content="jQuery, javascript, popup, blog, web">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/2010-06-19-jQuery-popup-the-easy-way/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>jQuery popup the easy way</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<p>Here is a fast and easy way to create jQuery popup.</p>
<pre class="sourceCode javascript"><code class="sourceCode javascript"><span class="co">// --- code popup ---</span>
<span class="kw">function</span> openPopup() {
$(<span class="kw">this</span>).<span class="fu">clone</span>(<span class="kw">false</span>).<span class="fu">appendTo</span>($(<span class="st">&quot;#_code&quot;</span>));
$(<span class="st">&quot;#_code&quot;</span>).<span class="fu">show</span>();
}
<span class="kw">function</span> closePopup() {
$(<span class="st">&quot;#_code&quot;</span>).<span class="fu">html</span>(<span class="st">&quot;&quot;</span>);
$(<span class="st">&quot;#_code&quot;</span>).<span class="fu">hide</span>();
}
<span class="kw">function</span> initCode() {
$(<span class="st">&quot;.code&quot;</span>).<span class="fu">click</span>(openPopup);
$(<span class="st">&quot;.code&quot;</span>).<span class="fu">css</span>({<span class="dt">cursor</span>: <span class="st">&quot;pointer&quot;</span>});
$(<span class="ch">&#39;body&#39;</span>).<span class="fu">append</span>(<span class="ch">&#39;&lt;div id=&quot;_code&quot;&gt;&lt;/div&gt;&#39;</span>);
$(<span class="ch">&#39;#_code&#39;</span>).<span class="fu">css</span>( { <span class="ch">&#39;text-align&#39;</span>: <span class="st">&quot;justify&quot;</span>, <span class="dt">position</span>: <span class="st">&quot;fixed&quot;</span>,
<span class="dt">left</span>:<span class="dv">0</span>, <span class="dt">top</span>:<span class="dv">0</span>, <span class="dt">width</span>: <span class="st">&quot;100%&quot;</span>, <span class="dt">height</span>: <span class="st">&quot;100%&quot;</span>,
<span class="st">&quot;background-color&quot;</span>: <span class="st">&quot;rgba(0, 0, 0, 0.8)&quot;</span>, <span class="ch">&#39;z-index&#39;</span>:<span class="dv">2000</span>, <span class="ch">&#39;padding&#39;</span>:<span class="ch">&#39;3px&#39;</span>} );
$(<span class="ch">&#39;#_code&#39;</span>).<span class="fu">hide</span>();
$(<span class="ch">&#39;#_code&#39;</span>).<span class="fu">click</span>(closePopup);
}
<span class="co">// --- end of code popup section ---</span></code></pre>
<p>What does this code do?</p>
<p>At the loading of the page, I create a <code>div</code> as wide as the window. This <code>div</code> is a bit transparent. Then I hide it. I also take care to its <code>z-index</code> value to be sure it is behind all elements.</p>
<p>Then when we click on a <code>div</code> of class <code>code</code>, I copy the content into this new wide <code>div</code>, and I show it. Really simple but really efficient. No need to use a <code>jQuery</code> plugin.</p>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2010-06-19
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,214 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - Cappuccino vs jQuery</title>
<meta name="keywords" content="Cappuccino, iPhone, web, javascript, jQuery, Cocoa, programming">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/2010-07-05-Cappuccino-and-Web-applications/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>Cappuccino vs jQuery</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<div class="intro">
<p><abbr class="sc" title="Too long; didn't read">tl;dr</abbr>:</p>
<ul>
<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>jQuery not as nice as the Cappuccino version but 106KB. iPhone compatible.</li>
<li>Ill give a try to Dashcode 3.</li>
</ul>
</div>
<hr />
<div class="intro">
<p>Before start, I must say I know Cappuccino and jQuery are no more comparable than Cocoa and the C++ standard library. One is oriented for user interface while the other is and helper for low level programming. Nonetheless I used these two to make the same web application. This is why I compare the experience I had with each of them for this specific task.</p>
</div>
<p>I made a web version of my dashboard widget <a href="http://yannesposito.com/Softwares/YPassword.html">YPassword</a>. It is a simple widget to manage your online password with a <em>strong</em> security and with a totally portable way. It is not intended to replace a <em>keychain</em>. It is more a password generator.</p>
<p>The first was made from the code of my dashboard widget and with some jQuery. You can try it <a href="http://yannesposito.com/YPassword.old">here</a>. I then made a second version with the <a href="http://cappuccino.org">Cappuccino</a>. You can try it <a href="http://yannesposito.com/YPassword">here</a>.</p>
<h2 id="what-this-widget-do">What this widget do?</h2>
<div class="intro">
<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>
</div>
<p>I manage my password on many site with a simple method. I remember a strong master password. And my password is mainly <code class="ruby">hash(masterPassword+domainName)</code></p>
<p>In reality I need a bit more informations to create a password:</p>
<ul>
<li>A master password,</li>
<li>an URL,</li>
<li>a maximal password length,</li>
<li>the kind of output base64 or hexadecimal,</li>
<li>how many times my password could have leaked.</li>
</ul>
<p>The result password is this:</p>
<pre class="sourceCode ruby"><code class="sourceCode ruby">domainName=domaine_Name_Of_URL(url)
hash=sha1( masterPassword + leakedTimes + domainName )
<span class="kw">if</span> ( kind == <span class="st">&#39;base64&#39;</span> )
hash=base64(hash)
<span class="kw">end</span>
<span class="kw">return</span> hash[<span class="dv">0</span>..maxlength]</code></pre>
<p>In fact depending of websites, some give some strange constraint to your password:</p>
<ul>
<li>minimal length,</li>
<li>maximal length,</li>
<li>must not contain a special character,</li>
<li>must contain a special character,</li>
<li>etc…</li>
</ul>
<p>And if you want to change your password the <em>leak number</em> is here for that. All informations such as user name, maximal length can be stored in a public file. The only real secret is the master password.</p>
<p>If you want to know even more details you can always look at some of my old blog entries:</p>
<ul>
<li><a href="http://yannesposito.com/YBlog/Computer/Entr%C3%A9es/2008/7/30_Easy%2C_secure_and_portable_password_management_system.html">simple portable password management</a></li>
<li><a href="http://yannesposito.com/YBlog/Computer/Entrées/2009/3/15_Shorter_Password_with_the_same_efficiency.html">base64</a></li>
<li><a href="http://yannesposito.com/YBlog/Computer/Entr%C3%A9es/2009/4/11_Be_able_to_change_your_password.html">change your password</a></li>
</ul>
<h2 id="cappuccino">Cappuccino</h2>
<p>First, Id like to say Cappuccino applications look simply awesome. It is like having a Cocoa application in your web browser. And this is <em>great</em>.</p>
<p>I also must admit I enjoyed making my application with Cappuccino. It is like programming for an iPhone application. If you are a bit familiar with Cocoa, you feel at home. 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. I am not a specialist, but I have done some MFC, java Swing<sup><a href="#fn1" class="footnoteRef" id="fnref1">1</a></sup> and WXWindows User Interfaces (some years ago). And I must say, Cocoa is far better than those.</p>
<p>Cappuccino is a great web application oriented development. But there was also some drawbacks</p>
<p>Things I liked:</p>
<ul>
<li>It looks great</li>
<li>It was fun to program</li>
<li>It was like programming a Mac application</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>
<p>Some things I didnt like:</p>
<ul>
<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>It doesnt work on iPhone.</li>
<li>It weighted 11MB to deploy.</li>
<li>It weight 1.3MB to load.</li>
</ul>
<p>I didnt use bindings because I believe they are not ready by now.</p>
<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. 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 “<em>dark side</em> javascript animation framework”<sup><a href="#fn2" class="footnoteRef" id="fnref2">2</a></sup>.</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>
<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>
<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>
<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. 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>
<div class="footnotes">
<hr />
<ol>
<li id="fn1"><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="#fnref1"></a></p></li>
<li id="fn2"><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="#fnref2"></a></p></li>
</ol>
</div>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2010-07-05
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,138 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - Do not use CSS gradient with Chrome</title>
<meta name="keywords" content="CSS, web, programming, Chrome, Safari, Firefox">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/2010-07-07-CSS-rendering-problems-by-navigator/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>Do not use CSS gradient with Chrome</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<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 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>
<ol style="list-style-type: decimal">
<li>Radial gradient on Chrome (not in Safari on Mac)</li>
<li>Box shadows on Firefox and Chrome</li>
</ol>
<h2 id="gradient">Gradient</h2>
<p>On Safari on Mac there is absolutely no rendering time problem. But when I use Chrome under Linux it is almost unusable.</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 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>
<p>I also detected that <strong><code>-moz-box-shadow</code></strong> elements slow down the rendering on Firefox under Linux. But there was very few time rendering issue with Safari on Mac.</p>
<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 Ill get them back.</p>
<h2 id="conclusion">Conclusion</h2>
<p>Do not use <strong><code>-webkit-gradient</code></strong> on Chrome browser yet. Try to use <strong><code>-moz-box-shadow</code></strong> sparingly.</p>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2010-07-07
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,213 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - Undecidabilities (part 1)</title>
<meta name="keywords" content="mathematics, science, philosophy, indecidability">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/2010-07-09-Indecidabilities/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>Undecidabilities (part 1)</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<p>&lt;% # toremove_ %&gt;</p>
<div class="intro">
<p><span class="sc"><abbr title="Too long; didn't read">tl;dr</abbr>: </span> I pretend to create a world to give examples of different meanings behind the word <em>undecidability</em>:</p>
<ul>
<li>Undecidability due to measure errors,</li>
<li>Big errors resulting from small initial measure error,</li>
<li>Fractal undecidability ;</li>
<li>Logic Undecidability.</li>
</ul>
</div>
<hr />
<h1 id="the-undecidabilities">The Undecidabilities</h1>
<div class="intro">
<p>If a demiurge made our world, he certainly had a great sense of humor. After this read, you should be convinced. Ill pretend to be him. Ill create a simplified world. A world that obey to simple mathematical rules. 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 predict many things that should be natural. Here begin the story.</p>
</div>
<p><img src="/Scratch/img/blog/2010-07-09-Indecidabilities/genesis.png" alt="" class="left"/></p>
<p>In the beginning there was only void. Then a blog post beginning to be written. I breath profoundly to feel the weight of the act I will accomplish. 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. Im the <em>demiurge</em> of this universe and you are its observer.</p>
<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. Note the difference. 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. Particularly, we can describe this world with axioms and mathematic rules. It is not so sure for our Universe. But well talk about that later.</p>
<p>Lets the work begin. I create an <em>Earth</em>. I populate it with intelligent people, the <em>Ys</em>. Of course they are curious. 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 are so naive. If only they knew. But Im here to help them.</p>
<p>I am a God who likes jokes. 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. I let Ys ameliorate their technology but there is a theoretical limit to the best precision they can reach.</p>
<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. Now, let the game begins.</p>
<p>Lets start easily, <em>errors can cause undecidability</em>.</p>
<h2 id="undecidability-due-to-measure-errors">Undecidability due to measure errors</h2>
<p>Here is what one of them think:</p>
<blockquote>
<p>All triangle I observe seems to share the same property. Each time I sum up their angles I obtain π radiants (180°). It is certainly a rule of my Universe. But how to be certain all triangle in my Universe share this property?</p>
</blockquote>
<p><img src="/Scratch/img/blog/2010-07-09-Indecidabilities/triangle_3_angles.png" alt="three triangles" class="left"/></p>
<p>Some began to formalize the problem. They end by writing a mathematical proof. Marvelous! The proof seems correct, but, a problem remains. The proof is based on rules and axioms. 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. The measure will never fail. But theyll never be certain the rules and axioms are right. Because then only way to verify all axioms depends of observation. And as a facetious god, I forbid perfect measure in observation.</p>
<p>Of course, they prey, they call me to help. And as any respectful god, I dont answer. Ah ah ah! Ive always loved to make these kind of thing. Lets act as if I dont exists. What a good joke!</p>
<p>They feel sad. But they have some hope:</p>
<p><em>Hope</em></p>
<blockquote>
<p>If we make small measure error, we will make small predictive error.</p>
</blockquote>
<h2 id="growing-errors-undecidability">Growing errors Undecidability</h2>
<p><img src="/Scratch/img/blog/2010-07-09-Indecidabilities/3_corps.png" alt="Three bodies" class="left"/></p>
<p>Unfortunately, the three bodies problem will crush this <em>hope</em>. 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. But now, add another body. All errors will grow. Errors will grow at a point that any prediction will be unusable.</p>
<p>Even with this bad news there is the <em>hope</em> to <em>control</em> the error.</p>
<blockquote>
<p>May we should know the maximal measure error we can handle to predict something. And we should at least determine what we can predict and what we cannot.</p>
</blockquote>
<p>Once again, this should not terminate has they hope.</p>
<h2 id="fractal-undecidability">Fractal Undecidability</h2>
<p>Consider the following question:</p>
<p><img src="/Scratch/img/blog/2010-07-09-Indecidabilities/mandelbrot.png" alt="Mandelbrot set" class="left"/></p>
<p>Consider some GPS coordinates on a point around the cost of the “Bretagne” in France. The coordinates are 3 feet precise. Is the point in the water or on Earth?</p>
<p>For some coordinates it is not possible to know. 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 “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><a href="#fn1" class="footnoteRef" id="fnref1">1</a></sup>.</p>
<h2 id="logical-undecidability">Logical Undecidability</h2>
<p><img src="/Scratch/img/blog/2010-07-09-Indecidabilities/stackOverflow.png" alt="recursive stack overflow" class="left"/></p>
<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 />Im sorry to say no. 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>Theorem: It is undecidable given a description of a program, whether the program finishes running or will run forever. The idea of the proof is simple enough to be part of this article. And this is with pleasure I give you one here.</p>
<blockquote>
<p>Suppose a program able to decide if any program halt exists. More precisely:</p>
<p>Hypothesis: there exists a program <code>P</code> such that:</p>
<ul>
<li><code>P(x,y)</code> return “stop” in a finite amount of time if <code>x(y)</code><sup><a href="#fn2" class="footnoteRef" id="fnref2">2</a></sup> will 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>
<p>Remark: Any program can be represented as a string. Therefore, a program can be used as the input of another program. It is authorized to write <code>P(x,x)</code>.</p>
<p>Let <code>Q</code> be the following program using the return value of <code>P</code>.</p>
<pre class="twilight">
Q(x) :
if P(x,x)="stop" then I enter in an infinite loop
if P(x,x)="loop" then I stop
</pre>
<p>Now, what is the value of <code>P(Q,Q)</code>?</p>
<ul>
<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 “loop” that means by construction of <code>Q</code> that <code>P(Q,Q)</code> return “stop”.</li>
</ul>
<p>Therefore there is a contradiction the only way to handle is by the non existence of the program <code>P</code>.</p>
</blockquote>
<p>I am the demiurge of this imaginary world. And I cannot know the future of this world. Therefore, creative power isnt equivalent to omnipotence.</p>
<hr />
<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. 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>
<div class="footnotes">
<hr />
<ol>
<li id="fn1"><p>The set Rhas this property.<a href="#fnref1"></a></p></li>
<li id="fn2"><p>Meaning <code>x</code> taking <code>y</code> as input.<a href="#fnref2"></a></p></li>
</ol>
</div>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2010-08-11
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

View file

@ -0,0 +1,125 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YBlog - New style after holidays</title>
<meta name="keywords" content="CSS, web, design">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/scientific.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<!-- Font -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomen"/>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
</head>
<body lang="en">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><div>Soon<img src="/Scratch/img/loading.gif" alt="Loading"/></div></div>');
// ]]>
</script>
<div id="content">
<div id="header">
<div id="choix">
<div id="choixlang">
<a href="/Scratch/fr/blog/2010-07-31-New-style-after-holidays/index.html"
onclick="setLanguage('fr')">
Français </a>
</div>
<script type="text/javascript">// <![CDATA[
document.write('<div id="switchcss"><a href="#">Change Theme</a></div>');
// ]]>
</script>
<div class="flush"></div>
</div>
<div id="navigation">
<a href="/">Home</a>
<span class="sep">¦</span>
<a href="/Scratch/en/blog">Blog</a>
<span class="sep">¦</span>
<a href="/Scratch/en/softwares">Softwares</a>
<span class="sep">¦</span>
<a href="/Scratch/en/about">About</a>
</div>
</div>
<div id="titre">
<h1>New style after holidays</h1>
</div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<p>Before my holidays many visitors tell me my website was too long to scroll. This is why I completely changed my website design. Now all should scroll smoothly on all platforms. I was inspired by Readability and iBooks(c) (the iPhone(c) application).</p>
<p>Tell me what you think of this new design.</p>
</div>
<div id="social">
<span>
<a class="rss" href="http://feeds.feedburner.com/yannespositocomen">RSS</a>
</span>
<span>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<span>
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</span>
<div class="flush"></div>
</div>
<div class="corps" id="comment">
<h2 class="first">Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yannesposito'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="bottom">
<div>
Published on 2010-07-31
</div>
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
Yann Esposito©
</div>
<div>
Done with
<a href="http://www.vim.org">Vim</a>
<span class="nicer">&amp;</span>
<a href="http://jaspervdj.be/hakyll">Hakyll</a>
</div>
</div>
</div>
</div>
</body>
<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/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>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</html>

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