This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """Small script to convert different kind of AI rules/instructions, starting from Cursor rules. Useful for teams which use mixed AI tools.""" | |
| import logging | |
| import re | |
| from pathlib import Path | |
| logging.basicConfig(level=logging.INFO, format="%(message)s") | |
| logger = logging.getLogger(__name__) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Django prefetch_related_objects() - Smart Gap Filling | |
| Intelligently prefetches only the missing related objects without re-fetching already loaded data. | |
| """ | |
| from django.db.models import prefetch_related_objects, Prefetch | |
| def process_books_mixed_sources(): | |
| # Load books from different sources with different prefetches |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| DirtyTracker - Efficient Django Model Field Change Tracking | |
| Tracks which fields changed on a model instance to enable efficient updates. | |
| Similar to django-dirtyfields (see https://pypi.org/project/django-dirtyfields/), | |
| but I was just wondering if a context manager is maybe cleaner | |
| and more focused than modifying the model class. Basically just an idea. | |
| Usage: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- Up until now, I thought the use of multi-swap like this here was very convenient.--> | |
| <div hx-post="" | |
| hx-swap="multi:#foo:outerHTML,#bar:outerHTML"> | |
| <!-- But for this we do not really need multi-swap. HTMX (since a couple of years at least) can do the above without an extension like this--> | |
| <div hx-post="" | |
| hx-swap="none" | |
| hx-select-oob="#foo:outerHTML,#bar:outerHTML"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "tailwindCSS.classAttributes": [ | |
| "class", | |
| "className", | |
| "ngClass", | |
| "class:list", | |
| "css_classes", | |
| "[a-z]*_css_classes" | |
| ], | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- A simple button component which normally could look like this with django-components --> | |
| {% component "button" icon="upload" css_classes"btn-primary" type="submit" %} | |
| Upload | |
| {% endcomponent %} | |
| <!-- can now be written like this --> | |
| <c-button icon="upload" | |
| class="btn-primary" | |
| type="submit"> | |
| Upload |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| import re | |
| import string | |
| from bs4 import BeautifulSoup | |
| from django.conf import settings | |
| from django.template import TemplateDoesNotExist | |
| from django.template.loaders.app_directories import Loader as AppDirectoriesLoader | |
| from django.template.loaders.base import Loader as BaseLoader | |
| from django.template.loaders.filesystem import Loader as FilesystemLoader |