This file contains 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 docstring_decorator(s): | |
""" | |
动态修改docstring装饰器 | |
>>> a = "test" | |
>>> @docstring_decorator(f"a={a}") | |
>>> def f(): | |
>>> pass | |
>>> print(f.__doc__) # a=test | |
""" |
This file contains 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
releases_api=https://api.github.com/repos/indygreg/python-build-standalone/releases/latest | |
urls=$(curl -s $releases_api | jq '.assets[].browser_download_url' -r | grep -E 'x86_64-unknown-linux-gnu-pgo%2Blto-full.tar.zst$') | |
echo "Available versions:" | |
echo "$urls" | awk -F "/" '{print $NF}' | awk -F "-" '{print $2}' | sed 's/%2B.*//g' | sort -V | uniq | |
echo "Enter the version you want to install: " | |
read version | |
url=$(echo "$urls" | grep "cpython-$version" | head -n 1) | |
version=$(echo "$url" | awk -F "/" '{print $NF}' | awk -F "-" '{print $2}' | sed 's/%2B.*//g') |
This file contains 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 db.models import Comment, User | |
from django.db.models import Prefetch | |
from django_print_sql import print_sql | |
import rich | |
import uuid | |
class User(models.Model): | |
name = models.CharField(max_length=100) |
This file contains 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 "PS1='\[\e[37;40m\][\[\e[32;40m\]\u\[\e[37;40m\]@\h \[\e[35;40m\]\W\[\e[0m\]]\$'" >> ~/.bashrc |
This file contains 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 functools | |
import hashlib | |
import inspect | |
import os | |
import pathlib | |
import pickle | |
import tempfile | |
from typing import Any, Callable, Concatenate, ParamSpec, TypeVar | |
from loguru import logger |
This file contains 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 Generic, TypeVar, cast | |
import eth_abi | |
import web3 | |
from eth_abi.exceptions import DecodingError | |
from eth_typing import ChecksumAddress, HexStr | |
from eth_utils.abi import function_signature_to_4byte_selector | |
from eth_utils.address import to_checksum_address | |
from hexbytes import HexBytes | |
from typing_extensions import ParamSpec |
This file contains 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
export SSH_AUTH_SOCK=$(ls -t /tmp/ssh-**/* | head -1) | |
# https://github.com/microsoft/vscode/issues/168202 |
This file contains 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
# https://github.com/Bogdanp/dramatiq | |
# start worker: dramatiq <module.name> | |
import sys | |
import dramatiq | |
import requests | |
from dramatiq.brokers.redis import RedisBroker | |
from dramatiq.middleware import CurrentMessage | |
from dramatiq.results import Results | |
from dramatiq.results.backends.redis import RedisBackend |
This file contains 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 django.db import models | |
class User(models.Model): | |
id = models.AutoField(primary_key=True) | |
parent = models.ForeignKey("self", null=True, blank=True, on_delete=models.CASCADE) | |
def get_tree_users_recursive(self) -> "models.QuerySet[User]": | |
return User.objects.extra( | |
where=[ |
This file contains 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 inspect | |
import logging | |
import os | |
import argparse | |
import pathlib | |
import signal | |
import subprocess | |
import sys | |
import time | |
import loguru |
NewerOlder