月度归档:2015年09月

mosh保持 SSH 连接不断开

服务端客户端各安装一个mosh

yum install mosh 或者

apt-get install mosh

客户端连接时

mosh root@www.so-cools.com

如果端口被修改

mosh root@www.so-cools.com –ssh=”ssh -p 100″

mosh root@www.so-cools.com -p 100

缺点,不能转发端口,只能作终端使用。

关于nginx_lua取get的两种方式

ngx.var.arg_xx与ngx.req.get_uri_args[“xx”]两者都是为了获取请求uri中的参数,例如

http://www.so-cools.com/index.php?strider=1

为了获取输入参数strider,以下两种方法都可以

local strider = ngx.var.arg_strider

local strider = ngx.req.get_uri_args[“strider”]

差别在于,当请求uri中有多个同名参数时,ngx.var.arg_xx的做法是取第一个出现的值,ngx.req_get_uri_args[“xx”]的做法是返回一个table,该table里存放了该参数的所有值,例如,当请求uri为:

http://www.so-cools.com/index.php?strider=1&strider=2&strider=3&strider=4

时,ngx.var.arg_strider的值为”1″,而ngx.req.get_uri_args[“strider”]的值为table
[“1”, “2”, “3”, “4”]。因此,ngx.req.get_uri_args属于ngx.var.arg_的增强。

前端 checkbox mark

网上很多文章在判断checkbox 是否选中时,都用  if($(‘#xxx’).attr(“checked”)){ 来判断是否选中。 这样子其实是错误的。


像checkbox,radio和select这样的元素,选中属性对应“checked”和“selected”,这些也属于固有属性,因此需要使用prop方法去操作才能获得正确的结果。
$(“#xxx”).prop(“checked”) == false
$(“#xxx”).prop(“checked”) == true
如果上面使用attr方法,则会出现:
$(“#xxx”).attr(“checked”) == undefined
$(“#xxx”).attr(“checked”) == “checked”


获取被选中按钮的值

var radio_v=$(‘input[name=”import_type”]:checked ‘).val();