Saturday, July 02, 2011

globalEval function of jQuery changed in version 1.6

globalEval function of jquery before version 1.6, such as 1.5.2 and 1.2.6, source code:

// Evalulates a script in a global context
globalEval: function( data ) {
if ( data && rnotwhite.test(data) ) {
// Inspired by code by Andrea Giammarchi
// http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
var head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement,
script = document.createElement( "script" );

if ( jQuery.support.scriptEval() ) {
script.appendChild( document.createTextNode( data ) );
} else {
script.text = data;
}

// Use insertBefore instead of appendChild to circumvent an IE6 bug.
// This arises when a base node is used (#2709).
head.insertBefore( script, head.firstChild );
head.removeChild( script );
}
},

globalEval function of jquery 1.6 source code:
// Evaluates a script in a global context
// Workarounds based on findings by Jim Driscoll
// http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
globalEval: function( data ) {
if ( data && rnotwhite.test( data ) ) {
// We use execScript on Internet Explorer
// We use an anonymous function so that context is window
// rather than jQuery in Firefox
( window.execScript || function( data ) {
window[ "eval" ].call( window, data );
} )( data );
}
},

rails 3.0.7 在ubuntu 11.04中安装问题


$> sudo gem install rails

This is the problematic part:

File not found: lib
ERROR: While generating documentation for rails-3.0.7
... MESSAGE: exit
...

这个问题是因为Rails新版本使用了最新的Rdoc/ri版本,而系统中原来的版本有些功能不是兼容的,因此报错。
卸载已经安装的rails3,先安装rdoc-data成功后再安装rails3。

$> sudo gem uninstall rails --version 3.0.7
$> sudo gem install rdoc-data
$> sudo rdoc-data --install
$> sudo gem install rails

安装成功信息:
Successfully installed rails-3.0.7
1 gem installed
Installing ri documentation for rails-3.0.7...
Installing RDoc documentation for rails-3.0.7...

Wednesday, May 18, 2011

configure php xdebug in ubuntu

先安装php和xdebug,并配置php.ini文件
$> sudo apt-get install apache2 php5 xdebug
$> sudo vi /etc/php5/apache2/php.ini
在php.ini文件最后面添加下面3行内容,其他如zend_extension的值ubuntu在xdebug安装完会自动在/etc/php5/conf.d/xdebug.ini中设置:


[Xdebug]
xdebug.remote_autostart=On
xdebug.remote_enable=On


然后从eclipse.org官网下载eclipse for php版本:
我的电脑是ubuntu 11.04 64位的机器,所以下载64位的版本:
$> wget http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/helios/SR2/eclipse-cpp-helios-SR2-linux-gtk-x86_64.tar.gz&url=http://mirrors.ustc.edu.cn/eclipse/technology/epp/downloads/release/helios/SR2/eclipse-cpp-helios-SR2-linux-gtk-x86_64.tar.gz&mirror_id=1093

打开eclipse之后,进入window-Performances-PHP-Debug设置面板,在右边的“PHP Debuger”中选择Xdebug,然后点击Xdebug的Configure,再选择其中的Xdebug进行编辑,将"Accept remote session(JIT)"的值设置为"localhost",(默认值为off时,是不会开启xdebug调试功能的),这个设置和php.ini设置必须要都做到才会开启debug功能。
这样配置就完成了,可以打开浏览器访问PHP页面,在eclipse中的PHP源码,如果有设置断点就会进入Debug模式。

在Debug模式中的Server就使用默认的http://localhost,"PHP Executeable"原来是"None Defined",这个没有关系,也可以手动设置一个值,如"/usr/bin/php5",这个不影响debug功能。

抄录部分xdebug远程调试相关的参数说明,官网可参考http://xdebug.org/docs/remote中的说明。

xdebug.remote_autostart
类型:布尔型 默认值:0
一般来说,你需要使用明确的HTTP GET/POST变量来开启远程debug。而当这个参数设置为On,xdebug将经常试图去开启一个远程debug session并试图去连接客户端,即使GET/POST/COOKIE变量不是当前的。

xdebug.remote_enable
类型:布尔型 默认值:0
这个开关控制xdebug是否应该试着去连接一个按照xdebug.remote_host和xdebug.remote_port来设置监听主机和端口的debug客户端。

xdebug.remote_host
类型:字符串 默认值:localhost
选择debug客户端正在运行的主机,你不仅可以使用主机名还可以使用IP地址

xdebug.remote_port
类型:整型 默认值:9000
这个端口是xdebug试着去连接远程主机的。9000是一般客户端和被绑定的debug客户端默认的端口。许多客户端都使用这个端口数字,最好不要去修改这个设置。

Windows的设置可以参考下面这个链接中说明:http://be-evil.org/post-70.html
Mac中可以下载一个MacGDBp,这个用来调试PHP,非常好用,与IDE就完全脱离关系了。