- Fast, reliable and reproducible lint setup
- Black / flake8 / ruff called directly or within pre-commit
- Not enforced on development machines
- Duplicate setup on CI
- Not all tools are wrapped
- The config options / versions don't match Then;
| # Delete merged branches | |
| git fetch -p && for branch in $(git for-each-ref --format '%(refname) %(upstream:track)' refs/heads | awk '$2 == "[gone]" {sub("refs/heads/", "", $1); print $1}'); do git branch -D $branch; done | |
| # Update origin from upstream | |
| git fetch upstream && git checkout main && git merge upstream/main | |
| # ^Same thing but for dinosaurs | |
| git fetch upstream && git checkout master && git merge upstream/master |
| # /// script | |
| # dependencies = [ | |
| # # TODO: Is there a min version requirement? | |
| # "niquests", | |
| # "ipdb", | |
| # ] | |
| # /// | |
| # .gitignore file header sample: | |
| # # Source: https://raw.githubusercontent.com/github/gitignore/7bfab2ec5b8a7576811b4342991bb6764fe725cf/Python.gitignore |
| import json | |
| import pygments | |
| from debug_toolbar.middleware import get_show_toolbar | |
| from django.http import HttpResponse | |
| from pygments.formatters import HtmlFormatter | |
| from pygments.lexers import JsonLexer | |
| TRUE_VALUES = ("t", "true", "1", 1, True) |
| # This script can be easily run with the following command: | |
| # $ hatch run uuid7_generation_speed.py | |
| # or you can manually install the dependencies and run the script as you like. | |
| # | |
| # https://github.com/pypa/hatch/blob/master/docs/how-to/run/python-scripts.md | |
| # | |
| # /// script | |
| # title = "Performance test for UUID7 generators" | |
| # requires-python = ">=3.12" | |
| # dependencies = [ |
| from pkgutil import iter_modules | |
| from pprint import pprint | |
| from importlib import import_module | |
| from importlib.metadata import version as version_il | |
| from importlib.metadata import PackageNotFoundError | |
| modules = list(iter_modules()) | |
| packages = filter(lambda x: x.ispkg, modules) | |
| packages = list(packages) # The filter needs to be iterated more than once |
| import time | |
| from django.db import connections | |
| def management_command_profiler(func): | |
| """ | |
| This decorator shows the execution time and query count of the function passed. | |
| Output is designed to use with methods of management commands. | |
| """ |
| # pip install "httpx>=0.16.1" | |
| # Make a dismiss request from https://www.kadenze.com/notifications page manually. | |
| # Get x-csrf-token and cookie from that request, fill HEADERS with them. | |
| import httpx | |
| from pprint import pprint | |
| HEADERS = { | |
| "accept": "application/json, text/javascript, */*; q=0.01", |
| import django.apps | |
| models = django.apps.apps.get_models() | |
| for model in models: | |
| print(model, model.objects.count()) |
| import jwt | |
| from channels.auth import AuthMiddlewareStack | |
| from django.conf import settings | |
| from django.contrib.auth.models import AnonymousUser | |
| from django.db import close_old_connections | |
| from rest_framework.authtoken.models import Token | |
| from members.models import MemberProfile | |