Skip to content

Instantly share code, notes, and snippets.

View amcgregor's full-sized avatar
🏢
Examining Options

Alice Zoë Bevan–McGregor amcgregor

🏢
Examining Options
View GitHub Profile
@amcgregor
amcgregor / channel.log
Last active May 16, 2023 20:57
Chat logs of a disruptive / unhinged user ("cantelope"—can't even spell, or get a host mask 😑) from the #webdev channel on Libera.
GetShwifty
put out fire deploys :(
00:13:18
explore
is it IT related
00:51:10
i don't want to assume it's IT/sw dev
@amcgregor
amcgregor / _Multiple File Upload Capture.md
Last active August 19, 2023 13:22
A sample application to try out capturing multi-file uploads with nested structures.

Create a new virtual environment somewhere you'd like to place these files.

python3.9 -m venv uploadtest
cd uploadtest
. bin/activate

Then drop these files in that directory. Install dependencies:

@amcgregor
amcgregor / scroll-spy.js
Created March 28, 2022 05:39
A relatively light-weight "scroll spy" to pivot scrolling events from edge → level.
{ // Detect scrolling of the viewport away from the absolute top of the document.
function scrollHandler(e) {
if ( window.scrollY == 0 && document.body.scrollTop == 0 ) document.body.classList.remove('offset')
else document.body.classList.add('offset')
}
// Watch for the page being scrolled.
window.addEventListener('scroll', scrollHandler)
document.body.addEventListener('scroll', scrollHandler)
}
@amcgregor
amcgregor / dialog.js
Last active September 1, 2023 17:35
A fairly complete HTML5 dialog utility implementation with a few "advanced" features, with accessibility in mind. Utilizing https://github.com/GoogleChrome/dialog-polyfill as a polyfill for ancient browsers, omit the first block (and polyfill) if Internet Explorer isn't your bag, baby.
// Present dialog content "lazily loaded" from a dedicated endpoint.
// Additionally, support automatic transformation of navigational links to modal popovers when annotated: rel=modal
// Any element annotated data-dismiss=modal will close the active dialog when clicked.
// Clicking the backdrop will automatically close the dialog when no form is present [or the form is unmodified].
// MIT Licensed: http://www.opensource.org/licenses/mit-license.php
// Copyright (c) 2021-2022, Alice Bevan-McGregor (alice -[at]- gothcandy [*dot*] com)
{ // Polyfill if required to support your browser needs.
dialogPolyfill.registerDialog(dialog) // Direct access to the DOM node as it is assigned to the window object by ID, ref: support.html
}
@amcgregor
amcgregor / imageflow.css
Created February 5, 2022 16:35
"ImageFlow" preservation; original location unavailable.
@charset "utf-8";
/* ImageFlow Settings
==================================== */
@media screen, projection {
.imageflow {
overflow:hidden;
position:relative;
text-align:left;
visibility:hidden;
@amcgregor
amcgregor / parametrics-to-the-rescue.md
Created January 17, 2022 16:23
A comparison between jsonpatch.com and typical "parametric" operators for the same manipulations such as those provided by Marrow Mongo or MongoEngine.

You Don't Need JSON Patch

For simplicity sake, excluding the first example and the Test example, other parametric examples will be provided with a JSON representation for clarity. (Fun note, my WebCore web framework supports endpoint argument collection from a variety of data sources, including form-encoded POST, or JSON-encoded POST.)

The Original Document
{
  "baz": "qux",
 "foo": "bar"
@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.