Skip to content

Instantly share code, notes, and snippets.

View amcgregor's full-sized avatar
🏢
I died! …well, I got better…

Alice Zoë Bevan–McGregor amcgregor

🏢
I died! …well, I got better…
View GitHub Profile
@amcgregor
amcgregor / address-component.py
Last active February 16, 2021 01:45
An example "trivial" Contentment component. Note in particular that this is all "data model" — HTML is merely one possible serialization of the data. View is not defined here, there are no presentation details, but a method is provided to permit introspection of the view capabilities or requirements.
from marrow.mongo import Document, utcnow
from marrow.mongo.field import Date, Link
from ..asset import Depend
class Address(Document):
"""An embedded document representing a verified e-mail address.
Intended for use in an Array() embedding these sub-documents.
@amcgregor
amcgregor / account.py
Last active February 12, 2023 06:15
A collected sample model for user accounts, sessions, and supporting record types. (JSON sample needs updating to conform to the updated/public models.)
# Note: No __collection__ defined on most of these.
# They're for "embedding" (nesting) within a real collection-level document.
from argon2 import PasswordHasher
from argon2.exceptions import VerifyMismatchError
from marrow.mongo import Document, Field, Index
from marrow.mongo.trait import Queryabe, Identified
from marrow.mongo.field import Reference, Set, String, ObjectId, Date, Embed,
@amcgregor
amcgregor / 1-modern-emoji
Last active December 7, 2023 08:48
My collection of System Preferences → Keyboard → Text automatic replacements. Because using the character picker is a pain in the rump. Yes, the :code: one is multi-line.
-_- 😑
;^P 🤪
;P 😜
:'( 😢
:( 🙁
:) 🙂
:/ 😕
:^P 🤪
:| 😐
:3 😽
@amcgregor
amcgregor / 0--git-repository-universal
Last active August 9, 2023 17:46
An example web application on-disk structure, and the general template I follow for my WebCore applications, both personal and professional. Also applicable to Django, Flask, or almost any other project that can be broken up modularly. — https://github.com/marrow/webcore#what-is-webcore
# Project root. Cloned into /Volumes/<org>/<project> and symlinked to `~/Projects/<workspace>/src` if isolated as a
# distinct project, or `~/Projects/<workspace>/<project>` if part of a collective work or business space alongside
# others.
# Project Metadata
.gitignore # From template.
.pre-commit-config.yaml # https://pre-commit.com
.travis.yml # Test runner configuration.
MANIFEST.in # Redistributable package inclusions.
Makefile # Automatically re-pip's when the metadata updates, runs tests, tests depend on up-to-date metadata, etc.
@amcgregor
amcgregor / self-rendering-models.py
Last active April 7, 2021 18:02
An example self-rendering model component.
from marrow.mongo import utcnow
from marrow.mongo.trait import Identified
from marrow.mongo.field import Date, Markdown, Reference
from ..asset import Depend
__all__ = ('Note', )
@amcgregor
amcgregor / 404.html
Last active October 5, 2025 01:37
My own HTML5 boilerplate sans most of the code. Because there's too much Romulus-be-damned boilerplate, and people fail to realize almost none of it is in any way needed. For more details than you probably wanted, ref: https://codepen.io/tomhodgins/post/code-that-you-just-never-ever-need-to-write formerly https://tomhodgins.hashnode.dev/code-tha…
<!DOCTYPE html><html lang=en>
<title>Page Not Found</title>
<meta charset=utf-8>
<meta name=viewport content="width=device-width,initial-scale=1">
<h1>Page Not Found</h1>
<p>Sorry, but the page you were trying to view does not exist.</p>
@fnky
fnky / ANSI.md
Last active July 20, 2026 11:49
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@Fang-
Fang- / iina-youtube.js
Last active October 19, 2025 03:06
Turn Youtube links into IINA application links.
// ==UserScript==
// @name Open Youtube links in IINA
// @namespace https://palfun-foslup.urbit.org/
// @description Replaces Youtube links with a link to open them in IINA. Set a useful whitelist for yourself.
// @include *youtube.com/*
// @updateURL https://gist.githubusercontent.com/Fang-/7db1ac4e798a7128f006fa535f42cfb0/raw/25b60b08e55be87d2b0d5630d1f580b15ca2870d/iina-youtube.js
// @downloadURL https://gist.githubusercontent.com/Fang-/7db1ac4e798a7128f006fa535f42cfb0/raw/25b60b08e55be87d2b0d5630d1f580b15ca2870d/iina-youtube.js
// @run-at document-end
// @version 1.0
// ==/UserScript==
import datetime
import itertools
import random
import sys
import timeit
from collections import defaultdict
from pymongo import version as pymongo_version
from distutils.version import StrictVersion
import mongoengine as db
from pycallgraph.output.graphviz import GraphvizOutput
@amcgregor
amcgregor / navigation.py
Last active October 13, 2023 03:40
JavaScripthon example ES6 module handling in-page navigation by XHR/Fetch vs. whole-page navigation.
from org.transcrypt.stubs.browser import __pragma__
from illico.common.vendor import Events
__pragma__ ('kwargs')
class NavigationManager: