<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>Ch-M.D</title><link href="http://blog.chmd.fr/" rel="alternate"></link><link href="http://blog.chmd.fr/feeds/all.atom.xml" rel="self"></link><id>http://blog.chmd.fr/</id><updated>2025-08-19T19:00:00+02:00</updated><entry><title>Self-Archiving Emails</title><link href="http://blog.chmd.fr/self-archiving-emails.html" rel="alternate"></link><published>2025-08-19T19:00:00+02:00</published><updated>2025-08-19T19:00:00+02:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2025-08-19:/self-archiving-emails.html</id><summary type="html">&lt;p&gt;The concept of Inbox Zero has been around since 2007, and we can thank
Merlin Mann for popularizing it. If you have not watched the
&lt;a href="https://www.youtube.com/watch?v=z9UjeTMb3Yk"&gt;presentation&lt;/a&gt;, I highly recommend doing it, because it is still
relevant in 2025.&lt;/p&gt;
&lt;p&gt;For the past 3 years, I have been running an automation which …&lt;/p&gt;</summary><content type="html">&lt;p&gt;The concept of Inbox Zero has been around since 2007, and we can thank
Merlin Mann for popularizing it. If you have not watched the
&lt;a href="https://www.youtube.com/watch?v=z9UjeTMb3Yk"&gt;presentation&lt;/a&gt;, I highly recommend doing it, because it is still
relevant in 2025.&lt;/p&gt;
&lt;p&gt;For the past 3 years, I have been running an automation which I now
consider essential to keeping my inbox tidy. I call it &lt;em&gt;self-archiving
emails&lt;/em&gt;. The concept is simple: if an email has been sitting in my inbox
for long enough (and for me, that's currently 8 months), I will probably
never do anything about it. So it might as well archive itself. In
practice, 8 months is a worst-case scenario, because a lot of the emails I
receive are only interesting for a few days. The expiration date is set on
a case by case situation, using regular email rules.&lt;/p&gt;
&lt;h2&gt;Gmail implementation&lt;/h2&gt;
&lt;p&gt;I am leveraging labels to implement this strategy. My flow is as follows:
using basic filters, I label every incoming email with one of the
following: &lt;code&gt;archive-1d&lt;/code&gt;, &lt;code&gt;archive-3d&lt;/code&gt;, &lt;code&gt;archive-7d&lt;/code&gt;, &lt;code&gt;archive-1m&lt;/code&gt;,
&lt;code&gt;archive-2m&lt;/code&gt;, &lt;code&gt;archive-4m&lt;/code&gt; or &lt;code&gt;archive-ifread&lt;/code&gt;. Every hour, a script
archives every message which sits in my inbox and is older than what the
label indicates.&lt;/p&gt;
&lt;p&gt;The script runs as a google apps script:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;run&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;// find all the archive-xx labels&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;labels&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;GmailApp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getUserLabels&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getName&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;startsWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;archive-&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;archive-xx&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;// archive all the expired emails according to their respective labels&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;of&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;duration&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;-&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mf"&gt;1&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nx"&gt;archive&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;in:inbox label:&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot; older_than:&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;duration&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;// archive anything older than 8m&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nx"&gt;archive&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;in:inbox older_than:8m&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;// archive emails which have no value once I have seen them&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nx"&gt;archive&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;in:inbox is:read label:archive-ifread&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;archive&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;search&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nx"&gt;Logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;archiving: &amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;search&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;threads&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;GmailApp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;search&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nx"&gt;Logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;found &amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;threads&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot; threads:&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;threads&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;thread&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;threads&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="nx"&gt;Logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mf"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;. &amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;thread&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getFirstMessageSubject&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;batch_size&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;100&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="k"&gt;while&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;threads&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;this_batch_size&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;threads&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;batch_size&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;this_batch&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;threads&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;splice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;this_batch_size&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nx"&gt;GmailApp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;moveThreadsToArchive&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;this_batch&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;There are already plenty of google apps scripts tutorials, so I will not
go into the details of deploying this script, but it roughly involves
going to &lt;a href="https://script.google.com"&gt;script.google.com&lt;/a&gt;, pasting this code into a new project and
setting the function &lt;code&gt;run&lt;/code&gt; to trigger every hour. I am sure you will
figure this out.&lt;/p&gt;
&lt;h2&gt;Office 365&lt;/h2&gt;
&lt;p&gt;My workplace uses office 365, but that did not stop me from implementing
the same logic using MS powerflows. It is, however, massively ugly, so I
will not share it here. If you are interested in how to do it, send me an
email, I may post another article about it if this is a popular request.&lt;/p&gt;
&lt;h2&gt;Feedback&lt;/h2&gt;
&lt;p&gt;3 years later, I can report that this concept of self-archiving emails has
drastically reduced the size of my inbox, to the point that I could not imagine
living without it. Surprisingly, I am the only person I know who runs such an
automation. I discussed about it with some friends the other day, and because
this generated some interest, I decided to share it here.  If you end up using
it as well, feel free to shoot me an email, and if you promote this approach to
others, please credit me 😉&lt;/p&gt;</content><category term="email"></category><category term="gmail"></category></entry><entry><title>Scripting sudo with pass</title><link href="http://blog.chmd.fr/scripting-sudo-with-pass.html" rel="alternate"></link><published>2020-01-06T14:30:00+01:00</published><updated>2020-01-06T14:30:00+01:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2020-01-06:/scripting-sudo-with-pass.html</id><summary type="html">&lt;p&gt;Like a lot of folks, I use &lt;a href="https://www.passwordstore.org/"&gt;zx2c4's pass&lt;/a&gt;. Like even more
people, I use sudo for administrative tasks on my machines.&lt;/p&gt;
&lt;h2&gt;Seamless integration&lt;/h2&gt;
&lt;p&gt;A lot of tools (&lt;a href="http://www.offlineimap.org/"&gt;offlineimap&lt;/a&gt;, &lt;a href="https://github.com/docker/docker-credential-helpers"&gt;docker&lt;/a&gt;, &lt;a href="https://www.sudo.ws/man/1.8.15/sudoers.man.html"&gt;ansible-vault&lt;/a&gt;...)
offer a way to provide the password through an external command. This is
where &lt;code&gt;pass&lt;/code&gt; excels. By allowing you …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Like a lot of folks, I use &lt;a href="https://www.passwordstore.org/"&gt;zx2c4's pass&lt;/a&gt;. Like even more
people, I use sudo for administrative tasks on my machines.&lt;/p&gt;
&lt;h2&gt;Seamless integration&lt;/h2&gt;
&lt;p&gt;A lot of tools (&lt;a href="http://www.offlineimap.org/"&gt;offlineimap&lt;/a&gt;, &lt;a href="https://github.com/docker/docker-credential-helpers"&gt;docker&lt;/a&gt;, &lt;a href="https://www.sudo.ws/man/1.8.15/sudoers.man.html"&gt;ansible-vault&lt;/a&gt;...)
offer a way to provide the password through an external command. This is
where &lt;code&gt;pass&lt;/code&gt; excels. By allowing you to extract any password with a simple
command line, it lets you have all of your passwords in one place, with no
overhead in your workflow.&lt;/p&gt;
&lt;h2&gt;What about sudo?&lt;/h2&gt;
&lt;p&gt;If you want to run a sudo command without typing the password
interactively, you would normally use the &lt;a href="https://www.sudo.ws/man/1.8.15/sudoers.man.html"&gt;NOPASSWD&lt;/a&gt; option in
&lt;code&gt;/etc/sudoers&lt;/code&gt;. I do not find it desirable: should you leave a console
unattended, this exposes you to somebody running administrative commands
too easily.&lt;/p&gt;
&lt;p&gt;So can you instead tell sudo to use pass for the password input? Sort of.
The &lt;code&gt;-A&lt;/code&gt; &lt;a href="https://www.sudo.ws/man/1.8.3/sudo.man.html"&gt;command line option&lt;/a&gt; is designed to provide the password
through an helper program. To quote the manpage:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;If the -A (askpass) option is specified, a (possibly graphical) helper
program is executed to read the user's password and output the password
to the standard output. If the &lt;code&gt;SUDO_ASKPASS&lt;/code&gt; environment variable is set,
it specifies the path to the helper program.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Let's take advantage of this!&lt;/p&gt;
&lt;h2&gt;Implementation&lt;/h2&gt;
&lt;p&gt;I store in pass my different "&lt;code&gt;user@host&lt;/code&gt;" passwords under the path
&lt;code&gt;host/&amp;lt;user&amp;gt;@&amp;lt;host&amp;gt;&lt;/code&gt;. If you adopt the same convention, this is what you can
do:&lt;/p&gt;
&lt;p&gt;Save the following file as executable under &lt;code&gt;~/.local/bin/sudo-askpass&lt;/code&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="ch"&gt;#!/bin/bash&lt;/span&gt;
pass&lt;span class="w"&gt; &lt;/span&gt;show&lt;span class="w"&gt; &lt;/span&gt;hosts/&lt;span class="k"&gt;$(&lt;/span&gt;whoami&lt;span class="k"&gt;)&lt;/span&gt;@&lt;span class="k"&gt;$(&lt;/span&gt;hostname&lt;span class="k"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;head&lt;span class="w"&gt; &lt;/span&gt;-n1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Insert your password in pass accordingly&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;pass&lt;span class="w"&gt; &lt;/span&gt;edit&lt;span class="w"&gt; &lt;/span&gt;hosts/&lt;span class="k"&gt;$(&lt;/span&gt;whoami&lt;span class="k"&gt;)&lt;/span&gt;@&lt;span class="k"&gt;$(&lt;/span&gt;hostname&lt;span class="k"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;And now if you run&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nb"&gt;export&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;SUDO_ASKPASS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;/.local/bin/sudo-askpass
sudo&lt;span class="w"&gt; &lt;/span&gt;-A&lt;span class="w"&gt; &lt;/span&gt;whoami
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The answer should be &lt;code&gt;root&lt;/code&gt;. Neat, but not seamless, since you need the -A
switch. You &lt;em&gt;could&lt;/em&gt; solve the problem by adding these 2 lines in your shell
startup file&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nb"&gt;export&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;SUDO_ASKPASS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;/.local/bin/sudo-askpass
&lt;span class="nb"&gt;alias&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;sudo&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;sudo -A&amp;#39;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;However, programs which invoke &lt;code&gt;sudo&lt;/code&gt; (such as &lt;a href="https://github.com/Jguer/yay"&gt;yay&lt;/a&gt;) will not know about
this alias, and you will still be required to type your password
interactively. What I do instead is to create my own sudo executable with
higher precedence in the path whicht insert the proper options before
invoking the real binary:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="ch"&gt;#!/bin/bash&lt;/span&gt;

&lt;span class="nv"&gt;SCRIPTDIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;$(&lt;/span&gt;dirname&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;$(&lt;/span&gt;which&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$0&lt;/span&gt;&lt;span class="k"&gt;))&lt;/span&gt;
&lt;span class="nv"&gt;PATH_WITHOUT_SCRIPTDIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$PATH&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;tr&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;:&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;\n&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;grep&lt;span class="w"&gt; &lt;/span&gt;-v&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="nv"&gt;$SCRIPTDIR&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;tr&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;\n&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;:&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;REAL_SUDO&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;$(&lt;/span&gt;env&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$PATH_WITHOUT_SCRIPTDIR&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;which&lt;span class="w"&gt; &lt;/span&gt;sudo&lt;span class="k"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;exec&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;env&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;SUDO_ASKPASS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;/.local/bin/sudo-askpass&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$REAL_SUDO&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;--askpass&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="nv"&gt;$@&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;If your distribution follows the &lt;a href="http://man7.org/linux/man-pages/man7/file-hierarchy.7.html"&gt;systemd file hierarchy&lt;/a&gt;, you can save
this file under &lt;code&gt;~/.local/bin/sudo&lt;/code&gt; and it will happily take precedence
over the real sudo.&lt;/p&gt;
&lt;h2&gt;Keychain&lt;/h2&gt;
&lt;p&gt;I employ a similar trick for unlocking my ssh keys with keychain. I store
in pass the password of the private ssh key of &lt;code&gt;&amp;lt;user&amp;gt;@&amp;lt;host&amp;gt;&lt;/code&gt; as
&lt;code&gt;ssh/&amp;lt;user&amp;gt;@&amp;lt;host&amp;gt;&lt;/code&gt;. The following file is saved as executable under
&lt;code&gt;~/.local/bin/ssh-askpass&lt;/code&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="ch"&gt;#!/bin/bash&lt;/span&gt;
pass&lt;span class="w"&gt; &lt;/span&gt;show&lt;span class="w"&gt; &lt;/span&gt;ssh/&lt;span class="k"&gt;$(&lt;/span&gt;whoami&lt;span class="k"&gt;)&lt;/span&gt;@&lt;span class="k"&gt;$(&lt;/span&gt;hostname&lt;span class="k"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;head&lt;span class="w"&gt; &lt;/span&gt;-n1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;And this goes in my shell startup file&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;keychain&lt;span class="w"&gt; &lt;/span&gt;&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;/dev/null&lt;span class="o"&gt;}&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;ssh-askpass&lt;span class="w"&gt; &lt;/span&gt;&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;/dev/null&lt;span class="o"&gt;}&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;source&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&amp;lt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;SSH_ASKPASS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;ssh-askpass&lt;span class="w"&gt; &lt;/span&gt;keychain&lt;span class="w"&gt; &lt;/span&gt;--quiet&lt;span class="w"&gt; &lt;/span&gt;--eval&lt;span class="w"&gt; &lt;/span&gt;id_rsa&lt;span class="w"&gt; &lt;/span&gt;&amp;lt;/dev/null&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;More to come&lt;/h2&gt;
&lt;p&gt;If you have a look at my &lt;a href="https://github.com/chmduquesne/dotfiles"&gt;dotfiles&lt;/a&gt;, you will realize that there is
more to this setup. The main additional thing to know is that I use a
&lt;a href="https://www.yubico.com/"&gt;smartcard&lt;/a&gt; to handle the gpg decryption, so that no machine contains
the gpg key that I use with &lt;code&gt;pass&lt;/code&gt;. This will likely be the purpose of a
different article. Until then and as always, I am gladly taking any
comment.&lt;/p&gt;
&lt;p&gt;Happy sudo-ing!&lt;/p&gt;</content><category term="code"></category><category term="passphrase"></category><category term="shell"></category></entry><entry><title>Looping simultaneously over multiple lists in legacy shells</title><link href="http://blog.chmd.fr/looping-simultaneously-over-multiple-lists-in-legacy-shells.html" rel="alternate"></link><published>2018-05-30T23:11:00+02:00</published><updated>2018-05-30T23:11:00+02:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2018-05-30:/looping-simultaneously-over-multiple-lists-in-legacy-shells.html</id><summary type="html">&lt;p&gt;I was recently confronted to the problem of looping over multiple lists
simultaneously in a legacy shell, and coming up with an elegant solution
was an interesting challenge. Legacy shells do not support arrays, which
means there is no structure you can directly address with an index i in
order …&lt;/p&gt;</summary><content type="html">&lt;p&gt;I was recently confronted to the problem of looping over multiple lists
simultaneously in a legacy shell, and coming up with an elegant solution
was an interesting challenge. Legacy shells do not support arrays, which
means there is no structure you can directly address with an index i in
order to get the iᵗʰ element. How can one then process multiple lists
simultaneously in order to get the first element of each list, then the
second element of each list, then the third... and so on?&lt;/p&gt;
&lt;h2&gt;A python analogy&lt;/h2&gt;
&lt;p&gt;In python, there is a neat buitin called &lt;code&gt;zip&lt;/code&gt;. Essentially, &lt;code&gt;zip&lt;/code&gt; takes an
arbitrary set of lists as an argument, and returns an iterator of tuples,
such that the first tuple is composed of the first element of each list,
the second tuple has the second element of each list, and so on. It always
goes better with an example:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;t&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;zip&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;[&lt;span class="s1"&gt;&amp;#39;a&amp;#39;&lt;/span&gt;,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;b&amp;#39;&lt;/span&gt;,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;c&amp;#39;&lt;/span&gt;,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;d&amp;#39;&lt;/span&gt;],&lt;span class="w"&gt; &lt;/span&gt;[&lt;span class="mi"&gt;1&lt;/span&gt;,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;],&lt;span class="w"&gt; &lt;/span&gt;[&lt;span class="s1"&gt;&amp;#39;!&amp;#39;&lt;/span&gt;,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;@&amp;#39;&lt;/span&gt;,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;#&amp;#39;&lt;/span&gt;,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;%&amp;#39;&lt;/span&gt;]&lt;span class="ss"&gt;)&lt;/span&gt;:
...&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="nv"&gt;print&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;t&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
...
&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;a&amp;#39;&lt;/span&gt;,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;!&amp;#39;&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;b&amp;#39;&lt;/span&gt;,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;@&amp;#39;&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;c&amp;#39;&lt;/span&gt;,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;#&amp;#39;&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;d&amp;#39;&lt;/span&gt;,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;%&amp;#39;&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The question is, how can we produce a similar function in a legacy shell?&lt;/p&gt;
&lt;h2&gt;Let's specify&lt;/h2&gt;
&lt;p&gt;Our goal is to produce a shell function that we will also conveniently
name &lt;code&gt;zip&lt;/code&gt;. Of course, this function must work in legacy shells such as
ash or dash. It will expect an unspecified number of lists as arguments,
and return a flattened list of tuples, where the iᵗʰ tuple is composed of
all of the iᵗʰ elements of each list. Like in python, if the lists
provided as arguments are not of equal lengths, the result will be cut at
the shortest length. Here are examples of expected behaviour:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;# 3 lists of same length
$ zip &amp;quot;a b c d&amp;quot; &amp;quot;1 2 3 4&amp;quot; &amp;quot;! @ # %&amp;quot;
 a 1 !
 b 2 @
 c 3 #
 d 4 %

# 1 list
$ zip &amp;quot;a b c d&amp;quot;
 a
 b
 c
 d

# 2 lists of different length
$ zip &amp;quot;a b&amp;quot; &amp;quot;1 2 3&amp;quot;
 a 1
 b 2

# 0 list
$ zip
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;How to use it would then just be a matter of using the set builtin:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;$&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;list1&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;1 2 3 4&amp;quot;&lt;/span&gt;
$&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;list2&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;a b c d&amp;quot;&lt;/span&gt;
$&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;$(&lt;/span&gt;zip&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="nv"&gt;$list1&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="nv"&gt;$list2&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;)&lt;/span&gt;
$&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;i&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;$(&lt;/span&gt;seq&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;4&lt;/span&gt;&lt;span class="k"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;do&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;processing &lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="s2"&gt; and &lt;/span&gt;&lt;span class="nv"&gt;$2&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;shift&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
processing&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;and&lt;span class="w"&gt; &lt;/span&gt;a
processing&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;and&lt;span class="w"&gt; &lt;/span&gt;b
processing&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;and&lt;span class="w"&gt; &lt;/span&gt;c
processing&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;4&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;and&lt;span class="w"&gt; &lt;/span&gt;d
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;The implementation&lt;/h2&gt;
&lt;p&gt;It is often not obvious to the beginner how to create variable names out
of other variables. For example, the name &lt;code&gt;list$i&lt;/code&gt; is an illegal variable
name, so you cannot do:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;i=1
list$i=&amp;quot;a b c&amp;quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;What is the way to get around that? The answer is &lt;code&gt;eval&lt;/code&gt;, of course!&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;i=1
eval &amp;quot;list$i=&amp;#39;a b c&amp;#39;&amp;quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;So our zip function begins like this&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;zip&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;nlists&lt;/span&gt;&lt;span class="o"&gt;=$&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ow"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;seq&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;$&lt;/span&gt;&lt;span class="n"&gt;nlists&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;do&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="n"&gt;eval&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;list$i=&amp;#39;$1&amp;#39;&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="n"&gt;shift&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;done&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="c1"&gt;# the input lists are now in the variable named list1, list2....&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;...&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;We would like to loop over all lists, extract the first element, append it
to the tuple, and update the list to reflect the tail. The least error
prone way I have found to extract the first element is to use a printf
construct&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;$&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;%s\n&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;a&lt;span class="w"&gt; &lt;/span&gt;b&lt;span class="w"&gt; &lt;/span&gt;c&lt;span class="w"&gt; &lt;/span&gt;d
a
b
c
d
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This prints all element of the list line by line. One can easily combine
it with &lt;code&gt;head -n1&lt;/code&gt; and &lt;code&gt;tail -n+2&lt;/code&gt; to get the head or the tail of the
list.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;head=$(printf &amp;#39;%s\n&amp;#39; $list | head -n1)
tail=$(printf &amp;#39;%s\n&amp;#39; $list | tail -n+2)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;It works more reliably, for example, than using the buitin &lt;code&gt;set&lt;/code&gt; to put the
elements of the list in the argument list &lt;code&gt;$1&lt;/code&gt;, &lt;code&gt;$2&lt;/code&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;set $list
head=$1
shift
tail=&amp;quot;$*&amp;quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Why? The reason is that if the first argument is the string litteral &lt;code&gt;-&lt;/code&gt;, set
will not behave the way we want! The second part of the function therefore
looks like this, with a bunch of &lt;code&gt;eval&lt;/code&gt;s&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;while&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;true&lt;/span&gt;&lt;span class="c1"&gt;; do&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;tuple&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;i&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;$&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;seq&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;$&lt;span class="nv"&gt;nlists&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;&lt;span class="c1"&gt;; do&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nv"&gt;eval&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;[ -z \&amp;quot;&lt;/span&gt;\$&lt;span class="nv"&gt;list&lt;/span&gt;$&lt;span class="nv"&gt;i&lt;/span&gt;\&lt;span class="s2"&gt;&amp;quot; ] &amp;amp;&amp;amp; return 0&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nv"&gt;eval&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;head=\$(printf &amp;#39;%s\\n&amp;#39; \$list$i | head -n1)&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nv"&gt;eval&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;list$i=\$(printf &amp;#39;%s\\n&amp;#39; \$list$i | tail -n+2)&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nv"&gt;tuple&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;$tuple $head&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;done&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;echo&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;$tuple&amp;quot;&lt;/span&gt;
&lt;span class="nv"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This looks about right: when one of the lists is empty, we know we will
not be able to complete the current tuple, so we return immediately
without further &lt;code&gt;echo&lt;/code&gt;ing. The devil is in the details, because if
provided with zero argument, this function will loop forever. However, we
really want to start looping if and only if there are arguments. This
could be achieved by changing&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;while&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;true&lt;/span&gt;&lt;span class="c1"&gt;; do&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;to&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;while&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;[&lt;span class="w"&gt; &lt;/span&gt;$&lt;span class="nv"&gt;nlists&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;!=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;]&lt;span class="c1"&gt;; do&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;I don't find this construct very readable, as it makes it look like this
condition could change during the loops. I'd rather add the check&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;[&lt;span class="w"&gt; &lt;/span&gt;$&lt;span class="nv"&gt;nlist&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;]&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;at the beginning of the function.&lt;/p&gt;
&lt;h2&gt;The result&lt;/h2&gt;
&lt;p&gt;Here is how the code looks at the end. I think this could be a fun
interview question!&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nv"&gt;zip&lt;/span&gt;&lt;span class="ss"&gt;()&lt;/span&gt;{
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;nlists&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;$#
&lt;span class="w"&gt;    &lt;/span&gt;[&lt;span class="w"&gt; &lt;/span&gt;$&lt;span class="nv"&gt;nlists&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;]&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;i&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;$&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;seq&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;$&lt;span class="nv"&gt;nlists&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;&lt;span class="c1"&gt;; do&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nv"&gt;eval&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;list$i=&amp;#39;$1&amp;#39;&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nv"&gt;shift&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;done&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;while&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;true&lt;/span&gt;&lt;span class="c1"&gt;; do&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nv"&gt;tuple&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;i&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;$&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;seq&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;$&lt;span class="nv"&gt;nlists&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;&lt;span class="c1"&gt;; do&lt;/span&gt;
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="nv"&gt;eval&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;[ -z \&amp;quot;&lt;/span&gt;\$&lt;span class="nv"&gt;list&lt;/span&gt;$&lt;span class="nv"&gt;i&lt;/span&gt;\&lt;span class="s2"&gt;&amp;quot; ] &amp;amp;&amp;amp; return 0&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="nv"&gt;eval&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;head=\$(printf &amp;#39;%s\\n&amp;#39; \$list$i | head -n1)&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="nv"&gt;eval&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;list$i=\$(printf &amp;#39;%s\\n&amp;#39; \$list$i | tail -n+2)&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="nv"&gt;tuple&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;$tuple $head&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nv"&gt;done&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nv"&gt;echo&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;$tuple&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;done&lt;/span&gt;
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Do you think it can be improved? Do you have your own different technique
to achieve this? Let me know in the comments!&lt;/p&gt;</content><category term="howto"></category><category term="shell"></category><category term="sh"></category><category term="dash"></category><category term="ash"></category></entry><entry><title>SSH over SSL, episode 4: a HAproxy based configuration</title><link href="http://blog.chmd.fr/ssh-over-ssl-episode-4-a-haproxy-based-configuration.html" rel="alternate"></link><published>2014-10-19T17:40:00+02:00</published><updated>2014-10-19T17:40:00+02:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2014-10-19:/ssh-over-ssl-episode-4-a-haproxy-based-configuration.html</id><summary type="html">&lt;h2&gt;Purpose of this article&lt;/h2&gt;
&lt;p&gt;In this article, I am describing how to SSH to a remote server as
discreetly as possible, by concealing the SSH packets into SSL. The
server will still be able to run an SSL website.&lt;/p&gt;
&lt;h2&gt;Rationale&lt;/h2&gt;
&lt;p&gt;In most cases, when your outgoing firewall blocks ssh, you …&lt;/p&gt;</summary><content type="html">&lt;h2&gt;Purpose of this article&lt;/h2&gt;
&lt;p&gt;In this article, I am describing how to SSH to a remote server as
discreetly as possible, by concealing the SSH packets into SSL. The
server will still be able to run an SSL website.&lt;/p&gt;
&lt;h2&gt;Rationale&lt;/h2&gt;
&lt;p&gt;In most cases, when your outgoing firewall blocks ssh, you can work around
with &lt;a href="http://www.rutschle.net/tech/sslh.shtml"&gt;sslh&lt;/a&gt;, a tool that listens
on the port 443 server-side, and selectively forwards, depending on the
packet type, the incoming TCP connections to a local SSH or SSL service.
You can then happily ssh to your server on the port 443 (normally
dedicated to HTTPS), and also run a website on the same server so your
connections look you are just harmlessly visiting this website. However,
if your firewall is really sneaky, it will detect that you are sending the
wrong packet type to the SSL port, and block your connection. In this
case, there is not much choice: we must hide the SSH connection into a
real SSL tunnel.&lt;/p&gt;
&lt;h2&gt;Comment for the long time readers&lt;/h2&gt;
&lt;p&gt;I know, I know: I covered this topic a few times already (here are the
&lt;a href="/ssh-over-ssl-a-quick-and-minimal-config.html"&gt;first&lt;/a&gt;,
&lt;a href="/ssh-over-ssl-episode-2-replacing-proxytunnel-with-socat.html"&gt;second&lt;/a&gt;,
and &lt;a href="/ssh-over-ssl-episode-3-avoiding-using-a-patched-apache.html"&gt;third&lt;/a&gt;
episodes). All of these setups were relying on a feature of HTTP 1.1
called CONNECT. However, it turns out that most webserver do not implement
this CONNECT feature. As a consequence, if you wanted to do this, you were
more or less stuck with Apache. This time, we are breaking free from
Apache, with a HAproxy-based configuration. We will use HAproxy advanced
packet inspection capabilities to implement a switch of protocol, the same
way sslh works.&lt;/p&gt;
&lt;h2&gt;Server configuration&lt;/h2&gt;
&lt;p&gt;Some assumptions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The port 443 of your server is publicly reachable&lt;/li&gt;
&lt;li&gt;It runs ssh (but no need for the port 22 to be reachable)&lt;/li&gt;
&lt;li&gt;Some web server is running on the port 80 and it supports the
  'X-Forwarded-Proto' header (see the documentation of your webserver to
  enable that).&lt;/li&gt;
&lt;li&gt;You have generated ssl certificates (you copied the public key and the
  private key in the same file /etc/ssl/private/certs.pem)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Now, you need to setup HAproxy. HAproxy defines backends and frontends, and it
can communicate with these backends both at the HTTP and at the TCP level. Let
us start with the backends:&lt;/p&gt;
&lt;p&gt;The web server backend: we tell HAproxy that a server is running on the
port 80, and speaks HTTP. On this backend, we add a X-Forwarded-Proto
header, such that the web server knows that the clients are connecting
securely. If you expose the same backend with HAproxy on the port 80,
don't forget to filter the X-Forwarded-Proto header!&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;backend secure_http
    reqadd X-Forwarded-Proto:\ https
    rspadd Strict-Transport-Security:\ max-age=31536000
    mode http
    option httplog
    option forwardfor
    server local_http_server 127.0.0.1:80
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The ssh server:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;backend ssh
    mode tcp
    option tcplog
    server ssh 127.0.0.1:22
    timeout server 2h
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;And now, the magic. This happens in the frontend section. We listen in TCP mode
and inspect the connections. Depending on whether we see ssh or not, we hook it
to one of the backends.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;frontend&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ssl&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;bind&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;X&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;X&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;X&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;X&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;443&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ssl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;crt&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;etc&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;ssl&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;private&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;certs&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pem&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;no&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;sslv3&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;mode&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;tcp&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;option&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;tcplog&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;tcp&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;inspect&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;tcp&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;accept&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;HTTP&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;acl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;client_attempts_ssh&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;bin&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;5353482&lt;/span&gt;&lt;span class="n"&gt;d322e30&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;use_backend&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ssh&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;HTTP&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;use_backend&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ssh&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;client_attempts_ssh&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;use_backend&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;secure_http&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;HTTP&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Once you are done, you can test if this works by connecting on the server
with openssl.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;openssl s_client -connect server.com:443 -quiet
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;If you see a string that looks like&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;SSH-2.0-OpenSSH_6.6.1p1 Debian-7
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;then everything went fine!&lt;/p&gt;
&lt;h2&gt;Connecting from an SSH client&lt;/h2&gt;
&lt;p&gt;To connect to your server from linux, just drop this in your ~/.ssh/config:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;Host server.com
    ProxyCommand openssl s_client -connect server.com:443 -quiet
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;If you are on windows and you cannot install anything client side, there
is also a solution for you. Download socat and putty (none of them
requires admin rights). Then, with socat, run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;socat TCP-LISTEN:8888 OPENSSL:server.com:443,verify=0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;And with putty, direct your client to 127.0.0.1 on the port 8888.&lt;/p&gt;
&lt;h2&gt;For the technically aware readers&lt;/h2&gt;
&lt;p&gt;So how does this work exactly? Basically, the &lt;a href="https://tools.ietf.org/html/rfc4253#section-4.2"&gt;RFC 4253, section
4.2&lt;/a&gt; states that clients
must send a string that starts with 'SSH-2.0' (this is also how sslh does
it). Moreover, 5353482d322e30 is the binary representation of the string
'SSH-2.0'. So everything boils down to this line:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;acl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;client_attempts_ssh&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;bin&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;5353482&lt;/span&gt;&lt;span class="n"&gt;d322e30&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;When a new connection is made on the port 443, HAproxy decrypts the SSL
layer, and checks whether the stream of data sent by the client starts
with this string. We use the result of this condition to choose the
backend. This handles the case of 'active' SSH clients (like
openssh-client on linux), who send a packet as soon as they connect.
There are also 'passive' SSH clients (like putty), who wait for the server
to send a string. These clients will get that string after 5 seconds (the
inspect-delay).&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Happy SSH!&lt;/p&gt;</content><category term="howto"></category><category term="ssh"></category><category term="ssl"></category><category term="HAproxy"></category></entry><entry><title>Editing a CV in markdown with pandoc</title><link href="http://blog.chmd.fr/editing-a-cv-in-markdown-with-pandoc.html" rel="alternate"></link><published>2013-10-30T15:53:00+01:00</published><updated>2013-10-30T15:53:00+01:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2013-10-30:/editing-a-cv-in-markdown-with-pandoc.html</id><summary type="html">&lt;p&gt;CV maintainance is one of these painful and repetitive tasks that you
don't want to burn too much time on.  For a while, I have been using latex
with the excellent &lt;a href="http://www.ctan.org/pkg/moderncv"&gt;moderncv class&lt;/a&gt;, but
the pdf format has annoying limitations:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Seeing a pdf document in a browser is not as …&lt;/li&gt;&lt;/ul&gt;</summary><content type="html">&lt;p&gt;CV maintainance is one of these painful and repetitive tasks that you
don't want to burn too much time on.  For a while, I have been using latex
with the excellent &lt;a href="http://www.ctan.org/pkg/moderncv"&gt;moderncv class&lt;/a&gt;, but
the pdf format has annoying limitations:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Seeing a pdf document in a browser is not as nice as seeing an html
  webpage;&lt;/li&gt;
&lt;li&gt;Human Resources usually prefer to work with word documents.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I thus decided to switch to the markdown syntax, and to generate various
formats with pandoc. The code of my résumé now looks like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="gh"&gt;Cave Johnson&lt;/span&gt;
&lt;span class="gh"&gt;============&lt;/span&gt;

----

&amp;gt;  Science isn&amp;#39;t about WHY. It&amp;#39;s about WHY NOT!

----

&lt;span class="gh"&gt;Corporate Experience&lt;/span&gt;
&lt;span class="gh"&gt;--------------------&lt;/span&gt;

1940-1980
:   &lt;span class="ge"&gt;*CEO of Aperture Science*&lt;/span&gt; (Upper Michigan, USA).

    Supervised the development of various gels, and of a Portable
    Quantum Tunneling Device.

&lt;span class="gh"&gt;Hobbies&lt;/span&gt;
&lt;span class="gh"&gt;-------&lt;/span&gt;

Interests
:   Refining moon rocks
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The file can then be compiled in various formats. To obtain the html
version:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;pandoc --standalone --from markdown --to html -o index.html index.md
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;But the default ouptut is rather ugly. That is why I wrote &lt;a href="//resume.chmd.fr/style.css"&gt;a
CSS&lt;/a&gt; to go with the html generated by pandoc.
It is inspired by moderncv, and specially adapted for this use case. The
command line becomes:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;pandoc --standalone -c style.css --from markdown --to html -o index.html index.md
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Now that you are at it, you can also generate a word document or even some
plain text file. No need to build a new one in a hurry!&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;pandoc --from markdown --to docx -o index.docx index.md
pandoc --standalone --smart --from markdown --to plain -o index.txt index.md
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;You can get a look at what it looks like on &lt;a href="//resume.chmd.fr"&gt;my own
résumé&lt;/a&gt;. The full code can be found on
&lt;a href="https://git.chmd.fr/?p=resume.git"&gt;git.chmd.fr&lt;/a&gt; (and
&lt;a href="https://github.com/chmduquesne/resume"&gt;github&lt;/a&gt;).&lt;/p&gt;</content><category term="code"></category><category term="pandoc markdown"></category></entry><entry><title>Using openid and the likes to protect static content (lighttpd)</title><link href="http://blog.chmd.fr/using-openid-and-the-likes-to-protect-static-content-lighttpd.html" rel="alternate"></link><published>2013-10-29T14:22:00+01:00</published><updated>2013-10-29T14:22:00+01:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2013-10-29:/using-openid-and-the-likes-to-protect-static-content-lighttpd.html</id><summary type="html">&lt;p&gt;I &lt;a href="http://blog.chmd.fr/sigal-a-static-gallery-generator.html"&gt;recently&lt;/a&gt;
set up a self-hosted gallery for my pictures. Obviously, I did this
because I wanted to stop giving my content to external platforms, but also
to gain some level of privacy: I want to limit the number of people who
are able to look at these pictures.&lt;/p&gt;
&lt;p&gt;While …&lt;/p&gt;</summary><content type="html">&lt;p&gt;I &lt;a href="http://blog.chmd.fr/sigal-a-static-gallery-generator.html"&gt;recently&lt;/a&gt;
set up a self-hosted gallery for my pictures. Obviously, I did this
because I wanted to stop giving my content to external platforms, but also
to gain some level of privacy: I want to limit the number of people who
are able to look at these pictures.&lt;/p&gt;
&lt;p&gt;While setting up the gallery was relatively easy, restricting the access
was an interesting problem. I did not want to use a global
&lt;code&gt;username:password&lt;/code&gt; combination, because this kind of credentials
inevitably become public at some point. A different combination for each
user would have been better, but some people are not as careful as I am
with their own credentials, and they may just give away their own access
to others. It is also a lot of maintenance, and I don't want to deal with
the risks involved with securely processing my friends' passwords.&lt;/p&gt;
&lt;p&gt;I then had a look at single sign on solutions such as openid. This kind of
technology was appealing, for several reasons:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;No password to process on my side&lt;/li&gt;
&lt;li&gt;People would identify with a very personal account (gmail, facebook),
  that they are unlikely to be willing to share with anyone else.&lt;/li&gt;
&lt;li&gt;It is very easy to use for the end user.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I have thus been looking for a solution to get openid/oauth authentication
to cooperate with lighttpd in order to protect my new gallery. After some
work, I came up with &lt;a href="https://git.chmd.fr/?p=lighttpd-external-auth;a=blob_plain;f=external-auth.lua"&gt;a lua magnet
script&lt;/a&gt;
that does the job. It is inspired by &lt;a href="https://github.com/tai/mod-auth-ticket-for-lighttpd"&gt;this
module&lt;/a&gt;, but it does
not require to be compiled and works out of the box on recent versions of
lighttpd (e.g.  debian stable). I also believe that it offers &lt;a href="https://github.com/tai/mod-auth-ticket-for-lighttpd/issues/4"&gt;a better
security&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;It works pretty well! You can try to visit
&lt;a href="https://gallery.chmd.fr"&gt;gallery.chmd.fr&lt;/a&gt;  and you should be presented
with my very own login page. Should you try to login, the script will
gently tell you that though your openid/oauth login was successful, you
cannot access the gallery because it is a privilege reserved to the people
I explicitly authorized. Beware that if you are not using linux, you might
experiment a warning from your browser: that is because I use a
certificate signed by &lt;a href="http://www.cacert.org/"&gt;cacert&lt;/a&gt;, a community-driven
certificate authority whose root certificate is not included in commercial
OS (yet).&lt;/p&gt;
&lt;p&gt;If you want to use this script on your own lighttpd server, I have set up
a &lt;a href="http://lighttpd-external-auth.chmd.fr/"&gt;dedicated website&lt;/a&gt; to explain
how to proceed. Check it out!&lt;/p&gt;
&lt;p&gt;One last thing: I am not a security expert, and I did this for fun. I
believe it is pretty secure (provided you trust the third parties
involved, of course), but I still have to warn you: don't use this to
protect important documents. If you have knowledge about security and want
to comment - or even better: to contribute - be my guest!&lt;/p&gt;</content><category term="howto"></category><category term="openid lighttpd"></category></entry><entry><title>Git on lighttpd</title><link href="http://blog.chmd.fr/git-on-lighttpd.html" rel="alternate"></link><published>2013-08-08T16:09:00+02:00</published><updated>2013-08-08T16:09:00+02:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2013-08-08:/git-on-lighttpd.html</id><summary type="html">&lt;h1&gt;Intro&lt;/h1&gt;
&lt;p&gt;I switched to lighttpd. The main reason for this change was the ease of
configuration: for example, with apache, when you want to serve the same
website with and without ssl, you end up doing something like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;#&lt;span class="w"&gt; &lt;/span&gt;file:&lt;span class="w"&gt; &lt;/span&gt;/etc/apache2/sites-available/domain.com.conf
&lt;span class="nt"&gt;&amp;lt;VirtualHost&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;*:80&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;Include&lt;span class="w"&gt; &lt;/span&gt;/etc …&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</summary><content type="html">&lt;h1&gt;Intro&lt;/h1&gt;
&lt;p&gt;I switched to lighttpd. The main reason for this change was the ease of
configuration: for example, with apache, when you want to serve the same
website with and without ssl, you end up doing something like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;#&lt;span class="w"&gt; &lt;/span&gt;file:&lt;span class="w"&gt; &lt;/span&gt;/etc/apache2/sites-available/domain.com.conf
&lt;span class="nt"&gt;&amp;lt;VirtualHost&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;*:80&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;Include&lt;span class="w"&gt; &lt;/span&gt;/etc/apache2/domain.com.inc.conf
&lt;span class="nt"&gt;&amp;lt;/VirtualHost&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;VirtualHost&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;*:443&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;Include&lt;span class="w"&gt; &lt;/span&gt;/etc/apache2/domain.com.inc.conf
&lt;span class="w"&gt;    &lt;/span&gt;SSLEngine&lt;span class="w"&gt; &lt;/span&gt;On
&lt;span class="w"&gt;    &lt;/span&gt;SSLCertificateFile&lt;span class="w"&gt; &lt;/span&gt;/etc/ssl/private/domain.com.pem
&lt;span class="nt"&gt;&amp;lt;/VirtualHost&amp;gt;&lt;/span&gt;

#&lt;span class="w"&gt; &lt;/span&gt;file:&lt;span class="w"&gt; &lt;/span&gt;/etc/apache2/sites-available/domain.com.inc.conf
ServerName&lt;span class="w"&gt; &lt;/span&gt;domain.com
DocumentRoot&lt;span class="w"&gt; &lt;/span&gt;/var/www/domain.com
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Including the website config as a separate file is pretty much the only
way to accomplish this without duplicating this config in both
virtualhosts. That is two files to maintain, for one domain.  If you want
to do this for every domain you control, you have to multiply the files
and includes.&lt;/p&gt;
&lt;p&gt;Doing this with lighttpd is really easier:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="c1"&gt;# file /etc/lighttpd/lighttpd.conf&lt;/span&gt;
&lt;span class="o"&gt;$&lt;/span&gt;&lt;span class="n"&gt;SERVER&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;socket&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;:443&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;ssl&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;engine&lt;/span&gt;&lt;span class="w"&gt;              &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;enable&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;ssl&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pemfile&lt;/span&gt;&lt;span class="w"&gt;             &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;/etc/ssl/private/domain.com.pem&amp;quot;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;$&lt;/span&gt;&lt;span class="n"&gt;HTTP&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;host&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;domain.com&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;server&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;document&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;/var/www/domain.com&amp;quot;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h1&gt;git and lighttpd&lt;/h1&gt;
&lt;p&gt;Now, let's do cool things. One of the subdomains I own is dedicated to
hosting my public git repositories. I (quite obviously) named it
&lt;a href="http://git.chmd.fr"&gt;http://git.chmd.fr&lt;/a&gt;. I want to use it for:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Serving a gitweb instance to browse all repositories, such that
  &lt;a href="https://git.chmd.fr/?p=netmon.git"&gt;https://git.chmd.fr/?p=netmon.git&lt;/a&gt;
  takes you to browsing the repository of netmon.&lt;/li&gt;
&lt;li&gt;Serving the git protocol, such that
  &lt;code&gt;git clone https://git.chmd.fr/netmon.git&lt;/code&gt; clones this repository.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Combining the two was tricky, but I ended up finding how to proceed. Here
is the relevant part of my config:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="o"&gt;$&lt;/span&gt;&lt;span class="n"&gt;HTTP&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;host&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;git.chmd.fr&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="c1"&gt;# This takes care of serving gitweb&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;server&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;document&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;/usr/share/gitweb&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;cgi&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;assign&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;.cgi&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;server&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;indexfiles&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;gitweb.cgi&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="c1"&gt;# And this condition matches git objects&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="o"&gt;$&lt;/span&gt;&lt;span class="n"&gt;HTTP&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;url&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=~&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;(?x)^/(.*/(HEAD | info/refs | objects/(info/[^/]+ | [0-9a-f]{2}/[0-9a-f]{38} | pack/pack-[0-9a-f]{40}\.(pack|idx)) | git-(upload|receive)-pack))$&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="n"&gt;alias&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="o"&gt;+=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;/usr/lib/git-core/git-http-backend&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="n"&gt;cgi&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;assign&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="n"&gt;setenv&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;add&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;environment&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;GIT_PROJECT_ROOT&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;/home/www/git-public-repos/&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;GIT_HTTP_EXPORT_ALL&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Combined with the trick from above, you can get this to work on both http
and https. I hope this will help others!&lt;/p&gt;</content><category term="howto"></category><category term="git gitweb server"></category></entry><entry><title>Sigal, a static gallery generator</title><link href="http://blog.chmd.fr/sigal-a-static-gallery-generator.html" rel="alternate"></link><published>2013-07-20T15:11:00+02:00</published><updated>2013-07-20T15:11:00+02:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2013-07-20:/sigal-a-static-gallery-generator.html</id><summary type="html">&lt;p&gt;I wanted to self-host my pictures. Nothing crazy, just a way to share them
with my friends without using a third party service. At first, I thought
about writing a lighttpd module that would generate thumbnails. Then I
thought about a using a php script, but all of them have …&lt;/p&gt;</summary><content type="html">&lt;p&gt;I wanted to self-host my pictures. Nothing crazy, just a way to share them
with my friends without using a third party service. At first, I thought
about writing a lighttpd module that would generate thumbnails. Then I
thought about a using a php script, but all of them have too many options,
and are too complicated for what I intended to do. I wanted something
simple and secure (e.g. no upload interface)! Then I thought about how
this blog is built: using a static blog generator! Did it exist for
galleries?&lt;/p&gt;
&lt;p&gt;It turns out that yes, there are &lt;a href="http://www.nico.schottelius.org/docs/static-image-gallery-generator-comparison/"&gt;plenty of
solutions&lt;/a&gt;
available. I tested some of them, and I found that
&lt;a href="http://sigal.saimon.org"&gt;sigal&lt;/a&gt; was my prefered one.&lt;/p&gt;
&lt;p&gt;Sigal is beautiful, and minimalistic. It lets you theme your gallery with
jinja templates, exactly like pelican. Furthermore, it is mature and very
well maintained (my main concern when I install something): there is a
testsuite, a good online documentation (not that it needs it, it is dead
simple to use) and continuous integration. There is even
&lt;a href="http://saimon.org/sigal-demo/colorbox/"&gt;two&lt;/a&gt;
&lt;a href="http://saimon.org/sigal-demo/galleria/"&gt;demo&lt;/a&gt; galleries, for you to test
it live before installing it. And of course, for maximal conveniency,
there is a python package, that you can install very simply: just run&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;pip install sigal
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The only thing that I was missing was video support. I sometimes film
short movies with my cameras, and I want to include them in the pictures
that I am sharing. I thus decided to give a go to the code, in order to
see if it easy to patch. It turned out to be rather easy. There's a &lt;a href="https://github.com/saimn/sigal/pull/18"&gt;pull
request&lt;/a&gt; pending...&lt;/p&gt;
&lt;p&gt;TL;DR you should try sigal!&lt;/p&gt;</content><category term="misc"></category><category term="sigal gallery static"></category></entry><entry><title>Jabber notifications on ssh login</title><link href="http://blog.chmd.fr/jabber-notifications-on-ssh-login.html" rel="alternate"></link><published>2012-09-19T15:33:00+02:00</published><updated>2012-09-19T15:33:00+02:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2012-09-19:/jabber-notifications-on-ssh-login.html</id><summary type="html">&lt;p&gt;I coined this little trick the other day, I thought I might share it. I
wanted, for fun, to be notified on gtalk everytime someone logs in my
server. You never know, maybe I could discover unexpected connections. It
turned out to be possible, and the whole thing costed me …&lt;/p&gt;</summary><content type="html">&lt;p&gt;I coined this little trick the other day, I thought I might share it. I
wanted, for fun, to be notified on gtalk everytime someone logs in my
server. You never know, maybe I could discover unexpected connections. It
turned out to be possible, and the whole thing costed me reading a couple
of manpages and typing 5 lines of code.&lt;/p&gt;
&lt;p&gt;Before you do the same thing with you own server, let me claim here that I
am absolutely not a security expert. It is more an experiment than
anything else, so I suggest being really careful and read all the manpages
involved if you want to do the same thing. Also, I'd be happy to be
notified of any potential threat in the comments.&lt;/p&gt;
&lt;p&gt;Basically, you can have PAM (Pluggable Authentication Modules, the thing
that handles authentication on Linux) execute external commands. The
module in question is called &lt;code&gt;pam_exec&lt;/code&gt;, and it is often used to rebuild
databases e.g. when passwords are changed. It can also be activated when
someone logs in. The manpage explains that the following PAM items are
exported as environment variables to the program executed:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt; PAM_RHOST, PAM_RUSER, PAM_SERVICE, PAM_TTY, PAM_USER, PAM_TYPE
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;I decided to use it to my advantage. I created on jabber.org an account
for my server. I added it in my gmail friends, and I wrote this little
script, using sendxmpp (saved as &lt;code&gt;/usr/local/bin/login_notify&lt;/code&gt;):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;
&lt;span class="normal"&gt;2&lt;/span&gt;
&lt;span class="normal"&gt;3&lt;/span&gt;
&lt;span class="normal"&gt;4&lt;/span&gt;
&lt;span class="normal"&gt;5&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="ch"&gt;#!/bin/sh&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="nv"&gt;$PAM_USER&lt;/span&gt;&lt;span class="s2"&gt;@`hostname` logged from &lt;/span&gt;&lt;span class="nv"&gt;$PAM_RHOST&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;sendxmpp&lt;span class="w"&gt; &lt;/span&gt;-u&lt;span class="w"&gt; &lt;/span&gt;server_account&lt;span class="w"&gt; &lt;/span&gt;-j&lt;span class="w"&gt; &lt;/span&gt;jabber.org&lt;span class="w"&gt; &lt;/span&gt;-p&lt;span class="w"&gt; &lt;/span&gt;xxxx&lt;span class="w"&gt; &lt;/span&gt;me@gmail.com&lt;span class="w"&gt; &lt;/span&gt;&amp;gt;/dev/null&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&amp;gt;&lt;span class="p"&gt;&amp;amp;&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;&amp;amp;&lt;/span&gt;
&lt;span class="nb"&gt;exit&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Note that the sendxmpp command runs in background and that its exit status
is ignored. Otherwise PAM would wait for the command to return before
letting me in, and it would deny me the access if the notification failed
to be delivered. Two things I clearly want to avoid.&lt;/p&gt;
&lt;p&gt;Then, the following line goes at the end of &lt;code&gt;/etc/pam.d/sshd&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;session         optional        pam_exec.so             /usr/local/bin/login_notify
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;There you go, notifications each time someone logs in.&lt;/p&gt;
&lt;h1&gt;Are you doing this for real? Read on...&lt;/h1&gt;
&lt;p&gt;Ok, just a couple of extra instructions for you:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Be really really careful before modifying &lt;code&gt;/etc/pam.d/sshd&lt;/code&gt;. If you
  put a bogus command in there, you might screw up your remote access.
  Please double check that the command &lt;code&gt;/usr/local/bin/login_notify&lt;/code&gt; is
  running with no error. Only when you are sure of that, you can add the
  line to &lt;code&gt;/etc/pam.d/sshd&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Don't forget to &lt;code&gt;chmod +x /usr/local/bin/login_notify&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;When you run &lt;code&gt;/usr/local/bin/login_notify&lt;/code&gt;, you should receive a
  jabber message. If you don't, then you have to verify that you can
  actually send messages to your gmail account. Use a jabber client
  and try to have a conversation with your gmail account. Then, try to
  use &lt;code&gt;sendxmpp&lt;/code&gt;, then try again with the &lt;code&gt;login_notify&lt;/code&gt; script.&lt;/li&gt;
&lt;li&gt;My instructions are probably incomplete. Use your brain to fill in the
  blanks.&lt;/li&gt;
&lt;/ul&gt;</content><category term="howto"></category><category term="security"></category><category term="ssh"></category></entry><entry><title>Choose your passphrase with a die</title><link href="http://blog.chmd.fr/choose-your-passphrase-with-a-die.html" rel="alternate"></link><published>2012-08-01T17:25:00+02:00</published><updated>2012-08-01T17:25:00+02:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2012-08-01:/choose-your-passphrase-with-a-die.html</id><summary type="html">&lt;p&gt;Lurking on the archlinux &lt;a href="https://wiki.archlinux.org/index.php/Disk_Encryption#Choosing_a_strong_passphrase"&gt;wiki&lt;/a&gt;, I found a very interesting resource
for choosing a strong, easy to remember passphrase. It's called the
&lt;a href="http://world.std.com/~reinhold/diceware.html"&gt;diceware method&lt;/a&gt;. You basically pick a die and throw it repeatedly
to determine the words of your passphrase.&lt;/p&gt;
&lt;p&gt;To associate a word with the results of the die …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Lurking on the archlinux &lt;a href="https://wiki.archlinux.org/index.php/Disk_Encryption#Choosing_a_strong_passphrase"&gt;wiki&lt;/a&gt;, I found a very interesting resource
for choosing a strong, easy to remember passphrase. It's called the
&lt;a href="http://world.std.com/~reinhold/diceware.html"&gt;diceware method&lt;/a&gt;. You basically pick a die and throw it repeatedly
to determine the words of your passphrase.&lt;/p&gt;
&lt;p&gt;To associate a word with the results of the die, you are given a list of
words that looks like what follows:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;...
46154 ox
46155 oxyda
46156 oxyde
46161 oxyder
46162 oy
46163 oz
46164 ozone
46165 ozones
46166 p
46211 pa
46212 pacha
46213 pack
46214 packs
46215 pacte
...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The numbers indicate what word you should pick on the base of 5 throws.
For example if you throw 4, 6, 1, 5, 5, you should pick the word 46155,
which is "oxyda". You then repeat this process until you have 6 or 7
words. Pick the words in the order you got them, and you now have a new
secure passphrase.&lt;/p&gt;
&lt;p&gt;What I like about this method is that it is &lt;strong&gt;fully automated&lt;/strong&gt;, yet
perfectly secure. You don't have to worry about making a choice: the die
makes it for you, and you still end up with something that is easy to
remember.&lt;/p&gt;
&lt;p&gt;Sure, I read &lt;a href="http://xkcd.com/936/"&gt;xkcd&lt;/a&gt; and I was already using long sentences that made
sense only if you are me, but this method beats mine, since there is no
way I was picking these words randomly.&lt;/p&gt;
&lt;p&gt;Since I could not find a list of french words, I quickly made &lt;a href="https://github.com/chmduquesne/diceware-fr"&gt;my own&lt;/a&gt;.&lt;/p&gt;</content><category term="howto"></category><category term="security"></category><category term="passphrase"></category></entry><entry><title>Operations Research and Beer drinking</title><link href="http://blog.chmd.fr/operations-research-and-beer-drinking.html" rel="alternate"></link><published>2011-11-19T17:06:00+01:00</published><updated>2011-11-19T17:06:00+01:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2011-11-19:/operations-research-and-beer-drinking.html</id><summary type="html">&lt;p&gt;I am just returning from Charlotte NC, where I had an amazing time at the
INFORMS 2011 conference. Being in the airport waiting for my flight, I
figured out I could use this spare time to share a cool story about
Operations Research.&lt;/p&gt;
&lt;p&gt;I happen to be a beer lover …&lt;/p&gt;</summary><content type="html">&lt;p&gt;I am just returning from Charlotte NC, where I had an amazing time at the
INFORMS 2011 conference. Being in the airport waiting for my flight, I
figured out I could use this spare time to share a cool story about
Operations Research.&lt;/p&gt;
&lt;p&gt;I happen to be a beer lover. If you're anything like me, you probably know
Belgium produces among the best beers in the world. You also probably know
about the &lt;a href="http://en.wikipedia.org/wiki/Trappist_beer"&gt;trappist beers&lt;/a&gt;, which are some of the most famous and
tastiest beers brewed in the area.&lt;/p&gt;
&lt;p&gt;Two years ago, &lt;a href="http://mickaelistria.wordpress.com/"&gt;one of my friends&lt;/a&gt; had a crazy idea: He looked at a
map, locating the trappist abbeys producing those excellent beers, and
noticed they all were not very far from each other. He thus proposed a
tour of Belgium that would visit all of them, by bicycle. I was
immediately very enthusiastic about the idea and started to think about
how to make it become true.&lt;/p&gt;
&lt;h2&gt;Planning the trip&lt;/h2&gt;
&lt;p&gt;So, given 7 cities and a tour to plan (The french abbey of &lt;a href="http://fr.wikipedia.org/wiki/Abbaye_du_Mont_des_Cats"&gt;Mont des
Cats&lt;/a&gt; and the german abbey of &lt;a href="http://trappist-beers.com/8th-trappist-beer-not-from-mont-des-cats-france-but-from-abbey-zundert-netherlands/"&gt;Maria Toevlucht&lt;/a&gt; had not announced
their plans of brewing their own beers at the time), can you guess what am
I immediately thought about? That's right, the &lt;a href="http://en.wikipedia.org/wiki/Travelling_salesman_problem"&gt;Travelling Salesman
Problem&lt;/a&gt;! Of course, the problem itself is NP-hard, but in practice,
with an instance of this size, it is doable manually.&lt;/p&gt;
&lt;p&gt;I could have done it by myself, but this was a unique opportunity to use
&lt;a href="http://www.tsp.gatech.edu/maps/index.html"&gt;the online solver&lt;/a&gt; from the &lt;a href="http://www.tsp.gatech.edu/index.html"&gt;TSP website&lt;/a&gt; of the university of
Georgia Tech! Since we did not actually needed to go back to the first
abbey, I removed the longest edge.&lt;/p&gt;
&lt;p&gt;I know what you are thinking: "Are you kidding me? A TSP Problem? If you
remove an edge, this is not a tour, this is an Hamiltonian Path!". You are
completely right, I did not solve the right problem. The thing is, I did
not know any Online Hamiltonian Path Solver at the time, and this was
probably the coolest use I could ever make of Concorde. Still a good
story, isn't it?&lt;/p&gt;
&lt;h2&gt;Doing it!&lt;/h2&gt;
&lt;p&gt;Here is the trip as we planned it:&lt;/p&gt;
&lt;iframe src="https://www.google.com/maps/embed?pb=!1m54!1m12!1m3!1d1397173.317358605!2d3.0095418362486455!3d50.56817093554189!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!4m39!3e1!4m3!3m2!1d50.048396999999994!2d4.311786!4m5!1s0x47ea8dcefbfe2723%3A0xa95a58f49956f256!2sOrval%2C+Florenville%2C+Belgique!3m2!1d49.6368489!2d5.3472466999999995!4m5!1s0x47c1c946c89a1663%3A0x40099ab2f4d6f20!2sRochefort%2C+Belgique!3m2!1d50.1596036!2d5.2221665!4m3!3m2!1d51.255824999999994!2d5.478648!4m5!1s0x47c6bfc0840d7433%3A0x966840aaf3612c5e!2sKoningshoeven%2C+5018+Tilburg%2C+Pays-Bas!3m2!1d51.551590999999995!2d5.111403!4m5!1s0x47c4003a88a0c5d5%3A0xce12a24262bd5c02!2sWestmalle%2C+Royaume+de+Belgique!3m2!1d51.2968136!2d4.694263299999999!4m5!1s0x47dcc122bb1a2a8d%3A0xc9b50882de0f3896!2sWestvleteren%2C+Vleteren%2C+Belgique!3m2!1d50.927605299999996!2d2.716907!5e1!3m2!1sfr!2sus!4v1448815744468" width="425" height="350" frameborder="0" style="border:0" allowfullscreen&gt;&lt;/iframe&gt;

&lt;p&gt;We ended up being two (me and my flatmate of the time - Mickael could not
make it) with train tickets to Belgium. Cool facts about this trip:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;We discussed with "le grand maître de &lt;a href="http://www.confreries.be/conf/grusalle/index.htm"&gt;la confrérie de la grusalle et de
  la trappiste de Rochefort&lt;/a&gt;".&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img alt="grand_maitre_rochefort.jpg" src="images/grand_maitre_rochefort.jpg"&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;We drank some "petit orval", a beer that you can find only at the abbey
  and at the bar (&lt;a href="http://www.orval.be/fr/accueil/auberge.html"&gt;l'auberge de l'Ange Gardien&lt;/a&gt;) and we learned about
  the &lt;a href="http://en.wikipedia.org/wiki/Orval_Abbey#The_legend_of_Orval"&gt;legend of Orval&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The lady at the little shop in front of the abbey of Koningshoven (the
  one that brews &lt;a href="http://fr.wikipedia.org/wiki/La_Trappe"&gt;la Trappe&lt;/a&gt;) was so amazed of what we were doing that
  she gave us a pack of 4 different flavors of Trappes which we brought
  back to France.&lt;/li&gt;
&lt;li&gt;In Gent, there is a barber which is called bar-bier, who serves bier
  while shaving the clients (check it out on &lt;a href="https://goo.gl/maps/g4byF8u2f6F2"&gt;google street view&lt;/a&gt;!).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img alt="gent_barbier.jpg" src="images/gent_barbier.jpg"&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Gent and Antwerpen are two of the most beautiful cities I have ever
  seen.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The only sad thing about this trip is that we could not get to drink any
Westvleteren : it is actually &lt;a href="http://en.wikipedia.org/wiki/Westvleteren_Brewery#Availability"&gt;quite hard to get some&lt;/a&gt;, given the fact
the monks over there have chosen to only produce as much beer as needed to
finance the community: when we arrived, they did not have any beer left.&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Three months ago, one of my best friends had the opportunity to get some
Westvleteren and he invited me to taste them, offering me the opportunity
to "finish my trip". For the record, the Westvleteren 12 is ranked the
best beer in the world by &lt;a href="http://www.ratebeer.com/"&gt;ratebeer.com&lt;/a&gt;. Needless to say, I enjoyed
it very much. He let me keep the capsules as a souvenir:&lt;/p&gt;
&lt;p&gt;&lt;img alt="westvleteren.jpg" src="images/westvleteren.jpg"&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="images/belgium_trip.jpg"&gt;&lt;img alt="Our actual map during the trip" src="images/belgium_trip.resized.jpg" title="Our actual map during the trip"&gt;&lt;/a&gt;&lt;/p&gt;</content><category term="misc"></category></entry><entry><title>Releasing Michel, a flat-text-file-to-google-tasks uploader</title><link href="http://blog.chmd.fr/releasing-michel-a-flat-text-file-to-google-tasks-uploader.html" rel="alternate"></link><published>2011-09-22T00:00:00+02:00</published><updated>2011-09-22T00:00:00+02:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2011-09-22:/releasing-michel-a-flat-text-file-to-google-tasks-uploader.html</id><summary type="html">&lt;p&gt;When it comes to handling my todo list, I'm a huge fan of flat text files.
The main reason why I prefer them over anything else is that I find it
far easier to display it with notification popups this way.&lt;/p&gt;
&lt;p&gt;I also heavily rely on gmail to organise myself …&lt;/p&gt;</summary><content type="html">&lt;p&gt;When it comes to handling my todo list, I'm a huge fan of flat text files.
The main reason why I prefer them over anything else is that I find it
far easier to display it with notification popups this way.&lt;/p&gt;
&lt;p&gt;I also heavily rely on gmail to organise myself. When I am reading emails
and organizing my life, it feels natural to use gtasks to take notes for
later.&lt;/p&gt;
&lt;p&gt;Since I both use text files and gtasks, I was missing was a way to sync
them together. Unfortunately, for a long time, google &lt;a href="http://code.google.com/p/gdata-issues/issues/detail?id=987"&gt;made us wait&lt;/a&gt;
for a gtask API. But no more! I discovered at the beginning of the week
that they had &lt;a href="http://googleappsdeveloper.blogspot.com/2011/05/getting-organized-with-tasks-api.html"&gt;announced&lt;/a&gt; a brand new RESTful interface.&lt;/p&gt;
&lt;p&gt;I decided to give it a go and I have written a small program that suit my
needs to help me handle my todo list text file. So here comes &lt;a href="https://github.com/chmduquesne/michel"&gt;Michel&lt;/a&gt;,
your friendly mate that helps you managing your todo list. It features two
commands&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;michel pull
michel push &amp;lt;file&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;which respectively push and pull taks in a text fashion.&lt;/p&gt;
&lt;p&gt;The code is on &lt;a href="https://github.com/chmduquesne/michel"&gt;github&lt;/a&gt;. Just like any python package, you should be
able to install it using easy_install (provided you install pyxdg with
your standard package manager, since it does not seem to be installable
from easy_install).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;easy_install michel
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</content><category term="code"></category><category term="gtasks"></category></entry><entry><title>Going static</title><link href="http://blog.chmd.fr/going-static.html" rel="alternate"></link><published>2011-09-15T20:10:00+02:00</published><updated>2011-09-15T20:10:00+02:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2011-09-15:/going-static.html</id><summary type="html">&lt;p&gt;I eventually got sick of wordpress and of my former hoster &lt;a href="http://free.fr"&gt;free.fr&lt;/a&gt;.
Wordpress is probably awesome if you are a team of 15 authors who want to
handle mass production of articles with a nice web interface. On the other
hand, it needs constant updates, and the last ones …&lt;/p&gt;</summary><content type="html">&lt;p&gt;I eventually got sick of wordpress and of my former hoster &lt;a href="http://free.fr"&gt;free.fr&lt;/a&gt;.
Wordpress is probably awesome if you are a team of 15 authors who want to
handle mass production of articles with a nice web interface. On the other
hand, it needs constant updates, and the last ones where requiring a
version of php that my hoster did not provide.&lt;/p&gt;
&lt;p&gt;Looking for an alternative, I found the &lt;a href="http://nicdumz.fr/blog/2010/12/why-blogofile/"&gt;argument of nicdumz about
blogofile&lt;/a&gt; pretty much convincing: why use php and databases where flat
html files could be just enough? I have thus decided to go for a static
website generator, and while I am at it, to host my blog on amazon s3.
This brings me the confort of writing my articles on vim, to version them
on git and to manage the whole process from a makefile.&lt;/p&gt;
&lt;h1&gt;Moving&lt;/h1&gt;
&lt;p&gt;If anyone who reads me plans to make such a move (wordpress to pelican),
I'll summarize the steps I went through.&lt;/p&gt;
&lt;h2&gt;Extracting your articles&lt;/h2&gt;
&lt;p&gt;Being open and in the spirit of every good free software, wordpress lets
you export your blog using an xml format. Pelican can &lt;a href="https://github.com/ametaireau/pelican/blob/master/tools/pelican-import"&gt;take advantage&lt;/a&gt;
of this xml file to generate rst files using pandoc. Or if you are lazy,
you can just provide an rss feed to the pelican importer, but you'll still
miss a way to get the comments.&lt;/p&gt;
&lt;h2&gt;Extracting your comments&lt;/h2&gt;
&lt;p&gt;Pelican does not provide a comment system by itself, but integrates nicely
with &lt;a href="http://disqus.com/"&gt;disqus&lt;/a&gt;. Just make an account and upload the Wordpress xml export
file I mentioned. Disqus provides a way to import comments from such a
file. You will later be able to reattach threads to their articles by
providing a csv map file following the syntax:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;old_url, new_url
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;Setting up an amazon account&lt;/h2&gt;
&lt;p&gt;The next step is to set up an amazon account for use with s3, and to buy a
domain name if you don't already own one. I bought the latter using
&lt;a href="http://www.gandi.net/"&gt;gandi.net&lt;/a&gt;, and I used &lt;a href="https://github.com/enigmacurry/vaporfile"&gt;vaporfile&lt;/a&gt; to set up an amazon bucket. I
don't see much to add here, given the fact vaporfile provides a friendly
wizard that tells you what to do quite accurately.&lt;/p&gt;
&lt;h1&gt;What I could not fix&lt;/h1&gt;
&lt;p&gt;The blog entries on my previous blog were obtained through links looking
like&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&amp;quot;http://chm.duquesne.free.fr/blog/?p=xxx&amp;quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Whereas on the new version, they look like&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&amp;quot;http://blog.chmd.fr/title-of-the-article.html&amp;quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;It would have been cool to be able to put 301 redirect entries in a
.htaccess, for the sake of SEO-friendliness. However, this would require
some url rewriting, which &lt;a href="http://free.fr"&gt;free&lt;/a&gt; does not support. I decided to skip
this step. I am keeping &lt;a href="https://github.com/chmduquesne/blog/blob/master/legacy/urlmap.csv"&gt;a map&lt;/a&gt; between the former and the new urls,
just in case I'd have the courage to write these redirections in php...&lt;/p&gt;</content><category term="misc"></category></entry><entry><title>plowbot, a jabber bot that downloads links from 1-click hosters</title><link href="http://blog.chmd.fr/plowbot-a-jabber-bot-that-downloads-links-from-1-click-hosters.html" rel="alternate"></link><published>2011-07-26T13:46:00+02:00</published><updated>2011-07-26T13:46:00+02:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2011-07-26:/plowbot-a-jabber-bot-that-downloads-links-from-1-click-hosters.html</id><summary type="html">&lt;p&gt;I wrote a jabber bot that does just one thing: it uses &lt;a href="https://code.google.com/p/plowshare/"&gt;plowshare&lt;/a&gt; to
download what you paste. It is quite minimalist and thus does not offer
queue management features nor advanced captcha solving possibilities, so
you should not try to use it on links plowshare can't break automatically
(basically …&lt;/p&gt;</summary><content type="html">&lt;p&gt;I wrote a jabber bot that does just one thing: it uses &lt;a href="https://code.google.com/p/plowshare/"&gt;plowshare&lt;/a&gt; to
download what you paste. It is quite minimalist and thus does not offer
queue management features nor advanced captcha solving possibilities, so
you should not try to use it on links plowshare can't break automatically
(basically &lt;a href="https://code.google.com/p/plowshare/wiki/Readme"&gt;those that use recaptcha&lt;/a&gt;), otherwise it will eventually
freeze. I used python-jabberbot, and to maximize the simplicity I store
the user configuration in json in an xdg fashion (which happened to be
both user-friendly -probably - and easy to write - certainly). If you want
to fork it and add whatever you find useful, it's on github:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/chmduquesne/plowbot"&gt;https://github.com/chmduquesne/plowbot&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I am personally quite satisfied with it (it fits my limited usage
for this kind of service), but I am open to pull requests. Of
course, I also made an AUR package for arch users, which adds an rc
script for starting it at boot as your prefered user.&lt;/p&gt;</content><category term="code"></category><category term="plowbot"></category><category term="plowshare"></category></entry><entry><title>SSH over SSL, episode 3: Avoiding using a patched apache.</title><link href="http://blog.chmd.fr/ssh-over-ssl-episode-3-avoiding-using-a-patched-apache.html" rel="alternate"></link><published>2011-07-11T13:12:00+02:00</published><updated>2011-07-11T13:12:00+02:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2011-07-11:/ssh-over-ssl-episode-3-avoiding-using-a-patched-apache.html</id><summary type="html">&lt;p&gt;If you are reading this, you might be interested in the full list of my
articles about doing SSH over SSL. I have been improving my configuration
over the years, so the more recent, the better:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;2010-11-12: &lt;a href="/ssh-over-ssl-a-quick-and-minimal-config.html"&gt;Quick and minimal config&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;2010-11-15: &lt;a href="/ssh-over-ssl-episode-2-replacing-proxytunnel-with-socat.html"&gt;Replacing proxytunnel with socat&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;2011-07-11: &lt;a href="/ssh-over-ssl-episode-3-avoiding-using-a-patched-apache.html"&gt;Avoiding using a …&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;</summary><content type="html">&lt;p&gt;If you are reading this, you might be interested in the full list of my
articles about doing SSH over SSL. I have been improving my configuration
over the years, so the more recent, the better:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;2010-11-12: &lt;a href="/ssh-over-ssl-a-quick-and-minimal-config.html"&gt;Quick and minimal config&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;2010-11-15: &lt;a href="/ssh-over-ssl-episode-2-replacing-proxytunnel-with-socat.html"&gt;Replacing proxytunnel with socat&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;2011-07-11: &lt;a href="/ssh-over-ssl-episode-3-avoiding-using-a-patched-apache.html"&gt;Avoiding using a patched Apache&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;2014-10-19: &lt;a href="/ssh-over-ssl-episode-4-a-haproxy-based-configuration.html"&gt;HAproxy based configuration&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;p&gt;Another episode of my adventures of firewall bypassing...&lt;/p&gt;
&lt;p&gt;In order to use the http CONNECT method to tunnel ssh, you have to
configure apache as I previously showed in &lt;a href="../ssh-over-ssl-a-quick-and-minimal-config.html"&gt;a previous post&lt;/a&gt;.  Sadly,
the current version of apache does not allow to do it over https. There
has been a &lt;a href="https://issues.apache.org/bugzilla/show_bug.cgi?id=29744"&gt;bug report&lt;/a&gt; for years and various patches have been
proposed, but as far as I know, still not any of these patches made it to
the official release.&lt;/p&gt;
&lt;p&gt;My solution so far was to apply the patch manually and recompile the
relevant module. Doing this for every release can be annoying, so I've
been looking for a different solution that would not involve recompiling
apache.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Edit 2015-05-07:&lt;/strong&gt; This bug has been fixed for 3 years. I still
recommend not to use the CONNECT method, because only apache supports it
and it will force you to use it. There are cooler, faster webservers out
there. Using the HAproxy based configuration is by far the most flexible
way I know (it allows you to use any web server, apache included).&lt;/p&gt;
&lt;p&gt;The workaround I now use is fun enough for me to talk about it here. Since
apache has no problem with the CONNECT method when SSL is not involved, I
have decided to do the SSL part by myself. Thus, I configure apache to
serve normally on the port 80, and I use stunnel to secure apache on the
port 443. Here is how I do it: I remove the SSL part of my apache config
and I add in my (normal, unencrypted) apache configuration:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;ProxyRequests&lt;span class="w"&gt; &lt;/span&gt;On
AllowConnect&lt;span class="w"&gt; &lt;/span&gt;22
&lt;span class="nt"&gt;&amp;lt; Proxy&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;*&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;Order&lt;span class="w"&gt; &lt;/span&gt;deny,allow
&lt;span class="w"&gt;    &lt;/span&gt;Deny&lt;span class="w"&gt; &lt;/span&gt;from&lt;span class="w"&gt; &lt;/span&gt;all
&lt;span class="nt"&gt;&amp;lt;/Proxy&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;Proxy&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;127.0.0.1&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;Order&lt;span class="w"&gt; &lt;/span&gt;deny,allow
&lt;span class="w"&gt;    &lt;/span&gt;Allow&lt;span class="w"&gt; &lt;/span&gt;from&lt;span class="w"&gt; &lt;/span&gt;all
&lt;span class="nt"&gt;&amp;lt;/Proxy&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Then, I install stunnel, and I set it up to listen on the port 443
(https) and to forward it to the port 80 (http).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;cert&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;etc&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;stunnel&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;stunnel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pem&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;https&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;accept&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;443&lt;/span&gt;
&lt;span class="k"&gt;connect&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;80&lt;/span&gt;
&lt;span class="n"&gt;TIMEOUTclose&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;stunnel requires a bit of configuration. From the &lt;a href="http://www.stunnel.org/?page=docs"&gt;documentation&lt;/a&gt;, here
is how to generate a certificate:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;cd /etc/stunnel
openssl req -new -x509 -days 365 -nodes -config stunnel.cnf -out stunnel.pem -keyout stunnel.pem
chown stunnel:stunnel stunnel.pem
chmod 600 stunnel.pem
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;I also nedded to add in /etc/hosts.allow&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;sshd&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ALL&lt;/span&gt;
&lt;span class="n"&gt;stunnel&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ALL&lt;/span&gt;
&lt;span class="n"&gt;https&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ALL&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;And that is all. I restart stunnel and httpd and I can enjoy SSH
over SSL. (actually since I did not want double encryption, I have
started to do telnet over SSL, but that is more or less the same
story).&lt;/p&gt;
&lt;p&gt;Other alternatives I have considered:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Switching from apache to another http server: it turns out I was unable
  to find any other http server supporting the http CONNECT method (at
  least thttpd, lighttpd and nginx don't support it)&lt;/li&gt;
&lt;li&gt;Using a perl script that serves on the port 443, waiting for the CONNECT
  method and forwarding every other message to apache (see
  &lt;a href="http://www.karlrunge.com/x11vnc/connect_switch"&gt;connect_switch&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I did not try this second method, but it seems rather cool. If
anyone does and has any success with it, please leave a comment
here, I am interested. I would also be interested if someone knows
any http server lighter than apache and guaranteed to support the
CONNECT method...&lt;/p&gt;</content><category term="howto"></category><category term="ssh"></category><category term="ssl"></category><category term="stunnel"></category><category term="apache"></category></entry><entry><title>[Je préfère ton clone] padopi</title><link href="http://blog.chmd.fr/je-prefere-ton-clone-padopi.html" rel="alternate"></link><published>2011-06-19T14:13:00+02:00</published><updated>2011-06-19T14:13:00+02:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2011-06-19:/je-prefere-ton-clone-padopi.html</id><summary type="html">&lt;p&gt;Je reprends du service sur ce blog pour parler d'un petit projet
libre qui m'a fait bien rigoler: padopi. C'est une application web
qui permet d'envoyer des faux mails à vos amis pour leur faire
croire qu'ils se sont fait coincer à télécharger. Bon, les mails en
question se terminent …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Je reprends du service sur ce blog pour parler d'un petit projet
libre qui m'a fait bien rigoler: padopi. C'est une application web
qui permet d'envoyer des faux mails à vos amis pour leur faire
croire qu'ils se sont fait coincer à télécharger. Bon, les mails en
question se terminent par une petite phrase qui explique que c'est
une blague, mais sinon c'est criant de vérité (il parait qu'ils
sont inspirés du véritable mail hadopi). Je vous préviens:
l'utilisation de ce genre de service est probablement
répréhensible, mais ça ne vous empêche pas de récupérer le code du
projet sur github:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;git clone https://github.com/padopi/padopi
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Ou bien, si vous préférez mon clone (Ho ho ho):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;git clone https://github.com/chmduquesne/padopi
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Aller, en bonus, la pub de référence :)&lt;/p&gt;
&lt;iframe width="560" height="315" src="http://www.youtube.com/embed/3WfdBQhGBgU" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;</content><category term="misc"></category><category term="libre"></category></entry><entry><title>Using a shell version of supergenpass from vimperator/pentadactyl</title><link href="http://blog.chmd.fr/using-a-shell-version-of-supergenpass-from-vimperatorpentadactyl.html" rel="alternate"></link><published>2010-12-20T18:39:00+01:00</published><updated>2010-12-20T18:39:00+01:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2010-12-20:/using-a-shell-version-of-supergenpass-from-vimperatorpentadactyl.html</id><summary type="html">&lt;p&gt;Last week, I was glad to be a &lt;a href="http://supergenpass.com/"&gt;supergenpass&lt;/a&gt;
user: &lt;a href="http://www.businessinsider.com/gawker-hacked-2010-12"&gt;gawker.com was
hacked&lt;/a&gt; and a huge
number of their username/password hashes was exposed.  While I am not
happy with the fact my email was part of the leak and I've stopped reading
anything from them, I know there …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Last week, I was glad to be a &lt;a href="http://supergenpass.com/"&gt;supergenpass&lt;/a&gt;
user: &lt;a href="http://www.businessinsider.com/gawker-hacked-2010-12"&gt;gawker.com was
hacked&lt;/a&gt; and a huge
number of their username/password hashes was exposed.  While I am not
happy with the fact my email was part of the leak and I've stopped reading
anything from them, I know there are very little chances for me to get
problems with that, because the password I used on their site was not
reused elsewhere.&lt;/p&gt;
&lt;p&gt;But &lt;a href="http://akibjorklund.com/2009/supergenpass-is-not-that-secure"&gt;supergenpass is not that
secure&lt;/a&gt;.
Any script executed in the same page as supergenpass is able to see your
master password. If the webmaster of the site you are visiting is evil, he
could grab your master password and hack all your accounts. If you are a
vimperator/pentadactyl user, it is easy to fix that, by executing
supergenpass as a shell command (What follows is from my pentadactylrc):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nv"&gt;map&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;modes&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;n&lt;/span&gt;,&lt;span class="nv"&gt;v&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nv"&gt;C&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;F6&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;y&lt;/span&gt;:&lt;span class="o"&gt;!~/&lt;/span&gt;.&lt;span class="nv"&gt;scripts&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;supergenpass&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nv"&gt;Space&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&amp;lt;S-Insert&amp;gt;&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;Return&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="nv"&gt;Esc&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="nv"&gt;gi&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nv"&gt;S&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;Insert&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;Return&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nv"&gt;map&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;modes&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;i&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nv"&gt;C&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;F6&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nv"&gt;Esc&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="nv"&gt;C&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;F6&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Where &lt;code&gt;~/.scripts/supergenpass&lt;/code&gt; is a python supergenpass script I
customized for my needs (it uses the gtk-based ssh-askpass program to get
the password, instead of using the python getpass library, which is
command line based). You'll find it in &lt;a href="https://bitbucket.org/chmduquesne/dotfiles/src/624d4f104f7d/scripts/supergenpass"&gt;my
dotfiles&lt;/a&gt;.
Original version from &lt;a href="http://michael.gorven.za.net/blog/2009/06/18/supergenpass-cellphones-command-line"&gt;Michael
Gorven&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;A little explanation:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;CTRL-F6&lt;/code&gt; is the shortcut to trigger the script (I've been using it for
  ages, it is originally the default shortcut used in the &lt;a href="https://addons.mozilla.org/fr/firefox/addon/3282/"&gt;password hasher
  firefox extension&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;y&lt;/code&gt; yanks the url,&lt;/li&gt;
&lt;li&gt;&lt;code&gt;:!~/.scripts/supergenpass&amp;lt;Space&amp;gt;'&amp;lt;S-Insert&amp;gt;'&amp;lt;Return&amp;gt;&lt;/code&gt; will call the
  program &lt;code&gt;~/.scripts/supergenpass&lt;/code&gt; with the content of the clipboard
  (using &lt;code&gt;Shift+Insert&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;Esc&amp;gt;2gi&lt;/code&gt; will then focus the second field (I usually call it once I've
  filled my login)&lt;/li&gt;
&lt;li&gt;and &lt;code&gt;&amp;lt;S-Insert&amp;gt;&lt;/code&gt; will paste the clipboard (now filled with the generated
  password) in this focused field.&lt;/li&gt;
&lt;/ul&gt;</content><category term="howto"></category><category term="supergenpass"></category><category term="pentadactyl"></category></entry><entry><title>Saving your crontab in your dotfiles</title><link href="http://blog.chmd.fr/saving-your-crontab-in-your-dotfiles.html" rel="alternate"></link><published>2010-12-02T19:25:00+01:00</published><updated>2010-12-02T19:25:00+01:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2010-12-02:/saving-your-crontab-in-your-dotfiles.html</id><summary type="html">&lt;p&gt;In order to share them across several machine, like a lot of people, I
synchronize my dotfile using a DVCS on &lt;a href="http://bitbucket.org/chmduquesne/dotfiles"&gt;a public
repository&lt;/a&gt;. I save as much
stuff as I can, provided it does not contains sensitive stuff like
passwords. Problem: How do you save your crontab? I finally …&lt;/p&gt;</summary><content type="html">&lt;p&gt;In order to share them across several machine, like a lot of people, I
synchronize my dotfile using a DVCS on &lt;a href="http://bitbucket.org/chmduquesne/dotfiles"&gt;a public
repository&lt;/a&gt;. I save as much
stuff as I can, provided it does not contains sensitive stuff like
passwords. Problem: How do you save your crontab? I finally had a look at
the crontab manual to realize that crontab could be called on a file. The
following line goes into my &lt;code&gt;~/.zshrc&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;alias crontab-e=&amp;#39;vi ~/.crontab &amp;amp;&amp;amp; crontab ~/.crontab&amp;#39;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Edit: I now find even better to use a shell function rather than an
alias:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="c1"&gt;# CRONTAB&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;test&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;$&lt;/span&gt;&lt;span class="n"&gt;CRONTABCMD&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;then&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="c1"&gt;# allows to source zshrc twice&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;export&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;CRONTABCMD&lt;/span&gt;&lt;span class="o"&gt;=$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;which&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;crontab&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;crontab&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;$&lt;/span&gt;&lt;span class="err"&gt;@&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;-e&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;]];&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;then&lt;/span&gt;
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="n"&gt;vim&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;~/.&lt;/span&gt;&lt;span class="n"&gt;crontab&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;$&lt;/span&gt;&lt;span class="n"&gt;CRONTABCMD&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;~/.&lt;/span&gt;&lt;span class="n"&gt;crontab&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt;
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="o"&gt;$&lt;/span&gt;&lt;span class="n"&gt;CRONTABCMD&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;$&lt;/span&gt;&lt;span class="err"&gt;@&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="n"&gt;fi&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="o"&gt;$&lt;/span&gt;&lt;span class="n"&gt;CRONTABCMD&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;~/.&lt;/span&gt;&lt;span class="n"&gt;crontab&lt;/span&gt;
&lt;span class="n"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</content><category term="howto"></category><category term="crontab"></category></entry><entry><title>Notifications from google calendar on my desktop</title><link href="http://blog.chmd.fr/notifications-from-google-calendar-on-my-desktop.html" rel="alternate"></link><published>2010-11-23T15:11:00+01:00</published><updated>2010-11-23T15:11:00+01:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2010-11-23:/notifications-from-google-calendar-on-my-desktop.html</id><content type="html">&lt;p&gt;I just added this in a crontab:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;*/30 &lt;span class="gs"&gt;* *&lt;/span&gt; * * DISPLAY=:0.0 gcalcli remind 240 &amp;#39;notify-send -t 300000 -i myniceicon.svg &amp;quot;Calendar&amp;quot; \%s&amp;#39;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;So every 30 minutes, I get a notification with a 5 minutes timeout
for upcoming events in the next 4 hours. I really don't need more.&lt;/p&gt;</content><category term="howto"></category><category term="notify-send"></category></entry><entry><title>SSH over SSL, episode 2: replacing proxytunnel with socat</title><link href="http://blog.chmd.fr/ssh-over-ssl-episode-2-replacing-proxytunnel-with-socat.html" rel="alternate"></link><published>2010-11-15T23:53:00+01:00</published><updated>2010-11-15T23:53:00+01:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2010-11-15:/ssh-over-ssl-episode-2-replacing-proxytunnel-with-socat.html</id><summary type="html">&lt;p&gt;If you are reading this, you might be interested in the full list of my
articles about doing SSH over SSL. I have been improving my configuration
over the years, so the more recent, the better:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;2010-11-12: &lt;a href="/ssh-over-ssl-a-quick-and-minimal-config.html"&gt;Quick and minimal config&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;2010-11-15: &lt;a href="/ssh-over-ssl-episode-2-replacing-proxytunnel-with-socat.html"&gt;Replacing proxytunnel with socat&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;2011-07-11: &lt;a href="/ssh-over-ssl-episode-3-avoiding-using-a-patched-apache.html"&gt;Avoiding using a …&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;</summary><content type="html">&lt;p&gt;If you are reading this, you might be interested in the full list of my
articles about doing SSH over SSL. I have been improving my configuration
over the years, so the more recent, the better:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;2010-11-12: &lt;a href="/ssh-over-ssl-a-quick-and-minimal-config.html"&gt;Quick and minimal config&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;2010-11-15: &lt;a href="/ssh-over-ssl-episode-2-replacing-proxytunnel-with-socat.html"&gt;Replacing proxytunnel with socat&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;2011-07-11: &lt;a href="/ssh-over-ssl-episode-3-avoiding-using-a-patched-apache.html"&gt;Avoiding using a patched Apache&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;2014-10-19: &lt;a href="/ssh-over-ssl-episode-4-a-haproxy-based-configuration.html"&gt;HAproxy based configuration&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;p&gt;Last week, I wrote &lt;a href="../ssh-over-ssl-a-quick-and-minimal-config.html"&gt;an article&lt;/a&gt; about how to quickly set up a server
and a client for doing ssh over ssl.  In this article, I was using
proxytunnel, but I realized today that it could probably be replaced with
socat (socat can do almost anything)...&lt;/p&gt;
&lt;p&gt;The principle is simple: Following the first part of
the tutorial, you make your server accept proxy_connect requests
to its private port localhost:22 through its public port 443,
encapsulating the whole thing in SSL (as a reminder, 22 and 443 are
respectively the standard ports for ssh and ssl).&lt;/p&gt;
&lt;p&gt;We now want to configure the ssh clients in order to connect through this
ssl tunnel. I said I was configuring the clients with proxytunnel. The
exact command (in .ssh/config) was:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;proxytunnel -q -E -p server.com:443 -d 127.0.0.1:22
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;I'll explain it:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;-q&lt;/code&gt; is for quiet&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-E&lt;/code&gt; is for encrypting between the proxy and us&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-p&lt;/code&gt; is for choosing the proxy&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-d&lt;/code&gt; is for requesting a destination (from the proxy point of view)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So basically, this means: "connect stdio to server.com on port 443 (-p
server.com:443) , in an encrypted way (-E), then from this server, require
to be connected to 127.0.0.1:22 (-d 127.0.0.1:22)".&lt;/p&gt;
&lt;p&gt;For those who like to play with all sorts of streams, socat is really the
best tool ever invented. I was wondering if I could reproduce
proxytunnel's behavior with socat, and it turns out you can. Here is how
to proceed: First, create an ssl tunnel between your client's
localhost:1080 and server.com:443:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;socat TCP-LISTEN:1080 OPENSSL:server.com:443
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This way, the port 443 of server.com is now available unencrypted
on localhost:1080 Then, use socat and its proxy mode to ask for
localhost:1080 (which is actually server.com:443 unencrypted) to
connect to localhost:22 (which is then server.com:22).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;socat - PROXY:127.0.0.1:127.0.0.1:22,proxyport=1080
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Bingo! You should see the ssh prompt. For the fun, I replaced in my
.ssh/config the former&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;ProxyCommand proxytunnel -q -E -p server.com:443 -d 127.0.0.1:22
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;with&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;ProxyCommand socat TCP-LISTEN:1080 OPENSSL:server.com:443,verify=0 &amp;amp; socat - PROXY:127.0.0.1:127.0.0.1:22,proxyport=1080
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Edit 2015-05-07&lt;/strong&gt;: See &lt;a href="https://blog.chmd.fr/ssh-over-ssl-episode-2-replacing-proxytunnel-with-socat.html#comment-2010371675"&gt;Vincent's
comment&lt;/a&gt;
for a cool idea to wrap the ssh command with the &lt;code&gt;-fMN&lt;/code&gt; options.&lt;/p&gt;
&lt;p&gt;It works just fine. There is however a flaw in what I did: I use a
hardcoded port, thus I can't establish two ssh connections at the
same time. Forwarding the server.com:443 on localhost:1080 fails
the second time, since this port is already occupied by the first
connection. The best way to fix that would be to use stdio for the
proxy_connect requests, instead of a port of localhost (since the
number of these port is limited). However, with my version of socat
(1.7.1.3), I don't see how to proceed differently: the PROXY method
requires three arguments and one of them is a port. If one of my
readers has a suggestion, he/she's welcome. This remains a cool hack!&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: The great &lt;a href="https://darkpan.com/"&gt;Marco Fontani&lt;/a&gt; gave a cool solution (see the
comments). Here is how my .ssh/config looks like:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;Host server.com
    ProxyCommand socat TCP-LISTEN:1080 OPENSSL:server.com:443,verify=0 &amp;amp; sleep 1 &amp;amp;&amp;amp; socat - PROXY:127.0.0.1:127.0.0.1:22,proxyport=1080
    DynamicForward 1080
    ServerAliveInterval 60
    ControlMaster auto
    ControlPath ~/.ssh/tmp/%h_%p_%r
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</content><category term="howto"></category><category term="socat"></category><category term="ssh"></category><category term="ssl"></category></entry><entry><title>SSH over SSL, a quick and minimal config.</title><link href="http://blog.chmd.fr/ssh-over-ssl-a-quick-and-minimal-config.html" rel="alternate"></link><published>2010-11-12T11:52:00+01:00</published><updated>2010-11-12T11:52:00+01:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2010-11-12:/ssh-over-ssl-a-quick-and-minimal-config.html</id><summary type="html">&lt;p&gt;If you are reading this, you might be interested in the full list of my
articles about doing SSH over SSL. I have been improving my configuration
over the years, so the more recent, the better:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;2010-11-12: &lt;a href="/ssh-over-ssl-a-quick-and-minimal-config.html"&gt;Quick and minimal config&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;2010-11-15: &lt;a href="/ssh-over-ssl-episode-2-replacing-proxytunnel-with-socat.html"&gt;Replacing proxytunnel with socat&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;2011-07-11: &lt;a href="/ssh-over-ssl-episode-3-avoiding-using-a-patched-apache.html"&gt;Avoiding using a …&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;</summary><content type="html">&lt;p&gt;If you are reading this, you might be interested in the full list of my
articles about doing SSH over SSL. I have been improving my configuration
over the years, so the more recent, the better:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;2010-11-12: &lt;a href="/ssh-over-ssl-a-quick-and-minimal-config.html"&gt;Quick and minimal config&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;2010-11-15: &lt;a href="/ssh-over-ssl-episode-2-replacing-proxytunnel-with-socat.html"&gt;Replacing proxytunnel with socat&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;2011-07-11: &lt;a href="/ssh-over-ssl-episode-3-avoiding-using-a-patched-apache.html"&gt;Avoiding using a patched Apache&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;2014-10-19: &lt;a href="/ssh-over-ssl-episode-4-a-haproxy-based-configuration.html"&gt;HAproxy based configuration&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;p&gt;So you are behind a vicious firewall that filters outgoing ssh and
vpn, and the only safe way out is SSL. In this article, I'll
describe how to SSH over SSL to a machine that runs an ssh server
and apache2. This machine will still be able to run an SSL website.
Clients will connect using a standard ssh client and proxytunnel.&lt;/p&gt;
&lt;h1&gt;Server configuration&lt;/h1&gt;
&lt;p&gt;I assume that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The server is accessible on the port 443 through the "server.com" domain
  name (otherwise using the raw ip will do the trick).&lt;/li&gt;
&lt;li&gt;It also runs an ssh server (but no need for the port 22 to be
  reachable).&lt;/li&gt;
&lt;li&gt;You already have set up certificates for SSL&lt;/li&gt;
&lt;li&gt;You've enabled the modules for ssl (a2enmod ssl)&lt;/li&gt;
&lt;li&gt;You're running the default ssl website in
  /etc/apache2/sites-available/default-ssl and it is enabled (a2ensite
  default-ssl)&lt;/li&gt;
&lt;li&gt;You've enabled necessary modules for proxying and using proxy connect
  methods (a2enmod proxy proxy_connect proxy_http)&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;File /etc/apache2/sites-available/default-ssl&lt;/h1&gt;
&lt;p&gt;It's minimalistic on purpose, so you can see what is really needed.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;IfModule&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;mod_ssl.c&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;VirtualHost&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;_default_:443&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;#&lt;span class="w"&gt; &lt;/span&gt;enable&lt;span class="w"&gt; &lt;/span&gt;ssl
&lt;span class="w"&gt;    &lt;/span&gt;SSLEngine&lt;span class="w"&gt; &lt;/span&gt;on
&lt;span class="w"&gt;    &lt;/span&gt;SSLCertificateFile&lt;span class="w"&gt;    &lt;/span&gt;/etc/ssl/certs/ssl-cert-snakeoil.pem
&lt;span class="w"&gt;    &lt;/span&gt;SSLCertificateKeyFile&lt;span class="w"&gt; &lt;/span&gt;/etc/ssl/private/ssl-cert-snakeoil.key
&lt;span class="w"&gt;    &lt;/span&gt;#&lt;span class="w"&gt; &lt;/span&gt;proxytunnel
&lt;span class="w"&gt;    &lt;/span&gt;Include&lt;span class="w"&gt; &lt;/span&gt;/etc/apache2/proxytunnel/main.conf
&lt;span class="nt"&gt;&amp;lt;/VirtualHost&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/IfModule&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h1&gt;File /etc/apache2/proxytunnel/main.conf&lt;/h1&gt;
&lt;p&gt;It enables forward proxying for anyone, but only if the client asks for
127.0.0.1:22 (other requests will be denied). This results in exposing the
port 22 (ssh) of your server through a proxy, in an encrypted way.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;ProxyRequests&lt;span class="w"&gt; &lt;/span&gt;On
AllowConnect&lt;span class="w"&gt; &lt;/span&gt;22
&lt;span class="nt"&gt;&amp;lt;Proxy&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;*&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;Order&lt;span class="w"&gt; &lt;/span&gt;deny,allow
&lt;span class="w"&gt;    &lt;/span&gt;Deny&lt;span class="w"&gt; &lt;/span&gt;from&lt;span class="w"&gt; &lt;/span&gt;all
&lt;span class="nt"&gt;&amp;lt;/Proxy&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;Proxy&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;127.0.0.1&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;Order&lt;span class="w"&gt; &lt;/span&gt;deny,allow
&lt;span class="w"&gt;    &lt;/span&gt;Allow&lt;span class="w"&gt; &lt;/span&gt;from&lt;span class="w"&gt; &lt;/span&gt;all
&lt;span class="nt"&gt;&amp;lt;/Proxy&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h1&gt;Client configuration&lt;/h1&gt;
&lt;p&gt;I assume that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;An ssh client is installed&lt;/li&gt;
&lt;li&gt;proxytunnel is installed&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;First, you'll need to test your server setting using proxytunnel alone.
Since debugging encryption problems can be tedious, at first, I suggest
you set up your server to provide the proxy in a non encrypted way,
commenting the three SSL related lines (you can switch to encrypted when
it works). Proxytunnel can "chain" two proxies (a local one, and a remote
one), but if the place you connect from does not use such a setting, here
is how you can proceed:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;proxytunnel -E -p server.com:443 -d 127.0.0.1:22 -v
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;-v is for verbose. Replace it with -q (quiet) if it works. You can say it
works when you are prompted an ssh login. Apache2 used to have &lt;a href="https://issues.apache.org/bugzilla/show_bug.cgi?id=29744"&gt;a bug&lt;/a&gt;
with proxy_connect and SSL, so using encryption may require some extra
work (like patching and recompiling the mod_proxy shared libraries or
using the latest alpha).&lt;/p&gt;
&lt;h1&gt;File .ssh/config&lt;/h1&gt;
&lt;p&gt;Once you're done, just drop the working command line in the .ssh/config of
your clients:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;Host server.com
    ProxyCommand proxytunnel -q -E -p server.com:443 -d 127.0.0.1:22
    DynamicForward 1080
    ServerAliveInterval 60
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;If you are stuck, I recommend you read &lt;a href="http://www.saulchristie.co.uk/how-to/bypass-firewalls"&gt;this excellent article&lt;/a&gt;. One
problem remains with this config: If the traffic is correctly monitored,
the ip of you server could be logged (even though it will be impossible to
prove you have been doing something not allowed). First, you should run an
https website on this ip (like a blog, or a code repository), in order to
make this traffic more realistic. What could also be cool would be to
chain proxies, &lt;a href="http://lifehacker.com/5484934/run-your-own-free-proxy-through-the-google-app-engine"&gt;using for example the appengine&lt;/a&gt;. This way your traffic
will look like it's going to google.&lt;/p&gt;</content><category term="howto"></category><category term="apache"></category><category term="ssh"></category><category term="ssl"></category><category term="tunnel"></category></entry><entry><title>Vim: complete C++ accurately, pulling informations from the compiler, with gccsense and clang_complete</title><link href="http://blog.chmd.fr/vim-complete-c-accurately-pulling-informations-from-the-compiler-with-gccsense-and-clang_complete.html" rel="alternate"></link><published>2010-10-27T23:11:00+02:00</published><updated>2010-10-27T23:11:00+02:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2010-10-27:/vim-complete-c-accurately-pulling-informations-from-the-compiler-with-gccsense-and-clang_complete.html</id><summary type="html">&lt;p&gt;It has been a while since I first dreamt about a reliable way to complete
C++ code within vim. Sure, there was omnicppcomplete, which was able to
complete more or less accurately from ctags databases, but the quality of
the completion was greatly dependent on your coding style (I never …&lt;/p&gt;</summary><content type="html">&lt;p&gt;It has been a while since I first dreamt about a reliable way to complete
C++ code within vim. Sure, there was omnicppcomplete, which was able to
complete more or less accurately from ctags databases, but the quality of
the completion was greatly dependent on your coding style (I never could
get myself used to put all my methods declarations on the same line).
What we missed was a clever completion plugin, something that would be
able to look deep inside the code, to resolve the types of the object you
are refering to and to provide the set of accurate methods. Actually, we
needed a plugin that would have the same knowledge the compiler has. That
is a huge task, which is probably the reason why it has been let aside for
so long.  But recently, almost at the same time, two plugins have
appeared, based on this idea.&lt;/p&gt;
&lt;p&gt;The first plugin, clang_complete, uses a feature from the compiler
clang++, from the llvm project. This new C++ compiler aims at being as
reliable as g++. Though as far as I know, it is still not ready for
production, it recently compiled boost, so expect to hear about it again.
clang++ features the ability to complete a given line of code from the
command line, and our first plugin is based on this feature: see
&lt;a href="http://www.vim.org/scripts/script.php?script_id=3302"&gt;http://www.vim.org/scripts/script.php?script&lt;/a&gt; for more information.&lt;/p&gt;
&lt;p&gt;The second plugin is based on a crazy gcc modification called
gcc-code-assist. The author has hacked in gcc's code and provides a
replacement for gcc that also builds a sqlite database at the same time
you build your code with it. Then a command line tool called gccsense
allows to query this database.  Basically, you just replace gcc with
gcc-code-assist in your makefile, and you install the plugin provided on
the author's website: &lt;a href="http://cx4a.org/software/gccsense/"&gt;http://cx4a.org/software/gccsense/&lt;/a&gt;.  The
modified gcc is really easy to compile, I even made a package for
archlinux that you can find on AUR. Obviously, this stuff is very unlikely
to make it to gcc's upstream...&lt;/p&gt;
&lt;p&gt;So, what to use?  Well, if clang++ builds your project without errors, I'd
go for it, because this is for sure a feature that will continue to be
maintained by the llvm crew. Otherwise, gccsense should work exactly like
gcc-4.4. Honestly, I did not have the chance to really test any of them,
so it will be difficult to provide good feedback for me. If someone has
the opportunity to test it, please leave a comment!&lt;/p&gt;</content><category term="code"></category><category term="vim"></category><category term="gccsense"></category><category term="clang_complete"></category></entry><entry><title>Google releasing a constraint programming library</title><link href="http://blog.chmd.fr/google-releasing-a-constraint-programming-library.html" rel="alternate"></link><published>2010-09-25T00:31:00+02:00</published><updated>2010-09-25T00:31:00+02:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2010-09-25:/google-releasing-a-constraint-programming-library.html</id><summary type="html">&lt;p&gt;As an Operation Research engineer/PhD student, I was very interested to
discover that Google just released a project in my field. It is simply
called "or-tools" and contains a constraint programming solver.&lt;/p&gt;
&lt;p&gt;While CP is not my primary field of study, I know the basics and I gave a …&lt;/p&gt;</summary><content type="html">&lt;p&gt;As an Operation Research engineer/PhD student, I was very interested to
discover that Google just released a project in my field. It is simply
called "or-tools" and contains a constraint programming solver.&lt;/p&gt;
&lt;p&gt;While CP is not my primary field of study, I know the basics and I gave a
quick look, just in order to know how big it was and what I would fine
inside. Technically, I liked what I saw: What is actually inside is C++,
wrapped in a swig interface. There are 58 C++ files (24 of them are
headers) and a total number of 35998 lines of code, which is reasonable (=
rather big, but still readable by 1/2 persons) for a project in this
language. Embedding C++ in script languages is probably the best way I
know to get the best of the two worlds since you get the power of scripts,
and the speed of C++. While this technique is very efficient and more and
more projects are using it, Operations Research is a field where things
are usually moving slowly in terms of technology, so I was glad to see
that google engineers are doing it, it might show the way for the rest of
the community.&lt;/p&gt;
&lt;p&gt;The project is supposed to build on the 3 major platforms. For linux, it
just uses a simple Makefile, which I liked even more: Having used
autotools a lot, I think I can now say I only have pure hate for them
(they never made things simpler) and I just want to hug every programmers
that are handling things with simple Makefiles.&lt;/p&gt;
&lt;p&gt;There are examples in python and in C++ that are classic CP
exercises for students (at least I already knew most of them). The
only thing I did not like was the fact they are using subversion. I
find it easier to hack in projects when they are distributed with
DCVS. But I guess the guys who did this don't need my opinion,
since it is not the first time they are writing code. I was curious
and googled the name of the commiter: apparently he's a former
engineer from ilog (now part of IBM), which is famous in the OR
field for cplex, the famous MIP solver.&lt;/p&gt;
&lt;p&gt;There are a mailing list:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://groups.google.com/group/or-tools-discuss"&gt;http://groups.google.com/group/or-tools-discuss&lt;/a&gt;
and a website:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://sites.google.com/site/ortoolssite/"&gt;https://sites.google.com/site/ortoolssite/&lt;/a&gt;,&lt;/p&gt;
&lt;p&gt;so I guess google also plans to maintain this library. Conclusion:
Good news for OR!&lt;/p&gt;</content><category term="code"></category><category term="or"></category></entry><entry><title>Mise à jour de TalkMyPhone</title><link href="http://blog.chmd.fr/mise-a-jour-de-talkmyphone.html" rel="alternate"></link><published>2010-09-07T13:07:00+02:00</published><updated>2010-09-07T13:07:00+02:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2010-09-07:/mise-a-jour-de-talkmyphone.html</id><summary type="html">&lt;p&gt;Salut planet-libre, J'ai mis à jour TalkMyPhone, mon application
android.&lt;/p&gt;
&lt;p&gt;Pour ceux qui n'auraient pas suivi le lancement de l'application la
semaine dernière, TalkMyPhone est une application permettant de contrôler
son mobile à distance via xmpp, le protocole utilisé par jabber/gtalk. La
version beta supporte désormais:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;la réponse aux …&lt;/li&gt;&lt;/ul&gt;</summary><content type="html">&lt;p&gt;Salut planet-libre, J'ai mis à jour TalkMyPhone, mon application
android.&lt;/p&gt;
&lt;p&gt;Pour ceux qui n'auraient pas suivi le lancement de l'application la
semaine dernière, TalkMyPhone est une application permettant de contrôler
son mobile à distance via xmpp, le protocole utilisé par jabber/gtalk. La
version beta supporte désormais:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;la réponse aux sms&lt;/li&gt;
&lt;li&gt;faire sonner le téléphone à distance (pour le retrouver)&lt;/li&gt;
&lt;li&gt;demander la géolocalisation du téléphone&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Ça se passe ici:
&lt;a href="https://code.google.com/p/talkmyphone/"&gt;https://code.google.com/p/talkmyphone/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Update: On en parle sur
&lt;a href="http://www.frandroid.com/33622/talkmyphone-controlez-votre-telephone-a-distance/"&gt;frandroid&lt;/a&gt;!&lt;/p&gt;</content><category term="misc"></category><category term="libre"></category><category term="talkmyphone"></category></entry><entry><title>TalkMyPhone, une appli android pour recevoir des notifications de son téléphone</title><link href="http://blog.chmd.fr/talkmyphone-une-appli-android-pour-recevoir-des-notifications-de-son-telephone.html" rel="alternate"></link><published>2010-09-01T16:29:00+02:00</published><updated>2010-09-01T16:29:00+02:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2010-09-01:/talkmyphone-une-appli-android-pour-recevoir-des-notifications-de-son-telephone.html</id><summary type="html">&lt;p&gt;Hello planet libre, J'ai codé une application android pour recevoir des
notifications de son téléphone.&lt;/p&gt;
&lt;p&gt;Le principe est simple: vous créez un compte jabber pour votre appareil et
vous l'inscrivez dans vos amis gtalk (vérifiez que ça marche avec
pidgin/empathy en vous envoyant un message). Puis vous installez
l'application …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Hello planet libre, J'ai codé une application android pour recevoir des
notifications de son téléphone.&lt;/p&gt;
&lt;p&gt;Le principe est simple: vous créez un compte jabber pour votre appareil et
vous l'inscrivez dans vos amis gtalk (vérifiez que ça marche avec
pidgin/empathy en vous envoyant un message). Puis vous installez
l'application sur votre appareil et vous la configurez comme il faut en
réglant les champs &lt;code&gt;login compte jabber téléphone&lt;/code&gt;/&lt;code&gt;mot de passe compte
jabber téléphone&lt;/code&gt;/&lt;code&gt;adresse gmail à notifier&lt;/code&gt;. Vous démarrez alors le
service et votre téléphone vous transmet les sms qu'il reçoit et vous
notifie des appels de vos correspondants.&lt;/p&gt;
&lt;p&gt;J'avoue que ça n'est pas d'une utilité fantastique, mais j'aime bien être
notifié de tout et n'importe quoi sur mon ordinateur, et ce genre de
notifications me manquait. Je prévois de rajouter de petites
fonctionnalités comme la possibilité de répondre aux sms quand j'aurai un
peu de temps.&lt;/p&gt;
&lt;p&gt;Évidemment le code est libre (LGPL, même, puisque google code ne connait
pas la WTFPL ;) ). N'hésitez pas à me laisser des commentaires gentils.
L'url du projet:
&lt;a href="https://code.google.com/p/talkmyphone/"&gt;https://code.google.com/p/talkmyphone/&lt;/a&gt;
PS: Je ne garantis pas que ça marche sur votre téléphone. J'ai fait ça sur
mon temps libre, pour le fun, et je ne compte pas y passer des nuits
blanches. Mais je regarderai les rapports de bug s'il y en a...&lt;/p&gt;</content><category term="code"></category><category term="android"></category><category term="talkmyphone"></category></entry><entry><title>De l'intérêt de détacher des programmes de la console (sans screen)</title><link href="http://blog.chmd.fr/de-linteret-de-detacher-des-programmes-de-la-console-sans-screen.html" rel="alternate"></link><published>2010-04-09T09:57:00+02:00</published><updated>2010-04-09T09:57:00+02:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2010-04-09:/de-linteret-de-detacher-des-programmes-de-la-console-sans-screen.html</id><summary type="html">&lt;p&gt;Qui n'a jamais perdu par erreur une compilation, une session ssh ou
une fenêtre irssi en fermant une console par inadvertance, à cause
d'un lag réseau, ou bien à cause d'un redémarrage brutal de X11?&lt;/p&gt;
&lt;p&gt;Les outils présentés ici permettent de vous affranchir de ce genre
de problème. dtach est …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Qui n'a jamais perdu par erreur une compilation, une session ssh ou
une fenêtre irssi en fermant une console par inadvertance, à cause
d'un lag réseau, ou bien à cause d'un redémarrage brutal de X11?&lt;/p&gt;
&lt;p&gt;Les outils présentés ici permettent de vous affranchir de ce genre
de problème. dtach est un petit programme bien pratique qui sert à
détacher un programme de la console où celui-ci tourne. De manière
simple, ça veut dire que si on quitte le terminal dans lequel on a
lancé le programme détaché, on pourra par une courte commande
récupérer ce programme.&lt;/p&gt;
&lt;p&gt;Exemple, la commande suivante permet de
lancer le programme irssi en détaché, sur le socket /tmp/irssi.sock
(qui sera créé par le programme), où, s'il est déjà lancé, de
récupérer ce programme.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;dtach -A /tmp/irssi.sock /usr/bin/irssi
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;J'en connais des tas qui ne jurent que par gnu screen. Mais  à quoi
bon, si on peut se contenter d'un simple alias?&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;alias irssi=&amp;#39;dtach -A /tmp/irssi.sock /usr/bin/irssi&amp;#39;`
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Jusque là, je me contentais de deux ou trois alias du genre, et j'avais
une petite fonction au début de mon .zshrc qui me permettait de toujours
lancer mon shell en détaché. Cependant, tout ceci manquant de souplesse,
je me suis intéressé à screen et à ses alternatives, et je dois dire que
je trouve tmux vraiment propre. Je mets de côté tous les aspects de
coupage d'écran en deux, onglets et tutti quanti, qui  sont plus ou moins
inutiles quand on utilise &lt;a href="http://awesome.naquadah.org/"&gt;un vrai window manager&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Si screen et tmux peuvent tous deux ouvrir un nombre illimité de sessions
(screen pouvant, si j'ai bien compris, ouvrir jusqu'à 10 fenêtres au sein
de la même session), tmux offre un mécanisme pour alterner entre
différentes sessions que j'ai cherché en vain dans screen (je vois d'ici
les ardents défenseurs de leur programme favori venir me crucifier dans
les commentaires: tant pis, si ça existe, j'assume ma mauvaise lecture des
pages de manuel).&lt;/p&gt;
&lt;p&gt;Dans tmux, avec la configuration par défaut, un simple CTRL-b suivi de s
montre une liste à choix des sessions ouvertes (attachées ou détachées) et
il suffit alors de selectionner une entrée pour que tmux se connecte à
ladite session (et si vous aimez couper l'écran en deux et mettre
plusieurs fenêtres dans la même session, vous pouvez, sans limitation de
nombre).&lt;/p&gt;
&lt;p&gt;Voici quelques lignes que j'ai rajoutées au début de mon .zshrc: elles
garantissent qu'une nouvelle session tmux est toujours lancée avec le
shell. La fermeture de la session en cours entraine l'essai de connection
à une autre session, sauf s'il n'y a plus aucune session de lancée.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;#&lt;span class="w"&gt; &lt;/span&gt;TMUX
#&lt;span class="w"&gt; &lt;/span&gt;if&lt;span class="w"&gt; &lt;/span&gt;no&lt;span class="w"&gt; &lt;/span&gt;session&lt;span class="w"&gt; &lt;/span&gt;is&lt;span class="w"&gt; &lt;/span&gt;started,&lt;span class="w"&gt; &lt;/span&gt;start&lt;span class="w"&gt; &lt;/span&gt;a&lt;span class="w"&gt; &lt;/span&gt;new&lt;span class="w"&gt; &lt;/span&gt;session
if&lt;span class="w"&gt; &lt;/span&gt;test&lt;span class="w"&gt; &lt;/span&gt;-z&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="cp"&gt;${&lt;/span&gt;&lt;span class="n"&gt;TMUX&lt;/span&gt;&lt;span class="cp"&gt;}&lt;/span&gt;;&lt;span class="w"&gt; &lt;/span&gt;then
&lt;span class="w"&gt;    &lt;/span&gt;tmux
fi
#&lt;span class="w"&gt; &lt;/span&gt;when&lt;span class="w"&gt; &lt;/span&gt;quitting&lt;span class="w"&gt; &lt;/span&gt;tmux,&lt;span class="w"&gt; &lt;/span&gt;try&lt;span class="w"&gt; &lt;/span&gt;to&lt;span class="w"&gt; &lt;/span&gt;attach
while&lt;span class="w"&gt; &lt;/span&gt;test&lt;span class="w"&gt; &lt;/span&gt;-z&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="cp"&gt;${&lt;/span&gt;&lt;span class="n"&gt;TMUX&lt;/span&gt;&lt;span class="cp"&gt;}&lt;/span&gt;;&lt;span class="w"&gt; &lt;/span&gt;do
&lt;span class="w"&gt;    &lt;/span&gt;tmux&lt;span class="w"&gt; &lt;/span&gt;attach&lt;span class="w"&gt; &lt;/span&gt;||&lt;span class="w"&gt; &lt;/span&gt;break
done
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Et désormais je lance irssi de la manière suivante:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;#&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;IRSSI&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;IN&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;TMUX&lt;/span&gt;
#&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;switch&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;irssi&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;session&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;and&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;necessary&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;starts&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;this&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;session&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;before&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;irssi&lt;/span&gt;&lt;span class="ss"&gt;()&lt;/span&gt;
{
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;tmux&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;has&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;t&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;irssi&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;gt;/&lt;/span&gt;&lt;span class="nv"&gt;dev&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;null&lt;/span&gt;&lt;span class="c1"&gt;; then&lt;/span&gt;
&lt;span class="w"&gt;         &lt;/span&gt;&lt;span class="nv"&gt;tmux&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;switch&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;t&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;irssi&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nv"&gt;TMUX&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;tmux&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;new&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;d&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;s&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;irssi&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;usr&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;bin&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;irssi&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nv"&gt;tmux&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;switch&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;t&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;irssi&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;fi&lt;/span&gt;
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Si vous utilisez zsh et/ou urxvt, et que vous souhaitez tenter l'essai, je
vous suggère de jeter un coup d'oeil à &lt;a href="https://github.com/chmduquesne/dotfiles/"&gt;ma configuration&lt;/a&gt; (les
problèmes de couleurs et de scrolling y sont réglés). À noter qu'il existe
d'autres alternatives à gnu screen, dont le très prometteur &lt;a href="http://caca.zoy.org/wiki/neercs"&gt;neercs&lt;/a&gt;,
qui permet entre autre de détacher des programmes qu'on avait oublié de
lancer dans neercs.&lt;/p&gt;</content><category term="howto"></category><category term="tmux"></category><category term="irssi"></category><category term="dtach"></category></entry><entry><title>renaming files and variables from vim</title><link href="http://blog.chmd.fr/renaming-files-and-variables-from-vim.html" rel="alternate"></link><published>2010-03-26T01:10:00+01:00</published><updated>2010-03-26T01:10:00+01:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2010-03-26:/renaming-files-and-variables-from-vim.html</id><content type="html">&lt;p&gt;I just wrote a plugin that does it (thanks to cscope). Find it here:
&lt;a href="http://www.vim.org/scripts/script.php?script_id=3028"&gt;http://www.vim.org/scripts/script.php?script_id=3028&lt;/a&gt;&lt;/p&gt;</content><category term="code"></category><category term="vim"></category></entry><entry><title>Continuous background compilation within vim</title><link href="http://blog.chmd.fr/continuous-background-compilation-within-vim.html" rel="alternate"></link><published>2010-03-14T16:36:00+01:00</published><updated>2010-03-14T16:36:00+01:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2010-03-14:/continuous-background-compilation-within-vim.html</id><summary type="html">&lt;p&gt;You &lt;em&gt;can&lt;/em&gt; do continuous background compilation within vim. The following
code snippet will compile your project with &lt;code&gt;make&lt;/code&gt; each time you save the
current buffer:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;augroup&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;
    &lt;span class="n"&gt;autocmd&lt;/span&gt; &lt;span class="n"&gt;BufWritePost&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;.{&lt;/span&gt;&lt;span class="n"&gt;hpp&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;cpp&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
                &lt;span class="err"&gt;\&lt;/span&gt; &lt;span class="n"&gt;silent&lt;/span&gt; &lt;span class="n"&gt;execute&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;:!make &amp;gt; ~/.vim/cpperrors 2&amp;gt;&amp;amp;1 &amp;amp;&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt;
                &lt;span class="err"&gt;\&lt;/span&gt; &lt;span class="n"&gt;redraw&lt;/span&gt;&lt;span class="err"&gt;!&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt;
                &lt;span class="err"&gt;\&lt;/span&gt; &lt;span class="n"&gt;cgetfile&lt;/span&gt; &lt;span class="o"&gt;~/&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;vim&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;cpperrors&lt;/span&gt;
&lt;span class="n"&gt;augroup&lt;/span&gt; &lt;span class="kr"&gt;END&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Of course you could replace the …&lt;/p&gt;</summary><content type="html">&lt;p&gt;You &lt;em&gt;can&lt;/em&gt; do continuous background compilation within vim. The following
code snippet will compile your project with &lt;code&gt;make&lt;/code&gt; each time you save the
current buffer:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;augroup&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;
    &lt;span class="n"&gt;autocmd&lt;/span&gt; &lt;span class="n"&gt;BufWritePost&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;.{&lt;/span&gt;&lt;span class="n"&gt;hpp&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;cpp&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
                &lt;span class="err"&gt;\&lt;/span&gt; &lt;span class="n"&gt;silent&lt;/span&gt; &lt;span class="n"&gt;execute&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;:!make &amp;gt; ~/.vim/cpperrors 2&amp;gt;&amp;amp;1 &amp;amp;&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt;
                &lt;span class="err"&gt;\&lt;/span&gt; &lt;span class="n"&gt;redraw&lt;/span&gt;&lt;span class="err"&gt;!&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt;
                &lt;span class="err"&gt;\&lt;/span&gt; &lt;span class="n"&gt;cgetfile&lt;/span&gt; &lt;span class="o"&gt;~/&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;vim&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;cpperrors&lt;/span&gt;
&lt;span class="n"&gt;augroup&lt;/span&gt; &lt;span class="kr"&gt;END&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Of course you could replace the make command with something more
complicated (for example calling some script that would run the
compilation on another machine, and getting the error file back in your
&lt;code&gt;~/.vim&lt;/code&gt; directory).&lt;/p&gt;</content><category term="code"></category><category term="vim"></category><category term="makefile"></category></entry><entry><title>Utilisons incron pour être notifiés des événements du système de fichiers</title><link href="http://blog.chmd.fr/utilisons-incron-pour-etre-notifies-des-evenements-du-systeme-de-fichiers.html" rel="alternate"></link><published>2010-02-18T00:26:00+01:00</published><updated>2010-02-18T00:26:00+01:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2010-02-18:/utilisons-incron-pour-etre-notifies-des-evenements-du-systeme-de-fichiers.html</id><summary type="html">&lt;p&gt;&lt;a href="http://incron.aiken.cz/"&gt;incron&lt;/a&gt; est un programme fonctionnant sur
le même principe que cron, mais basé sur des événements dans le
système de fichiers plutôt que sur des moments de la journée. C'est
très propre: pour l'utiliser, on spécifie un ou des fichiers à
surveiller, un type d'action à détecter sur le(s …&lt;/p&gt;</summary><content type="html">&lt;p&gt;&lt;a href="http://incron.aiken.cz/"&gt;incron&lt;/a&gt; est un programme fonctionnant sur
le même principe que cron, mais basé sur des événements dans le
système de fichiers plutôt que sur des moments de la journée. C'est
très propre: pour l'utiliser, on spécifie un ou des fichiers à
surveiller, un type d'action à détecter sur le(s) fichier(s) en
question, et une commande à déclencher lorsque l'événement
survient. Je me suis dit que c'était l'occasion où jamais de mettre
à jour un vieux script que j'avais, qui me met au courant des
modifications sur mes logs (je tire l'idée de ce script
&lt;a href="http://www.daemontux.org/?q=node/31"&gt;d'un ancien post sur le planet libre&lt;/a&gt;).
Après avoir installé incron, j'édite ma table de configuration
incron:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;incrontab -e
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Avec mon éditeur favori, je lui mets la ligne suivante:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="k"&gt;var&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nb"&gt;log&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;kernel&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;IN_MODIFY&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;sh&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;home&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;me&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;documents&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;scripts&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;popLog&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sh&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="k"&gt;var&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nb"&gt;log&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;kernel&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;popLog.sh est un script qui prend en argument un log, en extrait la
dernière ligne modifiée, la colorise avec `source-highlight`_ et
l'envoie en notification par le biais de `notify-send`_. Le but
de ce script est donc d'afficher le dernier log dans une bulle,
avec coloration syntaxique. Je fournis le script en question, et
j'ajoute quelques explications:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;source-highlight a besoin de parler un code couleurs compris
    par les bulles de notifications. notification-daemon comprend des
    couleurs de type &amp;lt;span color="couleur"&amp;gt;mots à colorier&amp;lt;/span&amp;gt;,
    d'où le fichier supplémentaire awesome.outlang (que j'avais écrit à
    l'origine pour naughty et donc compatible avec celui-ci, pour les
    utilisateurs d'&lt;a href="http://awesome.naquadah.org/"&gt;awesome wm&lt;/a&gt; - à ce
    propos il y a plusieurs entrées dans le wiki pour faire des choses
    semblables).&lt;/li&gt;
&lt;li&gt;incron ne comprend pas bien les variables d'environnement, il
    vaut mieux les redéfinir dans le script, comme je l'ai fait.&lt;/li&gt;
&lt;li&gt;faites attention à ne pas faire n'importe quoi avec incron, il
    est facile de créer une boucle infinie en surveillant par exemple
    /var/log/everything.log (vous notifiant du lancement de ce script,
    et donc générant une nouvelle notification): IN_NO_LOOP est votre
    ami.&lt;/li&gt;
&lt;li&gt;incron prend des chemins absolus.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Après tous ces avertissements, voici
/home/me/documents/scripts/popLog.sh:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt; 1&lt;/span&gt;
&lt;span class="normal"&gt; 2&lt;/span&gt;
&lt;span class="normal"&gt; 3&lt;/span&gt;
&lt;span class="normal"&gt; 4&lt;/span&gt;
&lt;span class="normal"&gt; 5&lt;/span&gt;
&lt;span class="normal"&gt; 6&lt;/span&gt;
&lt;span class="normal"&gt; 7&lt;/span&gt;
&lt;span class="normal"&gt; 8&lt;/span&gt;
&lt;span class="normal"&gt; 9&lt;/span&gt;
&lt;span class="normal"&gt;10&lt;/span&gt;
&lt;span class="normal"&gt;11&lt;/span&gt;
&lt;span class="normal"&gt;12&lt;/span&gt;
&lt;span class="normal"&gt;13&lt;/span&gt;
&lt;span class="normal"&gt;14&lt;/span&gt;
&lt;span class="normal"&gt;15&lt;/span&gt;
&lt;span class="normal"&gt;16&lt;/span&gt;
&lt;span class="normal"&gt;17&lt;/span&gt;
&lt;span class="normal"&gt;18&lt;/span&gt;
&lt;span class="normal"&gt;19&lt;/span&gt;
&lt;span class="normal"&gt;20&lt;/span&gt;
&lt;span class="normal"&gt;21&lt;/span&gt;
&lt;span class="normal"&gt;22&lt;/span&gt;
&lt;span class="normal"&gt;23&lt;/span&gt;
&lt;span class="normal"&gt;24&lt;/span&gt;
&lt;span class="normal"&gt;25&lt;/span&gt;
&lt;span class="normal"&gt;26&lt;/span&gt;
&lt;span class="normal"&gt;27&lt;/span&gt;
&lt;span class="normal"&gt;28&lt;/span&gt;
&lt;span class="normal"&gt;29&lt;/span&gt;
&lt;span class="normal"&gt;30&lt;/span&gt;
&lt;span class="normal"&gt;31&lt;/span&gt;
&lt;span class="normal"&gt;32&lt;/span&gt;
&lt;span class="normal"&gt;33&lt;/span&gt;
&lt;span class="normal"&gt;34&lt;/span&gt;
&lt;span class="normal"&gt;35&lt;/span&gt;
&lt;span class="normal"&gt;36&lt;/span&gt;
&lt;span class="normal"&gt;37&lt;/span&gt;
&lt;span class="normal"&gt;38&lt;/span&gt;
&lt;span class="normal"&gt;39&lt;/span&gt;
&lt;span class="normal"&gt;40&lt;/span&gt;
&lt;span class="normal"&gt;41&lt;/span&gt;
&lt;span class="normal"&gt;42&lt;/span&gt;
&lt;span class="normal"&gt;43&lt;/span&gt;
&lt;span class="normal"&gt;44&lt;/span&gt;
&lt;span class="normal"&gt;45&lt;/span&gt;
&lt;span class="normal"&gt;46&lt;/span&gt;
&lt;span class="normal"&gt;47&lt;/span&gt;
&lt;span class="normal"&gt;48&lt;/span&gt;
&lt;span class="normal"&gt;49&lt;/span&gt;
&lt;span class="normal"&gt;50&lt;/span&gt;
&lt;span class="normal"&gt;51&lt;/span&gt;
&lt;span class="normal"&gt;52&lt;/span&gt;
&lt;span class="normal"&gt;53&lt;/span&gt;
&lt;span class="normal"&gt;54&lt;/span&gt;
&lt;span class="normal"&gt;55&lt;/span&gt;
&lt;span class="normal"&gt;56&lt;/span&gt;
&lt;span class="normal"&gt;57&lt;/span&gt;
&lt;span class="normal"&gt;58&lt;/span&gt;
&lt;span class="normal"&gt;59&lt;/span&gt;
&lt;span class="normal"&gt;60&lt;/span&gt;
&lt;span class="normal"&gt;61&lt;/span&gt;
&lt;span class="normal"&gt;62&lt;/span&gt;
&lt;span class="normal"&gt;63&lt;/span&gt;
&lt;span class="normal"&gt;64&lt;/span&gt;
&lt;span class="normal"&gt;65&lt;/span&gt;
&lt;span class="normal"&gt;66&lt;/span&gt;
&lt;span class="normal"&gt;67&lt;/span&gt;
&lt;span class="normal"&gt;68&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="ch"&gt;#!/usr/bin/env bash&lt;/span&gt;

&lt;span class="c1"&gt;# Usage: popLog /var/log/yourlog&lt;/span&gt;
&lt;span class="c1"&gt;# pops a colored log with the last line of the log&lt;/span&gt;

&lt;span class="nb"&gt;export&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;DISPLAY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;:0.0&amp;quot;&lt;/span&gt;
&lt;span class="nb"&gt;export&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;HOME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;/home/me&amp;quot;&lt;/span&gt;

&lt;span class="c1"&gt;#Urgency&lt;/span&gt;
&lt;span class="nv"&gt;infoUrgency&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;low&amp;#39;&lt;/span&gt;
&lt;span class="nv"&gt;warningUrgency&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;normal&amp;#39;&lt;/span&gt;
&lt;span class="nv"&gt;errorUrgency&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;critical&amp;#39;&lt;/span&gt;
&lt;span class="nv"&gt;securityUrgency&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;critical&amp;#39;&lt;/span&gt;

&lt;span class="c1"&gt;#Popup time&lt;/span&gt;
&lt;span class="nv"&gt;infoPopupTime&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;5000&lt;/span&gt;
&lt;span class="nv"&gt;warningPopupTime&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;8000&lt;/span&gt;
&lt;span class="nv"&gt;errorPopupTime&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;11000&lt;/span&gt;
&lt;span class="nv"&gt;securityPopupTime&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;11000&lt;/span&gt;

&lt;span class="c1"&gt;#Icons&lt;/span&gt;
&lt;span class="nv"&gt;infoIcon&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;/usr/share/icons/gnome/32x32/status/dialog-information.png&amp;#39;&lt;/span&gt;
&lt;span class="nv"&gt;warningIcon&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;/usr/share/icons/gnome/32x32/status/dialog-warning.png&amp;#39;&lt;/span&gt;
&lt;span class="nv"&gt;errorIcon&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;/usr/share/icons/gnome/32x32/status/dialog-error.png&amp;#39;&lt;/span&gt;
&lt;span class="nv"&gt;securityIcon&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;/usr/share/icons/gnome/32x32/status/security-medium.png&amp;#39;&lt;/span&gt;

&lt;span class="nv"&gt;coloredLog&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;$(&lt;/span&gt;tail&lt;span class="w"&gt; &lt;/span&gt;-n&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt;&lt;span class="w"&gt;                   &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;source-highlight&lt;span class="w"&gt; &lt;/span&gt;--failsafe&lt;span class="w"&gt;                 &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="w"&gt;                   &lt;/span&gt;--src-lang&lt;span class="o"&gt;=&lt;/span&gt;log&lt;span class="w"&gt;             &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="w"&gt;                   &lt;/span&gt;--style-file&lt;span class="o"&gt;=&lt;/span&gt;default.style&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="w"&gt;                   &lt;/span&gt;--outlang-def&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;HOME&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;/documents/scripts/awesome.outlang&lt;span class="k"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[[&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$coloredLog&lt;/span&gt;!&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&amp;#39;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;then&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[[&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt;grep&lt;span class="w"&gt; &lt;/span&gt;info&lt;span class="k"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;then&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;messageType&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;info&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[[&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt;grep&lt;span class="w"&gt; &lt;/span&gt;warn&lt;span class="k"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;then&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;messageType&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;warning&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[[&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt;grep&lt;span class="w"&gt; &lt;/span&gt;err&lt;span class="k"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;then&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;messageType&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;error&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[[&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt;grep&lt;span class="w"&gt; &lt;/span&gt;auth&lt;span class="k"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;then&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;messageType&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;security&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[[&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt;grep&lt;span class="w"&gt; &lt;/span&gt;access&lt;span class="k"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;then&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;messageType&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;security&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[[&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$notification&lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt;grep&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;UFW BLOCK INPUT&amp;#39;&lt;/span&gt;&lt;span class="k"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;then&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nv"&gt;messageType&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;security&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[[&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$messageType&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&amp;#39;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;then&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;messageType&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;info&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;fi&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;case&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$messageType&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;in&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;info&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nv"&gt;urgency&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$infoUrgency&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nv"&gt;icon&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$infoIcon&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nv"&gt;popupTime&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$infoPopupTime&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;;;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;warning&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nv"&gt;urgency&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$warningUrgency&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nv"&gt;icon&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$warningIcon&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nv"&gt;popupTime&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$warningPopupTime&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;;;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;error&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nv"&gt;urgency&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$errorUrgency&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nv"&gt;icon&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$errorIcon&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nv"&gt;popupTime&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$errorPopupTime&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;;;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;security&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nv"&gt;urgency&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$securityUrgency&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nv"&gt;icon&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$securityIcon&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nv"&gt;popupTime&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$securityPopupTime&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;;;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;esac&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;notify-send&lt;span class="w"&gt; &lt;/span&gt;-u&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$urgency&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;-t&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$popupTime&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;-i&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="nv"&gt;$icon&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="nv"&gt;$coloredLog&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Et voici /home/me/documents/scripts/awesome.outlang:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;extension&lt;span class="w"&gt; &lt;/span&gt;&amp;quot;awesome&amp;quot;

color&lt;span class="w"&gt; &lt;/span&gt;&amp;quot;&lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="na"&gt;color=&lt;/span&gt;&lt;span class="s"&gt;\&amp;quot;$style\&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;$text&lt;span class="nt"&gt;&amp;lt;/span&amp;gt;&lt;/span&gt;&amp;quot;

colormap
&amp;quot;green&amp;quot;&lt;span class="w"&gt; &lt;/span&gt;&amp;quot;#33CC00&amp;quot;
&amp;quot;red&amp;quot;&lt;span class="w"&gt; &lt;/span&gt;&amp;quot;#FF0000&amp;quot;
&amp;quot;darkred&amp;quot;&lt;span class="w"&gt; &lt;/span&gt;&amp;quot;#990000&amp;quot;
&amp;quot;blue&amp;quot;&lt;span class="w"&gt; &lt;/span&gt;&amp;quot;#0000FF&amp;quot;
&amp;quot;brown&amp;quot;&lt;span class="w"&gt; &lt;/span&gt;&amp;quot;#9A1900&amp;quot;
&amp;quot;pink&amp;quot;&lt;span class="w"&gt; &lt;/span&gt;&amp;quot;#CC33CC&amp;quot;
&amp;quot;yellow&amp;quot;&lt;span class="w"&gt; &lt;/span&gt;&amp;quot;#FFCC00&amp;quot;
&amp;quot;cyan&amp;quot;&lt;span class="w"&gt; &lt;/span&gt;&amp;quot;#66FFFF&amp;quot;
&amp;quot;purple&amp;quot;&lt;span class="w"&gt; &lt;/span&gt;&amp;quot;#993399&amp;quot;
&amp;quot;orange&amp;quot;&lt;span class="w"&gt; &lt;/span&gt;&amp;quot;#FF6600&amp;quot;
&amp;quot;brightorange&amp;quot;&lt;span class="w"&gt; &lt;/span&gt;&amp;quot;#FF9900&amp;quot;
&amp;quot;brightgreen&amp;quot;&lt;span class="w"&gt; &lt;/span&gt;&amp;quot;#33FF33&amp;quot;
&amp;quot;darkgreen&amp;quot;&lt;span class="w"&gt; &lt;/span&gt;&amp;quot;#009900&amp;quot;
&amp;quot;black&amp;quot;&lt;span class="w"&gt; &lt;/span&gt;&amp;quot;#000000&amp;quot;
&amp;quot;teal&amp;quot;&lt;span class="w"&gt; &lt;/span&gt;&amp;quot;#008080&amp;quot;
&amp;quot;gray&amp;quot;&lt;span class="w"&gt; &lt;/span&gt;&amp;quot;#808080&amp;quot;
&amp;quot;darkblue&amp;quot;&lt;span class="w"&gt; &lt;/span&gt;&amp;quot;#000080&amp;quot;
default&lt;span class="w"&gt; &lt;/span&gt;&amp;quot;#66FFFF&amp;quot;
end
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Je vous laisse faire joujou, je suis sûr que vous allez trouver
plein d'idées.&lt;/p&gt;</content><category term="howto"></category><category term="incron"></category><category term="inotify"></category><category term="notify-send"></category></entry><entry><title>La TODO liste du pauvre</title><link href="http://blog.chmd.fr/la-todo-liste-du-pauvre.html" rel="alternate"></link><published>2009-12-20T22:08:00+01:00</published><updated>2009-12-20T22:08:00+01:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2009-12-20:/la-todo-liste-du-pauvre.html</id><summary type="html">&lt;p&gt;Il y a des dizaines de logiciels permettant de gérer sa TODO liste.
Paradoxalement, si on cherche quelque chose de simple, on ne trouve
pas. Ce que je cherchais à faire est on ne peut plus simple à
décrire: quelque chose qui apparaisse une fois par heure.&lt;/p&gt;
&lt;p&gt;En effet, le …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Il y a des dizaines de logiciels permettant de gérer sa TODO liste.
Paradoxalement, si on cherche quelque chose de simple, on ne trouve
pas. Ce que je cherchais à faire est on ne peut plus simple à
décrire: quelque chose qui apparaisse une fois par heure.&lt;/p&gt;
&lt;p&gt;En effet, le problème des notes persistantes est que l'on finit par ne
plus les voir. Pour cela, j'ai opté pour les notifications. Le principe
est simple: on met sa TODO liste dans le fichier &lt;code&gt;~/TODO&lt;/code&gt;. Une fois par
heure, le contenu de ce fichier est affiché dans une bulle de notification
qui dure 10 secondes. Une façon gentille de rappeler les choses à faire,
intrusive, certe, mais à la durée assez courte pour ne pas être ennuyeuse.
Ça se fait très facilement avec le script suivant:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt; 1&lt;/span&gt;
&lt;span class="normal"&gt; 2&lt;/span&gt;
&lt;span class="normal"&gt; 3&lt;/span&gt;
&lt;span class="normal"&gt; 4&lt;/span&gt;
&lt;span class="normal"&gt; 5&lt;/span&gt;
&lt;span class="normal"&gt; 6&lt;/span&gt;
&lt;span class="normal"&gt; 7&lt;/span&gt;
&lt;span class="normal"&gt; 8&lt;/span&gt;
&lt;span class="normal"&gt; 9&lt;/span&gt;
&lt;span class="normal"&gt;10&lt;/span&gt;
&lt;span class="normal"&gt;11&lt;/span&gt;
&lt;span class="normal"&gt;12&lt;/span&gt;
&lt;span class="normal"&gt;13&lt;/span&gt;
&lt;span class="normal"&gt;14&lt;/span&gt;
&lt;span class="normal"&gt;15&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="ch"&gt;#!/usr/bin/env bash&lt;/span&gt;

&lt;span class="c1"&gt;# pour que cron sache sur quel moniteur jouer la notification&lt;/span&gt;
&lt;span class="nv"&gt;DISPLAY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;:0.0

&lt;span class="c1"&gt;#params&lt;/span&gt;
&lt;span class="nv"&gt;todofile&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;/TODO
&lt;span class="nv"&gt;icon&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;/usr/share/icons/gnome/32x32/status/dialog-information.png&amp;#39;&lt;/span&gt;
&lt;span class="nv"&gt;popupTime&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;10000&lt;/span&gt;
&lt;span class="nv"&gt;urgency&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;low&amp;#39;&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;test&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;-f&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$todofile&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;then&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;notification&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;cat&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$todofile&lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;notify-send&lt;span class="w"&gt; &lt;/span&gt;-u&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$urgency&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;-t&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$popupTime&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;-i&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="nv"&gt;$icon&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;TODO&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="nv"&gt;$notification&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Le script, que j'ai nommé todo.sh est à faire invoquer toutes les
heures par une tache cron:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="mf"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;sh&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;${&lt;/span&gt;&lt;span class="n"&gt;HOME&lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;documents&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;scripts&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="kr"&gt;to&lt;/span&gt;&lt;span class="n"&gt;do&lt;/span&gt;&lt;span class="mf"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sh&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Simple comme bonjour, et efficace. Ça fait un moment que je
l'utilise, et j'en suis satisfait.&lt;/p&gt;</content><category term="howto"></category><category term="libre"></category><category term="notify-send"></category></entry><entry><title>Gérer ses plugins vim avec :GetLatestVimScripts</title><link href="http://blog.chmd.fr/gerer-ses-plugins-vim-avec-getlatestvimscripts.html" rel="alternate"></link><published>2009-11-05T18:52:00+01:00</published><updated>2009-11-05T18:52:00+01:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2009-11-05:/gerer-ses-plugins-vim-avec-getlatestvimscripts.html</id><summary type="html">&lt;p&gt;J'ai envie d'attirer l'attention sur une fonctionnalité sympa de
vim, qui pourtant semble méconnue de pas mal de monde, même des
utilisateurs avancés: la commande &lt;code&gt;:GetLatestVimScripts&lt;/code&gt;, ou son
alias &lt;code&gt;:GLVS&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Le principe est simple: vous installez un script pour vim, et vous voulez
que ce script se maintienne à jour …&lt;/p&gt;</summary><content type="html">&lt;p&gt;J'ai envie d'attirer l'attention sur une fonctionnalité sympa de
vim, qui pourtant semble méconnue de pas mal de monde, même des
utilisateurs avancés: la commande &lt;code&gt;:GetLatestVimScripts&lt;/code&gt;, ou son
alias &lt;code&gt;:GLVS&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Le principe est simple: vous installez un script pour vim, et vous voulez
que ce script se maintienne à jour (c'est à dire que vous voulez profiter
des versions successives du script par l'auteur).  Au lieu de vous embêter
à vérifier si il y a des nouvelles versions périodiquement et d'avoir à
suivre un procédé d'installation qui differera selon que vous ayez affaire
à un vimscript, un vimball, ou une quelconque archive, vous pouvez tout
simplement dire à vim de gérer tous vos scripts d'un coup. Pour cela, il
vous suffit de maintenir à jour la liste des scripts qui vous intéressent
dans le fichier &lt;code&gt;~/.vim/GetLatest/GetLatestVimScripts.dat&lt;/code&gt;. Le format de
ce fichier est simple:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&amp;lt;numéro du script&amp;gt; &amp;lt;numéro de version installée du script&amp;gt; :AutoInstall: &amp;lt;nom du script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Le numéro du script est dans l'url sur sourceforge, donné par &lt;code&gt;scriptid&lt;/code&gt;.
La version installée du script est maintenue directement par la commande
&lt;code&gt;:GLVS&lt;/code&gt;. Si vous voulez être sûr que la mise à jour soit faite, mettez 1.&lt;/p&gt;
&lt;p&gt;Maintenant, votre répertoire &lt;code&gt;~/.vim&lt;/code&gt; est assez facile à transporter. J'ai
pour habitude d'en garder une copie "vide", avec une arborescence sous la
forme:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;\.vim/
    |-GetLatest/
               |-GetLatestVimScripts.dat
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Un test?&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Vous pouvez tester l'astuce assez simplement: Sauvez votre répertoire
&lt;code&gt;~/.vim&lt;/code&gt; (si vous en avez un) en le bougeant sous un autre nom, et faites
en un nouveau ou vous recréerez l'arborescence décrite précedemment.
Insérez dans GetLatestVimScripts.dat les lignes suivantes:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="gh"&gt;ScriptID SourceID Filename&lt;/span&gt;
&lt;span class="gh"&gt;--------------------------&lt;/span&gt;
# Les lignes commençant par &amp;#39;#&amp;#39; sont des commentaires
# Les deux premières lignes sont nécessaires
#
# Script permettant d&amp;#39;avoir une complétion grâce à la touche &amp;lt;tab&amp;gt;
# le premier numéro a été obtenu dans l&amp;#39;url du script:
# http://www.vim.org/scripts/script.php?script_id=1643
1643 1 :AutoInstall: supertab.vim
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Ouvrez vim, tapez :GLVS. Le script va se mettre à jour de
  lui-même.&lt;/li&gt;
&lt;li&gt;Vous pouvez tester le script, assez sympa, qui permet de
  compléter les mots que vous tapez avec la touche de tabulation
  (pour savoir comment ça se paramètre, lisez le script, pour
  l'instant sa doc est incluse en commentaire dans le code - j'ai
  proposé au mainteneur un patch avec une vraie doc vim, accessible
  par :help et j'ai bon espoir qu'il l'inclue dans une future
  version)&lt;/li&gt;
&lt;li&gt;Fin de la démo. Vous pouvez supprimer votre répertoire .vim et
  remettre votre ancienne configuration (si vous en aviez une).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Une petite explication supplémentaire s'impose. Le mot clé :AutoInstall:
dans la ligne que j'ai préconisée n'est pas obligatoire. Cela vient du
fait que tous les scripts ne sont pas installables automatiquement (mais
tous sont téléchargeables automatiquement). Cela dit, les scripts
sourceforge sont assez standards et la plupart seront autoinstallables
même si l'auteur du script ne connaissait pas la fonctionnalité. Si jamais
votre script ne s'installe pas correctement, vous pouvez écrire à son
auteur afin qu'il le modifie (ça marche, je l'ai fait &lt;a href="http://slinky.imukuppi.org/2009/10/24/zenburn-v2-13/"&gt;récemment&lt;/a&gt; avec
&lt;a href="http://www.vim.org/scripts/script.php?script_id=415"&gt;zenburn&lt;/a&gt; en aidant son auteur à le mettre sous forme de vimball) et en
attendant, retirer ce mot clé.&lt;/p&gt;
&lt;p&gt;En espérant que ça serve... En bonus, voici la liste des plugins
que j'utilise. C'est très orienté C++. Mon conseil, c'est de vous
abonner au flux rss de vim.org, comme ça vous serez au courant des
plugins sympa qui sortent.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="gh"&gt;ScriptID SourceID Filename&lt;/span&gt;
&lt;span class="gh"&gt;--------------------------&lt;/span&gt;
39   1 :AutoInstall: matchit.zip
40   1 :AutoInstall: Drawit.vim
273  1 :AutoInstall: taglist.zip
294  1 :AutoInstall: Align.vim
302  1 :AutoInstall: AnsiEsc.vim
415  1 :AutoInstall: zenburn.vim
489  1 :AutoInstall: Manpageview.vim
610  1 :AutoInstall: ctags.vim
642  1 :AutoInstall: getscript.vim
1066 1 :AutoInstall: cecutil.vim
1075 1 :AutoInstall: netrw.vim
1116 1 :AutoInstall: maplesyrup.tar.gz
1195 1 :AutoInstall: vis.vba.gz
1502 1 :AutoInstall: vimball.vim
1506 1 :AutoInstall: LargeFile.vim
1520 1 :AutoInstall: omnicppcomplete.zip
1643 1 :AutoInstall: supertab.vim
1658 1 :AutoInstall: NERD_tree.zip
1697 1 :AutoInstall: surround.vim
2136 1 :AutoInstall: repeat.vim
2164 1 :AutoInstall: renamec.vim
2527 1 :AutoInstall: jpythonfold.vim
2540 1 :AutoInstall: snipMate.zip
2645 1 :AutoInstall: colourscheme_bandit.vim
2646 1 :AutoInstall: ctags_highlighting.vba
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</content><category term="howto"></category><category term="vim"></category></entry><entry><title>gdb 7.0 est sorti, c'est une merveille et vous ne le saviez pas.</title><link href="http://blog.chmd.fr/gdb-70-est-sorti-cest-une-merveille-et-vous-ne-le-saviez-pas.html" rel="alternate"></link><published>2009-10-06T19:19:00+02:00</published><updated>2009-10-06T19:19:00+02:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2009-10-06:/gdb-70-est-sorti-cest-une-merveille-et-vous-ne-le-saviez-pas.html</id><summary type="html">&lt;p&gt;L'annonce vient de tomber sur la mailing liste : gdb vient de sortir dans
sa version 7.0! Vous vous dîtes: "Bof, gdb je connais, une nouvelle
version d'un débogueur qui sort, il n'y a pas de quoi fouetter un chat."
Détrompez-vous!  Les progrès apportés sont tels que je n'allais pas …&lt;/p&gt;</summary><content type="html">&lt;p&gt;L'annonce vient de tomber sur la mailing liste : gdb vient de sortir dans
sa version 7.0! Vous vous dîtes: "Bof, gdb je connais, une nouvelle
version d'un débogueur qui sort, il n'y a pas de quoi fouetter un chat."
Détrompez-vous!  Les progrès apportés sont tels que je n'allais pas vous
laisser les ignorer.  Je veux bien entendu parler du "reverse debugging".
Hein? C'est quoi? Bon, j'explique : normalement, dans un debugger (ou un
"débogueur", en bon français), on déroule le programme toujours dans le
même sens. Et ben maintenant, on a la possibilité de revenir en arrière!
Dans le concept, c'est un peu comme rembobiner un film, mais pour un
programme. Donc voilà, par exemple, on avait "c" pour "continue", on a
maintenant "rc" pour "reverse continue".&lt;/p&gt;
&lt;p&gt;Bon, ça paye pas de mine, comme ça, mais à faire c'est probablement assez
compliqué. Ça fait tellement longtemps qu'on parle d'ajouter cela dans gdb
que ça justifie amplement le passage direct de 6.8 à 7.0 dans les numéros
de versions. Ça explique aussi pourquoi les développeurs la qualifiaient
d'avance de "major release".&lt;/p&gt;
&lt;p&gt;Là, on marque une pause et on s'incline. Ceux qui savent comment
fonctionne un ordinateur se demandent comment ça peut bien marcher (allez
regarder le code source, les gars). On se rend compte de l'exploit
technique que ça doit représenter, on y ajoute une petite réflexion sur le
nombre d'architectures que le machin supporte, et on se dit que
décidemment il y a des gens très forts.&lt;/p&gt;
&lt;p&gt;Je ne m'arrête pas en si bon chemin. Ceux qui ont tenté d'utiliser gdb ont
probablement aussi un assez mauvais souvenir de la maniabilité du
programme.  C'est pas très, comment dire...  "user friendly". Bon, pour
répondre à ces gens là je ne vous promets pas de miracle, mais sachez que
gdb est devenu scriptable en python. Ça promet d'améliorer sérieusement sa
souplesse, mais aussi, mon petit doigt me dit qu'on devrait probablement
voir de nouveaux front-end ultra souples voir le jour. Voilà pour mes
features préférées, mais il y en a d'autres. Je vous lie la fameuse
annonce, qui vaut son pesant de cacahuètes. Vivement que ma distribution
le package.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.gnu.org/software/gdb/download/ANNOUNCEMENT"&gt;L'annonce&lt;/a&gt;
&lt;a href="http://sourceware.org/gdb/download/onlinedocs/gdb_7.html#SEC51"&gt;La nouvelle doc sur le reverse debugging&lt;/a&gt;&lt;/p&gt;</content><category term="misc"></category><category term="gdb"></category></entry><entry><title>autotools, doxygen, et génération conditionnelle</title><link href="http://blog.chmd.fr/autotools-doxygen-et-generation-conditionnelle.html" rel="alternate"></link><published>2009-07-10T12:54:00+02:00</published><updated>2009-07-10T12:54:00+02:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2009-07-10:/autotools-doxygen-et-generation-conditionnelle.html</id><summary type="html">&lt;p&gt;On m'a donné une astuce bien sympa pour générer de la documentation
de manière conditionnelle avec doxygen. J'utilise ça dans le projet
que je code au boulot, et je pense que ça vaut le coup de partager.
L'idée est de générer la  documentation automatiquement à chaque
compilation de mon projet …&lt;/p&gt;</summary><content type="html">&lt;p&gt;On m'a donné une astuce bien sympa pour générer de la documentation
de manière conditionnelle avec doxygen. J'utilise ça dans le projet
que je code au boulot, et je pense que ça vaut le coup de partager.
L'idée est de générer la  documentation automatiquement à chaque
compilation de mon projet, en faisant appel aux features avancées
de doxygen en fonction des outils dont dispose l'utilisateur : dot,
htags, perl, etc... On va donc vérifier quels programmes sont
présents grâce au configure.ac, et on va générer le doxyfile en
fonction desquels sont présents. L'exemple que je donne n'est pas
complet, mais vous pouvez vous en inspirer: Fichier configure.ac&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;AC_CHECK_PROG&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;DOT&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;dot&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;yes&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;no&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;AC_CHECK_PROG&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;HTAGS&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;htags&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;yes&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;no&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;AC_PATH_PROG&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;PERL&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;perl&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;[]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;AM_CONDITIONAL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;DOXYGEN&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;test &amp;quot;x$doxygen_ok&amp;quot; = xyes&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;AM_CONDITIONAL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;DOT&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;test &amp;quot;x$dot_ok&amp;quot; = xyes&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;AC_CONFIG_FILES&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;doxygen_html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cfg&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Ensuite, il suffit de glisser les bonnes références dans le fichier
doc/doxygen_html.cfg.in :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;USE_HTAGS&lt;/span&gt;&lt;span class="w"&gt;              &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;@HTAGS&lt;/span&gt;&lt;span class="err"&gt;@&lt;/span&gt;
&lt;span class="n"&gt;PERL_PATH&lt;/span&gt;&lt;span class="w"&gt;              &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;@PERL&lt;/span&gt;&lt;span class="err"&gt;@&lt;/span&gt;
&lt;span class="n"&gt;HAVE_DOT&lt;/span&gt;&lt;span class="w"&gt;               &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;@DOT&lt;/span&gt;&lt;span class="err"&gt;@&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Ainsi, après l'appel de ./configure, le fichier doxygen_html.cfg
va être généré, et les expressions entre @ vont y être remplacées
par les bonnes valeurs. Vous pourrez ensuite vous servir de ce
fichier pour véritablement générer la doc...&lt;/p&gt;</content><category term="code"></category><category term="autotools"></category><category term="doxygen"></category><category term="libre"></category></entry><entry><title>Mettre des couleurs un peu partout (gcc, diff, grep...)</title><link href="http://blog.chmd.fr/mettre-des-couleurs-un-peu-partout-gcc-diff-grep.html" rel="alternate"></link><published>2009-06-19T21:31:00+02:00</published><updated>2009-06-19T21:31:00+02:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2009-06-19:/mettre-des-couleurs-un-peu-partout-gcc-diff-grep.html</id><summary type="html">&lt;p&gt;Aujourd'hui, après avoir passé un bout de temps à déchiffrer la
sortie d'une compilation, je me suis mis en quête d'améliorer mon
quotidien et d'y mettre... des couleurs! Pour ce faire, on cherche
un peu ce qui existe déjà, et on tombe sur colorgcc. C'est
disponible sur pas mal de …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Aujourd'hui, après avoir passé un bout de temps à déchiffrer la
sortie d'une compilation, je me suis mis en quête d'améliorer mon
quotidien et d'y mettre... des couleurs! Pour ce faire, on cherche
un peu ce qui existe déjà, et on tombe sur colorgcc. C'est
disponible sur pas mal de distributions, c'est juste un script perl
à appeler à la place de gcc, et ça rajoute des couleurs. Pour en
profiter, il suffit de glisser dans vos Makefile&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;CXX=/usr/bin/colorgcc
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Avec les autotools, on peut régler ça à l'invocation du script
configure :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;./configure CXX=/usr/bin/colorgcc
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Bon. Pas mal. Maintenant, les diff. Au boulot, je n'ai pas mieux
sous la main qu'un svn comme gestionnaire de version. Quand je me
tape des svn diff, j'aime bien que ça soit un peu lisible. Et si on
se mettait ça en couleurs? En lisant un peu la doc, on voit qu'il
suffit de se faire un script. Mettons diffwrap.sh.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt; 1&lt;/span&gt;
&lt;span class="normal"&gt; 2&lt;/span&gt;
&lt;span class="normal"&gt; 3&lt;/span&gt;
&lt;span class="normal"&gt; 4&lt;/span&gt;
&lt;span class="normal"&gt; 5&lt;/span&gt;
&lt;span class="normal"&gt; 6&lt;/span&gt;
&lt;span class="normal"&gt; 7&lt;/span&gt;
&lt;span class="normal"&gt; 8&lt;/span&gt;
&lt;span class="normal"&gt; 9&lt;/span&gt;
&lt;span class="normal"&gt;10&lt;/span&gt;
&lt;span class="normal"&gt;11&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="ch"&gt;#!/bin/sh&lt;/span&gt;
&lt;span class="c1"&gt;# Configure your favorite diff program here.&lt;/span&gt;
&lt;span class="nv"&gt;DIFF&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;/usr/bin/colordiff&amp;quot;&lt;/span&gt;
&lt;span class="c1"&gt;# Subversion provides the paths we need as the sixth and seventh&lt;/span&gt;
&lt;span class="c1"&gt;# parameters.&lt;/span&gt;
&lt;span class="nv"&gt;LEFT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;6&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
&lt;span class="nv"&gt;RIGHT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;7&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;# Call the diff command&lt;/span&gt;
&lt;span class="nv"&gt;$DIFF&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$LEFT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$RIGHT&lt;/span&gt;
&lt;span class="c1"&gt;# Return an errorcode of 0 if no differences were detected, 1 if some were.&lt;/span&gt;
&lt;span class="c1"&gt;# Any other errorcode will be treated as fatal.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;J'ai installé colordiff pour faire le boulot. Il suffit après
d'éditer \~/.subversion/config, et d'ajouter, section [helpers]&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;diff-cmd = /path/to/diffwrap.sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Bon ok, mais quand je fais make, j'ai toujours beaucoup de sortie
Il n'y aurait pas moyen de se cantonner aux erreurs gcc lorsqu'il y
en a? Aller, on va baisser un peu ça avec un petit peu (le -j3 est
pour multithreader le make : j'ai un dual core, autant en
profiter).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;alias make=&amp;#39;make -j3 -s&amp;#39;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Bien entendu, en tant qu'adepte de vim, j'utilise aussi beaucoup
:make. Dans le .vimrc, il peut s'avérer utile de glisser alors:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;autocmd BufNewFile,BufRead,BufEnter &lt;span class="gs"&gt;*.cpp,*&lt;/span&gt;.hpp set makeprg=make\ -j3\ -s
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Au passage, j'espère que vous connaissiez
&lt;a href="http://www.vim.org/scripts/script.php?script_id=1520"&gt;omnicppcomplete&lt;/a&gt;,
qui va chez moi dans la même section du .vimrc:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;autocmd BufNewFile,BufRead,BufEnter &lt;span class="gs"&gt;*.cpp,*&lt;/span&gt;.hpp set omnifunc=omni#cpp#complete#Main
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;On combine tout ça à quelques alias assez connus, et on vit un peu
mieux dans sa console...&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;#&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;SOME&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;COLORS&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;[&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;x&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;usr&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;bin&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;dircolors&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;]&lt;span class="c1"&gt;; then&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;eval&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;`dircolors -b`&amp;quot;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;alias&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;ls&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;ls --color=auto&amp;#39;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;alias&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;dir&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;dir --color=auto&amp;#39;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;alias&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;vdir&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;vdir --color=auto&amp;#39;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;alias&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;grep&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;grep --color=auto&amp;#39;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;alias&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;fgrep&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;fgrep --color=auto&amp;#39;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;alias&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;egrep&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;egrep --color=auto&amp;#39;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;alias&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;diff&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;colordiff&amp;#39;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;alias&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;less&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;less -R&amp;#39;&lt;/span&gt;
&lt;span class="nv"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Si vous avez des trucs utiles, n'hésitez pas! Je suis en
particulier à la recherche d'un script vim qui exploiterait un rien
les options 'errorformat' et 'QuickFixCmdPost' afin d'améliorer
encore la lisibilité des compilations dans la fenêtre quickfix.&lt;/p&gt;</content><category term="howto"></category><category term="colors"></category><category term="console"></category></entry><entry><title>vim+gdb=vimgdb</title><link href="http://blog.chmd.fr/vimgdbvimgdb.html" rel="alternate"></link><published>2009-02-25T00:29:00+01:00</published><updated>2009-02-25T00:29:00+01:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2009-02-25:/vimgdbvimgdb.html</id><summary type="html">&lt;p&gt;Ça faisait longtemps que je n'avais pas fait d'article, j'en profite donc
pour rendre hommage au méconnu &lt;a href="http://clewn.sourceforge.net/"&gt;vimgdb&lt;/a&gt;.
vimgdb est un patch pour vim qui permet de débogguer dans vim. On ne
vantera jamais assez les mérites d'un déboggeur (franchement, il y a un
stade où il faut arrêter les …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Ça faisait longtemps que je n'avais pas fait d'article, j'en profite donc
pour rendre hommage au méconnu &lt;a href="http://clewn.sourceforge.net/"&gt;vimgdb&lt;/a&gt;.
vimgdb est un patch pour vim qui permet de débogguer dans vim. On ne
vantera jamais assez les mérites d'un déboggeur (franchement, il y a un
stade où il faut arrêter les &lt;code&gt;fprintf(stdout, "kikoo")&lt;/code&gt; et les &lt;code&gt;cout
&amp;lt;&amp;lt;"lol"&lt;/code&gt;), que ce soit parce que c'est franchement plus élégant, que c'est
plus le pratique quand on maitrise, ou parce que c'est mille fois plus
puissant.&lt;/p&gt;
&lt;p&gt;Alors, me direz-vous, chers adeptes de gvim, qu'il existe déjà un plugin
pour vim nommé &lt;a href="http://clewn.sourceforge.net/"&gt;clewn&lt;/a&gt; (ou voir mieux,
&lt;a href="http://pyclewn.wiki.sourceforge.net/"&gt;pyclewn&lt;/a&gt;) qui fait la même chose
sans se taper de recompilation intempestive de son éditeur favori. Eh bien
moi je vous répond: oui mais dans gvim on ne peut pas retrouver le shell
en tapant Ctrl-Z (ce qui met vim en arrière-plan) et c'est un sérieux
handicap pour les gens comme moi qui apprécient énormément cette feature
(au fait, fg est votre ami si vous découvrez en lisant l'article et que
vous ne savez pas comment revenir à vim).&lt;/p&gt;
&lt;p&gt;Malheureusement, le paquet fait défaut sur la plupart des distrib (sauf
archlinux, où je me suis permis de l'ajouter dans
&lt;a href="http://aur.archlinux.org/packages.php?O=0&amp;amp;K=vimgdb&amp;amp;do_Search=Go"&gt;AUR&lt;/a&gt; --
si vous avez des suggestions pour améliorer le PKGBUILD, n'hésitez pas).
Vous pouvez donc vous inspirer dudit PKGBUILD pour &lt;a href="http://clewn.sourceforge.net/install.html"&gt;compiler votre
version&lt;/a&gt;, ou suivre les
indications du site (je vais pas vous dire comment compiler un programme,
quand même!). Après, en installant le plugin vim pour gdb (comme indiqué
dans la procédure du lien précédent), vous avez accès à tout un cas de
commandes sympa (&lt;code&gt;:help gdb&lt;/code&gt; pour l'aide), qui permettent de voir vos
variables et de suivre le déroulement des opérations dans l'éditeur. Cool,
non? Preuve que c'est bien pensé, je n'ai eu à changer aucun des
raccourcis par défaut (J'ai juste changé un &lt;code&gt;where&lt;/code&gt; en &lt;code&gt;where all&lt;/code&gt; dans
.vim/macros/gdb_mappings.vim). Evidemment, il est aussi possible
d'ajouter ses propres mappings ou de modifier ceux qui sont fournis.&lt;/p&gt;
&lt;p&gt;N'oubliez pas de rajouter run macros/gdb_mappings.vim dans votre .vimrc!
Je vous suggère aussi de vous renseigner sur gdb et de suivre le tuto de
&lt;a href="http://dirac.org/linux/gdb/"&gt;Peter Jay Salzman&lt;/a&gt;, qui m'a bien initié.
Pour ma part, je conserve aussi dans un coin &lt;a href="http://www.unknownroad.com/rtfm/gdbtut/gdbtoc.html"&gt;un excellent
lien&lt;/a&gt; qui me sert de
référence en cas de trou de mémoire... Bon déboggage! Si vous souhaitez
des screenshots, regardez &lt;a href="http://sourceforge.net/project/screenshots.php?group_id=111038"&gt;par
là&lt;/a&gt;...&lt;/p&gt;
&lt;p&gt;PS: apparemment mon PKGBUILD a été marqué "out of date", je vais
corriger ça dès que possible...&lt;/p&gt;</content><category term="code"></category><category term="vim"></category><category term="gdb"></category></entry><entry><title>l'UML automatisé et le libre : c'est pas gagné!</title><link href="http://blog.chmd.fr/luml-automatise-et-le-libre-cest-pas-gagne.html" rel="alternate"></link><published>2008-06-08T16:34:00+02:00</published><updated>2008-06-08T16:34:00+02:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2008-06-08:/luml-automatise-et-le-libre-cest-pas-gagne.html</id><summary type="html">&lt;p&gt;Je recherche en ce moment des outils qui me permettraient
d'importer/exporter de l'&lt;a href="http://fr.wikipedia.org/wiki/Unified_Modeling_Language"&gt;uml&lt;/a&gt; pour un projet C++ que je vais faire cet
été. L'idée est la suivante : je souhaiterais que les modifications de mon
code soient répercutées sur un fichier contenant de l'uml sous un format
quelconque, et …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Je recherche en ce moment des outils qui me permettraient
d'importer/exporter de l'&lt;a href="http://fr.wikipedia.org/wiki/Unified_Modeling_Language"&gt;uml&lt;/a&gt; pour un projet C++ que je vais faire cet
été. L'idée est la suivante : je souhaiterais que les modifications de mon
code soient répercutées sur un fichier contenant de l'uml sous un format
quelconque, et je souhaiterais par ailleurs pouvoir générer du code à
partir de ce format. Idéalement, une règle dans le Makefile, appelée à
chaque génération du projet serait idéale pour ce genre de truc. À moins
que j'ai mal compris, Umbrello est bien capable de générer du code, mais
malheureusement l'import est une autre histoire : si celui-ci est bien
capable d'importer une classe à partir du C++, en revanche il ne génère
aucun diagramme (voir &lt;a href="http://docs.kde.org/stable/en_GB/kdesdk/umbrello/code-import.html"&gt;la page consacrée de l'aide&lt;/a&gt;):&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Note that Umbrello UML Modeller will not create any kind of Diagram
for showing your classes, they will only be imported into your
Model so that you can use them later in any diagram you want.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;J'ai aussi jeté un coup d'oeil du côté d'ArgoUml. Malheureusement,
de ce côté non plus c'est pas la panacée puisqu'ici on ne parle que
de java : moi, je veux du C++.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;What is ArgoUML?
  ~ [...] ArgoUML also has the ability to reverse engineer
    compiling Java code and generate UML diagrams for it.
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;En allant inspecter les moteurs de recherche, j'ai fini par tomber
sur un outil intéressant:&lt;a href="http://dia2code.sourceforge.net/index.html"&gt;dia2code&lt;/a&gt;. Celui-ci
prend en entrée un schéma uml en dia, et génère du code dans le
langage choisi. J'ai regardé la section
&lt;a href="http://dia2code.sourceforge.net/examples.html"&gt;examples&lt;/a&gt; du site,
c'est assez convaincant. Pour ce schéma :&lt;/p&gt;
&lt;p&gt;&lt;img alt="uml_dia.png" src="images/uml_dia.png"&gt;&lt;/p&gt;
&lt;p&gt;Les fichiers suivants seront générés :&lt;/p&gt;
&lt;p&gt;foowindow.cpp 1/14&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="cpf"&gt;&amp;quot;foowindow.h&amp;quot;&lt;/span&gt;

&lt;span class="kt"&gt;void&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;FooWindow::redraw&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;foowindow.h 2/14&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="cp"&gt;#ifndef FOOWINDOW_H&lt;/span&gt;
&lt;span class="cp"&gt;#define FOOWINDOW_H&lt;/span&gt;

&lt;span class="cp"&gt;#include&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="cpf"&gt;&amp;quot;window.h&amp;quot;&lt;/span&gt;

&lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;FooWindow&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;public&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Window&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;// Associations&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;// Attributes&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;// Operations&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;public&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kt"&gt;void&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;redraw&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="cp"&gt;#endif&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;foowindowmanager.cpp 3/14&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="cpf"&gt;&amp;quot;foowindowmanager.h&amp;quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;foowindowmanager.h 4/14&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="cp"&gt;#ifndef FOOWINDOWMANAGER_H&lt;/span&gt;
&lt;span class="cp"&gt;#define FOOWINDOWMANAGER_H&lt;/span&gt;

&lt;span class="cp"&gt;#include&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="cpf"&gt;&amp;quot;windowmanager.h&amp;quot;&lt;/span&gt;

&lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;FooWindowManager&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;public&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;WindowManager&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;// Associations&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;// Attributes&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;// Operations&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="cp"&gt;#endif&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;point.cpp 5/14&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="cpf"&gt;&amp;quot;point.h&amp;quot;&lt;/span&gt;

&lt;span class="n"&gt;Point&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Point&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Point&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;getX&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Point&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;getY&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;point.h 6/14&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="cp"&gt;#ifndef POINT_H&lt;/span&gt;
&lt;span class="cp"&gt;#define POINT_H&lt;/span&gt;

&lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Point&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;// Associations&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;// Attributes&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;private&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;// Operations&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;public&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;Point&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;getX&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;getY&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="cp"&gt;#endif&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;rectangle.cpp 7/14&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="cpf"&gt;&amp;quot;rectangle.h&amp;quot;&lt;/span&gt;

&lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;Rectangle::getArea&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;rectangle.h 8/14&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="cp"&gt;#ifndef RECTANGLE_H&lt;/span&gt;
&lt;span class="cp"&gt;#define RECTANGLE_H&lt;/span&gt;

&lt;span class="cp"&gt;#include&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="cpf"&gt;&amp;quot;point.h&amp;quot;&lt;/span&gt;
&lt;span class="cp"&gt;#include&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="cpf"&gt;&amp;quot;shape.h&amp;quot;&lt;/span&gt;

&lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Rectangle&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;public&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Shape&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;// Associations&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="n"&gt;Point&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;points&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;// Attributes&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;// Operations&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;public&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;getArea&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="cp"&gt;#endif&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;shape.cpp 9/14&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="cpf"&gt;&amp;quot;shape.h&amp;quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;shape.h 10/14&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="cp"&gt;#ifndef SHAPE_H&lt;/span&gt;
&lt;span class="cp"&gt;#define SHAPE_H&lt;/span&gt;

&lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Shape&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;// Associations&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;// Attributes&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;// Operations&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;public&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;virtual&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;getArea&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="cp"&gt;#endif&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;window.cpp 11/14&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="cpf"&gt;&amp;quot;window.h&amp;quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;window.h 12/14&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="cp"&gt;#ifndef WINDOW_H&lt;/span&gt;
&lt;span class="cp"&gt;#define WINDOW_H&lt;/span&gt;

&lt;span class="cp"&gt;#include&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="cpf"&gt;&amp;quot;shape.h&amp;quot;&lt;/span&gt;

&lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Window&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;// Associations&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;// Attributes&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;private&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;Shape&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;visualrep&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;// Operations&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;public&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;virtual&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kt"&gt;void&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;redraw&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="cp"&gt;#endif&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;windowmanager.cpp 13/14&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="cpf"&gt;&amp;quot;windowmanager.h&amp;quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;windowmanager.h 14/14&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="cp"&gt;#ifndef WINDOWMANAGER_H&lt;/span&gt;
&lt;span class="cp"&gt;#define WINDOWMANAGER_H&lt;/span&gt;

&lt;span class="cp"&gt;#include&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="cpf"&gt;&amp;quot;window.h&amp;quot;&lt;/span&gt;

&lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;WindowManager&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;// Associations&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="n"&gt;Window&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;windows&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;// Attributes&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;// Operations&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="cp"&gt;#endif&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Pas mal. Il y a de l'idée. Maintenant, cherchons s'il existe le procédé
inverse. J'ai trouvé trois outils capables de générer de l'uml dia à
partir du C++ : &lt;a href="http://cpp2dia.sourceforge.net/"&gt;cpp2dia&lt;/a&gt;, &lt;a href="http://www.aarontrevena.co.uk/opensource/autodia/index.html"&gt;autodia&lt;/a&gt;, et &lt;a href="http://medoosa.sourceforge.net/"&gt;medoosa&lt;/a&gt;. Autant vous
dire tout de suite que rien de spécialement convaincant ne sort de ces
programmes.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Le dernier de ces 3 à avoir été mis à jour semble être autodia
    (2007). Autodia est un script perl qui peut parser plusieurs
    langage, mais il semblerait que le module C++ soit buggué. D'abord,
    la sortie est immonde et complètement enchevêtrée. Mais ça, ça
    s'édite avec dia (du moment que les associations sont bonnes, moi
    je suis content). Ensuite il prend mal les noms des classes
    puisqu'il m'a embarqué l'accolade ouvrante à chaque génération de
    classe (Je le soupçonne en fait d'avoir oublié de gérer les
    namespaces). J'ai tout de même écrit à l'auteur pour lui signaler
    le problème.&lt;/li&gt;
&lt;li&gt;cpp2dia est celui qui n'a pas été mis à jour depuis le plus de
    temps (mai 2003). Cependant, les
    &lt;a href="http://cpp2dia.sourceforge.net/screenshots.html"&gt;screenshots&lt;/a&gt; ont
    l'air sympa. C'est un script tcl que j'ai réussi à faire marcher,
    mais qui ne m'a pas du tout donné le même genre de résultat que ce
    qu'on peut voir sur le site. Pourtant, l'idée est intéressante : au
    lieu de parser le programme lui-même, il se sert des ctags pour
    récupérer ce qui l'intéresse, comptant ainsi sur un programme qui
    marche assez bien et auquel on peut résolument faire confiance. Par
    ailleurs, il utilise neato (qui fait partie de
    &lt;a href="http://www.graphviz.org/"&gt;graphviz&lt;/a&gt;) pour organiser le tout, donc
    la sortie est nettement plus lisible. Malheurleusement, j'ai eu
    beau traffiquer mon \~/.cpp2diarc, dans tous les sens, pas de bol
    pour moi, les attributs ne sont pas pris en compte (J'ai aussi
    contacté l'auteur pour lui demander s'il avait une astuce).&lt;/li&gt;
&lt;li&gt;Il reste medoosa, sans doute le plus élaboré des trois, mais
    non véritablement mieux maintenu que cpp2dia (août 2003 pour la
    dernière release). Ce programme a été écrit par un thésard, et sait
    lui aussi produire des
    &lt;a href="http://medoosa.sourceforge.net/medoosa-model.ps"&gt;sorties&lt;/a&gt; assez
    sexy. L'idée originale est que celui-ci se sert de ccdoc, un
    utilitaire de documentation à la doxygen, pour générer le graphe.
    Malheureusement, il faut une vieille version de ccdoc (la 0.7a)
    pour le faire marcher, et j'ai été incapable de trouver celle-ci en
    téléchargement (encore une fois, j'ai contacté l'auteur pour lui
    signaler ce problème, lui conseillant de s'arranger avec les
    auteurs de ccdoc pour qu'ils remettent une vieille version en
    ligne, car cela nuit à son programme).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Conclusion: rien de bien convaincant pour l'instant. Cependant, je n'avais
pas encore regardé bouml et je viens de voir qu'ils mentionnaient le genre
de fonctionnalités que je recherche.  Quelqu'un a testé? Ou bien dans le
cas général, connaissez-vous un quelque chose capable de faire mon
bonheur?&lt;/p&gt;</content><category term="code"></category><category term="uml"></category><category term="libre"></category></entry><entry><title>Les lecteurs de flux rss, en ligne, indépendants, libres (suite).</title><link href="http://blog.chmd.fr/les-lecteurs-de-flux-rss-en-ligne-independants-libres-suite.html" rel="alternate"></link><published>2008-05-02T18:51:00+02:00</published><updated>2008-05-02T18:51:00+02:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2008-05-02:/les-lecteurs-de-flux-rss-en-ligne-independants-libres-suite.html</id><summary type="html">&lt;p&gt;Hier, j'expliquais pourquoi je préférais de loin utiliser un
lecteur de flux rss en ligne et je donnais un petit panorama des
web-agregator libres que j'avais pu découvrir. J'ai fait ma petite
étude, et tiny tiny rss sort à mon avis grand gagnant. D'abord,
comme rien ne vaut un petit …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Hier, j'expliquais pourquoi je préférais de loin utiliser un
lecteur de flux rss en ligne et je donnais un petit panorama des
web-agregator libres que j'avais pu découvrir. J'ai fait ma petite
étude, et tiny tiny rss sort à mon avis grand gagnant. D'abord,
comme rien ne vaut un petit essai pour se faire une idée, voici des
liens vers les versions de démo que j'ai pu trouver :&lt;/p&gt;
&lt;p&gt;Tiny tiny rss -&amp;gt; [&lt;a href="http://tt-rss.org/trac/"&gt;site&lt;/a&gt;]
[&lt;a href="http://tt-rss.org/demo/tt-rss.php"&gt;démo&lt;/a&gt;] :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Sait aggréger plusieurs flux pour en former un seul dont vous
    pourrez donner l'adresse à vos amis&lt;/li&gt;
&lt;li&gt;Peut marcher sous PostgreSQL comme sur MySQL&lt;/li&gt;
&lt;li&gt;Gestion des tags par des règles de filtrage très facile à
    utiliser&lt;/li&gt;
&lt;li&gt;Sait s'autentifier pour lire des flux protégés (autentification
    simple, le https n'est pas encore supporté)&lt;/li&gt;
&lt;li&gt;navigation clavier intuitive (vim-like, comme gmail)&lt;/li&gt;
&lt;li&gt;bénéficie d'une
    &lt;a href="https://addons.mozilla.org/firefox/3342/"&gt;extension firefox pour les notifications&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;développement très actif&lt;/li&gt;
&lt;li&gt;installation difficile chez free (bug dans l'importation
    d'opml, voir les commentaires du billet précédent pour corriger ça,
    et les tags ne marchent pas du tout)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;gregarius -&amp;gt; [&lt;a href="http://tt-rss.org/trac/"&gt;site&lt;/a&gt;]
[&lt;a href="http://tt-rss.org/demo/tt-rss.php"&gt;démo&lt;/a&gt;] :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;ne marche qu'avec mysql, mais par contre buggue moins&lt;/li&gt;
&lt;li&gt;un énorme avantage : supporte des thèmes et des plugins divers
    et variés&lt;/li&gt;
&lt;li&gt;La navigation clavier est moins intuitive et moins complète&lt;/li&gt;
&lt;li&gt;installation super facile&lt;/li&gt;
&lt;li&gt;a aussi une bonne intégration avec firefox, mais pas de système
    de notification.&lt;/li&gt;
&lt;li&gt;développement moins actif&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Je n'ai pas trouvé de version de test disponible pour feed on feeds
-&amp;gt;[&lt;a href="http://tt-rss.org/trac/"&gt;site&lt;/a&gt;]. Sachez que Feed on feeds est
assez vieux et que son développement est apparemment arrêté. Il a
donné lieu à deux projets : FoFredux
-&amp;gt;[&lt;a href="http://tt-rss.org/trac/"&gt;site&lt;/a&gt;]
[&lt;a href="http://tt-rss.org/demo/tt-rss.php"&gt;démo&lt;/a&gt;] et à MonkeyChow
-&amp;gt;[&lt;a href="http://tt-rss.org/trac/"&gt;site&lt;/a&gt;], pour lequel je dispose
simplement d'un &lt;a href="http://www.shokk.com/mc.html"&gt;screencast&lt;/a&gt; (en
flash, beurk). Je n'ai pas poussé beaucoup mes tests, car aucun
d'eux n'a vu de nouvelle version sortir depuis 2006, ce qui est
selon moi trop vieux pour espérer voir maintenus ces projets qui
semblent par ailleurs assez prometteurs. En résumé, je ne retiens
que deux projets : Tiny tiny rss et gregarius. Même si gregarius et
beaucoup plus facile à installer, plus stable et bénéficie d'un
très bon système de plugins, ma préférence se porte sur Tiny tiny
rss, qui a un développement plus dynamique, et surtout dont
l'interface se révèle bien plus agréable et rapide à utiliser : si
j'ai un lecteur de flux rss, c'est pour gagner en productivité.&lt;/p&gt;</content><category term="misc"></category><category term="libre"></category></entry><entry><title>Les lecteurs de flux rss en ligne libres</title><link href="http://blog.chmd.fr/les-lecteurs-de-flux-rss-en-ligne-libres.html" rel="alternate"></link><published>2008-05-01T15:19:00+02:00</published><updated>2008-05-01T15:19:00+02:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2008-05-01:/les-lecteurs-de-flux-rss-en-ligne-libres.html</id><summary type="html">&lt;p&gt;Aujourd'hui, Samuel Martin a fait &lt;a href="http://blog.creaone.fr/post/2008/04/30/10-bonnes-raisons-dutiliser-Liferea-:-Lecteur-de-fils-rss/atom"&gt;un billet&lt;/a&gt; que j'ai trouvé assez
intéressant sur les avantages de liferea. J'avoue qu'il y a de bons
arguments, notamment le contrôle sur les données personnelles qu'on a avec
un tel lecteur et qu'on n'a pas chez les fournisseurs de services en
ligne.&lt;/p&gt;
&lt;p&gt;Cela ne …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Aujourd'hui, Samuel Martin a fait &lt;a href="http://blog.creaone.fr/post/2008/04/30/10-bonnes-raisons-dutiliser-Liferea-:-Lecteur-de-fils-rss/atom"&gt;un billet&lt;/a&gt; que j'ai trouvé assez
intéressant sur les avantages de liferea. J'avoue qu'il y a de bons
arguments, notamment le contrôle sur les données personnelles qu'on a avec
un tel lecteur et qu'on n'a pas chez les fournisseurs de services en
ligne.&lt;/p&gt;
&lt;p&gt;Cela ne me fera pas pour autant passer à liferea, car le problème
majeur qu'il me pose est celui de son accessibilité dès qu'on utilise un
autre ordinateur. En effet, je consulte mes flux rss de beaucoup
d'endroits différents, comme par exemple les ordis de mon école. Or,
comme je n'ai pas les droits pour y installer exactement tout ce que je
veux. C'est dans ce genre de cas que j'apprécie de n'avoir besoin que d'un
navigateur web pour m'en tirer.&lt;/p&gt;
&lt;p&gt;Cependant, sensible aux arguments sur la protection des données
personnelles, je me suis demandé s'il n'y avait pas un moyen de me
récupérer un autre lecteur de flux rss en ligne, qui n'utiliserait pas mes
informations personelles pour le profit d'une quelconque société (me
débarassant par la même occasion du cookie google qui traine dans le cache
de mon navigateur). J'ai donc fait des petites recherches sur les
solutions libres à héberger sur son propre serveur.  J'en ai trouvé
plusieurs, que je partage avec vous. Il faut que je regarde si c'est
possible d'en utiliser une sur mon compte free.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://tt-rss.org/trac/"&gt;tiny tiny rss&lt;/a&gt;
&lt;a href="http://gregarius.net/"&gt;gregarius&lt;/a&gt;
&lt;a href="http://feedonfeeds.com/"&gt;feed on feeds&lt;/a&gt; et ses petit frères
&lt;a href="http://fofredux.sourceforge.net/"&gt;FoFredux&lt;/a&gt; et
&lt;a href="http://sourceforge.net/projects/monkeychow/"&gt;Monckeyshow&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Si vous en connaissez d'autres, je suis preneur...&lt;/p&gt;</content><category term="misc"></category><category term="tt-rss"></category></entry><entry><title>Couper une vidéo et extraire une scène d'un film</title><link href="http://blog.chmd.fr/couper-une-video-et-extraire-une-scene-dun-film.html" rel="alternate"></link><published>2008-04-07T22:28:00+02:00</published><updated>2008-04-07T22:28:00+02:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2008-04-07:/couper-une-video-et-extraire-une-scene-dun-film.html</id><summary type="html">&lt;p&gt;Comme promis dans le dernier billet, voici comment on fait pour
extraire une scène d'un film, par exemple pour en faire un fichier
.gif (cf post précédent)... Pour cela vous utiliserez mencoder :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;sudo apt-get install mencoder
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Et la syntaxe est la suivante :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;mencoder -ss     h:mm:ss    \
         -endpos h:mm …&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</summary><content type="html">&lt;p&gt;Comme promis dans le dernier billet, voici comment on fait pour
extraire une scène d'un film, par exemple pour en faire un fichier
.gif (cf post précédent)... Pour cela vous utiliserez mencoder :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;sudo apt-get install mencoder
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Et la syntaxe est la suivante :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;mencoder -ss     h:mm:ss    \
         -endpos h:mm:ss    \
         film_origine.avi   \
         -o extrait.avi     \
         -oac copy -ovc copy
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;L'argument de -ss est le temps à partir duquel commence la
  scène à extraire.&lt;/li&gt;
&lt;li&gt;celui de -endpos est la durée de la scène à extraire (oui, je
  sais, c'est bizarre, j'aurais plutôt mis le temps où finit la
  scène)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;En espérant que ça vous serve! PS : Ce billet est assez court, je
compte me rattraper en en faisant un plus substantiel bientôt...&lt;/p&gt;</content><category term="misc"></category><category term="mencoder"></category><category term="gif"></category></entry><entry><title>Faire un gif animé à partir d'un film</title><link href="http://blog.chmd.fr/faire-un-gif-anime-a-partir-dun-film.html" rel="alternate"></link><published>2008-04-06T21:29:00+02:00</published><updated>2008-04-06T21:29:00+02:00</updated><author><name>Tof</name></author><id>tag:blog.chmd.fr,2008-04-06:/faire-un-gif-anime-a-partir-dun-film.html</id><summary type="html">&lt;p&gt;J'ai souvent vu des gens poser cette question : comment fait-on un
gif animé à partir d'un film sous ubuntu? Avec ffmpeg, rien de plus
aisé. Sous gnome, avec nautilus-actions, il vous sera même possible
de faire clic droit&amp;gt;générer un gif animé à partir de cette vidéo.
Commencez-donc par installer …&lt;/p&gt;</summary><content type="html">&lt;p&gt;J'ai souvent vu des gens poser cette question : comment fait-on un
gif animé à partir d'un film sous ubuntu? Avec ffmpeg, rien de plus
aisé. Sous gnome, avec nautilus-actions, il vous sera même possible
de faire clic droit&amp;gt;générer un gif animé à partir de cette vidéo.
Commencez-donc par installer ffmpeg et nautilus-actions.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;sudo apt-get install ffmpeg nautilus-actions
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;La syntaxe pour réaliser un gif animé à partir d'un film est&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;ffmpeg -i fichier_entree.avi -pix_fmt rgb24 \
 -s 120x120\
 -r 5\
 fichier_sortie.gif
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Vous pouvez régler la hauteur et la largeur du fichier de
    sortie en touchant au paramètre '-s 120x120' (cependant 120x120 est
    une taille raisonnable pour les forums).&lt;/li&gt;
&lt;li&gt;Vous pouvez régler le nombre d'image par seconde prises dans le
    film d'origine en touchant au paramètre '-r 5'.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Bon, maintenant, offrons-nous la possibilité de gérer tout ça à
coup de clic droit. Sous Ubuntu, si vous avez bien installé
nautilus-actions, ça se passe dans
système&amp;gt;préférences&amp;gt;configuration des actions de nautilus. Faites
'Ajouter'. Configurez la nouvelle action comme suit :&lt;/p&gt;
&lt;p&gt;&lt;img alt="nautilus-actions-1.png" src="images/nautilus-actions-1.png"&gt;
&lt;img alt="nautilus-actions-2.png" src="images/nautilus-actions-2.png"&gt;&lt;/p&gt;
&lt;p&gt;Ce qui est important, c'est le champ 'paramètres' :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;-i %M -pix_fmt rgb24 -s 120x120 -r 5 %M.gif
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Vous pouvez désormais vous amuser à faire toute sorte de gif
animés. Le seul défaut : les fichiers produits ont le désavantage
de ne pas boucler. Heureusement, il est très facile d'y remédier
avec the gimp. Il suffit d'ouvrir le .gif, et de le ré-enregistrer
en laissant cochée l'option 'boucle infinie'... Dans un prochain
billet, je vous expliquerais comment couper votre vidéo pour
extraire une scène qui vous intéresse. Ainsi, il vous sera possible
de chainer les deux méthodes pour faire exactement le gif que vous
voulez.&lt;/p&gt;</content><category term="howto"></category><category term="libre"></category></entry></feed>