Skip to content

Instantly share code, notes, and snippets.

@DougLee
DougLee / SM.py
Created April 16, 2020 09:01
素描
# -*- coding:utf-8 -*-
import cv2
import numpy as np
from tkinter import filedialog, Tk
from os import getcwd
from re import findall
import pymysql
from random import shuffle
def get_rand_option(cursor, pk):
sql = "SELECT `explain` FROM `words190905` where id <> %d order by rand() limit 3 ;" % pk
cursor.execute(sql)
result = cursor.fetchall()
return [item[0] for item in result]
@DougLee
DougLee / 190828-抽取题目.py
Last active August 29, 2019 08:31
抽取国庆题目
import re
def parse_question(file_path):
result = []
with open(file_path, encoding='utf8') as f:
question = ''
answer = ''
option = ''
tmp = dict()
@DougLee
DougLee / calc_tax.py
Created January 25, 2019 08:22
2019扣税计算小工具
import os,sys,re
#(start, end, ratio, fastleft)
tax_ratio = [(0, 36000, 0.03, 0), (36000, 144000, 0.1, 2520), (144000, 300000, 0.2, 16920), (300000, 420000, 0.25, 31920), (420000, 660000, 0.3, 52920), (660000, 960000, 0.35, 85920), (960000, -1, 0.45, 181920)]
input_str = input("Please Input Your Monthly Salary Like This : 月薪-专项扣除数+年终奖:")
#获取工资信息
@DougLee
DougLee / checkISSN
Last active August 26, 2015 08:12
计算ISSN是否合法
///验证ISSN是否有效
/*
ISSN有效性的算法:
1 ISSN号共8个字符每四位一组,以'-'连接,其中前7位是0-9的数字,最后一位是标识位,可能为 0-9 或者X
2 取ISSN号的前7位数字,并分别乘以对应的加权值(8 7 6 5 4 3 2 )
3 将第2步的各个乘积相加, 并对模数(11)求余
4 模数(11)减去余数即为标识位,若模数减余数值为10,则标识位为'X'
*/
function isISSN(value) {
var re = new RegExp("^[0-9]{4}-[0-9X]{4}$");
@DougLee
DougLee / gist:299a5a12fc21f26b8610
Created January 5, 2015 06:25
use muti delegate capture muti variable
static void Main(string[] args)
{
List<MethodInvoker> list = new List<MethodInvoker>();
for (int i = 0; i < 5; i++)
{
int counter = i * 10;
list.Add(delegate
{