2008年9月11日
最近着迷 Javascript 中的对象,回顾以往项目时,记得用到C#里的Dictionary<T, T>时,利用 Microsoft ASP.NET AJAX Client 技术,可以将Dictionary<T, T>直接转为Javascript对象使用,今天突然想到,当Dictionary中的键是int类型时,返回到页面的Javascript对象会是怎样的?这个试验还没来得及做。
在Javascript中,可以利用JSON格式来定义对象,比如
var obj = {
1: "重启",
2: "关机",
3: "开机"
}
alert(obj[2]); // 这句会正常执行
alert(obj.2); // 这句会报错
我们可以看到,对象名虽然有[_$a-zA-Z][_$a-zA-Z0-9]*的限制,但对于此obj[2],可以正常输出"关机",甚至,我们发现
var obj2 = {
1: "重启",
2: "关机",
3: "开机",
"!": "奇怪的Javascript!"
}
alert(obj2["!"]);
上述也能正常执行。
以前一直以为obj[property] === obj.property,看来错了。
obj.property的写法,仅仅当property为[_$a-zA-Z][_$a-zA-Z0-9]*时才成立。
而用obj[property]的写法,几乎可以支持任意符号。
遇到这点奇怪的,发上来,看看大家是否还可以挖掘一下。
2008年9月8日
新装的 Office Powerpoint 2007 不能输入中文,以为是Sogou输入法的问题,换成Google的问题依旧。
解决办法:在控制面板里开启高级文字服务。
原来一直用的是大S的imetools和internat.exe,挺好用的,现在不得不启用高级文字服务这个耗内存的东东了。
2008年9月3日

昨日得知 Google Chrome 即将发布,今日又看到 Google Chrome Comic Book 介绍。从 Google 一些产品的图标和宣传中,都透出浓厚的创作意味,各种手绘的图标、几何体等暗示着技术的优雅和创新。从 Chrome 的特点和内涵来看,Google 推出这款产品的意图很值得揣摩。
首先,我们简单了解一下 Chrome,虽然,Google 刚宣布和 Mozilla 的合作期会延续三年到 2011,虽然,Chrome 这个词经常会在 Mozilla 的源文件中出现,但 Google Chrome 并不是 Gecko 内核,而是和苹果的 Safari 一样内核——基于 Webkit。Google 没有重复制造轮子,它吸取了 Firefox 的开源和插件特点,吸取了 Opera 的 Speed Dial 和理念,从丹麦吸收了 Javascript V8 引擎,吸收了 The World / IE8 的 MDI 窗口多线程技术,和 IE8 的隐私模式等。
比较期待的特性是 JavaScript V8 引擎,早在半年前的新闻里,苹果推出 Windows 平台的 Safari 后就宣布他们在改善Javascript 引擎,在现在的 Web 上,Javascript 已经成为默认的标准,各大平台厂商都认识到,旧的 Javascript 解释器已经成为 Web 发展的瓶颈,Adobe 还更加激进地推动 ECMAScript 4 标准,不过此草案被否决,而延续向 ECMAScript 3.2 进发。
从趋势来看,商业化服务依赖于富客户端技术,富客户端依赖于 Web Browser, 而 Javascript 作为客户端粘合 Web Browser 应用的语言,其引擎也亟待改进。可以想象,在不久的将来,各大浏览器厂商对 Javascript 解释速度会越来越快,Browser 会越来越丰富,而 Javascript 必将再次迎来一波高潮。
作为开源软件推出的 Google Chrome 主旨应该不仅是和各大浏览器竞争市场——这是很不靠谱的事,但 Google Chrome 的推出会浏览器的竞争形成一种三角制衡,形成多元化,Web 规范和标准才不会被少数竞争对手的垄断,这有利于 Web 技术的创新,而Google 就是玩 Web 平台的公司,在 Web 平台上竞争正是其拿手好戏。
2008年9月2日
在服务器上发布了两个系统,一个可以正常使用,一个提示没有权限,但页面正常打开只是 Infragistics 下的一个控件 UltraWebNavigator 没法使用,并且偶尔会弹出如下对话框。
---------------------------
Windows Internet Explorer
---------------------------
UltraWebNavigator Trial Version. Copyright 2002-2004, Infragistics, Inc. All rights reserved.
---------------------------
确定
---------------------------
在C:\Inetpub\wwwroot\aspnet_client\infragistics下搜索js,没有发现如上Trial Version字样,估计是在Page类中发出的。
换了个角度,尝试上服务器重新安装UltraWebNavigator注册版,对话框不再弹出了。但依然会提示需要输入服务器的用户名和密码。
逐个检查网站涉及到的虚拟目录,发现都勾选了IIS的集成Windows身份验证和允许匿名登陆。
经过一次一次刷新浏览器,发现页面已经解析出Title后才提示要求输入服务器的用户名和密码,为了获得更精确的结论,请出了httpwatch,发现在服务器请求ig_common下的一个js文件时,服务器才会提示。
终于明白了,是infragistics的虚拟目录ig_common出了问题。尝试将7个主要用户和角色赋上全部权限,依然没能解决问题。
后来将infragistics目录复制出一份,更名为ig_common,没有设置任何权限,发现外部不再提示要求输入服务器的用户名和密码了。
在这个问题的解决中,中途求助了第三方,但第三方可能不清楚细节,也没有找到问题关键。
还是依靠对问题出现的现象细节判断,才想到了观测和解决办法,以后要多培养自己这种解决问题的嗅觉。
2008年8月31日

