<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" xml:lang="en-US">
  <title>lindsaar.net - Home</title>
  <id>tag:lindsaar.net,2009:mephisto/</id>
  <generator version="0.7.3" uri="http://mephistoblog.com">Mephisto Noh-Varr</generator>
  
  <link href="http://lindsaar.net/" rel="alternate" type="text/html" />
  <updated>2009-11-02T16:25:07Z</updated>
  <link rel="license" type="text/html" href="http://creativecommons.org/licenses/by-nc-sa/3.0/" /><logo>http://creativecommons.org/images/public/somerights20.gif</logo><link rel="self" href="http://feeds.feedburner.com/lindsaar-net" type="application/atom+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><entry xml:base="http://lindsaar.net/">
    <author>
      <name>mikel</name>
    </author>
    <id>tag:lindsaar.net,2009-11-02:11190</id>
    <published>2009-11-02T14:45:00Z</published>
    <updated>2009-11-02T16:25:07Z</updated>
    <link href="http://feedproxy.google.com/~r/lindsaar-net/~3/5nxYukd6gHk/mail-gets-some-compliments" rel="alternate" type="text/html" />
    <title>Mail gets some compliments!</title>
<summary type="html">&lt;p&gt;As you know, I have put out the new mail gem… here are some of the things people have said about it:&lt;/p&gt;</summary><content type="html">
            &lt;p&gt;As you know, I have put out the new mail gem… here are some of the things people have said about it:&lt;/p&gt;
&lt;p&gt;“Wow, I find this library very exciting!  Thanks for sharing.” – &lt;a href="http://blog.grayproductions.net/"&gt;James Edward Gray II&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;“Nice work.  Thanks Mikel.” – &lt;a href="http://blog.majesticseacreature.com"&gt;Gregory Brown&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;“I just finished parsing the whole Enron set (2.3gb) and the Trec 2005 set (0.5gb) again. The only issues that caused mail parser failures after the few commits on my fork are all related to bad header values. Everything else was clear sailing. I didn’t verify the correctness of the parser, just the success/failure, but still that’s ~500k emails that went through fine.” – &lt;a href="http://jimlindley.com/"&gt;Jim&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;“This is gorgeous.  If you’ve got this pile of total awesome waiting for release, I’d rather jump on it.” – &lt;a href="http://blog.segment7.net/"&gt;Eric Hodel&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;And only after a few short days, we have 84 people watching mail on github, compared to the few dozen on TMail.&lt;/p&gt;


	&lt;p&gt;Thanks for all your comments, keep them and your patches coming!&lt;/p&gt;


	&lt;p&gt;Mikel&lt;/p&gt;
          &lt;img src="http://feeds.feedburner.com/~r/lindsaar-net/~4/5nxYukd6gHk" height="1" width="1"/&gt;</content>  <feedburner:origLink>http://lindsaar.net/2009/11/2/mail-gets-some-compliments</feedburner:origLink></entry>
  <entry xml:base="http://lindsaar.net/">
    <author>
      <name>mikel</name>
    </author>
    <id>tag:lindsaar.net,2009-10-29:11113</id>
    <published>2009-10-29T01:05:00Z</published>
    <updated>2009-10-29T00:56:30Z</updated>
    <link href="http://feedproxy.google.com/~r/lindsaar-net/~3/0vP4JiQnqic/rails-unit-tests-uninitialized-constant-test-unit-testresult-testresultfailuresupport" rel="alternate" type="text/html" />
    <title>Rails Unit Tests: uninitialized constant error</title>
<summary type="html">&lt;p&gt;Rails doesn’t play well with test-unit 2.x… if you try you get something like:  Test::Unit::TestResult::TestResultFailureSupport on from /Library/Ruby/Gems/1.8/gems/test-unit-2.0.5/lib/test/unit/testresult.rb:28&lt;/p&gt;</summary><content type="html">
            &lt;p&gt;Rails doesn’t play well with test-unit 2.x… if you try you get something like:  Test::Unit::TestResult::TestResultFailureSupport on from /Library/Ruby/Gems/1.8/gems/test-unit-2.0.5/lib/test/unit/testresult.rb:28&lt;/p&gt;
&lt;p&gt;If you are getting something like this:&lt;/p&gt;


&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;mikel@baci.local ~/rails_programs/rails/actionmailer&lt;tt&gt;
&lt;/tt&gt; $ rake test&lt;tt&gt;
&lt;/tt&gt;(in /Users/mikel/rails_programs/rails/actionmailer)&lt;tt&gt;
&lt;/tt&gt;/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -I&amp;quot;lib:test&amp;quot; &amp;quot;/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb&amp;quot; &amp;quot;test/adv_attr_test.rb&amp;quot; &amp;quot;test/asset_host_test.rb&amp;quot; &amp;quot;test/delivery_method_test.rb&amp;quot; &amp;quot;test/mail_helper_test.rb&amp;quot; &amp;quot;test/mail_layout_test.rb&amp;quot; &amp;quot;test/mail_render_test.rb&amp;quot; &amp;quot;test/mail_service_test.rb&amp;quot; &amp;quot;test/quoting_test.rb&amp;quot; &amp;quot;test/test_helper_test.rb&amp;quot; &amp;quot;test/tmail_test.rb&amp;quot; &amp;quot;test/url_test.rb&amp;quot; &lt;tt&gt;
&lt;/tt&gt;DEPRECATION WARNING: ActiveSupport::DeprecatedCallbacks has been deprecated in favor of ActiveSupport::Callbacks. (called from included at /Users/mikel/rails_programs/rails/actionmailer/lib/../../actionpack/lib/../../activesupport/lib/active_support/testing/setup_and_teardown.rb:7)&lt;tt&gt;
&lt;/tt&gt;/Users/mikel/rails_programs/rails/actionmailer/lib/../../actionpack/lib/../../activesupport/lib/active_support/dependencies.rb:116:in `const_missing': uninitialized constant Test::Unit::TestResult::TestResultFailureSupport (NameError)&lt;tt&gt;
&lt;/tt&gt;        from /Library/Ruby/Gems/1.8/gems/test-unit-2.0.5/lib/test/unit/testresult.rb:28&lt;tt&gt;
&lt;/tt&gt;        from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'&lt;tt&gt;
&lt;/tt&gt;        from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'&lt;tt&gt;
&lt;/tt&gt;        from /Users/mikel/rails_programs/rails/actionmailer/lib/../../actionpack/lib/../../activesupport/lib/active_support/dependencies.rb:167:in `require'&lt;tt&gt;
&lt;/tt&gt;        from /Users/mikel/rails_programs/rails/actionmailer/lib/../../actionpack/lib/../../activesupport/lib/active_support/dependencies.rb:537:in `new_constants_in'&lt;tt&gt;
&lt;/tt&gt;        from /Users/mikel/rails_programs/rails/actionmailer/lib/../../actionpack/lib/../../activesupport/lib/active_support/dependencies.rb:167:in `require'&lt;tt&gt;
&lt;/tt&gt;        from /Library/Ruby/Gems/1.8/gems/test-unit-2.0.5/lib/test/unit/ui/testrunnermediator.rb:9&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;Then you need to downgrade from test-unit 2.x to test-unit 1.2.3 or so.&lt;/p&gt;


