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 / 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"] = {}
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "httpx",
# "rich",
# "typer",
# ]
# ///
"""
$ uv run django-top-100.py
@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
image: docker:latest
services:
- docker:dind
- postgres:latest
stages:
- build
- test
- release
# Usage:
# Building
# docker build -t jefftriplett/pinboardbot .
# Running (no saved state)
# docker run -it \
# jefftriplett/pinboardbot
#
FROM python:3.6-alpine as builder
LABEL maintainer "Jeff Triplett <jeff.triplett@...>"
@jefftriplett
jefftriplett / capture.py
Created October 27, 2018 15:44
Using Python 3, selenium, and headless chrome ala chromedriver to capture website screenshots
"""
To install:
# python requirements
$ pip install click selenium
# for headless chrome
$ brew install chromedriver
To use:
$ python capture.py https://revsys.com revsys.png