Sunday, January 10, 2010

MacRuby now supports non-ASCII string in regular expressions

MacRuby には僕ら日本人にとって信じがたい、日本語(というかASCII以外)を含む文字列に対して正規表現が使えないという問題がありましたが、先日、修正されたようです。まだ試してませんが。

0.4 のコードベースのときに、日本人としてなんとかしないとと思い、修正しようとして挫折しましたが、r3189 changeset を見ると意外と差分が少ないですね。

MacRuby が Mac OS X 10.7 のシステムの一部として利用できるようになれば、重たい MacRuby.framework をアプリケーションに含めずにリリースできるようになることを期待しています。

最近、ブログ書くのが億劫になってましたが、 ソフトウェアの i18n に関心がある身としてちょっと嬉しかったので...。

Sunday, November 8, 2009

Google's OAuth doesn't seem to support wave as a scope yet?

After releasing Unofficial Google Wave Notifier, many people have claimed it may steal gogle password.
They are right. you should not trust me nor the app. From beginning I know the issue, I'm sorry, but I'v neglected the security concern as I hasten to release the app.
(A poor execuse to prove my innocence. I open the source. Suspicious users should review the source and build a binary from reviwed source.)

Current version (0.4) of the app uses ClientLogin for Installed Applications for authentication. In the process, apps handles passwords immediatly.

By contrast with ClientLogin, apps which uses OAuth for Installed Application handles oauth tokens instead of precisous passwords.

It is obvious that I should choose OAuth. However I can't get it so far. At OAuth Playground, I tried to get oauth_token. The paramerters I specified are:
scope: https://wave.google.com/wave/
oauth_signature_method: HMAC-SHA1
oauth_consumer_key: anonymous
consumer secret: anonymous
And the response is:
Invalid scope: https://wave.google.com/wave/


By choosing other scope, I can get a oauth_toke.... I missed something? or Google doesn' support wave as a oauth scope (yet)?

Tuesday, November 3, 2009

Unofficial Google Wave Notifier for mac 0.4 and the notification wave



I'v just released version 0.4 of Unofficail Google Wave Notifier for mac.
Also, if you wanna be notified about new releases, join The "unoffical google wave notifier for mac" notification wave.

CHANGELOG
* Open a specific wave immediately by clicking a wave in the menu
* Display "Checked N min ago" biside "Check Now" like "Google Notifier"

Friday, October 23, 2009

Queuing ruby background processes with Ernie and BERT-RPC

僕のようにインフラ系が弱い Rails プログラマにとっては、 GitHub のインフラ担当? Tom Preston-Werner (aka mojombo) の GitHub ブログポスト How We Made GitHub Fast - GitHub は非常に参考になります。なかでも興味を引いたのは続くポスト Introducing BERT and BERT-RPC で紹介されている BERT-RPC とその実装の Ernie ですね。

過去には Rails アプリケーションのバックグラウンド処理で苦労した思い出があるので今度ツールを選ぶときは以下の課題を解決してくれるやつがほしいなと思ってました。
1. 重たい処理が連続してリクエストされたときに並列で実行せずに1タスクごとキューイングして実行してほしい
2. worker が死んでも自動で代わりを起動してほしい
3. 非同期も同期(終了するまでブロック)も両方OK

1 は Ernie の -n オプションで同時実行される handler の数は制限できるので -n 1 にすれば queue になるはず。

2 は BERT-RPC は call (同期), cast (非同期), info (コールバック情報などの送付) 3つの request が定義されていて、 ernie (v0.1) では call と cast の両方をサポートしているので同期/非同期両方OK。

3 はうろ覚えだけど Erlang でふつうにサーバーを実装すれば wroker (handler) の再起動とかはかってにやってくれるはず。実際に handler の ruby プロセスを kill してもすぐ代わりが起動するので大丈夫そうだ。

実際に queue になるか試してみた。 erlang ernie をインストール、簡単な handler を書いて、サーバーを handler 1つで起動。