&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;# gem uninstall test-unit&lt;tt&gt;
&lt;/tt&gt;# gem install test-unit -v 1.2.3&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;Enjoy&lt;/p&gt;
          &lt;img src="http://feeds.feedburner.com/~r/lindsaar-net/~4/0vP4JiQnqic" height="1" width="1"/&gt;</content>  <feedburner:origLink>http://lindsaar.net/2009/10/29/rails-unit-tests-uninitialized-constant-test-unit-testresult-testresultfailuresupport</feedburner:origLink></entry>
  <entry xml:base="http://lindsaar.net/">
    <author>
      <name>mikel</name>
    </author>
    <id>tag:lindsaar.net,2009-10-29:11112</id>
    <published>2009-10-29T00:43:00Z</published>
    <updated>2009-10-29T00:57:35Z</updated>
    <category term="Mail" />
    <category term="Ruby" />
    <link href="http://feedproxy.google.com/~r/lindsaar-net/~3/9rEX3gNFoXw/new-mail-gem-released" rel="alternate" type="text/html" />
    <title>New Mail gem released</title>
<summary type="html">&lt;p&gt;OK… birthday time.  Mail is now a gem!&lt;/p&gt;</summary><content type="html">
            &lt;p&gt;OK… birthday time.  Mail is now a gem!&lt;/p&gt;
&lt;p&gt;So, it is hosted on &lt;a href="http://www.gemcutter.org/gems/mail"&gt;gemcutter&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;It is uploaded to &lt;a href="http://github.com/mikel/mail"&gt;github&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;Let &lt;a href="http://github.com/mikel/mail/issues"&gt;me know&lt;/a&gt; how it runs!&lt;/p&gt;


	&lt;p&gt;Mikel&lt;/p&gt;
          &lt;img src="http://feeds.feedburner.com/~r/lindsaar-net/~4/9rEX3gNFoXw" height="1" width="1"/&gt;</content>  <feedburner:origLink>http://lindsaar.net/2009/10/29/new-mail-gem-released</feedburner:origLink></entry>
  <entry xml:base="http://lindsaar.net/">
    <author>
      <name>mikel</name>
    </author>
    <id>tag:lindsaar.net,2009-09-19:10066</id>
    <published>2009-09-19T14:31:00Z</published>
    <updated>2009-09-19T14:32:59Z</updated>
    <category term="Mail" />
    <category term="Ruby" />
    <link href="http://feedproxy.google.com/~r/lindsaar-net/~3/3ZodG7yZcls/mail-and-bounced-emails" rel="alternate" type="text/html" />
    <title>Mail and Bounced Emails</title>
<summary type="html">&lt;p&gt;You might have to deal with bounced emails in your application.  The new mail library makes this a no brainer…&lt;/p&gt;</summary><content type="html">
            &lt;p&gt;You might have to deal with bounced emails in your application.  The new mail library makes this a no brainer…&lt;/p&gt;
&lt;p&gt;I like code more than words… so:&lt;/p&gt;


