notes·de·pit - Mot-clé - perlParfois j'apprends à pêcher à des gens qui n'aiment pas le poisson2023-06-13T11:41:09+02:00PiTurn:md5:45526db4e4cfb511098640352c276065DotclearVrac #9urn:md5:397fd6b9351ec4468f5359e470e78b212012-04-26T14:58:00+02:002012-04-27T09:52:38+02:00PiTMes doigts dans le clavieralternativesdiversesigeekinutilejavaperlphppratiquevrac<p>Quelques outils de collaboration que je découvre et que l'on peut ajouter à ceux que l'on connait déjà.</p> <p><a href="http://framasoft">Framasoft</a>, qui promeut le logiciel libre, nous propose différents outils.</p>
<blockquote><p>Issu du monde éducatif, Framasoft est un réseau de sites web collaboratifs à géométrie variable dont le dénominateur commun est le logiciel libre et son état d’esprit. Il vise à diffuser le logiciel libre et à le faire connaître auprès du plus large public.</p></blockquote>
<blockquote><p>Extrait de <a href="http://framasoft.org">Framasoft</a></p></blockquote>
<p>Je connais déjà <a href="http://framadate.org">Framadate</a> (un clone libre de <a href="http://doodle.com">Doodle</a>) et je découvre <a href="http://framapad.org">Framapad</a> une utilisation de <a href="http://etherpad.org">Etherpad</a>. Un service (version plus récente) se trouve chez <a href="http://pad.riseup.net">pad.riseup.net</a>.</p>
<p>Un <em>pad</em> est un document en ligne facilement modifiable par plusieurs utilisateurs ... pour peu qu'ils connaissent le lien. Ces collaborateurs peuvent modifier « à la volée » le document, peuvent <em>chatter</em> dans une petite fenêtre. Une fois le document près, il peut être exporté dans divers formats.</p>
<p>Point <em>fun</em>, il est possible de <strong>revoir</strong> toutes les modifications sous forme de vidéo, précisant qui a modifié le document et quand.</p>
<blockquote><p>Etherpad is a hosted web service that allows really real-time document collaboration for groups of users.</p></blockquote>
<blockquote><p>Extrait de <a href="http://etherpad.org">Etherpad</a></p></blockquote>
<p>Ceux parmis vous qui veulent que ce soit un tiers qui héberge les documents peuvent utiliser <a href="http://libredocs.org/">LibreDocs</a>. Libredocs utilise Etherpad <strong>mais</strong> sur un document hébergé ailleurs. Pour l'instant, ils proposent <a href="https://owncube.com">OwnCube</a> (qui implémente <a href="http://owncloud.org">OwnCloud</a> dont j'ai parlé <a href="https://blog.namok.be/blog/index.php?post/2012/04/25/mes-fichiers-dans-les-nuages">dans mon billet précédent</a>) comme plateforme d'hébergement du document. C'est peut-être un peu parano (et le mouvement est là <a href="http://unhosted.org/#introduction">Unhosted</a>)... ou pratique suivant sa situation.</p>
<p>C'est pratique si je commence un document que j'héberge dans « ma partie de nuage» et que je veux autoriser d'autres contributeurs à le modifier. Le document reste « ma propriété ».</p>
<p><a href="https://pad.riseup.net/p/notespit-vrac9"><img src="https://blog.namok.be/public/images/divers/2012/.screenshot-padriseupnet_m.jpg" alt="screenshot-padriseupnet.png" style="display:block; margin:0 auto;" title="screenshot-padriseupnet.png, avr. 2012" /></a></p>
<hr />
<p>Pour ceux qui veulent s'essayer à <a href="http://www.latex-project.org/">LaTeX</a> sans rien installer (pour l'instant), <a href="http://writelatex.com">WriteLatex</a> permet de visualiser le document final en cours de frappe. Pratique pour l'essai d'un petit document.</p>
<p><a href="http://writelatex.com/1233cbphql"><img src="https://blog.namok.be/public/images/divers/2012/.screenshot-latexwrite_m.jpg" alt="screenshot-latexwrite.png" style="display:block; margin:0 auto;" title="screenshot-latexwrite.png, avr. 2012" /></a></p>
<hr />
<p>Un clone de <a href="https://blog.namok.be/?post/2012/04/26/pastebin.com">Pastebin</a> très très simplifié et dont les données sont cryptées par le client avant d'être envoyée au serveur ... le serveur n'a donc aucune info sur les données qu'il stocke. C'est <a href="http://sebsauvage.net/wiki/doku.php?id=php:zerobin">ZeroBin</a> et on peut le <a href="http://sebsauvage.net/paste/">tester là</a></p>
<p><a href="http://sebsauvage.net/paste/"><img src="https://blog.namok.be/public/images/divers/2012/.screenshot-zerobin_m.jpg" alt="screenshot-zerobin.png" style="display:block; margin:0 auto;" title="screenshot-zerobin.png, avr. 2012" /></a></p>
<p>Enjoy !</p>
<h4>À lire aussi</h4>
<ul>
<li><a href="https://blog.namok.be/blog/index.php?post/2012/04/25/mes-fichiers-dans-les-nuages">Mes fichiers dans les nuages</a></li>
<li><a href="https://blog.namok.be/blog/index.php?post/2012/02/07/Vrac-8">Vrac #8</a></li>
<li><a href="https://blog.namok.be/blog/index.php?post/2011/11/24/Vrac-7">Vrac #7</a></li>
</ul>
<h4>Sources et liens</h4>
<ul>
<li><a href="http://etherpad.org">Etherpad</a> proposé chez <a href="http://framapad.org">Framapad</a> et chez <a href="http://pad.riseup.net">Riseup</a></li>
<li><a href="http://libredocs.org/">LibreDocs</a></li>
<li><a href="https://blog.namok.be/?post/2012/04/26/writelatex.com">WriteLatex</a></li>
<li><a href="http://unhosted.org/#introduction">Unhoste</a></li>
<li><a href="http://sebsauvage.net/wiki/doku.php?id=php:zerobin">ZeroBin</a> chez <a href="http://sebsauvage.net/rhaa/">SebSAuvage</a></li>
<li>Merci à <a href="http://blog.pettiaux.be/">Nicolas</a> pour les infos partagées ...</li>
</ul>Notification d'emails notify-mailurn:md5:5a5c76e1a46888735b9d2505860623e92011-03-17T15:55:00+01:002011-03-17T16:42:23+01:00PiTMes doigts dans le clavierdebiandiversesigeekinutileperlpratiquescript<p><a href="https://blog.namok.be/public/images/divers/2011/screenshot-notify-send2.png"><img src="https://blog.namok.be/public/images/divers/2011/.screenshot-notify-send_t.jpg" alt="screenshot-notify-send.png" style="float:right; margin: 0 0 1em 1em;" title="screenshot-notify-send.png, mar. 2011" /></a></p>
<p>Je lisais quelque part qu'il était très simple de <strong>notifier</strong> un message à l'écran. Il suffit d'installer le paquet <code>libnotify</code> et la commande <code>notify-send</code> est disponible. Sa syntaxe est toute simple puisqu'il suffit d'écrire ...</p>
<pre>
notify-send "Mon titre" "Mon message" -i /elsewhere/monicone.png
</pre>
<p>Il ne m'en faut pas plus pour jouer un peu ...</p> <p>... je me rappelle avoir écrit un script permettant de tester le nombre de mails contenu dans une <em>mailbox</em> (de type <code>mailbox</code>). En reprenant ce script et en le modifiant un peu, j'obtiens un petite notification chaque fois que je reçois un nouveau message.</p>
<blockquote><p>You have got a message</p></blockquote>
<p>Voici le script</p>
<pre class="perl"><span style="color: #808080; font-style: italic;">#!/usr/bin/perl -w </span>
<span style="color: #808080; font-style: italic;"># Biff mailboxe and notify</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;"># Script for checking mailbox (mbox format) and notify result. </span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;"># Require: libnotify </span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;"># Usage:</span>
<span style="color: #808080; font-style: italic;"># notify-mail MBOX</span>
<span style="color: #808080; font-style: italic;"># MBOX : mbox file (/var/spool/user or anything else)</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;"># Author: Pierre BETTENS, <pb@namok.be></span>
<span style="color: #808080; font-style: italic;"># Thanks to Moshe Kaminsky <kaminsky@math.huji.ac.il>, </span>
<span style="color: #808080; font-style: italic;"># Version: 0.1</span>
<span style="color: #808080; font-style: italic;"># Copyright: Use it ... </span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #000000; font-weight: bold;">use</span> strict ;
<span style="color: #808080; font-style: italic;"># Import for lock file</span>
<span style="color: #000000; font-weight: bold;">use</span> Fcntl <span style="color: #ff0000;">':flock'</span>;
<span style="color: #808080; font-style: italic;"># Config</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$usage</span> = <span style="color: #ff0000;">"Usage : notify-mail <mboxfile> <span style="color: #000099; font-weight: bold;">
</span>"</span> ;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$icon_file</span> = <span style="color: #ff0000;">"/elsewhere/email_icon.jpg"</span>;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$mboxfile</span> ;
<span style="color: #0000ff;">$mboxfile</span> = <span style="color: #000066;">shift</span> <span style="color: #b1b100;">or</span> <span style="color: #000066;">die</span> <span style="color: #0000ff;">$usage</span> ;
<span style="color: #000066;">open</span> MBOX_FILE, <span style="color: #0000ff;">$mboxfile</span>
<span style="color: #b1b100;">or</span> <span style="color: #000066;">die</span> <span style="color: #ff0000;">"Failed to open folder: $mboxfile"</span> ;
<span style="color: #808080; font-style: italic;"># Ok, I count mails</span>
<span style="color: #808080; font-style: italic;"># Thanks to Moshe Kaminsky <kaminsky@math.huji.ac.il>, </span>
<span style="color: #808080; font-style: italic;"># I stole him the idea of "Status: R". </span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$mails</span> = <span style="color: #cc66cc;">0</span> ;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$oldmails</span> = <span style="color: #cc66cc;">0</span> ;
<span style="color: #000066;">flock</span><span style="color: #66cc66;">(</span>MBOX_FILE,LOCK_EX<span style="color: #66cc66;">)</span>; <span style="color: #808080; font-style: italic;"># lock </span>
<span style="color: #b1b100;">while</span> <span style="color: #66cc66;">(</span><span style="color: #009999;"><MBOX_FILE></span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>
<span style="color: #0000ff;">$mails</span>++ <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">/</span>^From <span style="color: #66cc66;">/</span>o;
<span style="color: #0000ff;">$oldmails</span>++ <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">/</span>^Status: R<span style="color: #66cc66;">/</span>o;
<span style="color: #66cc66;">}</span>
<span style="color: #000066;">flock</span><span style="color: #66cc66;">(</span>MBOX_FILE,LOCK_UN<span style="color: #66cc66;">)</span>; <span style="color: #808080; font-style: italic;"># unlock </span>
<span style="color: #000066;">close</span> MBOX_FILE;
<span style="color: #808080; font-style: italic;"># Work is done ... notify</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$nmessages</span> = <span style="color: #0000ff;">$mails</span>-<span style="color: #0000ff;">$oldmails</span>;
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">(</span> <span style="color: #0000ff;">$nmessages</span> <span style="color: #66cc66;">></span> <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$message</span> = <span style="color: #ff0000;">"You have got "</span>
. <span style="color: #0000ff;">$nmessages</span> . <span style="color: #ff0000;">" message <span style="color: #000099; font-weight: bold;">
</span>(in "</span> . <span style="color: #0000ff;">$mboxfile</span> .<span style="color: #ff0000;">")"</span>;
<span style="color: #808080; font-style: italic;"># I must add export DISPLAY because cron don't know my display :-(</span>
`export DISPLAY=:<span style="color: #cc66cc;">0.0</span> \n <span style="color: #66cc66;">&&</span> notify-<span style="color: #000066;">send</span> <span style="color: #ff0000;">"Notify mail"</span> <span style="color: #ff0000;">"$message"</span> -i <span style="color: #0000ff;">$icon_file</span>`;
<span style="color: #66cc66;">}</span></pre>
<p>J'apporte une petite précision. Je ne reçois <strong>une</strong> de notification <strong>dès</strong> que je reçois un mail mais je reçois une notification chaque fois que je décide de regarder si j'ai reçu un mail et ceci tant que le mail reste non lu ^^. Je dois donc ajouter mon script comme tache <code>cron</code> (<a href="http://fr.wikipedia.org/wiki/Cron">Qu'est-ce ?</a>). J'ajoute donc ma tâche afin qu'elle s'exécute toutes les 2 minutes<sup>[<a href="https://blog.namok.be/?post/2011/03/17/Notification-d-emails-notify-mail#pnote-1128-1" id="rev-pnote-1128-1">1</a>]</sup>.</p>
<pre>
$ crontab -e
*/2 * * * * /home/pit/bin/notify-mail /var/spool/mail/pit
</pre>
<p>Et <strong>bam</strong> ! Mon script ne fonctionne plus. Une <a href="http://crunchbanglinux.org/forums/topic/10602/cron/">petite recherche plus tard </a> et tout roule. Il faut spécifier à <code>cron</code> quel <em>display</em> utiliser<sup>[<a href="https://blog.namok.be/?post/2011/03/17/Notification-d-emails-notify-mail#pnote-1128-2" id="rev-pnote-1128-2">2</a>]</sup>.</p>
<p>Enjoy ...</p>
<p><strong>À lire également</strong></p>
<ul>
<li><a href="https://blog.namok.be/blog/index.php?post/2009/04/01/229-facebook-notification">Facebook notification</a></li>
</ul>
<div class="footnotes"><h4>Notes</h4>
<p>[<a href="https://blog.namok.be/?post/2011/03/17/Notification-d-emails-notify-mail#rev-pnote-1128-1" id="pnote-1128-1">1</a>] Ce qui peut être assez intrusif ...</p>
<p>[<a href="https://blog.namok.be/?post/2011/03/17/Notification-d-emails-notify-mail#rev-pnote-1128-2" id="pnote-1128-2">2</a>] D'où le <code>export</code> ajouté dans le script</p></div>
Goobook et groupesurn:md5:8ac6e53b5333333d4c2e801f201efed62011-01-24T11:08:00+01:002011-01-24T11:15:02+01:00PiTMes doigts dans le clavierdebiandiversesigeekgoobookperlscript<p>J'utilise <a href="http://blog-marcel.eu/index.php?article34/goobook-l-ami-de-mutt-l-imap-et-gmail">Goobook </a> pour accéder à mes contacts <a href="http://gmail.com">GMail</a> via mon lecteur de mail, <em>aka</em> <a href="http://mutt.org">Mutt</a> ... c'est mon choix ;-) Les utilisateurs de clients mail web ou plus graphiques peuvent passer leur chemin :-)</p>
<p>GMail permet de rassembler des contacts par groupes, ce dont j'use et abuse. Et il est donc naturel de vouloir envoyer un mail à tous les membres d'un groupe. Pour l'instant Goobook ne le permet pas.</p> <p>Si je fais un <code>goobook query Friends</code>, j'obtiens un résultat de la forme</p>
<pre>
Mon ami <('email@example.com', 'groupe principal')>,
Mon deuxième ami <('email@example.com', 'groupe principal')>,
</pre>
<p>et mutt me l'interprête comme suit</p>
<pre>
Mon ami <>, Mon deuxième ami <>
</pre>
<p>ce qui ne m'arrange par pour leur envoyer un mail.</p>
<p>J'ai posé la question à <a href="http://blog-marcel.eu/index.php?article62/goobook-perd-mes-contacts/#c1295805869-1">Marcel </a> <sup>[<a href="https://blog.namok.be/?post/2011/01/24/Goobook-et-groupes#pnote-1119-1" id="rev-pnote-1119-1">1</a>]</sup> qui me propose de régler ça à coup de <em>sed</em> ... mais ça ne fonctionne pas pour moi car ça ne me retourne que le premier contact. Comme je ne trouve pas mon erreur et que je ne parviens par à faire un <em>foreach</em> avec sed, je propose ce p'tit script <a href="http://perl.org">perl</a> qui fera l'affaire le temps que Goobook ne fasse ça proprement.</p>
<pre>
$> cat goobook-hack.pl
#!/usr/bin/perl
while ( <> ) {
@junk = split />, /;
foreach $i (@junk) {
$i =~ s/(.*) <\('(.*)',(.*)/"$1" <$2>/g;
print "$i,";
}
}
</pre>
<p>Il reste à placer ce script quelque part (dans <code>~/bin</code> par exemple) et de modifier son fichier <code>muttrc</code> comme suit;</p>
<pre>
#set query_command="goobook query '%s'"
set query_command="goobook query '%s' | ~/bin/goobook-hack.pl "
</pre>
<p>Enjoy</p>
<div class="footnotes"><h4>Notes</h4>
<p>[<a href="https://blog.namok.be/?post/2011/01/24/Goobook-et-groupes#rev-pnote-1119-1" id="pnote-1119-1">1</a>] Pas mon collègue, un autre.</p></div>