Skip to content

Instantly share code, notes, and snippets.

Madly deprecating Python 2.

Alice Zoë Bevan–McGregor amcgregor

Block or report user

Report or block amcgregor

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
amcgregor /
Last active Apr 24, 2019
A blog post-like thing covering Python, Textile formatting, and code ported from PHP without regard for Python idioms and practices. And how a little Pythonic design can wipe the floor with the bad code.

A few years back I reported a substantial performance issue with the Python-Textile package. I'll defend my choice of phrasing, "incredibly abysmal performance", with a dictionary.

Incredibly: to a great degree; extremely.

Abysmal: extremely bad; appalling. Very bad, dreadful, awful, terrible, frightful, atrocious, woeful, hopeless, lamentable, laughable, substandard, poor, inadequate, inferior, unsatisfactory; informal rotten, appalling, crummy, lousy, shocking, dire, the pits; British informal duff, a load of pants, pants.

I'm thinking a less offensive (though, my gods, being offended at a bug report with test case and measurable performance deficit…) way to phrase it would have been: "Performance is extremely pants." Of course, few would grok that, either.

Now, the maintainer two years ago mentioned he had a work-in-progress "cleanup" of the codebase. Two years ought to have been enough time to get that pushed out, so I've re-benchmar

amcgregor /
Last active Sep 11, 2018 — forked from apolkosnik/
Some mongoengine vs pymongo timing comparisons based on and discussion at Example using Embeded documents, with additional comparison against Marrow Mongo and PyModm.
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
# In your app, make sure to tell the serializer that your model objects are serializable...
# Helps if your model classes share a common base class you can register.
from collections import Mapping
app = Application(..., extensions=[
SerializationExtension(types=(list, Mapping, YourModel)),
amcgregor /
Created Sep 6, 2017
An ugly, ugly, but very specific phased benchmark comparison between MongoEngine and Marrow Mongo regarding MongoEngine/mongoengine#1624
  1. Pick three fonts. Italic versions of a font are themselves fonts for the purposes of this discussion. One font for headers, one font for content ("copy"), one for accent details (such as captions, blockquotes, etc.) A fixed-width font for code is exempt, 'cause it's code.

  2. Look at a book, newspaper, or magazine. Notice the conventions used: headings are typically sans-serif, copy text is typically serif, and accent can be whatever. Sans-serif is difficult to read large blocks of text in; there is no regular horizontal line shape for your eye to follow easily, whereas serif fonts "flatten" themselves into visually distinct lines.

: def inner
I'm an inner template. My content, here, represents a "level" template. No start or end, just the middle.
: end
:def outer
I'm an outer template. This is my rising edge.
: yield
This is the falling edge.
: end
amcgregor / iTunes Announcer.scpt
Last active Jun 22, 2017
An iTunes Announcer which speaks track information, pimps Patreon once an hour, features a silly Easter egg if you use a creepy little girl voice (I use Rosie Infovox iVox) and are up late, updates Ladiocast metadata, and announces to an IRC channel using Textual.
View iTunes Announcer.scpt
(* Radio caster announcement script.
Based on the "iTunes Announcer" originally written by Aaron Harnly (Nov. 2001) as updated by Doug Adams (Jan. 2012).
property volume_fade_step : 1 -- Rate of change for volume adjustment during announcement.
property idle_time : 7 -- Delay in seconds for iTunes status polling.
property volume_during_announcement : 66 -- Music volume from 0 to 100 during announcement.
property channel : "#webcore" -- IRC channel to notify.
amcgregor /
Last active Mar 30, 2017
A thought experiment job interview question / session in assistance of a user on IRC seeking mock interview advice. WIP cleanup, see previous commits.

Ask me your questions, gatekeeper, I am not afraid.

Given the opening and closing times for a store, how would you store that data, then subsequently query it, so as to answer the question: at time X (for example, now,) is the store open or closed?

What are the times?

Open 9:30am Monday, closes 5:30pm Monday. Tuesday through Friday open from 7am until 11pm. Saturday open from 11am to 4pm. Sunday closed.

:scribbles that on the whiteboard:

"""API sample.
Based on:
See also:
Requires: WebCore, web.dispatch.object, web.dispatch.resource
from web.core import Application
from web.ext.serialize import SerializationExtension
amcgregor / example.scss
Last active May 16, 2019
A mixin for easily utilizing (and customizing the behaviour of) FontAwesome icons in SCSS/SASS CSS.
View example.scss
// Now available in CodePen form:
@include "icons";
a:not(.no-icon) {
&[href^="https://www.twitter"] { @include icon($icon-twitter-square, false, true) { margin: 0; }; }
You can’t perform that action at this time.