Skip to content

Instantly share code, notes, and snippets.

View BlueGlassBlock's full-sized avatar
💭
Think

Nyuan Zhang BlueGlassBlock

💭
Think
View GitHub Profile
checking for platform ... linux
checking for architecture ... x86_64
checking for gcc ... /usr/bin/gcc
checking for nim ... no
checking for nim ... no
checking for git ... /usr/local/bin/git
checking for gzip ... /usr/bin/gzip
checking for tar ... /usr/bin/tar
/usr/local/bin/git rev-parse HEAD
checking for ninja ... no
@BlueGlassBlock
BlueGlassBlock / json5.pest
Created April 19, 2024 10:43
Basic JSON5 in Rust
// Reference: https://spec.json5.org/#grammar
// See also: https://262.ecma-international.org/5.1/
// JSON5 Grammar
LineTerminator = _{ "\u{000A}" | "\u{000D}" | "\u{2028}" | "\u{2029}" }
LineTerminatorSeq = _{ "\u{000D}\u{000A}" | LineTerminator }
LineContinuation = _{ "\\" ~ LineTerminatorSeq }
Char = _{ !("\\" ~ LineTerminator) ~ ANY }
from __future__ import annotations
import argparse
from logging import getLogger, basicConfig
from pathlib import Path
from zipfile import ZipFile
basicConfig(level="INFO")
try:
@BlueGlassBlock
BlueGlassBlock / test_hash_fancy_wheel.py
Created November 13, 2022 13:51
Hashing `fancy_wheel`
def test_generate_record(fancy_wheel):
with WheelFile.open(fancy_wheel) as w:
for elem in w.get_contents():
byte_data = elem[1].read()
print(
f"{elem[0][0]},sha256={urlsafe_b64encode(sha256(byte_data).digest()).rstrip(b'=').decode()},{len(byte_data)}"
)
assert 0 # Let pytest spit out the stdout data
from time import sleep
from typing import List
from kayaku import ConfigModel, initialize, save
from kayaku.model import create
class B(ConfigModel, domain="graia.ariadne"):
account: int = 0
"""More annotations"""

get_entrypoints() -> {name, provider_define}

name could be used in:

# file?
# pyprojects? x

# model 不需要在 entry point 里面声明吧? 有必要么...就是他能做到什么
@BlueGlassBlock
BlueGlassBlock / MessageChain_strat.py
Created June 22, 2022 13:36
MessageChain strategy for hypothesis
import typing
from hypothesis import given
from hypothesis import strategies as st
from pydantic import BaseModel, EmailStr, PaymentCardNumber, PositiveFloat
from graia.ariadne.message.chain import MessageChain, MessageContainer
from graia.ariadne.message.element import At, AtAll, Image, Plain, Voice
chain_strategy = st.builds(
From 588b72f29de2e15a361959d4b336d3972f46ee7b Mon Sep 17 00:00:00 2001
From: BlueGlassBlock <blueglassblock@outlook.com>
Date: Sun, 29 May 2022 15:15:58 +0800
Subject: [PATCH] chore: migrate builtin service to launart
---
poetry.lock | 36 +++++++++----
pyproject.toml | 1 +
src/graia/amnesia/builtins/aiohttp.py | 69 ++++++++++++++-----------
src/graia/amnesia/builtins/common.py | 2 +-
@BlueGlassBlock
BlueGlassBlock / owo.md
Created April 18, 2022 14:43
Amnesia Auto Reconnect

【Dev】GreyElaina 2022/4/18 22:27:21 声明一个declare model配置transport的自动重连设定

【Dev】GreyElaina 2022/4/18 22:27:28 可指定scope

【Dev】GreyElaina 2022/4/18 22:27:35 默认全局应用

【Dev】GreyElaina 2022/4/18 22:28:03

@BlueGlassBlock
BlueGlassBlock / poly.py
Last active March 26, 2022 13:49
Polynomial, Atcoder ABC245 Task D
from typing import List
from itertools import zip_longest
class Poly:
data: List[int]
def __init__(self, data: List[int] = []) -> None:
self.data = data or []