Skip to content

Instantly share code, notes, and snippets.

View jefftriplett's full-sized avatar
Living the dream

Jeff Triplett jefftriplett

Living the dream
View GitHub Profile
@jefftriplett
jefftriplett / magic-link.py
Last active April 5, 2021 09:29
Django Management Command to print a "Magic Link" for one-click log-in. This is nice for people who project switch or don't want to remember passwords.
@jefftriplett
jefftriplett / Makefile
Created August 30, 2020 21:34
Minimal TailwindCSS setup
.PHONY: static
static:
@npx -p tailwindcss@1.7.5 tailwindcss build ./assets/index.css \
--config ./assets/tailwind.config.js \
--output ./frontend/css/output.css
@jefftriplett
jefftriplett / docker-compose-project-name.yml
Last active March 4, 2024 10:34
Watchtower in Docker Compose
version: "3.3"
services:
web:
container_name: my-fancy-container
image: docker.pkg.github.com/jefftriplett/private-repo/private-project:latest
labels:
- "com.centurylinklabs.watchtower.enable=true"
- "com.centurylinklabs.watchtower.lifecycle.post-update='./post-update.sh'"
@jefftriplett
jefftriplett / main.py
Last active March 24, 2021 02:51
This is a quick script to check the "CF-Cache-Status" header to see if Cloudflare is serving your content out of cache.
import frontmatter
import requests
import typer
def main(url: str):
request = requests.get(url)
post = frontmatter.loads("")
headers = request.headers
post["headers"] = {}
"""
$ wget https://hugovk.github.io/top-pypi-packages/top-pypi-packages-30-days.json
$ python django-top-100.py
"""
import json
from pathlib import Path
@jefftriplett
jefftriplett / mypy.ini
Created December 9, 2019 20:08
pytest + mypy + django + drf
[mypy]
python_version = 3.7
ignore_missing_imports = True
plugins =
mypy_django_plugin.main,
mypy_drf_plugin.main
strict_optional = True
[mypy.plugins.django-stubs]
django_settings_module = "config.test_settings"
@jefftriplett
jefftriplett / python-django-postgres-ci.yml
Last active March 27, 2024 04:27
This is a good starting point for getting Python, Django, Postgres running as a service, pytest, black, and pip caching rolling with GitHub Actions.
name: CI
on: [push]
jobs:
test:
runs-on: ubuntu-latest
services:
@jefftriplett
jefftriplett / modd.conf
Last active January 13, 2020 15:03
My setup for: Modd, Python, Django, TailwindCSS, Black, and pytest
# Update project requirements when requirements.txt changes.
requirements.txt {
prep +onchange: "pip install -U -r requirements.txt"
}
../.envrc {
prep +onchange: "direnv allow"
}
**/index.css **/tailwind.config.js {
FROM python:3.7
COPY hello.py /
CMD [ "python", "/hello.py" ]
@jefftriplett
jefftriplett / modd.conf
Last active July 4, 2019 20:34
Django + Modd + Maybe Docker
# Run the test suite if a source or test file changes
**/tests/test_*.py {
# prep +onchange: pytest @dirmods
prep +onchange: pytest @mods
}
requirements.txt {
# prep +onchange: pytest @dirmods
prep +onchange: "
pip install -U -r requirements.txt