Skip to content

Instantly share code, notes, and snippets.

View JobsDong's full-sized avatar

JobsDong JobsDong

  • Alibaba
  • HangZhou, China
View GitHub Profile
@JobsDong
JobsDong / sub.py
Last active May 4, 2018 07:55 — forked from FZambia/sub.py
使用tornado将命令行操作包装成异步
#!/usr/bin/python2.7
#-*- coding=utf-8 -*-
import shlex
import subprocess
from tornado.gen import coroutine, Task, Return
from tornado.process import Subprocess
from tornado.ioloop import IOLoop
@coroutine
@JobsDong
JobsDong / gistools.py
Created January 8, 2014 07:58
Mercator to BD09, BD09 to GCJ03
#!/usr/bin/python
#-*- coding=utf-8 -*-
"""用于和地理信息有关的数据处理
"""
__author__ = ['"wuyadong" <wuyadong@tigerknows.com>']
import math
#!/usr/bin/python
#-*- coding=utf-8 -*-
"""用于描述一些具体的方法
"""
__author__ = ['"wuyadong" <wuyadong@tigerknows.com>']
import warnings
import functools
@JobsDong
JobsDong / item.py
Last active August 29, 2015 13:56
python metaclass的使用
"""
Scrapy Item
See documentation in docs/topics/item.rst
"""
from pprint import pformat
from UserDict import DictMixin
from scrapy.utils.trackref import object_ref
@JobsDong
JobsDong / api.py
Created February 21, 2014 11:56
python 另类包装器 __call__的用法
class api_route(object):
"""api的包装器
Attributes:
_api_methods: 字典,key是路径名,value是函数对象
"""
_api_methods = {}
def __init__(self, uri):
@JobsDong
JobsDong / redis-server
Created February 24, 2014 05:37
redis-server in init.d
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
@JobsDong
JobsDong / dict2xml.py
Last active August 29, 2015 13:57
dict to xml and xml to dict
from xml.dom import minidom
from collections import Mapping
from petl.io import RowContainer
from lxml import etree
def fromxml(source, rowmatch, *args, **kwargs):
return XmlView(source, rowmatch, *args, **kwargs)
@JobsDong
JobsDong / HttpUtils.java
Last active August 29, 2015 14:03
charset detect in web crawling
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@JobsDong
JobsDong / TrieTree.java
Last active November 28, 2015 08:22
TrieTree
package com.shenbian.service.personchange.impl.utils;
import java.util.*;
/**
* Trie Tree
* @author JobsDong
*/
public class TrieTree {
@JobsDong
JobsDong / singleton.py
Created December 4, 2015 03:42
python singleton
#!/usr/bin/python
# -*- coding: utf-8 -*-
import threading
class KbTerms(object):
"""singleton
"""
_instance_lock = threading.Lock()