This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A(dict): | |
def __new__(cls): | |
ret = dict.__new__(cls) | |
ret.a = 1 | |
return ret | |
class B(A): | |
def __new__(cls, a): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import itertools | |
t = input('输入四个数:') | |
nums = list(map(int, re.split('\s+', t))) | |
div = lambda x, y : x // y | |
signs = [int.__add__, int.__sub__, int.__mul__, div] | |
signs_txt = {signs[0]: '+', signs[1]: '-', signs[2]: '*', signs[3]: '/'} | |
signs_to_txt = lambda x: signs_txt[x] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 基于 peewee,需要传入 model 类和查询条件 | |
def parse_query(sheet_model, statements): | |
""" | |
statements: | |
['and', | |
['==', 'col1', val1], | |
['!=', 'col2', val2], | |
['and', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import struct | |
from PIL import Image | |
fp = open('myshot.raw', 'rb') | |
size = struct.unpack('II', fp.read(8)) | |
img = Image.frombytes('RGBA', size, fp.read()) | |
img.save('out.bmp') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image, ImageFont, ImageDraw | |
text = '立行跃击' | |
font = ImageFont.truetype('../font/SourceHanSansCN-Regular.otf', 80) | |
for i in text: | |
img = Image.new('RGBA', (100, 100)) | |
brush = ImageDraw.Draw(img) | |
brush.text((10,0), i, fill='#000', font=font) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function getSvgPositionFromToEl(stage, el) { | |
var point = stage.createSVGPoint(); | |
let matrix = stage.getScreenCTM().inverse().multiply(el.getScreenCTM()); | |
return point.matrixTransform(matrix); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
def run(): | |
head, *data = input('> ').strip().split(' ') | |
if head in ['ls', 'dir']: | |
path = data[0] if len(data) else '' | |
for i in os.listdir(path): | |
print(i) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Copyright (c) 2018 fy | |
This software is provided 'as-is', without any express or implied | |
warranty. In no event will the authors be held liable for any damages | |
arising from the use of this software. | |
Permission is granted to anyone to use this software for any purpose, | |
including commercial applications, and to alter it and redistribute it | |
freely, subject to the following restrictions: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"errors" | |
"fmt" | |
"io" | |
"log" | |
"net/rpc" | |
"net/rpc/jsonrpc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
# 更新于2017/10/02,python3测试通过 | |
import re | |
import requests | |
# 领取 X 铜币 | |
# 每日登录奖励已领取 | |
base_headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.57 Safari/537.36 OPR/40.0.2308.15 (Edition beta)', 'Referer': 'https://www.v2ex.com/signin', 'Origin': 'https://www.v2ex.com'} |
OlderNewer