Ever tried logging into a machine with ssh and found you have to wait much longer than reasonable for the session to start? This happened to me a few times and was especially annoying with machines on my local network (or a VM attached to a virtual network) that should be letting me in immediately.
I eventually got mad enough to strace the SSH daemon and debug what was going on and it turns out it’s a DNS thing. Basically the session is slow to start because the SSH server is trying to lookup the hostname of the SSH client and for whatever reason it’s timing out (e.g., it can’t reach a nameserver, because you happen to be offline)
There are a couple of very simple ways to fix that:
1 2
add "UseDNS no" to /etc/ssh/sshd_config add the client's net address to the server's /etc/hosts
function User(name, age) { this.name = name || "Oliver Queen"; this.age = age || 27; } var user1 = new User(); console.log(user1.name); // Oliver Queen console.log(user1.age); // 27
var user2 = new User("Barry Allen", 25); console.log(user2.name); // Barry Allen console.log(user2.age); // 25
var length = array.length; for (var i = 0; i < length; i++) { console.log(array[i]); }
为了更简洁,可以这么写:
1 2 3
for (var i = 0, length = array.length; i < length; i++) { console.log(array[i]); }
6) 检测对象中的属性
当你需要检查某些属性是否存在,避免运行未定义的函数或属性时,这个技巧非常有用。如果你打算编写跨浏览器代码,你也可能会用到这个技术。例如,我们假设你需要编写与旧版Internet Explorer 6兼容的代码,并且想要使用document.querySelector()来通过ID获取某些元素。 但是,在现代浏览器中,这个函数不存在。所以,要检查这个函数是否存在,你可以使用in运算符。看下这个例子:
1 2 3 4 5
if ('querySelector' in document) { document.querySelector("#id"); } else { document.getElementById("id"); }
var elements = document.querySelectorAll("p"); // NodeList var arrayElements = [].slice.call(elements); // 现在已经转换成数组了 var arrayElements = Array.from(elements); // 把NodeList转换成数组的另外一个方法
12) 对数组元素进行洗牌
如果要像外部库Lodash那样对数据元素重新洗牌,只需使用这个技巧:
1 2 3 4
var list = [1, 2, 3]; console.log(list.sort(function() { return Math.random() - 0.5 })); // [2,1,3]
For installing device HUAWEI E3131 in CentOS 6.4 Linux you have to follow instructions below. Can be used to send SMS by AT command and also to establish HiSpeed Mobile Internet connection.
##Install requirements
You have to download usb_modeswitch and data with configurations.