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 test19(): | |
src_fpath = "gbk.txt" | |
dst_fpath = "utf8.txt" | |
dstf = open(dst_fpath,"w") | |
for line in open(src_fpath): | |
try: | |
dstf.write(line.decode("gbk").encode("utf8")) | |
except Exception as e: | |
print "error when handle '%s': '%s'"%(repr(line),e) |
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 ping(server, port): | |
''' Check if a server accepts connections on a specific TCP port ''' | |
try: | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.connect((server, port)) | |
s.close() | |
return True | |
except socket.error: | |
return False |
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 | |
#coding=utf-8 | |
def main(): | |
from optparse import OptionParser | |
import os | |
import logging | |
import sys | |
import time |
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 | |
#coding=utf-8 | |
import gevent | |
from gevent.subprocess import Popen, PIPE | |
import sys | |
def run(cmd,name="",index=1,color=True): | |
fc = 32 + index%5 | |
if name: |
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
import time | |
tstr = time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(time.time())) | |
print tstr |
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
worker_processes 1; | |
error_log logs/error.log; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
server { | |
listen 6699; | |
location / { |
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
from subprocess import Popen, PIPE, STDOUT | |
import os | |
def runcmd(cwd,cmd): | |
oldcwd = os.getcwd() | |
os.chdir(cwd) | |
runcmd_timeout = 3600 | |
p = Popen(cmd,stdout=PIPE,stderr=STDOUT,shell=True,preexec_fn=os.setpgrp) | |
p.wait(runcmd_timeout) | |
if p.returncode==None: |
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
{ | |
"emojis": [ | |
{"emoji": "👩👩👧👧", "name": "family_mothers_two_girls", "shortname": "", "unicode": "", "html": "👩‍👩‍👧‍👧", "category": "p", "order": ""}, | |
{"emoji": "👩👩👧👦", "name": "family_mothers_children", "shortname": "", "unicode": "", "html": "👩‍👩‍👧‍👦", "category": "p", "order": ""}, | |
{"emoji": "👩👩👦👦", "name": "family_mothers_two_boys", "shortname": "", "unicode": "", "html": "👩‍👩‍👦‍👦", "category": "p", "order": ""}, | |
{"emoji": "👨👩👧👧", "name": "family_two_girls", "shortname": "", "unicode": "", "html": "👨‍👩‍👧‍👧", "category": "p", "order": ""}, | |
{"emoji": "👨👩👧👦", "name": "family_children", "shortname": "", "unicode": "", "html": "👨‍👩‍👧‍👦", "category": "p", "order": ""}, | |
{"emoji": "👨👩👦👦", "name": "family_two_biys", "shortname": "", "unicode": "", "html": "👨&zw |
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 | |
from __future__ import print_function | |
def main(): | |
pass | |
if __name__=='__main__': | |
main() |
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 | |
#coding=utf-8 | |
import gevent | |
from gevent.server import StreamServer | |
from gevent.queue import Queue | |
import json | |
def sendmsg2fobj(fobj,msg): |