This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if __name__ == '__main__': | |
pid_file = cur_file_dir() + '/logstat.pid' | |
fp = open(pid_file, 'w') | |
try: | |
fcntl.lockf(fp, fcntl.LOCK_EX | fcntl.LOCK_NB) | |
except IOError: | |
# another instance is running | |
sys.exit(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def my_date(unixtime, format='%m/%d/%Y %H:%M'): | |
d = datetime.datetime.fromtimestamp(unixtime) | |
return d.strftime(format) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def cur_file_dir(): | |
# 获取脚本路径 | |
path = sys.path[0] | |
# 判断为脚本文件还是py2exe编译后的文件,如果是脚本文件,则返回的是脚本的目录,如果是py2exe编译后的文件,则返回的是编译后的文件路径 | |
if os.path.isdir(path): | |
return path | |
elif os.path.isfile(path): | |
return os.path.dirname(path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Fib implements Iterator{ | |
var $a = 0; | |
var $b = 1; | |
var $i = 0; | |
var $max = 100; | |
public function __construct($n=100){ | |
$this->max = $n; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Fib: | |
def __init__(self, max): | |
self.max = max | |
def __iter__(self): | |
self.a = 0 | |
self.b = 1 | |
return self | |
def next(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Simple JavaScript Templating | |
// John Resig - http://ejohn.org/ - MIT Licensed | |
(function(){ | |
var cache = {}; | |
this.tmpl = function tmpl(str, data){ | |
// Figure out if we're getting a template, or if we need to | |
// load the template - and be sure to cache the result. | |
var fn = !/\W/.test(str) ? | |
cache[str] = cache[str] || |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// " MATCH($field) AGAINST('$searchon' IN BOOLEAN MODE) "; | |
//"SHOW GLOBAL VARIABLES LIKE 'ft\\_min\\_word\\_len'"; | |
class normalizeText{ | |
var $mMinSearchLength; | |
var $strictMatching = true; | |
var $searchTerms = array(); | |
var $ignorecase = true; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> | |
<title>cross 跨域</title> | |
</head> | |
<body> | |
<input type='button' value='开始测试' onclick='crossDomainRequest()' /> | |
<div id="content"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getRangePos(obj){ | |
var Pos = 0; //ie | |
if (document.selection){ | |
obj.focus(); | |
var Sel = document.selection.createRange(); | |
Sel.moveStart('character', -obj.value.length); | |
Pos = Sel.text.length; | |
}else if (obj.selectionStart || obj.selectionStart == '0'){ | |
Pos = obj.selectionStart; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
# Copyright 2009 Facebook | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); you may | |
# not use this file except in compliance with the License. You may obtain | |
# a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# |
NewerOlder