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
| #!/bin/bash | |
| # Ubuntu 24 安全初始化脚本 | |
| # 请以 root 用户运行: sudo bash secure-init.sh | |
| # 1. 输入新用户名 | |
| read -p "请输入新用户名: " NEWUSER | |
| adduser $NEWUSER | |
| usermod -aG sudo $NEWUSER | |
| # 2. 输入公钥并写入 authorized_keys |
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 diskcache import Cache | |
| import functools | |
| import asyncio | |
| from typing import Any, Callable, TypeVar, Union, Awaitable | |
| import time | |
| import logging | |
| import hashlib | |
| import json | |
| T = TypeVar('T') |
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 rich_show import progress | |
| from rich.console import Console | |
| from rich.progress import Progress, TimeElapsedColumn, TimeRemainingColumn, BarColumn, MofNCompleteColumn, SpinnerColumn | |
| from rich.live import Live | |
| # from rich import print | |
| console = Console() | |
| # 创建 Progress 对象和任务 | |
| progress = Progress( | |
| SpinnerColumn(), |
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 logging | |
| import colorlog | |
| fmt = "{asctime} {log_color}{levelname} {name}: {message}" | |
| colorlog.basicConfig(style="{", format=fmt, stream=None) | |
| # logging.basicConfig(level=logging.DEBUG, format="%(asctime)s %(levelname)s %(message)s",stream=None) | |
| log = logging.getLogger(name="test") | |
| # 放到main使用 | |
| log.setLevel(logging.DEBUG) |
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 requests | |
| import json | |
| import hashlib | |
| import base64 | |
| import os | |
| class WeComBot(): | |
| headers = {"Content-Type": "application/json"} | |
| req_message = {"errcode": 1,"errmessage": "请求微信企业失败,请检查网络"} | |