Skip to content

Instantly share code, notes, and snippets.

View Hyvi's full-sized avatar
🎯
Focusing

Hyvi Hyvi

🎯
Focusing
  • huawei Inc
  • china
View GitHub Profile
@Hyvi
Hyvi / javascript_this.js
Created November 15, 2011 09:18
11.15对javascript this的理解,灾难源于这样的一段代码
/**
* 关于事件监听最佳实践  
* http://www.cnblogs.com/snowball/archive/2006/08/16/478531.html
*/
function associateObjWithEvent(obj, methodName){
return (function(e){
e = e||window.event;
// obj == DthmlObject , it's OK , but obj == new DthmlObject(),it's not
/**
* 遗留的问题: 这是utf-8 ??
* 关于encodeURIComponent 与 encodeURI 的最佳实践
* http://stackoverflow.com/questions/75980/best-practice-escape-or-encodeuri-encodeuricomponent
*
Unicode Strings
In most browsers, calling window.btoa on a Unicode string will cause a Character Out Of Range exception.
To avoid this, consider this pattern, noted by Johan Sundström
@Hyvi
Hyvi / code_snippet.js
Created November 8, 2011 10:57
array.map 和 sendAsBinary的兼容实现
/**
* http://javascript0.org/wiki/Portable_sendAsBinary
* portable sendAsBinary
*/
XMLHttpRequest.prototype.sendAsBinary = function(datastr) {
function byteValue(x) {
return x.charCodeAt(0) & 0xff;
}
var ords = Array.prototype.map.call(datastr, byteValue);
@Hyvi
Hyvi / QQ云输入法JS脚本.js
Created May 13, 2011 15:34
#QQ 云输入法 嵌入页面的 JS脚本# 其中第二行 使用了“!!q” 而不是直接使用 “q”
(function(q){
!!q?q.toggle():
(function(d,j){
j=d.createElement('script');
j.src='//ime.qq.com/fcgi-bin/getjs';
j.setAttribute('ime-cfg','lt=2');
d.getElementsByTagName('head')[0].appendChild(j)
}
)
(document)}
@Hyvi
Hyvi / 服务器测试
Created March 16, 2011 00:44
服务器,在学校机房测试
http://tool.chinaz.com/ 站长工具
http://www.linkwan.com/gb/ 网络测试(基于google地图)
@Hyvi
Hyvi / test
Created February 27, 2011 12:19
test for gwf
spawn openvpn --config /etc/openvpn/Global.ovpn
#expect "[sudo] password for hyvi: "
#send "密码\n"
#sleep 2
expect "Enter Auth Username:"
send "邮箱\r"
sleep 2
expect "Enter Auth Password:"
send "密码\r"
expect eof