Skip to content

Instantly share code, notes, and snippets.

View synodriver's full-sized avatar
🙃

synodriver

🙃
  • /dev/null
View GitHub Profile
import scrapy
from scrapy.http import TextResponse
import json
class BiliSpider(scrapy.Spider):
name = 'bili'
allowed_domains = ['www.bilibili.com', "api.bilibili.com"]
start_urls = [
#define PY_SSIZE_T_CLEAN
#include <Python.h>
static binaryfunc origin = NULL;
static PyObject *
new_func(PyObject *self, PyObject *other)
{
return PyLong_FromLong(1);
"""
Copyright (c) 2008-2021 synodriver <[email protected]>
"""
import numpy as np
YIELD_STRESS = 400 # 屈服强度400Mpa
def main():
data = np.loadtxt("data.csv", delimiter=",") # 读取应力应变曲线 第一列应力 第二列应变
function main(splash, args)
assert(splash:go(args.url, nil, {
["Cookie"] = args.cookie
}))
assert(splash:wait(1))
local element = splash:select("#accessCode")
local ok, reason = element:send_text("glib") -- 输入提取码
if not ok then
return reason
@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():
@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
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 / 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)
@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": [
# -*- coding: utf-8 -*-
import ctypes
from collections import namedtuple
from ctypes import wintypes
# import win32process
class MODULEENTRY32W(ctypes.Structure):
_fields_ = [
("dwSize", wintypes.DWORD),