Skip to content

Instantly share code, notes, and snippets.

LittleCoder littlecodersh

Block or report user

Report or block littlecodersh

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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'
@littlecodersh
littlecodersh / flask_qr.py
Created Dec 5, 2016
A demo of how to show itchat qrcode through website.
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):
@littlecodersh
littlecodersh / WeChatCheckFriend.py
Created Sep 28, 2016
Demo of checking friends' status of wechat.
View WeChatCheckFriend.py
#coding=utf8
import itchat
CHATROOM_NAME = 'friend'
CHATROOM = None
HELP_MSG = u'''\
好友状态监测
* 发送名片将会返回好友状态
* 请确有名为%s的未使用的群聊
* 并将该群聊保存到通讯录
@littlecodersh
littlecodersh / WechatSmartWish.py
Created Sep 28, 2016
Demo of sending smart wishes through wechat.
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即可
@littlecodersh
littlecodersh / PCMusicViaWechat.py
Created Sep 28, 2016
Demo of controlling music player through wechat.
View PCMusicViaWechat.py
#coding=utf8
import os
import itchat
from NetEaseMusicApi import interact_select_song
# 第三方包通过该命令安装:pip install itchat, NetEaseMusicApi
HELP_MSG = u'''\
欢迎使用微信网易云音乐
帮助: 显示帮助
@littlecodersh
littlecodersh / fields.py
Created Sep 17, 2016
Put this in requests/packages/urllib3 and you may upload files with Chinese name in itchat (python 2)
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.
@littlecodersh
littlecodersh / fields.py
Last active Apr 26, 2019
Put this in requests/packages/urllib3 and you may upload files with Chinese name in itchat (python 3)
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.
You can’t perform that action at this time.