mozilla url('') bug

31 July 2006


try something like:
background-image:url('')
in mozilla Firefox.

that would make your browser visit the page twice.

Firefox 好象就是有这样的 bug, 对于 url('') 这样会再访问一次该页面。mm, 看 access_log 就会知道了。

这应该算个 Mozilla 的 bug 吧。

subversion on google

28 July 2006


我以前去 sf.net 申请过 project, 不过被拒绝的。

目前 google 推出了 code.google, 去申请了下,一下子就通过了。
把自己的几个 CPAN 模块弄上去了。放在自己电脑里也不算太安全,万一哪天机子崩溃了咋办。硬盘完蛋了咋办。Google 还是比较值得信任的。

我的项目地址:http://code.google.com/p/fayland/
目前就几个 CPAN modules, 有空把 Eplanet 和 Foorum 都弄上去。
当然有些代码涉及到保密,我就不整上去了。

cross-domain "ajax" by On-Demand Javascript

14 July 2006


Ajax 不能调用跨域名的脚本,mm, XML.com 介绍了三种解决方案,两种 proxy 方案,比较容易设置。另一种就是 On-Demand Javascript 方案。

On-Demand Javascript 讲起来比较简单,但是写起来比较复杂。
简单的讲是,在当前的 page 里用 javascript 制造一个 script 标签,然后给一个 src (可以是 cross-domain 的)。然后在这个远程的 src 地址中输出 text/javascript 的东西。比如定义 var response = 'test'; 什么的。最后在 page 的 div 里显示这个 var respose
在 XML 的 Fixing AJAX: XMLHttpRequest Considered Harmful 中给出的例子里,在 Firefox 我测试的时候是有点错误的:
    if (BROWSER_IS_IE) {
if (oScript.readyState == "loaded") {
eval(callback);
oScript.onreadystatechange = null;
} else {
oScript.onreadystatechange = CheckAgain;
}
// All other web browsers just do the callback function
} else {
eval(callback);
}
这里的 eval(callback) 要调用 src 文件传来的变量如 var response, 但问题是这个 src 传递的很慢(服务端的程序总比客户端的慢)时,Firefox 会报错,response not defined 这样的错误。然后过一会儿传过来了就不会错了。 IE 上因为用了 if (oScript.readyState == "loaded") 这样在确定了 script 被载入后才 eval(callback) 就不会出错了。

我解决的方案是在这个 src 的文件中,比如 perl 文件中写点类似 $('divname').innerHTML = $result_value_from_perl;这样的 javascript 代码,而不用定义一个 var response 然后用 javascript 更新 divname.innerHTML. 在 Perl 代码中直接写能避免不同步的问题。

好象说的比较乱。但目前人的状态也很乱。整天忙得不得了。

Fetch mail by Net::POP3, parser mail by MIME::Parser

11 July 2006


用 Net::POP3 去读 mail, 然后用 MIME::Parser 去解析邮件内容。这样是绝佳组合。
比如任务是根据 mail 过来的 sender 来建立一个档案库或者根据 subject 来建立一个档案库。这样的东西当然可以用 Thunderbird 或 Outlook 的 filter 来搞定。但是 Perl 也是可以的。
如果再加上 CPAN 一大堆可以用 STMP 来发送邮件的模块,我们就能写个脚本来完成普通的收件和发件功能。

应该说网络上发送邮件的资料很多,而且模块也很多,但是收取的比较少。我自己写了一点,发现用 MIME::Parser 解析的时候看 doc 看的比较乱。就 Google 了一下,找到了一篇绝妙的文章和代码:Saving Only POP3 Email Attachments
这是 Spidering Hacks 里面的一小 hack, 那本书里用了很多 Perl modules 去 hack 网络资料。很值得一看。

PS, I'm back home. Thank God.

DBIx-Class sucks sometimes

08 July 2006


mmmm, I just convert one complex SQL sentence into DBIx-Class like, but it doesn't work at all. I ask the maillist around, the answer is no way.

see http://lists.rawmode.org/pipermail/dbix-class/2006-July/001894.html for more details.

I think I should use ->storage->dbh instead. mmm, I should do the pager myself.(I like the built-in pager in DBIx-Class a lot.)

Ajax IE cache

05 July 2006


IE 总是会 cache 不是 method='post' 的 url, 即便是以 cgi 结尾的。
今天做 Ajax.Request 的时候就发现 Firefox 都是很正常,IE 就是有 cache 的问题。
当然,解决的方法很简单。设置 cgi 的 header 为马上 expires, no-cache 的那种。

PS, modperl 的情况下直接用 print CGI->header 的时候可能会出现这样的错误:
Can't call method "send_cgi_header" on an undefined value at
很简单的改为
my $q = CGI->new;
print $q->header
就可以了。

keep learning

01 July 2006


It has been a long time since I posted my last blog. but I have never forget to keep learning though I don't have much time to have a rest. The day work is so busy.
Things changed a lot. I'll be lost if I don't keep abreast of the latest developments.

Catalyst is divided into Catalyst::Devel and Catalyst::Runtime. Catalyst::Runtime will not require some hard-to-install dependency modules. and the new Catalyst has some new attributes like PathPart('hello') Chained('/') CaptureArgs(1) like. u should try Catalyst::Runtime then. :)

DBIx::Class is updated too. I think I should learn to write a case of some new modules like Object::Accessor maybe I can use it to fake a dbix-class record. Man, I need that.

PS, mr.Jojo write a new simple httpd server based on POE named cAmel. It seems nice. I want to learn POE for a long time (I planned it in the beginning of this year).

PS2, joe will host a perl meeting at shanghai. cnhackTNT will be there. a pity that I cann't go since I'm in Zhengzhou now. I'm planning to be back RuiAn next week.

xinha rocks

19 June 2006


ya, tiny_mce sucks, fckeditor sucks. they chomp the flash param when we insert an flash object.

but xinha rocks.
when u need to pick up one html editor. I suggest u have a try of xinha.

and try a demo at http://www.zorpia.com/cgi/myjournals.cgi?action=new_journal

graduate from ZJUT

15 June 2006


After the commencement at 6.18, I'll be graduated from ZJUT.
It's sad to separate from my lovely classmate.

but it's happy to see my girl within 4 days. I miss her very much.

God bless us.

DBIx::Class + TT sucks, javascript sucks

07 June 2006


DBIx::Class ++ TT sucks.

ok, assuming that we get a record like this:
my $topic = $c->model('DBIC')->resultset('Topic')->search( { topic_id => $topic_id } )->first;
$topic->{post_on} = &format_date($topic->post_on);
now TT has two [% topic.post_on %], one is $topic->{post_on}, another one is $topic->post_on.
TT will fetch the "$topic->post_on" but ingore the $topic->{post_on}.
if we need TT fetch the "$topic->{post_on}", we have two ways:
1. $topic->{_column_data}->{post_on} = &format_date($topic->post_on);
2. $topic->{post_on_date} = &format_date($topic->post_on); [% topic.post_on_date %]

javascript sucks.

IE will complain at:
var myAjax = new Ajax.Request( url, {
method: 'get',
parameters: pars,
onSuccess: showCityResponse,
onFailure: reportCityError,
} );

but Firefox will not.
The reason is "onFailure: reportCityError," chomp the last ","
"onFailure: reportCityError" will work.

It's hard to debug under IE, and Firefox has "FireBug". Thank God.