&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;15&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;require &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;mail&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class="iv"&gt;@mail&lt;/span&gt; = &lt;span class="co"&gt;Mail&lt;/span&gt;.read(&lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;/path/to/bounce_message.eml&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class="c"&gt;# You can also do Mail.new('String of email message')&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class="iv"&gt;@mail&lt;/span&gt;.bounced?&lt;tt&gt;
&lt;/tt&gt;&lt;span class="c"&gt;#=&amp;gt; true&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class="iv"&gt;@mail&lt;/span&gt;.final_recipient&lt;tt&gt;
&lt;/tt&gt;&lt;span class="c"&gt;#=&amp;gt; rfc822;mikel@dont.exist.com&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class="iv"&gt;@mail&lt;/span&gt;.action&lt;tt&gt;
&lt;/tt&gt;&lt;span class="c"&gt;#=&amp;gt; failed&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class="iv"&gt;@mail&lt;/span&gt;.error_status&lt;tt&gt;
&lt;/tt&gt;&lt;span class="c"&gt;#=&amp;gt; 5.5.0&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class="iv"&gt;@mail&lt;/span&gt;.diagnostic_code  &lt;tt&gt;
&lt;/tt&gt;&lt;span class="c"&gt;#=&amp;gt; smtp;550 Requested action not taken: mailbox unavailable &lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class="iv"&gt;@mail&lt;/span&gt;.retryable?&lt;tt&gt;
&lt;/tt&gt;&lt;span class="c"&gt;#=&amp;gt; false&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;You can get mail from my &lt;a href="http://www.github.com/mikel/mail/"&gt;GitHub repository&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;Once we finish a few more points in the library, I’ll release a gem.&lt;/p&gt;


	&lt;p&gt;Mikel&lt;/p&gt;
          &lt;img src="http://feeds.feedburner.com/~r/lindsaar-net/~4/3ZodG7yZcls" height="1" width="1"/&gt;</content>  <feedburner:origLink>http://lindsaar.net/2009/9/19/mail-and-bounced-emails</feedburner:origLink></entry>
  <entry xml:base="http://lindsaar.net/">
    <author>
      <name>mikel</name>
    </author>
    <id>tag:lindsaar.net,2009-09-18:10017</id>
    <published>2009-09-18T04:22:00Z</published>
    <updated>2009-09-19T14:25:50Z</updated>
    <category term="Mail" />
    <category term="RSpec" />
    <category term="Ruby" />
    <link href="http://feedproxy.google.com/~r/lindsaar-net/~3/lvWnyCcYaCQ/mail-tmail-the-future-of-ruby-email-handling" rel="alternate" type="text/html" />
    <title>Mail, TMail, The Future of Ruby Email Handling</title>
<summary type="html">&lt;p&gt;You may know I maintain the TMail library.  Well, recently I’ve been working on the next version.&lt;/p&gt;</summary><content type="html">
            &lt;p&gt;You may know I maintain the TMail library.  Well, recently I’ve been working on the next version.&lt;/p&gt;
&lt;p&gt;TMail was getting hard to maintain and monkey patch.  It’s implementation does not take into account many little things that create a problem when trying to get Ruby 1.9 compatibility working.&lt;/p&gt;


	&lt;p&gt;Anyway, I started working on Mail… code speaks louder than words… so Mail can do the following right now:&lt;/p&gt;


&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;15&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;&lt;span class="co"&gt;Mail&lt;/span&gt;.defaults &lt;span class="r"&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  smtp &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;127.0.0.1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class="r"&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class="co"&gt;Mail&lt;/span&gt;.deliver &lt;span class="r"&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  to &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;nicolas@test.lindsaar.net.au&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  from &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;Mikel Lindsaar &amp;lt;mikel@test.lindsaar.net.au&amp;gt;&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  subject &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;First multipart email sent with Mail&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  text_part &lt;span class="r"&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    body &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;Here is the attachment you wanted&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class="r"&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  html_part &lt;span class="r"&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    content_type &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;text/html; charset=UTF-8&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    body &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;&amp;lt;h1&amp;gt;Funky Title&amp;lt;/h1&amp;gt;&amp;lt;p&amp;gt;Here it is&amp;lt;/p&amp;gt;&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class="r"&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  add_file &lt;span class="sy"&gt;:filename&lt;/span&gt; =&amp;gt; &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;/path/to/myfile.pdf&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class="r"&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;And you just sent a multipart text and html email with an attachment!&lt;/p&gt;


	&lt;p&gt;Mail is my attempt to just &lt;span class="caps"&gt;HANDLE&lt;/span&gt; the problem of Ruby Email handling.&lt;/p&gt;


	&lt;p&gt;I developed it from the ground up with complete spec coverage… I am not &lt;em&gt;quite&lt;/em&gt; at 100%... but very close.  It is also a completely object oriented design and pure ruby too!&lt;/p&gt;


	&lt;p&gt;Mail tries it’s darn hardest not to crash.  In fact it already checks every email in the TMail test suite and doesn’t crash once on parsing any of the emails in there.&lt;/p&gt;


	&lt;p&gt;In any case, I now have pretty much all the basic email and mime and attachment handlings working.  Next up is handling multiple character sets in the header and body.&lt;/p&gt;


	&lt;p&gt;You are welcome to check it out from my &lt;a href="http://github.com/mikel/mail"&gt;GitHub account&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;It’s version 0.1 right now… but expect to see the multi character set support soon.&lt;/p&gt;


	&lt;p&gt;Forks and patches welcome!&lt;/p&gt;


	&lt;p&gt;Mikel&lt;/p&gt;
          &lt;img src="http://feeds.feedburner.com/~r/lindsaar-net/~4/lvWnyCcYaCQ" height="1" width="1"/&gt;</content>  <feedburner:origLink>http://lindsaar.net/2009/9/18/mail-tmail-the-future-of-ruby-email-handling</feedburner:origLink></entry>
  <entry xml:base="http://lindsaar.net/">
    <author>
      <name>mikel</name>
    </author>
    <id>tag:lindsaar.net,2009-07-04:7789</id>
    <published>2009-07-04T16:22:00Z</published>
    <updated>2009-07-04T16:36:14Z</updated>
    <link href="http://feedproxy.google.com/~r/lindsaar-net/~3/MkW5KJMZq7Y/custom-music-on-hold-for-asterisk" rel="alternate" type="text/html" />
    <title>Custom Music on Hold for Asterisk</title>
<summary type="html">&lt;p&gt;I needed to change the music on hold for my Asterisk servers…&lt;/p&gt;</summary><content type="html">
            &lt;p&gt;I needed to change the music on hold for my Asterisk servers…&lt;/p&gt;
&lt;p&gt;First, find your favorite music files in basically any format, get them somewhere where you can access them.&lt;/p&gt;


	&lt;p&gt;Then make sure you have ffmpeg installed, for mac users you can just do “port install ffmpeg” which can take a while as it has to install all the audio and video format libraries.&lt;/p&gt;


	&lt;p&gt;Go into the folder where you put the music files, and run the following (assuming you are on a &lt;span class="caps"&gt;UNIX&lt;/span&gt; client)&lt;/p&gt;


&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;for f in `ls *.mp3` ; do FILE=$(basename $f .mp3) ;&lt;tt&gt;
&lt;/tt&gt;  ffmpeg -i $FILE.mp3 -ar 8000 -ac 1 -ab 64 $FILE.wav \&lt;tt&gt;
&lt;/tt&gt;  -ar 8000 -ac 1 -ab 64 -f mulaw $FILE.pcm \&lt;tt&gt;
&lt;/tt&gt;  -map 0:0 -map 0:0 ;&lt;tt&gt;
&lt;/tt&gt;done&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;This will change your “MP4” files into a &lt;span class="caps"&gt;PCM&lt;/span&gt; (ulaw) and &lt;span class="caps"&gt;WAV&lt;/span&gt; file format.&lt;/p&gt;


	&lt;p&gt;Then move the existing music on hold directory in asterisk to another name:&lt;/p&gt;


&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;# mv /var/lib/asterisk/moh /var/lib/asterisk/moh-original&lt;tt&gt;
&lt;/tt&gt;# mkdir /var/lib/asterisk/moh&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;Then install your new music files&lt;/p&gt;


&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;# cp ~/*.pcm /var/lib/asterisk/moh/&lt;tt&gt;
&lt;/tt&gt;# cp ~/*.wav /var/lib/asterisk/moh/&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;Then reload Asterisk and you should be good to go!&lt;/p&gt;


	&lt;p&gt;Mikel&lt;/p&gt;
          &lt;img src="http://feeds.feedburner.com/~r/lindsaar-net/~4/MkW5KJMZq7Y" height="1" width="1"/&gt;</content>  <feedburner:origLink>http://lindsaar.net/2009/7/4/custom-music-on-hold-for-asterisk</feedburner:origLink></entry>
  <entry xml:base="http://lindsaar.net/">
    <author>
      <name>mikel</name>
    </author>
    <id>tag:lindsaar.net,2009-05-03:5743</id>
    <published>2009-05-03T14:59:00Z</published>
    <updated>2009-05-03T15:00:20Z</updated>
    <category term="Javascript" />
    <category term="Ruby on Rails" />
    <link href="http://feedproxy.google.com/~r/lindsaar-net/~3/fxFAGqyHsNo/always-getting-an-invalid-authenticity-token-error" rel="alternate" type="text/html" />
    <title>Always getting an invalid authenticity token error</title>
<summary type="html">&lt;p&gt;I had a Ruby on Rails app giving a bunch of invalid authenticity token errors.  I spent a while hunting down the solution until I found this write up.  Very useful.&lt;/p&gt;</summary><content type="html">
            &lt;p&gt;I had a Ruby on Rails app giving a bunch of invalid authenticity token errors.  I spent a while hunting down the solution until I found this write up.  Very useful.&lt;/p&gt;
&lt;p&gt;This write up was by &lt;a href="http://www.workingwithrails.com/person/5484-peter-de-berdt"&gt;Peter De Berdt&lt;/a&gt; on one of the Ruby mailing lists, I am putting it here more for my own future (maybe) reference as it is a very good solution for the situation I was running into.  The entire thread is at the &lt;a href="http://www.ruby-forum.com/topic/167917#751085"&gt;ruby forum site&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;If you have a situation where you are getting invalid authenticity tokens and are doing strange things with forms on your website with file uploads etc, and can’t for some reason just use the authenticity form helper, then this solution worked for me and should work for you too.&lt;/p&gt;


&lt;hr /&gt;

	&lt;p&gt;The solution is pretty simple to be honest:&lt;/p&gt;


	&lt;p&gt;In your view layout file, add this to the &amp;lt;header&gt; section:&lt;/p&gt;


&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;&lt;span class="ta"&gt;&amp;lt;script&lt;/span&gt; &lt;span class="an"&gt;type&lt;/span&gt;=&lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;text/javascript&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class="an"&gt;charset&lt;/span&gt;=&lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;utf-8&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class="ta"&gt;&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    window._token = '&lt;span class="c"&gt;&amp;lt;%= form_authenticity_token -%&amp;gt;&lt;/span&gt;';&lt;tt&gt;
&lt;/tt&gt;&lt;span class="ta"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;In application.js, add the following:&lt;/p&gt;


&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;Ajax.Base.prototype.initialize = Ajax.Base.prototype.initialize.wrap(&lt;tt&gt;
&lt;/tt&gt;   &lt;span class="r"&gt;function&lt;/span&gt;(p, options){&lt;tt&gt;
&lt;/tt&gt;     p(options);&lt;tt&gt;
&lt;/tt&gt;     &lt;span class="pc"&gt;this&lt;/span&gt;.options.parameters = &lt;span class="pc"&gt;this&lt;/span&gt;.options.parameters || {};&lt;tt&gt;
&lt;/tt&gt;     &lt;span class="pc"&gt;this&lt;/span&gt;.options.parameters.authenticity_token = &lt;span class="pt"&gt;window&lt;/span&gt;._token || &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;   }&lt;tt&gt;
&lt;/tt&gt;);&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;It will automatically add the authenticity token to &lt;span class="caps"&gt;ALL&lt;/span&gt; ajax requests,
even those you invoke from custom code (graceful degrading and/or even
delegated events for example).&lt;/p&gt;


	&lt;p&gt;A similar solution for those swapping out Prototype with JQuery has
been posted &lt;a href="http://henrik.nyh.se/2008/05/rails-authenticity-token-with-jquery"&gt;here&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;As for file uploaders, a normal field within a form (multipart=true)
will be sent as part of the form (and isn’t an ajax request in the
first place) and shouldn’t be a problem. If you are using &lt;span class="caps"&gt;ANY&lt;/span&gt; other
“ajax” uploader, there’s more to it. I already posted several times on
how to get SWFUpload to play nicely with Rails, an overview with links
to the appropriate posts can be found &lt;a href="http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/45f70281a5992fa7"&gt;here.&lt;/a&gt;&lt;/p&gt;
          &lt;img src="http://feeds.feedburner.com/~r/lindsaar-net/~4/fxFAGqyHsNo" height="1" width="1"/&gt;</content>  <feedburner:origLink>http://lindsaar.net/2009/5/3/always-getting-an-invalid-authenticity-token-error</feedburner:origLink></entry>
  <entry xml:base="http://lindsaar.net/">
    <author>
      <name>mikel</name>
    </author>
    <id>tag:lindsaar.net,2009-01-06:2830</id>
    <published>2009-01-06T13:30:00Z</published>
    <updated>2009-01-06T13:32:51Z</updated>
    <link href="http://feedproxy.google.com/~r/lindsaar-net/~3/Q0uatC28pb4/windows-ipconfig-does-not-show-anything" rel="alternate" type="text/html" />
    <title>Windows ipconfig does not show anything</title>
<summary type="html">&lt;p&gt;I had a Windows XP system (service pack 2) that would only return “Windows IP configuration” and then nothing, no indication of network disconnection nothing, well, there’s a good fix for it.&lt;/p&gt;</summary><content type="html">
            &lt;p&gt;I had a Windows XP system (service pack 2) that would only return “Windows IP configuration” and then nothing, no indication of network disconnection nothing, well, there’s a good fix for it.&lt;/p&gt;
&lt;p&gt;The system wouldn’t pickup an IP address from &lt;span class="caps"&gt;DHCP&lt;/span&gt;, it was like it was just confused.&lt;/p&gt;


	&lt;p&gt;You can do the following at a &lt;span class="caps"&gt;CMD&lt;/span&gt; prompt to reset the network configurations:&lt;/p&gt;


&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;C:\&amp;gt; netsh winsock reset catalog&lt;tt&gt;
&lt;/tt&gt;C:\&amp;gt; netsh int ip reset reset.log&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;The first line resets all the &lt;span class="caps"&gt;WINSOCK&lt;/span&gt; entries to their defaults, the second line resets all the &lt;span class="caps"&gt;TCP&lt;/span&gt;/IP entries to their defaults.&lt;/p&gt;


	&lt;p&gt;The first one will ask you to reboot, don’t.  Do both commands and then reboot your system.&lt;/p&gt;


	&lt;p&gt;Once I did this, the computer got it’s &lt;span class="caps"&gt;DHCP&lt;/span&gt; address again quite happily.&lt;/p&gt;


	&lt;p&gt;blogLater&lt;/p&gt;


	&lt;p&gt;Mikel&lt;/p&gt;
          &lt;img src="http://feeds.feedburner.com/~r/lindsaar-net/~4/Q0uatC28pb4" height="1" width="1"/&gt;</content>  <feedburner:origLink>http://lindsaar.net/2009/1/6/windows-ipconfig-does-not-show-anything</feedburner:origLink></entry>
  <entry xml:base="http://lindsaar.net/">
    <author>
      <name>mikel</name>
    </author>
    <id>tag:lindsaar.net,2009-01-05:2819</id>
    <published>2009-01-05T20:18:00Z</published>
    <updated>2009-01-05T20:20:39Z</updated>
    <link href="http://feedproxy.google.com/~r/lindsaar-net/~3/-lQ67ft7Bsg/freebsd-rc-scripts" rel="alternate" type="text/html" />
    <title>FreeBSD rc scripts</title>
<summary type="html">&lt;p&gt;I’ve always wanted a concise practical guide to rc scripting in FreeBSD, well, &lt;a href="http://www.freebsd.org/doc/en/articles/rc-scripting/"&gt;here it is&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/lindsaar-net/~4/-lQ67ft7Bsg" height="1" width="1"/&gt;</summary>  <feedburner:origLink>http://lindsaar.net/2009/1/5/freebsd-rc-scripts</feedburner:origLink></entry>
  <entry xml:base="http://lindsaar.net/">
    <author>
      <name>mikel</name>
    </author>
    <id>tag:lindsaar.net,2008-11-24:2432</id>
    <published>2008-11-24T06:37:00Z</published>
    <updated>2008-11-24T06:41:42Z</updated>
    <link href="http://feedproxy.google.com/~r/lindsaar-net/~3/mdNoGsM3Ju4/how-to-monitor-a-logged-in-professional" rel="alternate" type="text/html" />
    <title>How to monitor a logged in professional</title>
<summary type="html">&lt;p&gt;Sometimes you will need to get a professional to log into your system to help you out.  You should watch what they do, and this is the easiest way I know.&lt;/p&gt;</summary><content type="html">
            &lt;p&gt;Sometimes you will need to get a professional to log into your system to help you out.  You should watch what they do, and this is the easiest way I know.&lt;/p&gt;
&lt;p&gt;I needed to get someone from a hardware company to log into one of our phone servers to help debug a problem, but I wasn’t just about to give them full carte blanche access to my server.  Especially as it is behind a firewall.&lt;/p&gt;


	&lt;p&gt;I trust these guys somewhat, I mean, if they screw up, no more customer and hello to bad PR… but at the same time, you should always watch.&lt;/p&gt;


	&lt;p&gt;So, I went hunting around, and Screen is the best answer.&lt;/p&gt;


	&lt;p&gt;Get them to log into your system and type:&lt;/p&gt;


&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;$ screen -S support&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;Then, from your shell:&lt;/p&gt;


&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;$ screen -x support&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;And bam, you are both sharing the same screen.&lt;/p&gt;


	&lt;p&gt;Nice and simple.&lt;/p&gt;


	&lt;p&gt;Of course, this isn’t fool proof, and it only really lets you follow what the other guy is doing.  But it is a hell of a lot better than sitting there blind listening on the phone to a few hundred key strokes wondering ‘what is he up to?’&lt;/p&gt;


	&lt;p&gt;blogLater&lt;/p&gt;


	&lt;p&gt;Mikel&lt;/p&gt;
          &lt;img src="http://feeds.feedburner.com/~r/lindsaar-net/~4/mdNoGsM3Ju4" height="1" width="1"/&gt;</content>  <feedburner:origLink>http://lindsaar.net/2008/11/24/how-to-monitor-a-logged-in-professional</feedburner:origLink></entry>
  <entry xml:base="http://lindsaar.net/">
    <author>
      <name>mikel</name>
    </author>
    <id>tag:lindsaar.net,2008-11-22:2415</id>
    <published>2008-11-22T16:35:00Z</published>
    <updated>2008-11-22T16:36:49Z</updated>
    <link href="http://feedproxy.google.com/~r/lindsaar-net/~3/SOf7GkjaijE/tmail-moves-to-git" rel="alternate" type="text/html" />
    <title>TMail Moves to GIT</title>
<summary type="html">&lt;p&gt;Social networking here we come!&lt;/p&gt;</summary><content type="html">
            &lt;p&gt;Social networking here we come!&lt;/p&gt;
&lt;p&gt;I have moved TMail onto &lt;span class="caps"&gt;GIT&lt;/span&gt;.&lt;/p&gt;


	&lt;p&gt;You can &lt;a href="http://github.com/mikel/tmail/tree/master"&gt;see it here&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;Please fork / patch / follow / help out :)&lt;/p&gt;


	&lt;p&gt;Mikel&lt;/p&gt;
          &lt;img src="http://feeds.feedburner.com/~r/lindsaar-net/~4/SOf7GkjaijE" height="1" width="1"/&gt;</content>  <feedburner:origLink>http://lindsaar.net/2008/11/22/tmail-moves-to-git</feedburner:origLink></entry>
  <entry xml:base="http://lindsaar.net/">
    <author>
      <name>mikel</name>
    </author>
    <id>tag:lindsaar.net,2008-11-20:2397</id>
    <published>2008-11-20T22:39:00Z</published>
    <updated>2008-11-20T22:48:48Z</updated>
    <link href="http://feedproxy.google.com/~r/lindsaar-net/~3/ECzzUwq1f9I/funny" rel="alternate" type="text/html" />
    <title>Funny...</title>
