<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="http://www.placenet.org/benoit/index.php/feed/rss2/xslt" ?><rss version="2.0"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
  <title>Harvard Business School of Echec - ruby</title>
  <link>http://www.placenet.org/benoit/index.php/</link>
  <description></description>
  <language>fr</language>
  <pubDate>Fri, 12 Sep 2008 21:21:30 +0200</pubDate>
  <copyright></copyright>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Dotclear</generator>
  
    
  <item>
    <title>ruby regexp</title>
    <link>http://www.placenet.org/benoit/index.php/post/2007/04/03/ruby-regex</link>
    <guid isPermaLink="false">urn:md5:f8e41e54276f86b625ee59234bd79020</guid>
    <pubDate>Tue, 03 Apr 2007 15:06:00 +0200</pubDate>
    <dc:creator>Benoît Dejean</dc:creator>
        <category>monotone</category><category>performance</category><category>ruby</category>    
    <description>    &lt;p&gt;I am working on a bunch of utilities in ruby to process logs and parse hundreds of webalizer reports. I track my work with &lt;a href=&quot;http://monotone.ca/&quot;&gt;monotone&lt;/a&gt; which runs fine on Windows. I also use monotone to track appliances configurations.&lt;/p&gt;


&lt;p&gt;One on my scripts analyses about one thousand of HTTP documents of ~50KiB each. ruby &lt;code&gt;net/http&lt;/code&gt; module is perfect to retrieve them. This script is quite slow because of the regex it uses like &lt;code&gt;%r|Foo.+?&amp;lt;B&amp;gt;(\d+)&amp;lt;/B&amp;gt;(?:.+?Bar.+?&amp;lt;B&amp;gt;(\d+)&amp;lt;/B&amp;gt;)*|m&lt;/code&gt;. But as the script runs every night on my desktop, I don't really care if it takes 10 seconds or 10 minutes. It is clean and easy to extend and that's what matters to me.&lt;/p&gt;


&lt;p&gt;I have found that slow regexp is a common ruby issue : here's a &lt;a href=&quot;http://www.pervwatch.org/articles/2005/11/21/ruby-can-learn-from-perl&quot;&gt;simple demonstration&lt;/a&gt;. &lt;a href=&quot;http://swtch.com/~rsc/regexp/regexp1.html&quot;&gt;More details&lt;/a&gt; about regular expressions performance.&lt;/p&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>evolution + bogofilter</title>
    <link>http://www.placenet.org/benoit/index.php/post/2007/02/17/evolution-bogofilter</link>
    <guid isPermaLink="false">urn:md5:af1e28d7fc8cef810448a81f4012594f</guid>
    <pubDate>Sat, 17 Feb 2007 02:14:00 +0100</pubDate>
    <dc:creator>Benoît Dejean</dc:creator>
        <category>GNOME</category>
        <category>bogofilter</category><category>bug</category><category>evolution</category><category>gnome</category><category>memory</category><category>ruby</category><category>spam</category>    
    <description>    &lt;p&gt;There is &lt;a href=&quot;http://bugzilla.gnome.org/show_bug.cgi?id=272411&quot;&gt;no standard bogofilter plugin&lt;/a&gt; for evolution. I am not happy with spamassassin/spamd/spamc CPU and RAM requirements. Like 'sa-learn --version' which takes 1.8s even on warm start...&lt;/p&gt;


&lt;p&gt;So I wrote a tiny (stupid) ruby script to emulate SpamAssassin programs with bogofilter.&lt;/p&gt;

&lt;pre&gt;
#!/usr/bin/env ruby

# 1 spam, 0 not-spam
def bogo_exec(mode)

  system 'bogofilter', '-l', mode

  exit case $?.exitstatus
    when 0
    1
    else
    0
  end
end

if ARGV.include?('--version') then
  print &amp;quot;SpamAssassin version 3.1.0-bogo\n&amp;quot;
  exit
end

if ARGV.include?('--spam') then
  bogo_exec '-s'
end

if ARGV.include?('--ham') then
  bogo_exec '-n'
end

if ARGV.include?('-c') or ARGV.include?('--exit-code') then
  bogo_exec '-u'
end
&lt;/pre&gt;


&lt;p&gt;I then created symlinks &lt;code&gt;{spamassassin, spamc, spamd, sa-learn} -&amp;gt; spam.rb&lt;/code&gt;  in my &lt;code&gt;PATH&lt;/code&gt;. Maybe it WAS incomplete and broken, but it NOW works. No more daemon. Mail retrieval is no longer CPU-bound. Evolution and I are happy.&lt;/p&gt;


&lt;h3&gt;Update&lt;/h3&gt;

&lt;p&gt;I have fixed the script.
To feed spam/ham here is what i did :&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;selected a bunch of messages in evolution and Saved As '/tmp/mails'&lt;/li&gt;
&lt;li&gt;run &lt;code&gt;sa-learn --spam &amp;lt; /tmp/mails&lt;/code&gt; or &lt;code&gt;sa-learn --ham &amp;lt; /tmp/mails&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;</description>
    
    
    
      </item>
    
</channel>
</rss>