Skip to content

Instantly share code, notes, and snippets.

View spookylukey's full-sized avatar

Luke Plant spookylukey

View GitHub Profile
;; My Emacs blogging setup:
;;
;; - nikola - https://getnikola.com/
;; with some extensions:
;; - orgmode - https://plugins.getnikola.com/v8/orgmode/
;; - sass - https://plugins.getnikola.com/v7/sass/
;; - ditaa - custom - https://gist.github.com/spookylukey/e25c1d9d99acacd776029c01a50337c6
;; - shell - custom - https://gist.github.com/spookylukey/c175709610d5466f1bba49f356f505a1
;;
;; - Mostly reStructuredText for markup. It's powerful, and has good support for syntax extensions
@spookylukey
spookylukey / ditaa.py
Created August 20, 2024 08:05
Custom ditaa extension for Nikola
# Copyright © 2021 Luke Plant
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the
# Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the
# Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@spookylukey
spookylukey / shell.py
Created August 20, 2024 08:03
Custom shell plugin for Nikola
"""
Custom reST_ directive for passing a block through a shell command
"""
from subprocess import PIPE, Popen
from docutils import statemachine
from docutils.nodes import literal_block, raw
from docutils.parsers.rst import Directive, directives
from nikola.plugin_categories import RestExtension
@spookylukey
spookylukey / after_fetch_queryset_mixin.py
Created September 2, 2021 20:31
AfterFetchQuerySetMixin for Django
class AfterFetchQuerySetMixin:
"""
QuerySet mixin to enable functions to run immediately
after records have been fetched from the DB.
"""
# This is most useful for registering 'prefetch_related' like operations
# or complex aggregations that need to be run after fetching, but while
# still allowing chaining of other QuerySet methods.
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
I have been attempting to sign up for an HL SIPP, and I cannot proceed past https://online.hl.co.uk/apply/account-application/account/70/personal-details due to errors on this page.
This is an error report that needs to be passed on to your developers. It is preventing me from being able to access your services and start an account.
Details:
Web browser: Firefox
Steps:
@spookylukey
spookylukey / get_all_subclasses.py
Last active November 29, 2023 09:17
get_all_subclasses utility
import itertools
flatten = itertools.chain.from_iterable
def get_all_subclasses(cls: type) -> set[type]:
"""
Return all subclasses of a class, recursively.
"""
# `type` and other metaclasses don't behave nicely with `__subclasses__`,
# we have to filter them out
@spookylukey
spookylukey / model_utils.py
Created November 14, 2020 10:41
Visidata 2 glue code for Django models and attrs, with type support
from datetime import date
from django.db.models import QuerySet
import visidata
def get_main_attrs(instance):
if hasattr(instance, '_meta'):
return meta_to_col_list(instance._meta)
The make_OnboardingRenameTeamForm class was a hack to try to get around some problems:
We want to do this at module level:
OnboardingRenameTeamForm = global_preference_form_builder(preferences=[("organization_name", "branding")])
However, this is a problem because `global_preference_form_builder` does database queries,
which is in general a bad idea to do when modules are loading, and it breaks our test suite badly.
First idea - change `OnboardingRenameTeamForm` to a function that will return the form - the wizard shouldn't
npm run dev:report git master ~/devel/clients/datapane/datapane-hosted/web-components [12:56]
> datapane-next@0.0.0 dev:report
> NODE_ENV=development vite build --mode development --config base/vite.config.ts && NODE_ENV=development vite build --watch --mode development --config report/vite.config.ts
vite v3.2.5 building for development...
transforming (32) node_modules/core-js/internals/create-property-descriptor.jsUse of eval is strongly discouraged, as it poses security risks and may cause issues with minification
✓ 243 modules transformed.
dist/base/style.css 79.34 KiB / gzip: 12.87 KiB
dist/base/index.es.js 269.97 KiB / gzip: 68.23 KiB
# This file is automatically @generated by Poetry and should not be changed by hand.
[[package]]
name = "boltons"
version = "21.0.0"
description = "When they're not builtins, they're boltons."
category = "main"
optional = false
python-versions = "*"
files = [