<summary type="html">&lt;p&gt;Some people think that rails is getting bloated… but through the hard efforts of core committers, the fluff and fat is getting sliced and trimmed down like a Döner kebab spit at a turkish festival…&lt;/p&gt;</summary><content type="html">
            &lt;p&gt;Some people think that rails is getting bloated… but through the hard efforts of core committers, the fluff and fat is getting sliced and trimmed down like a Döner kebab spit at a turkish festival…&lt;/p&gt;
&lt;p&gt;And here is the perfect example seen on Rails-Contrib on freenode last night:&lt;/p&gt;


&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;GitHub142: rails: David Heinemeier Hansson 2-2-stable&lt;tt&gt;
&lt;/tt&gt;SHA1-9d8cc60&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;[19:07] GitHub142: Reduced the number of literal aliases to the&lt;tt&gt;
&lt;/tt&gt;range that has actually seen personal use. With the massive&lt;tt&gt;
&lt;/tt&gt;savings in overhead, I was able to fit Array#fourty_two&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;Here’s the &lt;a href="http://is.gd/8oJA"&gt;commit&lt;/a&gt; if you are interested…&lt;/p&gt;


	&lt;p&gt;blogLater&lt;/p&gt;


	&lt;p&gt;Mikel&lt;/p&gt;
          &lt;img src="http://feeds.feedburner.com/~r/lindsaar-net/~4/ECzzUwq1f9I" height="1" width="1"/&gt;</content>  <feedburner:origLink>http://lindsaar.net/2008/11/20/funny</feedburner:origLink></entry>
  <entry xml:base="http://lindsaar.net/">
    <author>
      <name>mikel</name>
    </author>
    <id>tag:lindsaar.net,2008-11-02:2295</id>
    <published>2008-11-02T19:47:00Z</published>
    <updated>2008-11-02T19:49:37Z</updated>
    <link href="http://feedproxy.google.com/~r/lindsaar-net/~3/mm-WHuTdPUg/how-to-reset-a-sequence-with-postgresql" rel="alternate" type="text/html" />
    <title>How to reset a sequence with PostgreSQL</title>
