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 / 0-html.py
Created November 9, 2021 20:47
A demonstration of the code transformation that occurs when Python imports a cinje module.
# encoding: cinje
# To use this module:
# : from cinje.std import html
# : using html.page ...
: from collections import Mapping, Set, Sequence, Iterator
: _list = list # We override an important __builtin__ name in this module.
@amcgregor
amcgregor / change-delay.js
Last active February 8, 2024 17:44
Currently untested ES6 notepad sketches of isolatable global behaviors.
{ // "Change delay" committal of altered form fields and editable content without waiting for blur.
function monitorTyping(
element,
initial = 1000, // Initial delay value of one second.
highlight = true, // When entering a field, select its contents.
minimum = 500, // Minimum wait time.
threshold = 2, // Don't bother if the field has fewer than this many characters.
forceable = true // Ignore threshold on blur and when pressing enter.
) {
var timeout,
@amcgregor
amcgregor / ddelange-pip-constraints.md
Created July 28, 2021 04:50
Particularly interesting comment by ddelange on resolving Python packaging version complexity issues using pip's constraints functionality.

From: pypa/pip#9187 (comment)

could there be an easy option that forbides pip-21.2.1 to downgrade any already installed package (like specifying the existing packages version as a minimal constraint >= ) ?

@stonebig if you still have your pip cache populated, there is a way to achieve it without spamming the pypi registry: you can use the output of pip freeze and feed it to your pip command with an additional -r (it can be used multiple times):

pip freeze | sed 's/==/>=/' >> ./constraints.txt
pip install <some-new-package> -r ./constraints.txt
@amcgregor
amcgregor / reply.md
Last active June 10, 2021 13:25
In case https://diegobasch.com/ill-give-mongodb-another-try-in-ten-years#comment-628676 doesn't pass moderation, from a blog post entitled "I’ll Give MongoDB Another Try. In Ten Years." A classic complaint post referenced by https://blog.serverdensity.com/does-everyone-hate-mongodb/

:cough: So it's been 10 years.

This is a horrendous design flaw for a piece of software that calls itself a database.

Ignoring that 64-bit is hardly new or controversial, even at that time, or that it even represents any form of onus on IT…

In relation to errors passing silently, there's a giant warning displayed if you attempt to utilize the 32-bit version, and it's been there for a very long time, plus red flags of warning on the download page and documentation relating to it. Similar to the warning emitted if it detects you have THP (Transparent Huge Pages) enabled in your kernel, which violates assumptions over memory pages being 4KiB and the performance guarantees of allocation operations.

If you tell a database to store something, and it doesn’t complain, you should safely assume that it was stored.

@amcgregor
amcgregor / 1-#webcore.log
Last active June 7, 2021 22:09
Goodbye Freenode. It was a mostly-fun 15 years.
# "Official services" forced out of channel, usurper joins and gains control.
[2021-05-25T23:04:14-0400] ChanServ (ChanServ@services.) left the channel
[2021-05-25T23:04:17-0400] freenodecom (~com@freenode/staff) joined the channel
[2021-05-25T23:04:17-0400] freenodecom sets mode +o freenodecom
[2021-05-25T23:04:17-0400] freenodecom changed the topic to This channel has moved to ##webcore. The topic is in violation of freenode policy: https://freenode.net/policies
[2021-05-25T23:04:17-0400] <@freenodecom> This channel has been reopened with respect to the communities and new users. The topic is in violation of freenode policy: https://freenode.net/policies
# All channel modes reset (bans, quiets, …)
[2021-05-25T23:04:17-0400] OperServ sets mode +o freenodecom
[2021-05-25T23:04:17-0400] ChanServ sets mode +imnpscf-bbb ##webcore *!*@*shell/* *!*@*.powered.by.lunarbnc.net $a:average
GPG/PGP Signature Leader
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

About your project

@amcgregor
amcgregor / _summary.md
Last active May 21, 2021 12:54
Another user, ComCat, kicks up a fuss with the seeming intent of being banned.

Random anonymized user pops in, pops off thinking he's heping instead of hurting, gets banned.

Shocking no-one.

But, really, though. This is blatant enough for me to recognize as, potentially, the (or an agent of the) hostile agent attempting to sabotague good will more directly. It's hilarious and pathetic, but noteworthy.

More likely, though, it's one of the intermittently persistent assholes I've had to ban from ##webdev in the past. One held a grudge for three years crossing two networks whilst using autism as a defense for his bad behavior.

This adds "sad" to the pile with "hilarious" and "pathetic".

@amcgregor
amcgregor / libera-marrow-request.md
Created May 20, 2021 15:23
Project registration request for the Marrow Open Source Collective, covering a discrete channel (historical), one channel namespace, and one cloak namespace.
GPG/PGP Signature Leader
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

About your project

@amcgregor
amcgregor / ot.py
Last active June 28, 2021 16:12
A declarative description of Operational Transform (OT) operations developed with the context of Quill's Delta format for representation of rich text content changes.
"""An implementation of the Delta text markup format using MongoDB as back-end storage.
For details, please see:
- https://quilljs.com/guides/designing-the-delta-format/
- https://quilljs.com/docs/delta/
"""
from collections import deque
from weakref import proxy
@amcgregor
amcgregor / zip_longest_repeat_last.py
Last active December 4, 2020 14:36
Consume multiple iterators, filling each when exhausted with the last value they produced.
from itertools import repeat
def zip_longest_repeating(*iterables):
"""Consume multiple iterables, filling each when exhausted with the last value they produced, until all are exhausted."""
tracking = {} # Track the last value seen for each iterable passed in.
iterators = [iter(it) for it in iterables]
count = len(iterators)
if not count: return