Monday, July 31, 2006

mozilla url('') bug

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 吧。
Friday, July 28, 2006

Zorpia.cn

Zorpia 启动了 http://www.zorpia.cn/ Zorpia 中文版
可以存无限制的图片。或许你会感兴趣。:)

subversion on google

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

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

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

I'm not alone

"I'm feeling hot, no hug please".
Friday, July 14, 2006

cross-domain "ajax" by On-Demand Javascript

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 代码中直接写能避免不同步的问题。

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

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

用 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.
Saturday, July 08, 2006

DBIx-Class sucks sometimes

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.)
Wednesday, July 05, 2006

Ajax IE cache

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
就可以了。
Saturday, July 01, 2006

keep learning

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.