<content type="html">
            &lt;p&gt;I would think that&lt;/p&gt;


&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;ALTER SEQUENCE sequence_name&lt;tt&gt;
&lt;/tt&gt;      RESTART WITH (SELECT max(id) FROM table_name);&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;would work, but it doesn’t.  Use:&lt;/p&gt;


&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;SELECT SETVAL('sequence_name', (SELECT MAX(id) FROM table_name) + 1);&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;instead and you will be a lot more happier.&lt;/p&gt;


	&lt;p&gt;blogLater&lt;/p&gt;


	&lt;p&gt;Mikel&lt;/p&gt;
          &lt;img src="http://feeds.feedburner.com/~r/lindsaar-net/~4/mm-WHuTdPUg" height="1" width="1"/&gt;</content>  <feedburner:origLink>http://lindsaar.net/2008/11/2/how-to-reset-a-sequence-with-postgresql</feedburner:origLink></entry>
  <entry xml:base="http://lindsaar.net/">
    <author>
      <name>mikel</name>
    </author>
    <id>tag:lindsaar.net,2008-11-01:2280</id>
    <published>2008-11-01T20:17:00Z</published>
    <updated>2008-11-01T20:19:29Z</updated>
    <link href="http://feedproxy.google.com/~r/lindsaar-net/~3/C13Hxt_9AOg/openbsd-raid-and-temp-sensors-on-hp-proliant-dl-360-and-380-series" rel="alternate" type="text/html" />
    <title>OpenBSD RAID and Temp Sensors on HP Proliant DL 360 and 380 Series</title>
