Skip to content

Instantly share code, notes, and snippets.

View synodriver's full-sized avatar
🙃

synodriver

🙃
  • /dev/null
View GitHub Profile
import re
from matplotlib import pyplot as plt
from PIL import Image,ImageColor, ImageDraw, ImageFont
import numpy as np
import zhconv
text = """A140   , 、 。 . ‧ ; : ? ! ︰ … ‥ ﹐ ﹑ ﹒
A150 · ﹔ ﹕ ﹖ ﹗ | – ︱ — ︳ ╴ ︴ ﹏ ( ) ︵
A160 ︶ { } ︷ ︸ 〔 〕 ︹ ︺ 【 】 ︻ ︼ 《 》 ︽
@synodriver
synodriver / gist:be3da44b305fc171d25141808e10a848
Created November 2, 2022 03:40
让abaqus切换语言。report只有英文版输出的可以给别的软件
# 摸板抄你自己的
template = """
###
### This file contains configuration information for Abaqus/CAE
### language settings.
###
####################################################################
# This section describes what language and what encoding Abaqus/CAE
# should use for a given system locale name.
@synodriver
synodriver / test.py
Created October 7, 2022 12:21
shutil with rar support
# -*- coding: utf-8 -*-
import os
os.environ["UNRAR_LIB_PATH"] = r"C:\Program Files (x86)\UnrarDLL\x64\UnRAR64.dll"
import shutil
from unrar import rarfile
from pprint import pprint
@synodriver
synodriver / qq_message_xml.md
Created October 6, 2022 17:13 — forked from koukuko/qq_message_xml.md
发送XML消息的格式

QQ的XML消息格式整理

QQ可以使用xml的方式发送消息,以下为了方便描述统称为卡片。

发送方式

通过机器人的API进行发送xml即可,但是如果选择发送xml,那么其他如[image=xxx][@xxx]这些命令就不可使用了。整个消息只有XML。

基本结构

xml主要由msg,item,source这3部分组成

<?xml version='1.0' encoding='utf-8' standalone='yes'?>
# -*- coding: utf-8 -*-
import ctypes
from collections import namedtuple
from ctypes import wintypes
# import win32process
class MODULEENTRY32W(ctypes.Structure):
_fields_ = [
("dwSize", wintypes.DWORD),
@synodriver
synodriver / test.py
Created August 16, 2022 09:22
A simple app to test trailer extension
async def app2(scope, receive, send):
if scope["type"] == "http":
# request = Request(scope, receive)
# body = await request.body()
# print(body)
await send(
{
"type": "http.response.start",
"status": 200,
"headers": [
@synodriver
synodriver / safe.py
Created August 9, 2022 09:01
py安全沙盒环境
def safe_eval(c):
allow_func = {"print": print, "input": input}
bytecode = compile(c, "", "eval")
for name in bytecode.co_names:
if name not in allow_func:
raise Exception(f"not allowed function: {name}")
return eval(bytecode, {"__builtins__": {}}, allow_func)
import sys
import hashlib
md = hashlib.md5()
with open(sys.argv[1], "rb") as f:
while chunk := f.read(60 * 1024):
md.update(chunk)
print(md.hexdigest())
@synodriver
synodriver / unistd.h
Created July 29, 2022 07:27
解决win没有这个header
#ifndef _UNISTD_H
#define _UNISTD_H
#include <io.h>
#include <process.h>
#endif
@synodriver
synodriver / auto.py
Last active July 28, 2022 08:33
自动格式化
"""
Copyright (c) 2008-2022 synodriver <[email protected]>
"""
import asyncio
from pathlib import Path
from watchfiles import Change, awatch
async def main():