$ sudo port install erlang +ssl # 時間かかります
...
$ sudo gem install ernie -s http://gemcutter.org

$ cat > sleep.rb
require 'rubygems'
require 'ernie'
mod(:sleep) do
fun(:wait) do |idx, sec|
sleep sec
print "#{idx}: awake from #{sec} sec.\r\n"
end
end
^d

$ ernie -p 9999 -n 1 -h sleep.rb
erl -boot start_sasl -detached +Bc +K true -smp enable -pz /Library/Ruby/Gems/1.8/gems/ernie-1.0.0/bin/../ebin \
-ernie_server_app port 9999 -ernie_server_app handler '"sleep.rb"' -ernie_server_app number 10 -ernie_server_app log_level 2 -run ernie_server_app boot
...

別 shell の irb で 2秒スリープ指定 で 10回 cast。

$ irb -r bertrpc
>> svc = BERTRPC::Service.new('localhost', 9999)
=> #
>> 10.times{|i| svc.cast.sleep.wait(i, 2) }
=> 10

$ ernie を実行した erlang shell では

0: awake from 2 sec.
1: awake from 2 sec.
2: awake from 2 sec.
3: awake from 2 sec.
4: awake from 2 sec.
5: awake from 2 sec.
6: awake from 2 sec.
7: awake from 2 sec.
8: awake from 2 sec.
9: awake from 2 sec.

実際に見てると2秒ごとに出力されていたので、ちゃんと queuing されてますね。

Sunday, October 18, 2009

Unofficial Google Wave Notifier for mac

2009-11-17: If you have any idea, feel free to issue a feature request, or vote them (the small triangle at bottom-left corner of a item)
2009-11-3: version 0.4 released



I wolud like to know whether I have unread messages at Google Wave or not, like Google Notifier for Mac for GMail and Google Calendar. I could find Google Wave Add-on for Firefox at That Smith. So I implemented one as referencing the add-on. Thank you Chad at That Smith.

You can download it form Downloads for hiroshi's Unofficial-Google-Wave-Notifier - GitHub. Before download it, be sure that is makes NO WARRANTY.

Google Wave の新着通知も Google Notifier for Mac のように通知されたいのですが、探しても Google Wave Add-on for Firefox at That Smith しか見つからなかったので、その Add-on のソースを参考にして作ってみました。

Downloads for hiroshi's Unofficial-Google-Wave-Notifier - GitHub からダウンロードできます。

Tuesday, September 1, 2009

routes_cov to reveal untested actions


I'v released a new rails plugin, routes_cov. This plugin tells you whether untested controller action there or not against routes. I'll be happy if you think it it useful.

routes_cov というRailsプラグインを作ってみました。テストで実際に実行されたアクションと routes (rake routes で表示されるやつ) を比較してテストされてないアクションを列挙します。まだまだ改善の余地はありますが、使ってみて下さい。



$ rake test:functionals
....
Finished in 13.932317 seconds.

121 tests, 307 assertions, 0 failures, 0 errors

There are unperformed actions here:
groups#index
groups#show
users#member
...

Monday, August 17, 2009

port install subversion+unicode_path

git-svn を試してみようと思って macports で git-core +svn をインストールするときに、何気に subversion port の info を見たら unicode_path という variant があるじゃないですか。
パッチファイルのコードを見るとなんだか見覚えがあります。
例の subversion の issue のコメント (by Philip Kime)を見るとやっぱり僕のパッチがもとになってるようです。

というわけで、前回の記事で紹介した方法のように面倒なことしなくても、

$ sudo port install subversion +unicode_path

で OK です。MacPorts 万歳。

ちなみに、 +unicode_path のパッチファイルは以下のパスにあるハズです。

/opt/local/var/macports/sources/rsync.macports.org/release/ports/devel/subversion/files/patch-path.c.diff

ソースコードコメントのインチキな英語もそのままだ...。