最近的 RSS 消息中弥漫着 Ubiquity 的文章—— Mozilla Labs 推出的智能页面Mashup工具。在官方http://labs.mozilla.com/2008/08/introducing-ubiquity/下载安装了这个插件,并看了相关介绍视频。于是马上想起了,Mozilla 挖角 http://humanized.com/ 的事情,Ubiquity 差不多就是 Enso,经确认,也是由 Enso 原班人马做的。
humanized 是一家致力于人性化交互研究的公司,其主要产品的操作模式——type and run,需要用户记住一个热键,在按下热键后,交互界面会出现在屏幕,用户接着type上软件能识别的命令,软件会给出一些实时suggestion,经过用户的继续type或者选择,选择最终命令,放开热键,软件则执行命令。
值得一提的是,命令是可扩展的,软件具有学习的功能,会越用越聪明,越能了解个人的键入信息。这种聚合信息的方式,正是软件的初衷——把人从繁复重复中解放出来,现在,Enso做到了,Ubiquity也做到了,更加值得一提的是,软件甚至具有了智能识别语言动作的能力。
这背后需要前端的支撑技术——强大的搜索、语义识别、和数个高可用的WebService...
前几天的文章里添加了几次代码,发现毁坏了在低分辨率下ClearGertrude的样式。
经过源文件里的定位,发现 http://www.cnblogs.com/css/common.css 中
.cnblogs_code{
...
width: 700;
...
}
于是在 customcss 里加上了以下代码,页面就正常了。
.cnblogs_code{
width: 600px;
}
查看源文件时,发现除了
<link id="CommondCss" type="text/css" rel="stylesheet" href="http://www.cnblogs.com/css/common.css" />
<link id="MainCss" type="text/css" rel="stylesheet" href="http://www.cnblogs.com/Skins/ClearGertrude/style.css" />
以外,还增加了
<link id="SecondaryCss" type="text/css" rel="stylesheet" href="http://www.cnblogs.com/likun/customcss.aspx" />
也就是刚刚添加的自定义样式。
2008年8月26日
Embarcadero 发布了 Delphi 和 C++Builder 的 Windows 开发工具。
官方称 Delphi 2009 是自 Delphi 3 以来最重要的一个版本。
其更新的亮点有:
内置支持 Unicode,很棒!
原生支持 Delphi 泛型
C++0x 语言最新标准,也是第一个支持 C++0x 的商业 IDE
DataSnap 的更新
Architect 版本中包含了 ER/Studio® 开发版,屡获大奖的数据库建模环境
VCL 方面的更新有新的 Office 风格控件, PNG 图片原生支持
VCL for the Web 方面的更新。
售价方面(北美):
升级专业版:$399
企业版:$1,299
架构版:$2,299
Embarcadero Goes Global with Next-Generation Delphi® and C++Builder Development Tools for Windows®
New tools enable ISVs and business developers to build high-performance client/server and packaged software applications that support rich user experiences worldwide.
SAN FRANCISCO, CA – August 25, 2008 – Embarcadero Technologies today unveiled the next generation of the popular CodeGear™ rapid application development (RAD) tools for Windows: Delphi 2009 and C++Builder® 2009, geared specifically for both Independent Software Vendors (ISVs) and workgroup client/server development.
Developers can now easily expand the global reach of their applications with built-in support for Unicode™ throughout Delphi 2009 and C++Builder 2009. Built-in support for Unicode means that applications will look and operate properly on all language versions of Windows and seamlessly support both Unicode and ANSI data. In addition, new and enhanced localization tools make it easier to translate applications to take advantage of specific local opportunities.
“For us as a database vendor, Delphi 2009 is the most important new release since Delphi 3,” said Thorsten Engler, Principal Software Architect at Nexus Database Systems. “The full Unicode support and the numerous changes to the data access layers put Delphi 2009 at the top in terms of rapid application development. For anyone serious about internationally deployed database applications, Delphi 2009 is an absolute must.”
Delphi and C++Builder 2009 are the only tools tailor-made for organizations building packaged software for resale/redistribution, high-performance graphical workstation applications, and client/server workgroup database applications. Top industries using Delphi and C++Builder today to build next-generation solutions include ISVs, MicroISVs, Banking/Finance, Manufacturing, Government, Healthcare, Science/Engineering and Telecommunications.
This new release takes the Delphi and C++ languages forward with a host of powerful new programming language features such as Delphi generics and upcoming C++0x standard language features. A new multi-tier DataSnap™ architecture enables developers to use RAD to build high-performance, highly scalable database middleware applications. The middleware applications can be connected to via a lightweight, open communications protocol with thin, full-featured clients that can reside on virtually any native or Web client platform.
In addition, Delphi 2009 and C++Builder 2009 represent the first Embarcadero solutions to bring together advanced CodeGear and DatabaseGear™ functionality in a single offering. The Delphi and C++Builder Architect editions include ER/Studio® Developer Edition to provide a complete solution for designing and building database applications. This integration results in enhanced productivity and time-to-market for developers.
Other new and enhanced features of the two products include:
New Visual Component Library (VCL) components including Microsoft Office style ribbon controls, Portable Network Graphics (PNG) image support, dozens of new capabilities for existing controls, and the ability to seamlessly build powerful UIs for Windows XP and Vista desktop applications simultaneously.
Major new language features including Delphi generics and anonymous methods, and the first commercial IDE support for C++0x and Technical Report 1 (TR1) in the C++ language.
VCL for the Web for creating AJAX and Silverlight-enabled rich intranet and line of business web applications.
Updated built-in dbExpress support for CodeGear InterBase® and Blackfish™ SQL, Oracle®, Microsoft SQL Server™ , Informix®, IBM® DB2®, SQL Anywhere®, Sybase® and MySQL® databases.
“Our goal with 2009 is to deliver the best Delphi and C++Builder ever, to enable ISVs and client/server developers to simultaneously and seamlessly expand their business footprint globally with more client platforms and databases, and richer UIs,” said Michael Swindell, Vice President of Products for Embarcadero Technologies.
“Our goal as a combined company is to eliminate the development barriers between applications and databases. This release combines award-winning database architecture and design features from ER/Studio with Delphi and C++Builder to create the ultimate database application design and development solution – the all new Delphi and C++Builder Architect Editions,” said Swindell.
Delphi and C++Builder 2009 support development and deployment on Windows Vista, Windows XP, Windows 2000, Windows Server 2003, and Windows Server 2008.
Pricing and Availability
Delphi 2009 and C++Builder 2009 are immediately available worldwide for pre-orders. North American upgrade pricing begins at $399 per license for Professional editions, $1,299 for Enterprise editions and $2,299 for Architect editions. They can be purchased directly through Embarcadero or through one of its global partners. For more information, visit: www.codegear.com/products/delphi/win32 and www.codegear.com/products/cppbuilder.
Community Resources
See Delphi and C++Builder 2009 in action at http://www.codegear.com/cg-videos/
Learn more with these webinars: http://dn.codegear.com/article/38478
For the latest on Delphi and C++Builder, visit: http://dn.codegear.com/delphi and
http://dn.codegear.com/cpp
See the many popular Delphi-built applications and components being used by millions today: http://delphi.wikia.com/wiki/Delphi_Wiki
To subscribe to Embarcadero’s CodeGear RSS newsfeed, visit http://dn.codegear.com/atom
About Embarcadero Technologies
Embarcadero Technologies Inc. empowers application developers and database professionals with tools to design, build and run software applications in the environment they choose. A community of more than three million worldwide and 90 of the Fortune 100 rely on Embarcadero’s CodeGear™ and DatabaseGear™ product lines to increase productivity, openly collaborate and be free to innovate. Founded in 1993, Embarcadero is headquartered in San Francisco, with offices located around the globe. Embarcadero is online at http://www.embarcadero.com/.
###
Embarcadero, the Embarcadero Technologies logos and all other Embarcadero Technologies product or service names are trademarks or registered trademarks of Embarcadero Technologies, Inc. All other trademarks are property of their respective owners.
2008年8月23日
django 需要 mod_python,网上可找到很多配置文章,整个过程没有什么可说的,仅有一点:
如果 python 不是 Install for all users 安装的,则启动 apache 时会提示:
The Apache service named reported the following error: >>> httpd.exe: Syntax error on line 496 of E:/Eric/Apache/conf/httpd.conf: Cannot load E:/Eric/Apache/modules/mod_python.so into server: \xd5\xd2\xb2\xbb\xb5\xbd\xd6\xb8\xb6\xa8\xb5\xc4\xc4\xa3\xbf\xe9\xa1\xa3 . 有关更多信息,请参阅在 http://go.microsoft.com/fwlink/events.asp 的帮助和支持中心。
print '\xd5\xd2\xb2\xbb\xb5\xbd\xd6\xb8\xb6\xa8\xb5\xc4\xc4\xa3\xbf\xe9\xa1\xa3'
显示为:“找不到指定的模块。”
利用注册表和文件监视软件可以观察到这个过程。
2008年8月14日
最近做了一个.Net系统升级项目。从ASP.NET 1.1 升级到 ASP.NET 2.0/3.5,开始发现不兼容的都是第三方控件,等升级完毕后,才戏曲性的发现,兼容性产生的问题大多来自 .Net Framework 本身。比如 TextBox 类 ReadOnly 属性的脚本不兼容问题。
在 ASP.NET 1.1 项目中,可能会经常会用到选择器,确切的说,这是一种操作模式:用户提供一组复杂条件,查找出待选的项,通常的实现,是基于一个 TextBox,一个能打开待选项页面或区域的按钮,但选定后再用脚本将用户选择的项填充到 TextBox 里,通常这个 TextBox 还不希望直接修改。(可能说得很复杂,说实例比如日期选择器就是一个典型。)
通常,我们会对 TextBox 加上 ReadOnly="true" 来避免用户的直接输入,这个服务端属性,会在客户端的 HTML input 中输出 readonly="readonly",在 1.1 中,这一切运行得很好,但在 3.5 里,出现了问题,客户端脚本不再可修改 ReadOnly="true"的 TextBox 的值,所以选择器就永远无法选到值。其实,客户端脚本的确改变了 HTML input 的值,只不过一Postback,在服务端又就恢复了旧值。
开始时的解决办法是在页面的pageready事件里,加上

