2007-04-25

在Firefox下阅读chm文件

Firefox借助插件chm reader可以打开chm格式的文件。这个插件以前的版本还只支持Linux下的Firefox,不过现在的版本已经支持Windows下运行的Firefox了。不少chm文件都不提供放大或缩小字体的功能。要修改chm中字体的大小必须借助修改IE中的字体大小来完成,更为麻烦的是修改完IE中的字体大小后还必须关掉chm文件重新打开chm文件才能生效。现在有了chm reader方便多了。

2007-04-24

vim 中常用删除

供查看方便:

删除第3-18行
:3,18d

删除行首空白
:%s=^\s*==

此处用 \s 匹配空白。 

删除行尾空白
:%s= *$==

匹配首尾空白字符的正则表达式:^\s*|\s*$

删除行首和行尾的空白:
:%s=^\s*|\s*$==

2007-04-20

保存pdf文件

今天用Adobe Acrobat 7.0打开了一个关于XPath的ebook,并做了简单的修改。原文档拒绝保存修改,试着另存为一个PDF文件。保存后文件的大小显著减小,从原来的57.560.207 Bytes到现在的5.995.126 Bytes。保存中曾有显示程序消除了一些冗余的图像,我想这应该是文件体积减小的主要原因。

保存Tomcat的访问日志记录

Tomcat的访问日志默认时关闭的,要打开访问日志记录只需修改conf/server.xml文件,去掉下面一段的注释:

<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="localhost_access_log." suffix=".txt"
pattern="common" resolveHosts="false"/>

2007-04-19

PuTTYcyg

PuTTYcyg 是一个Putty的patch版本,搭配cygwin才能使用,能提供一个命令行页面。用惯了putty,总觉得cygwin的界面不习惯。连接本地的cygwin时,只需在connection type中选择cygterm,在主机名填入短横线 - ,然后存成一个session,如cygwinterm就可以了。做一快捷方式,建立一个cygwinterm.bat文件,包含:

c:\puttycyg.exe -load cygwinterm

2007-04-18

修正gvim的右键菜单

我在家里的电脑上安装的gvim 7.0有edit with gvim的右键菜单,在办公室里的电脑上安装了同样的文件,却找不到这样右键菜单,虽然能用,但是总觉缺点什么。两台机器都是同样的操作系统和同样的补丁,只是办公室电脑是通过clone的方式安装的,因此估计在注册表上有问题。于是从家里电脑里导出了有关gvim的键值,再导入到另一台机器上,右键菜单就有了。

附上注册表的文件:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Vim]

[HKEY_LOCAL_MACHINE\SOFTWARE\Vim\Gvim]
"path"="D:\\Programme\\Vim\\vim70\\gvim.exe"

[HKEY_CLASSES_ROOT\Applications\gvim.exe]

[HKEY_CLASSES_ROOT\Applications\gvim.exe\shell]

[HKEY_CLASSES_ROOT\Applications\gvim.exe\shell\edit]

[HKEY_CLASSES_ROOT\Applications\gvim.exe\shell\edit\command]
@="D:\\Programme\\Vim\\vim70\\gvim.exe \"%1\""

[HKEY_CLASSES_ROOT\CLSID\{0F0BFAE1-4C90-11D1-82D7-0004AC368519}]
@="Vim"

[HKEY_CLASSES_ROOT\CLSID\{0F0BFAE1-4C90-11D1-82D7-0004AC368519}\LocalServer32]
@="D:\\Programme\\Vim\\vim70\\gvim.exe"

[HKEY_CLASSES_ROOT\CLSID\{0F0BFAE1-4C90-11D1-82D7-0004AC368519}\ProgID]
@="Vim.Application.1"

[HKEY_CLASSES_ROOT\CLSID\{0F0BFAE1-4C90-11D1-82D7-0004AC368519}\TypeLib]
@="{0F0BFAE0-4C90-11D1-82D7-0004AC368519}"

[HKEY_CLASSES_ROOT\CLSID\{0F0BFAE1-4C90-11D1-82D7-0004AC368519}\VersionIndependentProgID]
@="Vim.Application"

[HKEY_CLASSES_ROOT\CLSID\{51EEE242-AD87-11d3-9C1E-0090278BBD99}]

[HKEY_CLASSES_ROOT\CLSID\{51EEE242-AD87-11d3-9C1E-0090278BBD99}\InProcServer32]
@="D:\\Programme\\Vim\\vim70\\gvimext.dll"
"ThreadingModel"="Apartment"

2007-04-15

禁止Firefox窗口被改变大小

浏览有些网页时,有些脚本会改变浏览器的窗口大小,很是烦人。通过下面的设置可以禁止窗口大小被改变:

Here is how to prevent sites from resizing your Firefox window…

1. Open Firefox, Preferences (or if you’re on Windows…Tools, Options)

2. Go to the Content Tab

3. To the right of “Enable Javascript” hit “Advanced…”.

4. Uncheck “Move or Resize Existing Windows”

2007-04-12

在windows下使用GnuPGP签名邮件

在Windows下,以Thuderbird作为邮件客户端:
下载GnuPG 1.4.7二进制文件和Thuderbird的插件Enigmail

  1. 安装上面的两个文件,并把安装后的GnuPG目录添加到路径变量中。

  2. 测试gpg安装是否成功:

  3. C:\Dokumente und Einstellungen\jia>gpg --version gpg (GnuPG) 1.4.7
    Copyright (C) 2006 Free Software Foundation, Inc.
    This program comes with ABSOLUTELY NO WARRANTY.
    This is free software, and you are welcome to redistribute it
    under certain conditions. See the file COPYING for details.

    Home: C:/Dokumente und Einstellungen/jia/Anwendungsdaten/gnupg
    Supported algorithms:
    Pubkey: RSA, RSA-E, RSA-S, ELG-E, DSA
    Cipher: 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH
    Hash: MD5, SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
    Compression: Uncompressed, ZIP, ZLIB, BZIP2

  4. 运行OpenPGP Key Management向导,生成一对Key,并提交到Key Server。


详细步骤参见:http://enigmail.mozdev.org/gpgconf.html#install

注释JMS block

把cocoon作为一个webapp分发在Tomcat下,如果在启动Tomcat时出现警告提示:


WARN! *** JMS block is installed but jms client library not found. ***
- For the jms block to work you must install and start a JMS server and place the client jar in WEB-INF/lib.
- The default server, OpenJMS is configured in cocoon.xconf but is not bundled with Cocoon.

解决办法:
在xcoocon.conf文件里注释掉关于jms-connection-manager的配置内容即可:
<jms-connection-manager logger="core.jms">
...
</jms-connection-manager>

在Tomcat 5.5下使用APR

在windwos下启动Tomcat 5.5下时,命令行窗口会提示:

INFO: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: D:\jdk1.5\bin;.;C:\WINDOWS\system32; ...

为了提高Tomcat的性能,应让Tomcat使用APR,Apache Portble Runtime。具体信息参见http://tomcat.apache.org/tomcat-5.5-doc/apr.html

在windows安装方法:下载编译好的dll文件,tcnative-1.dll,把它复制到%SystemRoot%\system32目录下即可。 

解决无法复制aurorun.inf文件的问题

不止一次赶上这样的情况了,无法把autorun.inf文件从本地硬盘上的一个文件夹复制到映射的网络硬盘上,但却可以复制到本地硬盘的另一个文件夹下。复制时,得到错误提示:
access denied。
请确保磁盘没有满,也没有写保护,或文件当前没有被使用。

网上搜索的结果表明,这是由McAfee的访问保护机制引起的。在McAfee的访问保护下有个文件,共享和文件夹保护选项,下面有个选项:
prevent remote creation of autorun.inf files

如果这个选项被选中,就会出现无法复制到远程机器的问题。

利用鼠标放大和缩小文字

现在有不少程序都支持利用鼠标放大和缩小文字,只要在摁住control键时,转动鼠标滑轮就可以了。我知道的最早支持这个特性的是Firefox,随后发现IE 7和Opera 9都有这个功能了。可是这个功能在Firefox下和在IE/Opera下略有差别:在Firefox下,滑轮往下转,文字变大,而在IE/Opera下刚好相反,滑轮往下转,字号变小。此外在Opera下,轻轻转动一下,文字就会变的很大或很小,感觉不够细腻。

另外新版本的XMLSPY 2007也支持这个功能。这样在编辑器查看文件时,可以很方便的调整字号了,而不用进到菜单里去调整显示字号大小。

2007-04-11

奥组委的网页

今天在msn上看到以前的一个同学留言,说ZDF找地服人员。顺道看了一下第29届奥林匹克运动会组织委员会的网页,http://www.beijing2008.cn ,提供中文,英文和法文版。英文和法文根本就没有点进去。按理说这么重要的赛事,应该弄个制作精良的网页出来。不说精美至少也多少符合web标准吧,可是扫一眼代码,满眼的<table> <tr><td>。不用说也知道这是什么水平了。我相信,国内能做出比这个网页好上百倍的网页的个人,公司和机构的实体有的是。可是组委会的人多半是不懂这些的,也没有第三方的资讯机构。这样相关的负责人一句话就随便圈定某个人来做。于是大家就看到了这么糟糕的网页,只能贻笑大方。

Firefox扩展:LiveHttpHeaders

