摘要: 在写守护进程的时候,会涉及一些启动锁文件,进程id文件等信息。而当程序一旦挂掉(有时候可能是程序不工作,多线程引起的资源死锁等。),要强制关闭进程并且删除相关的文件信息。手动来操作,比较麻烦。写个程序会比较好:import subprocess,re,syspidReg = re.compile("root\s+(\d+)\s")def kill(process): p = subprocess.Popen("ps axu | grep py",shell=True,stdout=subprocess.PIPE) for pro in p.stdout. 阅读全文
posted @ 2011-04-11 10:17 simayixin 阅读(847) 评论(0) 推荐(0) 编辑
摘要: js过程中常常会用到字符串拼接,很多时候这些拼接又长又硬,而js又没有提供像其他语言一样的字符串格式化方式,于是我们只好DIY了。一般来说,我们需要实现如下两种方式的格式化:"{0},{1},hehe".format("hello","world")"数学={数学},语文={语文},hou".format({"数学":100,"语文":95})第一种是常规的格式化方法 ,很多语言中常见。第二种就不那么常见了 ,但是在Js中却很重要,特别是在ajax交互式后我们返回一堆的jso 阅读全文
posted @ 2011-03-29 10:59 simayixin 阅读(60431) 评论(4) 推荐(2) 编辑
摘要: 我们从结果向实现推,首先看我们要实现什么样的效果:css(hi,"color","red")css([hi,hello],"color","red")css(hi,{"border":"1px solid #000","width":"200px"})var color = css(hi,"color")这是很常见的写法,然后看我们希望怎么写:Overload("css",window, { &q 阅读全文
posted @ 2011-03-28 10:44 simayixin 阅读(2448) 评论(2) 推荐(1) 编辑
摘要: 首先请阅读此文:http://www.cnblogs.com/snandy/archive/2011/03/24/1993380.html通过此文 ,我们了解到,对于浏览器内置对象的一些方法,在ie中表现为类静态方法,可以托管给其他“指针”来代表,而其他浏览器中则表现为类实例方法,需要有指定的对象来触发。为了方便统一调用,可写出下面代码:var isIe = navigator.userAgent.indexOf("MSIE")>=0 ,d = document,l = d.location,h = window.history, wrap = function(fn 阅读全文
posted @ 2011-03-24 11:15 simayixin 阅读(1689) 评论(0) 推荐(0) 编辑
摘要: Type(x)Type(y)Result type(x)==type(y) x===y otherwise... false null undefined true undefined null true Number String x==toNumber(y) String Number toNumber(x)==y Boolean (any) toNumber(x)==y (any) Boolean x==toNumber(y) String or Number Object x==toPrimitive(y) Object String or Number toPrimitive(x). 阅读全文
posted @ 2011-03-21 22:57 simayixin 阅读(717) 评论(2) 推荐(0) 编辑