Skip to content

Instantly share code, notes, and snippets.

@MatMoore
MatMoore / builder.py
Last active October 2, 2025 09:25
Form builder: conditional field patterns
"""
Possible DSL for building conditional fields
It should take care of
- conditional `required` validation
- passing the `conditional` html to the frontend component
- preserving ordering of errors
- blanking values if the matching option is deselected
"""
class MyForm(FormWithConditionalFields):
@MatMoore
MatMoore / auth.md
Created August 18, 2025 10:34
Some authorization options for python

Some authorization options for python apps

Django-specific

django.contrib.auth

Comes with ModelBackend - an authorization system based on permissions stored in the database. You need to assign to user or groups.

By default there are CRUD permissions created per model, which is very granular. You can also define custom permissions at a model level.

Pros:

@MatMoore
MatMoore / eagerloading.md
Created June 23, 2025 10:56
Django vs Rails eager loading
Rails Django Description
preload prefetch_related one query per table
eager_load select_related one query with joins
includes N/A same as preload if associated table not references, otherwise eager_load
@MatMoore
MatMoore / notes.md
Last active May 28, 2025 10:16
Automated accessibility testing with playright (python)
@MatMoore
MatMoore / Gitleaks vs Github.md
Last active April 17, 2025 16:01
Secret scanning comparison

Cost/licensing

What's detected

@MatMoore
MatMoore / Nunjucks vs Jinja.md
Last active April 10, 2025 11:18
Nunjucks / Jinja compatability spike
@MatMoore
MatMoore / logs.md
Created July 23, 2024 08:22
0.13.2.4
2024-07-03T11:39:41.2461669Z [2024-07-03 11:39:41,181] ERROR    {datahub.ingestion.run.pipeline:491} - Caught error
2024-07-03T11:39:41.2463027Z Traceback (most recent call last):
2024-07-03T11:39:41.2465452Z   File "/home/runner/work/data-catalogue/data-catalogue/.venv/lib/python3.11/site-packages/datahub/sql_parsing/sqlglot_utils.py", line 239, in try_format_query
2024-07-03T11:39:41.2467355Z     return expression.sql(dialect=dialect, pretty=True)
2024-07-03T11:39:41.2468362Z            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-07-03T11:39:41.2470085Z   File "/home/runner/work/data-catalogue/data-catalogue/.venv/lib/python3.11/site-packages/sqlglot/expressions.py", line 601, in sql
2024-07-03T11:39:41.2471674Z     return Dialect.get_or_raise(dialect).generate(self, **opts)
2024-07-03T11:39:41.2472492Z            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-07-03T11:39:41.2475987Z   File "/home/runner/work/data-catalogue/data-catalogue/.venv/lib/python3.11/site-packages/sqlglot/diale
@MatMoore
MatMoore / concat.py
Created July 17, 2024 07:53
Long query examples
expression = """
WITH T2 AS ( SELECT (
coalesce('foo', 'bar') ||
coalesce('foo', 'bar') ||
coalesce('foo', 'bar') ||
coalesce('foo', 'bar') ||
coalesce('foo', 'bar') ||
coalesce('foo', 'bar') ||
coalesce('foo', 'bar') ||
coalesce('foo', 'bar') ||
@MatMoore
MatMoore / links.md
Last active February 5, 2024 17:11
Resources for building a search form in Django
@MatMoore
MatMoore / Rspec output.txt
Created February 5, 2024 11:27
Finder frontend behaviour
TopicalFacet
#sentence_fragment
multiple values
is expected to eql "end_date"
disallowed values
is expected to be nil
single value
is expected to eql "end_date"
Registries::TopicTaxonomyRegistry