Skip to content

Instantly share code, notes, and snippets.

View KaitoHH's full-sized avatar

KaitoHH KaitoHH

View GitHub Profile
KaitoHH /
Last active December 4, 2021 17:19
A decorator to decorate a class and all its member function
# Refer to for a complete tutorial
from functools import wraps, partial
def NamedLogger(cls=None, name='default Logger'):
if cls is None:
return partial(NamedLogger, name=name)
@wraps(cls, updated=()) # see
class ClassWrapper:
KaitoHH /
Created December 1, 2017 15:18
make qr code from JSON config file of shadowsocks
import qrcode
import sys
import json
import base64
with open(sys.argv[1]) as fp:
document = json.load(fp)
method = document['method']
hostname = document['server']
KaitoHH / douyu_gift_stat.js
Last active October 1, 2017 08:20
count gift in douyu
// paste these code snippets into browser console of anyone of anchor and you will get live statistic of received gift
// some function can be used to adjust behaviour, see the code below
var giftCnt = {};
var msgMonitor;
var showTableFlag = true;
var req = require("shark/lang/observer").on("", function(e) {
if (!e) return;
var msg = jQuery(e).find(".chat-msg-item").text();
var gift = jQuery(e).find(".gift-name").text();
var combo = jQuery(e).find(".hy-org").text();
KaitoHH / color.bas
Last active July 5, 2017 08:16
change into rainbow color for every single characters (tested on Microsoft Word 2016)
Sub color()
Application.ScreenUpdating = False
Dim i As Long
Dim color
'rainbow color
color = Array(8388736, 255, 33023, 65535, 65280, 16776960, 16711680)
With ActiveDocument
For i = 1 To .Characters.Count
.Characters(i).Font.color = color(i Mod 7)