Code
setReadOnly("controlID");
function setReadOnly(id){
document.getElementById(id).setAttribute("readonly", "readonly");
}
或者直接在服务端用服务器控件的Attribute.Add添加,本质都一样,这样就回避了使用属性 ReadOnly="true" 来禁止输入。到此,问题解决了。
具体来说,问题的根源在System.Web.dll中,拿出Lutz Roeder的宝器,反编译出 TextBox 里到底发生了什么,在LoadPostData方法中我们发现:
if (!this.ReadOnly && !text.Equals(str2, 4))
是的,这就是问题根源,可以看到出于某种原因,微软拒绝了脚本去修改TextBox的Text值。

Code
protected virtual bool LoadPostData(string postDataKey
, NameValueCollection postCollection)
{
base.ValidateEvent(postDataKey);
string text = this.Text;
string str2 = postCollection[postDataKey];
if (!this.ReadOnly && !text.Equals(str2, 4))
{
this.Text = str2;
return true;
}
return false;
}
这样的修复办法真不好,导致一个隐蔽的不兼容问题,让升级过来的系统可能发生意想不到的问题。
直到前几天,我的一位同事告诉我一个更好的办法,这个办法在IE和Firefox下均有效,就是利用 HTML input 的 ContentEditable 属性来控制是否允许输入。

