Skip to content

Instantly share code, notes, and snippets.

twolfson /
Created October 26, 2023 05:24
Django <> React cookie based authentication example
twolfson /
Last active October 22, 2023 19:08
Django messages as AJAX endpoint

Django messages as AJAX endpoint

Simple endpoint to expose Django messages as JSON (Django 4.2)

Reading messages removes them from tracker, so make sure you're properly exposing them always

Also including the React side of the impementation (React 18.2), though this may vary for you

This is part of a larger exploration in:

twolfson / README.rst
Last active July 18, 2024 19:33
Evaluation and comparison of various Python templating libraries


twolfson / .gitignore
Last active April 2, 2023 23:09
Exploration to split up an image into different sections for easier OCR parsing
twolfson / README.txt
Created February 3, 2022 20:49
How I stack PRs in GitHub
The following process is rather tedious but removes headaches from dealing with merge conflicts due to using a historically timed commit
When starting stacked work:
- git status # On pr1 branch
- git checkout main
- git checkout -b pr2.base # This will act as base for easy PR review and merge conflict resolution
- git checkout pr1 -p # Pull over all changes from pr1 into a single commit, including file deletion (git checkout -- . would miss this) (single commit removes noisy git history from PR)
- git commit -m "Single commit containing pr1 changes"
- git checkout -b pr2
- # Work on pr2
twolfson /
Created January 22, 2022 01:14
Add `persist` flag to Python's tempfile.TemporaryDirectory
class PersistableTemporaryDirectory(tempfile.TemporaryDirectory):
def __init__(self, *args, persist: bool, **kwargs):
self.persist = persist
ret_val = super().__init__(*args, **kwargs)
# If we're persisting, then remove `weakref` binding for cleanup at garbage collection
if self.persist:
return ret_val
twolfson /
Created January 4, 2022 23:40
Tipalti API name support via fuzzing
# Last updated: 2022-01-04
def is_valid_tipalti_name(name):
# Max length: 70 -- Incorrect: During testing it's 35 characters...
# Latin and numeric (cannot be only numeric)
# Spaces, periods, dashes (cannot be the first character)—e.g., "Mary Jo", "Jr.", "Mary-Jo"
# We've found additional cases like "Test 4" which fail, see tests for robust overview
# Their API truncates names at 35 characters
# This is fine for our use case and we won't reject a name for being too long
twolfson / index.js
Last active November 10, 2021 20:39
polygon-clipping: "Unable to complete output ring" reproduction script
const polygonClipping = require('polygon-clipping');
const poly1 = [
[-89.6913437618266, 32.5917775294804],
[-89.6913424001509, 32.5873713360798],
[-89.6913420772531, 32.5863246737333],
[-89.6932638650491, 32.5863115360137],
[-89.6932452075745, 32.5843574521187],
[-89.6951228354689, 32.584358882942],
twolfson / .gitignore
Last active October 25, 2021 22:15
Tried/failed attempt to reproduce nested dialog issues with Reakit
twolfson / .gitignore
Created January 20, 2021 07:33
Proof of concept to explore grid based line builder