Skip to content

Instantly share code, notes, and snippets.

View fy0's full-sized avatar
🎲
thinking

fy fy0

🎲
thinking
View GitHub Profile
@fy0
fy0 / test.py
Last active September 21, 2016 06:38
class A(dict):
def __new__(cls):
ret = dict.__new__(cls)
ret.a = 1
return ret
class B(A):
def __new__(cls, a):
@fy0
fy0 / 24点.py
Last active October 8, 2016 13:58
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]
# 基于 peewee,需要传入 model 类和查询条件
def parse_query(sheet_model, statements):
"""
statements:
['and',
['==', 'col1', val1],
['!=', 'col2', val2],
['and',
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')
@fy0
fy0 / PIL文本生成图片.py
Last active May 7, 2017 13:26
PIL文本生成图片
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)
export function getSvgPositionFromToEl(stage, el) {
var point = stage.createSVGPoint();
let matrix = stage.getScreenCTM().inverse().multiply(el.getScreenCTM());
return point.matrixTransform(matrix);
}
@fy0
fy0 / mpt.py
Last active November 12, 2017 10:24
MicroPython Simple Terminal
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)
@fy0
fy0 / mb_simple_demo.cpp
Last active May 5, 2018 11:08
包含创建窗口,JS/CPP互调,最大化/最小化,无边框窗口拖动,获取窗口句柄,根据exe文件图标设置窗口图标、只允许单实例等等
/**
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:
package main
import (
"context"
"errors"
"fmt"
"io"
"log"
"net/rpc"
"net/rpc/jsonrpc"
# 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'}