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
| # Compiled source # | |
| ################### | |
| *.com | |
| *.class | |
| *.dll | |
| *.exe | |
| *.o | |
| *.so | |
| # Packages # |
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
| import sys | |
| import os | |
| from loguru import logger | |
| def setup_logger( | |
| log_dir: str = "logs", | |
| console_level: str = "INFO", | |
| file_level: str = "DEBUG", | |
| error_level: str = "ERROR" | |
| ): |
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
| services: # 定义服务 | |
| web: # 服务名 | |
| image: nginx:latest # 使用的镜像 | |
| ports: # 端口映射 | |
| - "20080:80" | |
| volumes: # 挂载目录 | |
| - ./web:/usr/share/nginx/html # Nginx 用来存储和提供 HTML 文件的默认目录。 | |
| environment: # 定义环境变量 | |
| - NGINX_HOST=localhost | |
| # 定义依赖 |
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 | |
| # %% | |
| # 从字符串创建Path对象 | |
| current_dir = Path(".") # 当前目录 | |
| home_dir = Path.home() # 用户目录 | |
| abo_dir = Path("/home") # 绝对路径 | |
| rel_dir = Path("~") | |
| doc_dir = home_dir / "Documents" # 使用/操作符拼接路径 |
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 get_list(size: Sequence[int], ele: Any = None) -> List[Any]: | |
| # TODO:这个函数可以上传到 gist 中 | |
| """ | |
| Generate a nested list of a specified size, filled with a specified element. | |
| Args: | |
| size (Sequence[int]): A list of integers representing the size of each dimension. | |
| ele (Any, optional): The element to fill the list with. Defaults to None. | |
| Returns: | |
| List[Any]: A nested list of the specified size, filled with the specified element. | |
| Raises: |
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
| """ | |
| Generator functions for prime numbers using sieve of Eratosthenes. | |
| """ | |
| from typing import Generator, Optional, Callable | |
| def natural_numbers(start: int = 0, | |
| stop: Optional[int] = None, | |
| step: int = 1) -> Generator[int, None, None]: |
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
| # 非root用户 | |
| (type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y)) \ | |
| && sudo mkdir -p -m 755 /etc/apt/keyrings \ | |
| && wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \ | |
| && sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \ | |
| && echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \ | |
| && sudo apt update \ | |
| && sudo apt install gh -y |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.