Skip to content

Instantly share code, notes, and snippets.

View frankwiles's full-sized avatar
💻
Artisanal bits built just for you!

Frank Wiles frankwiles

💻
Artisanal bits built just for you!
View GitHub Profile
@edraobdu
edraobdu / get_queries.py
Last active March 4, 2023 14:58
pytest fixture to help debugging (and asserting) database queries on django tests.
"""
Based on this answer https://stackoverflow.com/a/59125267
Requirements:
- django
- pytest
- pytest-django
Include this fixture in your `conftest.py`
@gladiatr72
gladiatr72 / deployment-status-to-env.yaml
Last active December 16, 2021 20:52
pull status elements into environment
spec:
containers:
-
name: misc
image: gladiatr72/misc:util-21
env:
-
name: POD_IP
valueFrom:
fieldRef:
@tannerlinsley
tannerlinsley / createCrudHooks.js
Created November 29, 2020 06:39
A naive, but efficient starter to generate crud hooks for React Query
export default function createCrudHooks({
baseKey,
indexFn,
singleFn,
createFn,
updateFn,
deleteFn,
}) {
const useIndex = (config) => useQuery([baseKey], indexFn, config)
const useSingle = (id, config) =>
@jefftriplett
jefftriplett / python-django-postgres-ci.yml
Last active March 27, 2024 04:27
This is a good starting point for getting Python, Django, Postgres running as a service, pytest, black, and pip caching rolling with GitHub Actions.
name: CI
on: [push]
jobs:
test:
runs-on: ubuntu-latest
services:
@apollo13
apollo13 / chromelogger.py
Last active May 12, 2022 01:09
Django logging to Firefox/Chrome devtools
"""
License: MIT - https://opensource.org/licenses/MIT
ChromeLogger is a protocol which allows sending logging messages to the Browser.
This module implements simple support for Django. It consists of two components:
* `LoggingMiddleware` which is responsible for sending all log messages
associated with the request to the browser.
* `ChromeLoggerHandler` a python logging handler which collects all messages.

======================== DEP XXX: Simplified routing syntax

  • DEP: XXX
  • Author: Tom Christie
  • Implementation Team: Tom Christie
  • Shepherd: Tim Graham
  • Status: Draft
  • Type: Enhancement
@frankwiles
frankwiles / blocks.py
Created May 17, 2015 03:13
Code and Markdown blocks for Wagtail 1.0 StreamField
from django.utils.safestring import mark_safe
from markdown import markdown
from pygments import highlight
from pygments.formatters import get_formatter_by_name
from pygments.lexers import get_lexer_by_name
from wagtail.wagtailcore import blocks
class CodeBlock(blocks.StructBlock):