# https://just.systems | |
set quiet | |
set dotenv-load | |
set export | |
# List commands | |
_default: | |
just --list --unsorted --justfile {{justfile()}} --list-heading $'Available commands:\n' | |
{# | |
class ReviewForm(forms.ModelForm): | |
class Meta: | |
model = Review | |
fields = ( | |
"comment", | |
"score", | |
) | |
help_texts: ClassVar = { |
import mmap | |
def get_last_lines(path: str, count: int) -> list[str]: | |
"""Get count last lines from a file.""" | |
with open(path, "r+b") as text_file: | |
text_mmap = mmap.mmap(text_file.fileno(), 0, mmap.ACCESS_READ) | |
position = len(text_mmap) | |
while count and (position := text_mmap.rfind(b"\n", 0, position)) != -1: | |
count -= 1 |
# Might be outdated! Check https://github.com/marketplace/actions/build-docker-and-deploy-to-caprover for the latest version. | |
name: Create and publish Docker image to CapRover | |
# Requires the following Action secrets to be set in your GitHub repo: | |
# - CAPROVER_APP_TOKEN | |
# - CAPROVER_SERVER_URL | |
on: | |
push: |
# Delete all forks that haven't been updated since 2020 | |
gh auth refresh -h github.com -s delete_repo | |
gh search repos \ | |
--owner tonybaloney \ | |
--updated="<2020-01-01" \ | |
--include-forks=only \ | |
--limit 100 \ | |
--json url \ | |
--jq ".[] .url" \ | xargs -I {} gh repo delete {} --confirm |
This logging setup configures Structlog to output pretty logs in development, and JSON log lines in production.
Then, you can use Structlog loggers or standard logging
loggers, and they both will be processed by the Structlog pipeline (see the hello()
endpoint for reference). That way any log generated by your dependencies will also be processed and enriched, even if they know nothing about Structlog!
Requests are assigned a correlation ID with the asgi-correlation-id
middleware (either captured from incoming request or generated on the fly).
All logs are linked to the correlation ID, and to the Datadog trace/span if instrumented.
This data "global to the request" is stored in context vars, and automatically added to all logs produced during the request thanks to Structlog.
You can add to these "global local variables" at any point in an endpoint with `structlog.contextvars.bind_contextvars(custom
Stable branch, I can see you in the stable branch
See you again, I see you again
In my dreams, in my dreams, in my dreams, in my dreamsMorning light, I remember the morning li-i-i-i-ight
Outside my door (outside my door), I'll see you no more (see you no more)
In my dreams, in my dreams, in my dreams, in my dreams
>
# render pdf using weasyprint | |
# depends on: weasyprint | |
import weasyprint | |
from django.template.loader import render_to_string | |
def render_to_pdf(template_src, context_dict=None): | |
html = render_to_string(template_src, context_dict) | |
try: | |
pdf = weasyprint.HTML(string=html).write_pdf() | |
except Exception as e: |
web: python manage.py collectstatic --noinput && bin/start-pgbouncer bin/start-nginx gunicorn -c gunicorn.conf.py project.wsgi |