This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def read_visible_rows_to_dataframe(file_path: str, sheet_name: str|None=None) -> pd.DataFrame: | |
| """ | |
| Reads the specified sheet of an Excel file, ignores all hidden rows, and returns a pandas DataFrame. | |
| :param file_path: Path to the Excel file | |
| :param sheet_name: Name of the sheet to read. If None, reads the active sheet. | |
| :return: A pandas DataFrame containing data from visible rows | |
| """ | |
| wb_info = load_workbook(filename=file_path, read_only=False) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from pathlib import Path | |
| import re | |
| import html | |
| posts = list(Path('_posts').glob('*.md')) | |
| for post_p in posts: | |
| content = post_p.read_text(encoding='utf-8') | |
| content = content.replace('<pre><code>', '<pre><code class="language-text">') | |
| content = content.replace('"', '"') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from random import randint | |
| from fastapi import FastAPI | |
| from enum import Enum | |
| app = FastAPI() | |
| class DynamicEnum(Enum): | |
| pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def merge(ops: list[str], values: list[int], final_merger=False): | |
| priority = {'*': 1, '/': 1, '+': 2, '-': 2, '$': 9999} | |
| while True: | |
| if len(ops) >= 2: | |
| last, last_last = [ops.pop() for _ in range(2)] | |
| if final_merger: | |
| last_last, last = last, last_last | |
| elif len(ops) >= 1 and len(values) >= 2: | |
| last_last, last = ops.pop(), '$' | |
| else: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from __future__ import annotations | |
| import io | |
| from functools import lru_cache | |
| from PIL import Image | |
| import numpy as np | |
| import pickle | |
| import os |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class DataclassesBase: | |
| def __init__(self, **data): | |
| self._annotations = self.__annotations__ if hasattr(self, "__annotations__") else {} | |
| annotations = self._annotations.copy() | |
| for key, value in data.items(): | |
| if key in annotations: | |
| if isinstance(value, annotations[key]): | |
| self.__dict__[key] = value | |
| annotations.pop(key) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| echo "deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse | |
| # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse | |
| deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse | |
| # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse | |
| deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse | |
| # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse | |
| deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse | |
| # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse | |
| " > /etc/apt/sources.list |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| tar –xvf file.tar //解压 tar包 | |
| tar -xzvf file.tar.gz //解压tar.gz | |
| tar -xjvf file.tar.bz2 //解压 tar.bz2 | |
| tar –xZvf file.tar.Z //解压tar.Z |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| git log --author="myuanz" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s|%.2f%%, removed lines: %s|%.2f%%, total lines: %s\n", add, add/(add + subs)*100, subs, subs/(add + subs)*100, loc }' - |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from typing import Union, Dict, Any, Callable | |
| from inspect import isfunction, isclass | |
| class ChangeName: | |
| name = "" | |
| def __init__(self, name): | |
| self.name = name |