Archive for the ‘Study’ Category

Rejaw Shout Client in Japanese for beginners

Saturday, September 6th, 2008

Rejaw 企画第2弾 Rejaw Shout Client 「れじゃぅ〜」を作ってみました。

勉強のために今回設定した目標は、
1.Plurkのように個別Shoutもページ内に表示(Ajax処理)。
2.HahloやiPhone.FacebookのようにiUIを使ったiPhone UI。

作ってて今までポイントになった部分をちょっとだけ紹介。
1.ログイン画面も含めて全て1 HTMLで行っているので、ログイン情報がブラウザに保存されない場合がある。(実際のSubmit時に保存ダイアログが表示されるらしい)ので、Safari(iPhoneを含む)の場合、Structured client-side storage を使ってログイン情報を端末側に保存することにした。
JavaScript++かも日記: 【iPhone】iPhone用 JavaScriptデータベースプログラミング入門 (1)
http://jsgt.org/mt/archives/01/002154.html

2.iPhone では CSS の position: fixed; が使えないらしいので、逐次固定位置に戻す処理を追加した。
iPhone向けサイトを考える
http://blog.livedoor.jp/hayashi311/

3.Comet の JSONP を FireFoxで使った場合、そのリクエストがレスポンスするまで、他の JSONP をブロックしてしまうので、Comet の JSONP だけ、GreaseMonkey の GM_xmlhttpRequest を使うように、UserScript を用意した。(かなり裏技。)

4.Webkit ベースの Chrome でも動くらしい。

5.ちょっとテキストだけだと寂しかったので、Plurk のように絵文字を入れるための UserSciript を提供してみた。(画像のロードがちょっと重い。。。)

まだやってないこと、
1.表示件数/全件数の表示
(これはもっと早くに実装すべき!忘れてたw)

というわけで、
「れじゃぅ〜」デビュー
http://yungsang.com/rejaw/i/

FireFox 用 Observe UserScript
http://yungsang.com/rejaw/i/observe.user.js

絵文字用 UserScript
http://yungsang.com/rejaw/i/smile.user.js

っつーことで、どっすか?

PS:
今回は何故か思いつきでひらがなにしてみました。
意味無く、小学校1年生でも、日本語を勉強し始めた外国人にも、優しい作りになってますw

Whisperとか他の機能が欲しい人は、もうすぐ出るオフィシャルの iPhone App を待ちましょう。

Rejaw Shout Bookmarklet

Saturday, August 9th, 2008

Rejaw.com 用の bookmarklet を作った。

Shout on Rejaw

Updated: 2008/08/10
JPG, GIF, PNG, MP3, FLV, Youtube URL and GoogleVideo URLはコンテンツの先頭に無いと反応しないため、URLが先頭になるように変更した。

Updated: 2008/08/11
各行の先頭にあればいいということがわかったので、再修正。タイトルとURLの間に改行を入れた。
(先頭でなくても反応するように本体が修正された。)

Timelined Twitter Search

Thursday, July 17th, 2008

TwitterSummize を買収し公式検索として発表されましたね。

Summize は、日本語に弱い面もありますが、高速で安定していて私は好きですね。

それを記念して、というか、Timeline ライブラリの勉強の為に、検索結果をタイムライン上に配置するツールを作ってみました。

これを使うと、キーワードがいつ話題になったのかが直感的、視覚的にわかります。

http://yungsang.com/timeline/twitter/?q=モナ&zoom=6

(表示件数が多かったり少ないときは Zoom 機能を使って調節出来ます。)

また Google Maps みたいにぐりぐり動かせるのも面白いです。

さらに、Summize でおなじみの強力な検索オペレータも使えば、いろいろな検索が過去に遡って出来ます。

http://yungsang.com/timeline/twitter/?q=from:yungsang+OR+to:yungsang+OR+yungsang

使い方は簡単。
キーワードを入力して、Search ボタンをクリックするだけ。
More ボタンをクリックする毎に20件ずつ追加していきます。

では〜。

(more…)

What I did on the Plurk

Tuesday, July 8th, 2008

I just got an email from Amir of Plurk Inc. this morning.

He says;
> We have been informed that you plurked as another user:
> http://www.plurk.com/user/(censored by me)

This is not the truth.
(She is who added me as a friend on Plurk yesterday.)

I responded;
> She just clicked the following link.
> http://www.plurk.com/TimeLine/addPlurk?qualifier=says&content=キタコレ

This is one of Plurk’s APIs to plurk and not hacking.
I explained it right after her clicking, but she didn’t understand.

This is the story.
That’s it.

I apologize to all plurkers for this issue.

Update: 2008/07/08 20:45 PDT
Also it is not related with my userscirpts.
They are still there.

Update: 2008/07/12
Absolutely my bookmarklet for Plurk was harmless as well.
But the old one doesn’t work any more, because of the Plurk API Update.
I released a patch for the bookmarklet to my friends only.

Patch up a Currency Format of Magento and Zend Framework for JPY

Saturday, June 28th, 2008

DesignWalker の管理人さんから依頼がありまして、Magento というECサイト構築エンジンで「ロケールを日本にしても価格表示に小数点以下が表示される」という問題にパッチを当てました。

Magento って全く知りませんで、中身を見るとどうやら Zend フレームワークを使っているご様子。こっちも初めてでいろいろ複雑です。

結局 Magento の問題というよりは Zend 側の Currency クラスに問題がありました。

1.ロケール情報XMLファイルの currencyFormat に小数点が含まれていました。
2.ところが、実際の表示には currencyFormat が使われていません。

つーことで、1.を修正しつつ、2.に対応するためのパッチを当てるはめに。

とりあえずの応急処置ですが晒しときます。
本格的にやるにはちょっと時間がかかりそうなのでこの辺でw

/lib/Zend/Locale/Data/ja.xml

<currencyFormats>
  <currencyFormatLength>
       <currencyFormat>
      <pattern>¤#,##0.00</pattern>
    </currencyFormat>
  </currencyFormatLength>
</currencyFormats>

/lib/Zend/Currency.php

protected function _updateFormat()
{
    $locale = empty($this->_options['format']) ? $this->_locale : $this->_options['format'];

    //getting the format information of the currency
    $format = Zend_Locale_Data::getContent($locale, ‘currencynumber’);

    iconv_set_encoding(’internal_encoding’, ‘UTF-8′);
    if (iconv_strpos($format, ‘;’)) {
        $format = iconv_substr($format, 0, iconv_strpos($format, ‘;’));
    }

    // Patched a currency format for JPY by YungSang
    if (!strpos($format, ‘.’)) {
        $this->_options['precision'] = 0;
    }

    //knowing the sign positioning information
    if (iconv_strpos($format, ‘¤’) == 0) {
        $position = self::LEFT;
    } else if (iconv_strpos($format, ‘¤’) == iconv_strlen($format)-1) {
        $position = self::RIGHT;
    }

    return $position;
}