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
# -*- coding: utf-8 -*- | |
#author: myvyang#gmail.com | |
import threading | |
import Queue | |
__all__ = ["ThreadPool"] | |
class ThreadPool(object): |
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
// Javascript 函数与对象 起源 | |
// 先来看看几个东西 | |
// typeof 作用符: 查看类型 | |
typeof 1 | |
typeof x |
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 absolute(location, relative) { | |
if (relative.startsWith("http://") | |
|| relative.startsWith("https://") | |
|| relative.startsWith("data:")) { | |
return relative; | |
} | |
if (relative.startsWith("//")) { | |
return location.protocol + relative; | |
} |
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 request(url, method, data, callback) { | |
function ready() { | |
if (httpRequest.readyState === XMLHttpRequest.DONE) { | |
if (httpRequest.status === 200) { | |
callback(httpRequest.responseText); | |
} | |
} | |
} |
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
# -*- utf-8 -*- | |
from __future__ import division | |
NUMBER_TAG = "{NUM}" | |
class Node(object): | |
def __init__(self, name): | |
self.parent = None | |
self.children = set() |
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 requests | |
import re | |
url = "https://weibo.com/p/aj/album/loading?ajwvr=6&type=photo&owner_uid=1935400180&viewer_uid=1935400180&since_id=4266739550726685_-1_20180831_-1&page_id=1005051935400180&page=2&ajax_call=1&__rnd=1539765676886" | |
re_img = "curclear_picSrc=(.*?)%3F" | |
re_since = "since_id=([0-9_-]+)" | |
while 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" Python3 only """ | |
import requests | |
import http | |
http.client.HTTPConnection._http_vsn = 10 | |
http.client.HTTPConnection._http_vsn_str = "HTTP/1.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
1. 所有操作设置超时;保证限定时间内完成,或报错; | |
2. 错误隔离;保证错误在一个小范围内,不会影响整个程序的运行,失败的任务记录下来; |
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
REQ: GET /api/v1/object/{number}/property | |
REQ: POST /api/v1/object/{number}/action | |
{"xx": "xx"} | |
RES: { | |
"code": 0/1/-1, | |
"msg": "", | |
"resp": { | |
} |
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 json_structure(j): | |
""" | |
JSON有三种结构:字面值(int, bool, str), dict, list | |
为简化处理,将list通过转换视为dict结构,key为序号。 | |
["a", 1] -> {"0": "a", "1": 1} | |
这个函数返回json的结构信息,"值"会被丢弃。 | |
{"a": 1, "b": ["n", false]} | |
-> |
OlderNewer