<summary type="html">&lt;p&gt;I have a bunch of &lt;span class="caps"&gt;HP DL 360&lt;/span&gt; and &lt;span class="caps"&gt;DL 380&lt;/span&gt; servers that I run OpenBSD on as gateways.  This is how to monitor their &lt;span class="caps"&gt;RAID&lt;/span&gt; drive status and temperature status…&lt;/p&gt;</summary><content type="html">
            &lt;p&gt;I have a bunch of &lt;span class="caps"&gt;HP DL 360&lt;/span&gt; and &lt;span class="caps"&gt;DL 380&lt;/span&gt; servers that I run OpenBSD on as gateways.  This is how to monitor their &lt;span class="caps"&gt;RAID&lt;/span&gt; drive status and temperature status…&lt;/p&gt;
&lt;p&gt;What you need to do is enable the &lt;span class="caps"&gt;IPMI&lt;/span&gt; driver.&lt;/p&gt;


	&lt;p&gt;If you read the man page, the &lt;span class="caps"&gt;IPMI&lt;/span&gt; driver provides an &lt;span class="caps"&gt;API&lt;/span&gt; like interface to the hardware it is running on.&lt;/p&gt;


	&lt;p&gt;This means you can query sysctl to get data like this:&lt;/p&gt;


&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;$ sysctl hw.sensors&lt;tt&gt;
&lt;/tt&gt;hw.sensors.acpitz0.temp0=8.35 degC (zone temperature)&lt;tt&gt;
&lt;/tt&gt;hw.sensors.ciss0.drive0=online (sd0), OK&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;If you then yank one of a mirror set you get:&lt;/p&gt;


