88171.net


💭

いくらコマンドライン教徒といえども、毎度毎度サーバにログインして書くのも面倒なので、例によってメールでpostするためのスクリプトemail2blosxomを書いてみた。

まぁ全体的に自分向けに書き捨てた感じなので、もし使う場合はうまいこといじくり回してください。

以下、perldoc email2blosxom から。

NAME
       email2blosxom - A MIME message to individual file(s) converter

SYNOPSIS
       email2blosxom < mailfile

DESCRIPTION
       email2blosxom parses MIME message and splits into individual file(s).  As its name
       suggests, it's been intended to post new article for blosxom
       <http://blosxom.sourceforge.net/>.  However, it simplly behaves as, to say, MIME splitter.

CONFIGURATION
   DATA
       This script contains text template in itself, after the "__DATA__" token, in Template
       Toolkit format.  Substitutable variables are:

       title
           title text (expanded from e-mail subject)

       body
           body text (expanded from e-mail body)

       picts
           array of pictures (may be empty if no picture attached)

       pict.name
           file name of a picture

       pict.alt
           file name of a picture (identical with "pict.name", but you can overwrite by
           $cleanup_text, if you want)

   $output_file
       Points where to put text file into.  If you want some complex naming (i.e. include current
       date in file name), you can set this variable calling anonymous subroutine.

           our $output_file = &{sub{
               ... do something ...
               return $filename;
           }};

       If the file (or something) already exists, incremental number (like
       /some/path/basename-N.suffix) is automatically added.

   $picture_directory
       Points where to put attached picture(s) into.

       The original file name (included in MIME header) will be respected, but when the file
       already exists, will be treated in the same way as $output_file.

   $cleanup_text
       Reference to subroutine to be called just before writing new text file, to cleanup (i.e.
       escaping) text.

       This subroutine will be passed a hash reference.

           $ref = {
               'title' => title text,
               'body'  => body text,
               'picts' => [
                           {
                            name => file name of 1st picture,
                            alt  => identical with name,
                           },
                           .....
               ],
           };

   umask(XXXX)
       You may want set umask, especially when directories to put files into are shared by other
       users.

KNOWN BUGS
       ·   This script itself doesn't have any authentication mechanism (and I have no plan to
           implement.)

           You MUST filter e-mails using other programs, like procmail, before passing to this
           script.

       ·   This script sees 1st MIME part as text, and other parts (if exist) as attachments.  I
           know thant fixing this wouldn't be a hard work.  But because this behaviour seems to
           be OK in practical use, I won't fix it ;-)

AUTHOR
       ohkawa <http://88171.net/>

LICENSE
       This software is distributed under CC BY 3.0 license.

       <https://creativecommons.org/licenses/by/3.0/>

TokyoPromenadeとblosxomの性能比較

Muninのグラフを眺めてたら、なかなか興味深い事実に気づいた。 http_loadtime プラグインの出力から各フェーズ任意の5日間を選び、 期間中の平均値を調べた結果、

  1. Tokyo Promenade CGI版: 31.24 ms/req
  2. FastCGI化: 26.27 ms/req
  3. Google Code Prettifyをローカルに: 11.13ms/req
  4. blosxomに入れ替え後: 319.68 ms/req

笑えるくらいにTokyoPromenadeが爆速。 ちなみに http_loadtime プラグインは wget -p を叩いているので、 外部リソースのレスポンスも絡んでくる。その点で3と4はほぼ同一条件なので、 Tokyo Promenade (FastCGI版) はblosxomの28.7倍速い という結論になる。

体感で速い速いとは思ってたけど、これほどだったとはなぁ。


blosxom Disqusプラグイン

探してはみたものの(主にspam対策的な意味で)良さげなコメントプラグインが見つからず、でも一応コメント欄くらいは付けとくかなと思って、Disqus用のプラグインを書いたFacebookのComments Boxも考えたんだけど、あんまりFacebookにロックインされるのもどうかなぁ、と。

いや、でもコメント欄を外出しにするなんて、昔は考えてもみなかったけどね。 時代は変わりますわ。