项目里做了一个通用锁,使用 decorator 来方便的包住某些需要限制并发的函数。因为并发不是函数级别的,而是根据参数来限制,所以需要把参数传到通用锁的 decorator 里,代码大致如下
def lock_decorator(key=None):
def _lock_func(func):
// ==UserScript== | |
// @name TaobaoMultiSkuPriceChecker | |
// @version 1.0.1 | |
// @author leemars, whusnoopy | |
// @description Check multi sku price on search page of taobao | |
// @match https://s.taobao.com/* | |
// @downloadURL https://gist.github.com/whusnoopy/683925af701094b97fa20ece45bcb6b6/raw/taobao_sku_price.user.js | |
// @connect item.taobao.com | |
// @connect detailskip.taobao.com | |
// @connect detail.tmall.com |
# coding: utf8 | |
# https://www.yewen.us/blog/2018/10/append-machine-learning-3-linear-regression/ | |
from mxnet import autograd, nd | |
num_inputs = 9 # 特征数,当前问题里的变量数 1-9 | |
num_examples = 1000 # 样例数,我们会随机生成多少份样例来学习 | |
true_w = nd.array([0, 0, 0, 0, 0, 1, 0, 2, 1]) # 真实值 | |
features = nd.random.normal(scale=1, shape=(num_examples, num_inputs)) # 随机生成数据集 | |
labels = nd.dot(features, true_w) # 数据集对应的结果 |
关于知乎 "装修全用宜家是否合适" 的问题, 我的回答是
长文见下
// ==UserScript== | |
// @name unblock cnbeta | |
// @namespace http://cnbeta.com/ | |
// @downloadURL https://gist.github.com/whusnoopy/489c77059457c00c7b75/raw/unblock_cnbeta.user.js | |
// @version 0.3 | |
// @description force pc version on cnbeta during rss readers | |
// | |
// @match *://m.cnbeta.com/* | |
// | |
// @copyright 2017+, Snoopy |
/* | |
Bo-Blog v2.1 default skin mod by snoopy for felix021.com | |
link-color: #0d80bd; | |
light-link-color: #3d99ca; | |
border-color: #9ecce4; | |
light-border-color: #bee6fd; | |
background-color: #2e93c9; |
# coding: utf8 | |
from argparse import ArgumentParser | |
def color_str(o_str, color_num): | |
return '\033[1;{}m{}\033[m'.format(color_num, o_str) | |
def red_str(o_str): |