View multilinereprintforwindows.py
#coding=utf8 | |
import re, sys, time, os | |
from ctypes import Structure, c_short, windll, byref | |
try: | |
from shutil import get_terminal_size | |
except: | |
from backports.shutil_get_terminal_size import get_terminal_size | |
CN_REGEX = re.compile(u'[\u4e00-\u9fff]') |
View trip-coroutine-demo.py
import time, functools | |
import requests, trip | |
def timeit(fn): | |
start_time = time.time() | |
fn() | |
return time.time() - start_time | |
url = 'http://httpbin.org/get' |
View flask_qr.py
import threading | |
from flask import Flask, make_response | |
import itchat | |
qrSource = '' | |
def start_flask(): | |
flaskApp = Flask('itchat') | |
@flaskApp.route('/') |
View future-demo.py
from tornado import httpclient, gen, ioloop, concurrent | |
def fetch(urlList, minRequire): | |
resultList = [] | |
@gen.coroutine | |
def _fetch(): | |
fetchList = [httpclient.AsyncHTTPClient().fetch(url) for url in urlList] | |
yieldList = [concurrent.Future() for i in range(minRequire)] | |
def callback(f): |
View semaphore-demo.py
from tornado import httpclient, gen, ioloop, locks | |
def fetch(urlList, minRequire): | |
l = locks.Semaphore(len(urlList)) | |
resultList = [] | |
@gen.coroutine | |
def _fetch(): | |
@gen.coroutine | |
def __fetch(url): |
View WeChatCheckFriend.py
#coding=utf8 | |
import itchat | |
CHATROOM_NAME = 'friend' | |
CHATROOM = None | |
HELP_MSG = u'''\ | |
好友状态监测 | |
* 发送名片将会返回好友状态 | |
* 请确有名为%s的未使用的群聊 | |
* 并将该群聊保存到通讯录 |
View WechatSmartWish.py
#coding=utf8 | |
import itchat, time | |
SINCERE_WISH = u'祝%s新年快乐!' | |
REAL_SINCERE_WISH = u'祝%s新年快乐!!' | |
def send_wishes(): | |
friendList = itchat.get_friends(update=True)[1:] | |
for friend in friendList: | |
# 如果不是演示目的,把下面的方法改为itchat.send即可 |
View PCMusicViaWechat.py
#coding=utf8 | |
import os | |
import itchat | |
from NetEaseMusicApi import interact_select_song | |
# 第三方包通过该命令安装:pip install itchat, NetEaseMusicApi | |
HELP_MSG = u'''\ | |
欢迎使用微信网易云音乐 | |
帮助: 显示帮助 |
View fields.py
from __future__ import absolute_import | |
import email.utils | |
import mimetypes | |
from .packages import six | |
def guess_content_type(filename, default='application/octet-stream'): | |
""" | |
Guess the "Content-Type" of a file. |
View fields.py
from __future__ import absolute_import | |
import email.utils | |
import mimetypes | |
from .packages import six | |
def guess_content_type(filename, default='application/octet-stream'): | |
""" | |
Guess the "Content-Type" of a file. |
NewerOlder