Code
<input type="text" id="txtTest" ContentEditable="false" />
这也算是个 hack 吧,结论:
在升级ASP.NET 1.1到ASP.NET 3.5时,如果程序中有利用脚本修改属性ReadOnly为true的TextBox时,因替换ReadOnly="True"为ContentEditable="false",这个属性由于不和服务端属性冲突,会被原样输出到客户端,达成同样的效果。
2008年8月11日
相信大多数.Net程序员都有使用Reflactor的经历。无论出于什么目的,当用Reflactor反编译托管程序后,还想对其代码加以修改,那么本文所列举的可能是一份有用的参考。
用Reflactor的FileGenerator插件反编译代码后可以得到包括项目文件的源代码,但代码中存在各种问题,一般无法一次编译通过,以下将详谈这些问题:
枚举问题
为了代码可读,可能需要花点时间查阅metadata把int值修改回枚举值,尤其是想利用窗体设计器的,VS2008可能还不理解int值。
属性问题
比如一个叫Names的属性被反编译后,可能还原为的set_Names(names),get_Names()方法,逐个替换可能很慢,可采用正则表达式整体替换。
对于set_Xxx(xxx)方法,可替换
set_{[a-z]*}\(
为
\1 = (
对于get_Xxx()方法,可替换
get_{[a-z]*}\(\)
为
\1
然后,再修复个别被误换的方法。
委托和回调函数问题
一般会被还原为add_Xxx(MethodsName)方法,需要改为 += MethodsName
资源问题
需要使用.Net Framework SDK 下的 resgen.exe 工具,反编译嵌入资源文件*.resources为*.resx文件,
语法为:ResGen.exe *.resources *.resx,然后将*.resx包含入项目,就会自动和同名的窗体文件*.cs关联,如果没有关联可采用先排除再添加大法,一一搞定。
命名空间问题
如果需要切换到IDE的窗体设计器,而不出错,则还需要在*.cs中添加比如System.Windows.Forms的命名空间前缀。
窗体设计器识别问题
需要把以下代码
ComponentResourceManager manager = new ComponentResourceManager(typeof(ClassName));
替换为
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ClassName));
窗体设计器才能正常识别。