Skip to content

Instantly share code, notes, and snippets.

@joshuadavidthomas
joshuadavidthomas / conftest.py
Last active May 6, 2024 16:16
`factory-boy` vs `model-bakery`
from __future__ import annotations
import itertools
import pytest
from model_bakery import baker
from .factories import ActivityFactory
@joshuadavidthomas
joshuadavidthomas / auth_django.py
Created April 23, 2024 21:54
Single file Django application with `django-allauth`
from __future__ import annotations
from pathlib import Path
from django import conf
from django import http
from django import setup
from django import urls
from django.contrib.auth.decorators import login_required
from django.core.handlers.wsgi import WSGIHandler
import pytest
from django.db import models
from django_q.models import Schedule
from model_bakery import baker
class Task(models.Model):
q_schedule = models.OneToOneField(
"django_q.Schedule",
on_delete=models.SET_NULL,
from __future__ import annotations
import click
@click.command()
@click.argument("name", type=str, default="World")
def main(name: str):
print(f"Hello, {name.title()}!")
@joshuadavidthomas
joshuadavidthomas / decorators.py
Last active February 7, 2024 15:10
if `neapolitan.views.CRUDView` and `rest_framework.viewsets.Viewset`/`rest_framework.routers.SimpleRouter` had a baby, it would be ugly as hell
def route(methods=None, detail=None, url_path=None, url_name=None, **kwargs):
"""
Mark a ViewSet method as a routable action.
`@action`-decorated functions will be endowed with a `mapping` property,
a `MethodMapper` that can be used to add additional method-based behaviors
on the routed action.
:param methods: A list of HTTP method names this action responds to.
Defaults to GET only.

Keybase proof

I hereby claim:

  • I am elderlydoofus on github.
  • I am jimmyjosh (https://keybase.io/jimmyjosh) on keybase.
  • I have a public key ASAbQnp7Z68s_JV1VKW3VAdU3XG6suNKZBKypV24pcftsQo

To claim this, I am signing this object: