这两种写法都没有使用传递变量。
#define swap(x,y) x = x + y;y = x - y;x = x - y #define swap(x,y) x^=y^=x^=y
这两种写法都没有使用传递变量。
#define swap(x,y) x = x + y;y = x - y;x = x - y #define swap(x,y) x^=y^=x^=y
今天在firefox下遇到一个奇怪的问题。
html中有下面一个INPUT元素
<input id="q" name="q" value="123"/>
使用input.getAttribute可以取得该input的值
document.getElementById("q").getAttribute("value"); //return 123
但是当通过界面输入将INPUT的值改为456之后,在通过input.getAttribute的方式取值,仍然返回123,但是使用input.value可以返回456.
document.getElementById("q").getAttribute("value"); // return 123
document.getElementById("q").value; //return 456
下面的网页中有对该问题的完整的分析和测试(已被墙,请用代理访问)
http://updatepanel.net/2008/12/31/more-on-getattribute-setattribute-and-the-value-attribute/
参考上面的分析可以还原出firefox下的实现
假设
那么在firefox中
htmlElement.value作为等式右值时等价于
function(){
return this._properties["value"]||this._attributes["value"]
}
htmlElement.value作为等式左值时等价于
function(right_value){
this._properties["value"]=right_value;
}
htmlElement.getAttribute(“value”)等价于
function(){
return this._attributes["value"];
}
htmlElement.setAttribute(“value”,”123″)等价于
function(name,value){
this._attributes[name]=value;
}
而在IE中property和attribute的值是完全等价的不存在差异。
1.下载bash-completion-20060301-1.noarch.rpm
$ wget http://www.caliban.org/files/redhat/RPMS/noarch/bash-completion-20060301-1.noarch.rpm
或者下载下面文件
2.安装rpm包
$ rpm -ivh bash-completion-20060301-1.noarch.rpm
3.在~/.bashrc中添加如下内容
$ vi ~/.bashrc
if [ -f /etc/bash_completion ]; then . /etc/bash_completion fi
4.重新载入配置
$ . ~/.bashrc
1.修改/etc/hosts
sudo vi /etc/hosts
修改为
127.0.0.1 myhostname localhost.localdomain localhost
2.修改/etc/sysconfig/network
sudo vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=myhostname
GATEWAY=61.67.71.126
3.使用hostname命令
hostname myhostname
4.重新登录
在CentOS5.3下配置了XDMCP,但是从外网始终没法连上,本机可以连接,google了2天,未果。
SSH的方式可以连接上远端的服务器,于是想到了可以使用SSH X11 转发的方式,连接
1.首先开始服务器上XDMCP服务和远程连接
$ sudo /etc/gdm/custom.conf
修改内容如下
[security]
DisallowTCP=false
[xdmcp]
Enable=true
2.使用-X参数开始SSH X11 Forwarding
$ ssh -X -l LOGINUSER REMOTEHOST
3.使用Xnest打开X桌面
$ Xnest :1 -ac -once -query localhost
第二步和第三步可以合并为
$ ssh -X -C -l LOGINUSER REMOTEHOST -n Xnest :1 -ac -once -query localhost
远程登录到linux可以使用VNC或者XDMCP的方式,windows下有一个很有名的XDMCP客户端Xmanager,其实UBuntu下默认也安装了该客户端,一次打开[应用程序]-[internet]-[终端服务客户端(Terminal Server Client)]或者在命令行输入tsclient,在常规标签中的协议选项可以看到XDMCP,只不过是灰色的无法选择,需要先安装协议支持。
$ sudo apt-get install xnest
装完后就可以使用了。