&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;$ sysctl hw.sensors.ciss0.drive0&lt;tt&gt;
&lt;/tt&gt;hw.sensors.ciss0.drive0=degraded (sd0), WARNING&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;If you then put a new drive back into the mirror set you get:&lt;/p&gt;


&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;$ sysctl hw.sensors.ciss0.drive0&lt;tt&gt;
&lt;/tt&gt;hw.sensors.ciss0.drive0=rebuilding (sd0), WARNING&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;Once the system has rebuilt, you get:&lt;/p&gt;


&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;$ sysctl hw.sensors.ciss0.drive0&lt;tt&gt;
&lt;/tt&gt;hw.sensors.ciss0.drive0=online (sd0), OK&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;Which is very useful and basic data needed for monitoring systems like Nagios.&lt;/p&gt;


	&lt;p&gt;There is a catch though, the &lt;span class="caps"&gt;IPMI&lt;/span&gt; driver is not enabled by default in OpenBSD &lt;span class="caps"&gt;GENERIC&lt;/span&gt; (at least at 4.4).  To enable it, you have two options.&lt;/p&gt;


	&lt;p&gt;At boot time, you can enable it by doing:&lt;/p&gt;


&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;&amp;gt;&amp;gt; OpenBSD BOOT 640/31744 k [1.29]&lt;tt&gt;
&lt;/tt&gt;use ? for file list, or carriage return for defaults&lt;tt&gt;
&lt;/tt&gt;use hd(1,a)/bsd to boot sd0 when sd0 is also installed&lt;tt&gt;
&lt;/tt&gt;Boot: -c&lt;tt&gt;
&lt;/tt&gt;Booting...&lt;tt&gt;
&lt;/tt&gt;=======snip=======&lt;tt&gt;
&lt;/tt&gt;User Kernel Config&lt;tt&gt;
&lt;/tt&gt;UKC&amp;gt; enable ipmi&lt;tt&gt;
&lt;/tt&gt;441 ipmi0 enabled&lt;tt&gt;
&lt;/tt&gt;UKC&amp;gt; quit&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;This will then boot normally and if everything worked, you’ll have an operational system that you can type the above commands in to query the status of your &lt;span class="caps"&gt;RAID&lt;/span&gt; set.&lt;/p&gt;


	&lt;p&gt;If it won’t start, then reboot without doing anything and it will go back to the way it was before, then contact openbsd misc with a copy of your dmesg.&lt;/p&gt;


	&lt;p&gt;If it all worked, you’ll probably want to enable this feature permanently, to do this, use the config(8) utility like so:&lt;/p&gt;


&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;# config -u -o /bsd.new -e /bsd&lt;tt&gt;
&lt;/tt&gt;(tells you about the kernel)&lt;tt&gt;
&lt;/tt&gt;Enter 'help' for information&lt;tt&gt;
&lt;/tt&gt;ukc&amp;gt; enable ipmi&lt;tt&gt;
&lt;/tt&gt;441 ipmi0 enabled&lt;tt&gt;
&lt;/tt&gt;ukc&amp;gt; quit&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;This then will produce an output file /bsd.new which is your new kernel.&lt;/p&gt;


	&lt;p&gt;To install the new kernel, do something like this:&lt;/p&gt;


&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;# cp /bsd /bsd-original &amp;amp;&amp;amp; cp -f /bsd.new /bsd&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;And then you can reboot to an &lt;span class="caps"&gt;IPMI&lt;/span&gt; enabled system.&lt;/p&gt;


	&lt;p&gt;Enjoy.&lt;/p&gt;
          &lt;img src="http://feeds.feedburner.com/~r/lindsaar-net/~4/C13Hxt_9AOg" height="1" width="1"/&gt;</content>  <feedburner:origLink>http://lindsaar.net/2008/11/1/openbsd-raid-and-temp-sensors-on-hp-proliant-dl-360-and-380-series</feedburner:origLink></entry>
  <entry xml:base="http://lindsaar.net/">
    <author>
      <name>mikel</name>
    </author>
    <id>tag:lindsaar.net,2008-09-11:1912</id>
    <published>2008-09-11T10:40:00Z</published>
    <updated>2008-09-13T01:47:28Z</updated>
    <link href="http://feedproxy.google.com/~r/lindsaar-net/~3/qt-N3O4QNWU/terminator-timeout-without-mercy" rel="alternate" type="text/html" />
    <title>Terminator - Timeout without Mercy</title>
<summary type="html">&lt;p&gt;If you have been following my posts on Ruby-Talk and Ruby on Rails and even RSpec mailing list (and who wouldn’t?!  I mean, aside from my mother) then you would have noticed I have been banging my head against a brick wall on the subject of System calls not being handled by the Timeout libraries in Ruby…&lt;/p&gt;</summary><content type="html">
            &lt;p&gt;If you have been following my posts on Ruby-Talk and Ruby on Rails and even RSpec mailing list (and who wouldn’t?!  I mean, aside from my mother) then you would have noticed I have been banging my head against a brick wall on the subject of System calls not being handled by the Timeout libraries in Ruby…&lt;/p&gt;
