Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Alice Zoë Bevan–McGregor amcgregor

🏠
Working from home
View GitHub Profile
@amcgregor
amcgregor / _Multiple File Upload Capture.md
Last active Apr 21, 2022
A sample application to try out capturing multi-file uploads with nested structures.
View _Multiple File Upload Capture.md

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 Mar 28, 2022
A relatively light-weight "scroll spy" to pivot scrolling events from edge → level.
View scroll-spy.js
{ // 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 / imageflow.css
Created Feb 5, 2022
"ImageFlow" preservation; original location unavailable.
View imageflow.css
@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 Jan 17, 2022
A comparison between jsonpatch.com and typical "parametric" operators for the same manipulations such as those provided by Marrow Mongo or MongoEngine.
View parametrics-to-the-rescue.md

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 Nov 9, 2021
A demonstration of the code transformation that occurs when Python imports a cinje module.
View 0-html.py
# 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 Oct 18, 2021
Currently untested ES6 notepad sketches of isolatable global behaviors.
View change-delay.js
{ // "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 Jul 28, 2021
Particularly interesting comment by ddelange on resolving Python packaging version complexity issues using pip's constraints functionality.
View ddelange-pip-constraints.md

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 Jun 10, 2021
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/
View reply.md

: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 Jun 7, 2021
Goodbye Freenode. It was a mostly-fun 15 years.
View 1-#webcore.log
# "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
View libera-webdev-registration.md
GPG/PGP Signature Leader
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

About your project