Tuesday, September 09, 2008

涂鸦(?)

在地址栏中敲入以下命令,页面就会变得可编辑(仅限文字,好像),是个篡改了截屏的好助手。
javascript:document.body.contentEditable='true'; document.designMode='on'; void 0

Wednesday, August 13, 2008

扩展名原来很重要

所谓世事难预料,估计我在 DreamHost 有仇家,今天我的站点突然全线瘫痪,Catalyst 始终报 500 错误。可是,站点程序又完全没有更新过,百思不得其解。Google 了一圈又一圈,抱着死马当活马医的态度,把 pl 改成了看起来更 fastcgi 的 fcgi,哎,就好了。
[razzle ~]$ cp script/myapp_fastcgi.pl script/myapp_fastcgi.fcgi
[razzle ~]$ diff .htaccess.old .htaccess
1c1
< AddHandler fastcgi-script pl
---
> AddHandler fastcgi-script fcgi
12,13c12,13
< RewriteCond %{REQUEST_URI} !^/script/myapp_fastcgi.pl
< RewriteRule ^(.*)$ script/myapp_fastcgi.pl/$1 [PT,L]
---
> RewriteCond %{REQUEST_URI} !^/script/myapp_fastcgi.fcgi
> RewriteRule ^(.*)$ script/myapp_fastcgi.fcgi/$1 [PT,L]

没想出问题所在,如果哪位大侠精通此道,还望不吝赐教。

Monday, May 05, 2008

perl 调用 localtime 的时区问题

测试用例:
{
local $ENV{TZ} = 'UTC+0';
print scalar localtime, "\n";
}
print scalar localtime, "\n";

@CentOS 4.2
Mon Sep 24 01:05:52 2007
Mon Sep 24 01:05:52 2007

@CentOS 4.4
Mon Sep 24 01:05:52 2007
Mon Sep 24 09:05:52 2007

Bug 的详情可以参考
http://rt.perl.org/rt3/Public/Bug/Display.html?id=26136
摘要:
* threaded perl calls localtime_r(3) instead of localtime(3)
* localtime(3) calls tzset(3), but localtime_r(3) does not

一些时间类的模块受此影响,比如 Date::Simple。

CentOS 4.4/ Red Hat Enterprise Linux 4 Update 4 已解决此问题,详情见 perl 的 changelog:
$ rpm -q --changelog perl
* Thu May 11 2006 Jason Vas Dias <jvdias@redhat.com> - 3:5.8.5-30.RHEL4

- fix errata testing issues:
o bug 161305 localtime_r_needs_tzset incorrectly not set on 64-bit arches
o generate perl headers correctly to avoid missing / unresolved headers

* Thu Apr 06 2006 Jason Vas Dias <jvdias@redhat.com> - 3:5.8.5-28.RHEL4

- fix bug 161305: call tzset() before localtime_r

而 perl 的 community patch 应用于 perl 5.8.8 发布之后,此后发布的新版本目前只有 perl 5.10.0。

综上,有以下数种对应解决办法:
1、如果 OS 为 CentOS 4.4 以下,使用 yum 直接升级 perl 即可。
2、其他 OS 可以查找是否有相应的 vendor patch。
3、自行编译安装禁用线程(-Uusethreads)的 perl。
4、自行编译安装 perl 5.10.0。
5、给受影响的模块打补丁,Date::Simple 的补丁这里有。

相关链接:
小心时区陷阱(一)
小心时区陷阱(二)

Sunday, May 04, 2008

Apacheのログに携帯のユーザIDを記録する

iモードIDの登場に伴って、三キャリアのユーザIDはすべてHTTPリクエストヘッダから取れるようになった。Apacheの場合、下記ような設定でユーザIDはログに記録される。
SetEnvIf X-DCMGUID    ^(.+)$ User-ID=$1
SetEnvIf X-UP-SUBNO ^(.+)$ User-ID=$1
SetEnvIf X-JPHONE-UID ^(.+)$ User-ID=$1
CustomLog "logs/access_log" "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" \"%{User-ID}e\""