Skip to content

Instantly share code, notes, and snippets.

View asukaminato0721's full-sized avatar
💭
I may be slow to respond.

Asuka Minato asukaminato0721

💭
I may be slow to respond.
View GitHub Profile
@asukaminato0721
asukaminato0721 / main.py
Created April 16, 2024 04:47
simple-parser-v2, support some var
# only consider base case
from enum import Enum, auto
import unittest
import re
from typing import List, Union
class Status(Enum):
Normol = auto()
Number = auto()
# only consider base case
from enum import Enum, auto
import re
from typing import List, Union
class Status(Enum):
Normol = auto()
Number = auto()
"""
learned from https://www.sitepen.com/blog/unlocking-the-power-of-parser-combinators-a-beginners-guide
author: asuka minato
"""
from __future__ import annotations
import string as S
from dataclasses import dataclass, field
from typing import Callable, Dict, Iterable
@asukaminato0721
asukaminato0721 / cargo-why.py
Created September 11, 2023 18:46
A simple script to do cargo tree -i, use that instead. I wrote this since I didn't find that.
import sys
try:
import tomllib
except ImportError as e:
print(e, "require python 3.11, exit", file=sys.stderr)
exit()
from pathlib import Path
from typing import Any, Dict, List
from __future__ import annotations
from dataclasses import dataclass
from typing import Callable, List
from operator import attrgetter, add, sub, mul, truediv
def adder(a: Connector, b: Connector, c: Connector):
return TernaryConstraint(a, b, c, add, sub, sub)
@asukaminato0721
asukaminato0721 / Seven-segment display.py
Created October 5, 2022 09:08
good data structure + simple algorithm.
num2str = {
k: v.split("\n")[1:]
for k, v in {
1: """
|
|""",
2: """
_
_|
@asukaminato0721
asukaminato0721 / eigen_style_mat.py
Created September 25, 2022 14:18
a simple mat class which mimic the behavior of Eigen.
from dataclasses import dataclass
from typing import Any, Optional, Sequence
@dataclass
class Mat:
row: int
col: int
data: Optional[Sequence[Sequence[Any]]] = None
@asukaminato0721
asukaminato0721 / iostream.py
Created July 15, 2022 19:18
make iostream in python
class _cout:
def __lshift__(self, x):
print(x, end="")
return self
class _cin:
def __rshift__(self, x):
globals()[x] = input()
return self
@asukaminato0721
asukaminato0721 / S007: データヒストグラム.py
Last active June 11, 2022 14:31
paiza S007: データヒストグラム
'''
cut token, then use ast to traverse.
paiza
S007: データヒストグラム
'''
from collections import defaultdict
from dataclasses import dataclass
from functools import reduce
@asukaminato0721
asukaminato0721 / GalGame_auto_ocr.py
Last active March 7, 2022 09:34
needs improve for deal with picture.
#!/usr/bin/env python3
# use pillow https://pillow.readthedocs.io/en/latest/reference/ImageGrab.html to copy a place of screen, get pillow object
# use tesseract to transform a picture into text
# use TextBlob to translate text
# use google translate to translate text
from time import sleep
from typing import Tuple