&lt;p&gt;I’ve done a lot of work with this.  I mean a lot.&lt;/p&gt;


	&lt;p&gt;So I thought I would share.&lt;/p&gt;


	&lt;p&gt;It all starts with a basic requirement I have, which is to replicate a data set from one side of the planet to the other.  This involves logging into a database server remotely using ActiveRecord across some encrypted VPNs, querying some tables, and then inside of a transaction, replicating down certain data on certain rows.&lt;/p&gt;


	&lt;p&gt;The solution I have works well, I can replicate about 2-5 rows per second across the link which is more than adequate (the dataset changes upto about 100 rows per minute).  The problem is that occasionally, ActiveRecord’s link to the remote database will hit a snag, then Ruby will wait, and wait, and wait to Timeout…. This can take hours, and in fact, sometimes, it never does timeout, leaving a zombie process.&lt;/p&gt;


	&lt;p&gt;To avoid multiple replication problems, I have lock files which prevent further copies of the replicator firing up if it detects that one is already running.&lt;/p&gt;


	&lt;p&gt;So, in the end, I get stuck with several replicators “running”, all hung, all waiting for a link to come back that never will, and no replication happening.  In the mean time, the rows are still changing and I am getting backlogged.  Leave it for a day and you are 80,000 rows backlogged and people start asking questions and I start looking for old travel tickets that I had ‘forgotten about’.&lt;/p&gt;


	&lt;p&gt;But why does ruby do this?&lt;/p&gt;


	&lt;p&gt;Shouldn’t the Timeout library protect us from such evilness?&lt;/p&gt;


	&lt;p&gt;Well, yes and no.  The problem is because ruby uses Green threads.  Green threads mean that there is only one real Ruby process running on the server, and it “internally” makes other “threads” that it schedules within the main ruby process’ kernel time.  Green threads are very efficient (they save a lot of context switching) but the problem is that if you get a System call that ‘blocks’, then the kernel will stop servicing your main ruby thread until your system call is complete, and &lt;span class="caps"&gt;THIS&lt;/span&gt; means that the little ‘Timeout.timeout(5) { my code }’ block you put in, will never get called…&lt;/p&gt;


	&lt;p&gt;And then you get a hang… forever.&lt;/p&gt;


	&lt;p&gt;I tried a couple of handlings, the first was the &lt;a href="http://ph7spot.com/articles/system_timer"&gt;SystemTimer&lt;/a&gt; library by Philippe Hanrigou.  This entry actually has a really good and simple example of what Green threads and blocking system calls mean. If you want to brush up, it is a good read.&lt;/p&gt;


	&lt;p&gt;But SystemTimer didn’t work.  It uses alarm signals which could have some problems.  But in my case, it didn’t work and I still got never ending timeouts.&lt;/p&gt;


	&lt;p&gt;So I asked again on the Ruby-Talk mailing list and &lt;a href="http://codeforpeople.com/"&gt;Ara T. Howard&lt;/a&gt; came back with a quick script that created little homicidal external ruby processes to kill the ruby process I was in if it didn’t “make it” in time.&lt;/p&gt;


	&lt;p&gt;The approach was actually very clever, and it works!&lt;/p&gt;


	&lt;p&gt;What he did was go “We can’t be sure that the existing Ruby process will be able to nuke itself, so instead, lets start up another Ruby instance, running on it’s own, that has the PIDs of the ruby instance that spawned it, and if the time runs out, do a system based kill &lt;span class="caps"&gt;TERM&lt;/span&gt; on the pids.”&lt;/p&gt;


	&lt;p&gt;You could say that our little ruby processes have a license to kill.  Literally.&lt;/p&gt;


	&lt;p&gt;So I implemented his idea, found a couple of problems, gave back some ideas, and he coded, I spec’d, tested and described and we released a brand new gem…&lt;/p&gt;


	&lt;h4&gt;The Terminator.&lt;/h4&gt;


	&lt;p&gt;You can get it with;&lt;/p&gt;


&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;gem install terminator&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;Or grab the &lt;a href="http://codeforpeople.com/lib/ruby/terminator"&gt;source code.&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;And how do you use it?  Simple:&lt;/p&gt;


&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;require &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;terminator&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class="co"&gt;Terminator&lt;/span&gt;.terminate &lt;span class="i"&gt;1&lt;/span&gt; &lt;span class="r"&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  sleep &lt;span class="i"&gt;2&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  puts &lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;I'll never print&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class="r"&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;This will never print because the terminator times out after 1 second, which is before the sleep of 2 seconds inside the block.  This will raise a Terminator::Error, which you could catch and try again if you want.&lt;/p&gt;


	&lt;p&gt;This will always work.  It is because we are starting a separate process of Ruby (which has some minor overhead) that waits the specified number of seconds and then just simple does a system kernel &lt;span class="caps"&gt;TERM&lt;/span&gt; on our misbehaving process.&lt;/p&gt;


	&lt;p&gt;Why should you use it?&lt;/p&gt;


	&lt;p&gt;Well, if you are making &lt;span class="caps"&gt;ANY&lt;/span&gt; calls to external web services, external databases, OpenID, Youtube, Google Maps… anything, then you should have a fail fast policy in place and time out rapidly if these fail.  As these are external system calls, they will most likely not be caught by Ruby’s timeout.rb library… and that means that your application will just hang, waiting for the call that never comes back.&lt;/p&gt;


	&lt;p&gt;It is much better to go “Ok, 2 seconds are up, no response, let’s tell the user to try again in a minute” and render an appropriate message, than have the user frustratingly whack the reload button a few hundred more times wondering why your application is not responding.&lt;/p&gt;


	&lt;p&gt;So yes, I think you should use Terminator.&lt;/p&gt;


	&lt;p&gt;Besides, how many other gems do you know that have the method ‘plot_to_kill’ ?&lt;/p&gt;


	&lt;p&gt;blogLater&lt;/p&gt;


	&lt;p&gt;Mikel&lt;/p&gt;
          &lt;img src="http://feeds.feedburner.com/~r/lindsaar-net/~4/qt-N3O4QNWU" height="1" width="1"/&gt;</content>  <feedburner:origLink>http://lindsaar.net/2008/9/11/terminator-timeout-without-mercy</feedburner:origLink></entry>
</feed>
