Skip to content

Instantly share code, notes, and snippets.

@twolfson
twolfson / README.md
Created October 26, 2023 05:24
Django <> React cookie based authentication example
@twolfson
twolfson / README.md
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
twolfson / README.rst
Last active October 26, 2024 18:21
Evaluation and comparison of various Python templating libraries

gist-python-templating-evaluation

@twolfson
twolfson / .gitignore
Last active April 2, 2023 23:09
Exploration to split up an image into different sections for easier OCR parsing
screenshot.png
out/
@twolfson
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
twolfson / main.py
Created January 22, 2022 01:14
Add `persist` flag to Python's tempfile.TemporaryDirectory
# https://github.com/python/cpython/blob/v3.10.2/Lib/tempfile.py#L782-L852
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:
self._finalizer.detach()
return ret_val
@twolfson
twolfson / main.py
Created January 4, 2022 23:40
Tipalti API name support via fuzzing
# Last updated: 2022-01-04
def is_valid_tipalti_name(name):
# https://support.tipalti.com/Content/Topics/Development/APIs/PayeeAPI/UpdatePayee/CreatePayeeInfoAutoIdap/Intro.htm#PayeeDetailsItem1
# 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
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
twolfson / .gitignore
Last active October 25, 2021 22:15
Tried/failed attempt to reproduce nested dialog issues with Reakit
node_modules/
@twolfson
twolfson / .gitignore
Created January 20, 2021 07:33
Proof of concept to explore grid based line builder
node_modules/
.cache/