js校验身份证,—没有最好,只有更好

18位身份证校验

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function idcard(){
    var idcard = $("#idcard").val();
    var code = idcard.substring(0,17);
    var weight= [7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2];
    var validate= ['1','0','X','9','8','7','6','5','4','3','2'];
    var arr = code.split("");
    var sum = 0;
    for(var i=0;i<17;i++){
        var cheng=Number(arr[i]) * Number(weight[i]);
        var sum = sum + cheng;
    }
    var mode = sum % 11;
    var res = code+validate[mode.toString()];
    console.log(idcard)
    console.log(res)
    if(idcard.toString() != res.toString()){
        alert("error")
    }else{
        alert("yes")
    }
}
Posted in: CSS

Net-Speeder为搬瓦工提升网速

net-speeder可以在高延迟不稳定链路上优化单线程下载速度。运行时依赖的库:libnet、libpcap 。debian/ubuntu安装libnet:apt-get install libnet1 ;安装libpcap: apt-get install libpcap0.8 。编译需要安装libnet和libpcap对应的dev包,debian/ubuntu安装libnet-dev:apt-get install libnet1-dev ,安装libpcap-dev: apt-get install libpcap0.8-dev 。

第一步:下载
wget https://coding.net/u/njzhenghao/p/download/git/raw/master/net_speeder-installer.sh

第二步:编译并安装
bash net_speeder-installer.sh

第三步:端口加速(启动)

1
    nohup /usr/local/net_speeder/net_speeder venet0 "ip" >/dev/null 2>&1 &

开机自启:

1
echo 'nohup /usr/local/net_speeder/net_speeder venet0 "ip" >/dev/null 2>&1 & ' >> /etc/rc.local

查看net-speeder是否运行:
ps aux|grep net_speeder|grep -v grep


ˆ Back To Top