Firefox数目众多,功能丰富的扩展真好。今天测试联邦档案馆会议记录的搜索功能时多亏有了LiveHttpheaders才发现我的问题在于提交request时,header里没有包括jessionid这个变量,所以搜索的结果分页问题不能解决。

另外在Tomcat的邮件列表中名为Christ写了一段很好的关于在搜索中使用jsessionid的问题:
> Is there anyway to create JSessionIDs per window rather than per browser?
> I am having the problem of when you open multiple tabs within
> a browser, and enter two simultaneous queries, the results returned are
> corrupted. Any suggestions? Thanks for the help.

I have an application that allows the user to perform searches and paginate through the results. Since the search really only needs to be performed once, pagination can be as simple as picking a segment of the results (stored in the session) and displayed on the screen.

I store the query that was performed as well as a "token" which is generated when the query is created. I place this token in all of the URLs on the page (most importantly, the ones involved with pagination).
If a request comes into the server including a token, I check the token against what I have in the session. If the tokens match, I skip the search. If they do not match, I re-run the search and re-set the token. Rinse, repeat.

In your case, you might want multiple simultaneous paginating queries, though I'm not exactly sure why. You could adopt a similar approach using a List of queries (using the same session key, I would imagine),
each with separate tokens for the windows.

The only problem with an implementation like this is that it is very hard to decide when you are "finished" with a query, and that it's okay to purge it from the session. That is left as an exercise for the reader
;)

Hope that helps,
-chris

2007-04-10

Dremaweaver 8的bug?

今天使用Dreamweaver 8.02时发现一个奇怪的问题。我用它打开一个XML文件,其中的元素名大多是HTML里的元素。文件里的元素名本身小写的,但是用Dreamweaver 8.02打开时,在编辑器里除了第一行XML声明和第二行文件类型声明外,其他行中的元素名全都显示为大写。不光是显示成大写,只要在Dreamweaver下保存这个文件,这些标签名就真正的变为大写。类似这样:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<HTML LANG="de">
<HEAD>
<TITLE>"Suche"</TITLE>
<LINK href="./skin/KaPr_basis_structure.css" REL="stylesheet" TYPE="text/css"/>
<LINK href="./skin/KaPr_top.css" REL="stylesheet" TYPE="text/css"/>
<LINK href="./skin/KaPr_header_footer.css" REL="stylesheet" TYPE="text/css"/>
<LINK href="./skin/KaPr_left_menue.css" REL="stylesheet" TYPE="text/css"/>
<LINK href="./skin/KaPr_left_suchformular.css" REL="stylesheet" TYPE="text/css"/>
<LINK href="./skin/KaPr_left_funktionsunterscheidung.css" REL="stylesheet" TYPE="text/css"/>
<LINK href="./skin/KaPr_text_treffer.css" REL="stylesheet" TYPE="text/css"/>
<LINK href="./skin/KaPr_Color_Fonts.css" REL="stylesheet" TYPE="text/css"/>
</HEAD>

... ...

</HTML>

用其他的编辑器,如vim,打开就不是这样,所有的元素名保持原来的大小写。这里Dreamweaver应该算是画蛇添足,算作Dreamweaver的一个bug?

2007-04-04

Windows XP下不输入用户名及密码自动登录

强烈不推荐,可是有的人偏偏喜欢这样,知道一下也无妨。

执行rundll32 netplwiz.dll,UsersRunDll,如果机器没有加入一个域,就可以去掉上方的“要使用本机,用户必须输入用户名和密码”选项前的小勾,再按“应用”按钮,会有个设置默认用户和密码的窗口弹出,输入用想默认登录的用户名和密码即可。

在XSL中对变量作加法

在XSL中对变量作加法:

如果使用的转换器只支持XSLT 1.0,则:

<xsl:variable name="n1">
<xsl:choose>
<xsl:when test="number($t1) = number($t1)">
<xsl:value-of select="$t1"/>
</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="n2">
<xsl:choose>
<xsl:when test="number($t2) = number($t2)">
<xsl:value-of select="$t2"/>
</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="temp1" select="$n1 + $n2"/>

如果XSLT parser支持XSLT 2.0:  

XSLT 2.0 makes it easier because of the conditional expressions in XPath 2.0. You can do:

<xsl:variable name="n1"
select="if (number($t1) = number($t1)) then $t1 else 0" />
<xsl:variable name="n2"
select="if (number($t2) = number($t2)) then $t2 else 0" />
<xsl:variable name="temp1" select="$n1 + $n2" />

Depending on how you're getting the values of $t1 and $t2 (and the final definition of if-absent()) it might also be possible to use the if-absent() function:

<xsl:variable name="temp1" select="if-absent($t1, 0) + if-absent($t2, 0)" />