Skip to content

Instantly share code, notes, and snippets.

View Zearin's full-sized avatar

Zearin Zearin

  • Virginia, U.S.A.
View GitHub Profile
@Zearin
Zearin / python_decorator_guide.md
Last active March 30, 2024 12:28
The best explanation of Python decorators I’ve ever seen. (An archived answer from StackOverflow.)

NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.


Q: How can I make a chain of function decorators in Python?


If you are not into long explanations, see [Paolo Bergantino’s answer][2].

Config objects

  • Config classes.
  • eleventyConfig.
    • Many class constructors and methods accept an eleventyConfig argument.
    • In Eleventy.initializeConfig(), this is a TemplateConfig instance.
    • A TemplateConfig instance holds a reference to a UserConfig instance. If I understand correctly, this is so that a user’s configuration can be tweaked on a template-by-template basis. Is this correct?
  • “Config” vs. “options”.
  • When a class handles both “config” and “options”, what distinguishes whether a setting falls into one category or
@Zearin
Zearin / sketch.js
Last active October 1, 2021 15:34
I enjoy programming, but I’m mathematically challenged. :) This gist is a request for help from the author of a fantastic answer on StackOverflow.
class Boid {
// ...
/**
* @param {Boid} other
* @returns {Boolean}
*/
canSee (other) {
// Adapted from
@Zearin
Zearin / metalsmith3-design-goals.md
Last active July 6, 2018 14:49
Goals for Metalsmith v3 (WIP)

Metalsmith v3 Goals

“Big Picture” Goals

  • Modern ES code. ES/JS moves fast these days. I want Metalsmith 3 to be best-in-class, and stay best-in-class for several years.

  • Performance (with Scalability). If Metalsmith 3 can boast performance that is so good, big companies with big websites start using it, that would be pretty fantastic. :)

  • Convenience.

@Zearin
Zearin / OrderedSet.py
Last active December 17, 2015 01:09
An OrderedSet for Python.
# -*- coding: utf-8 -*-
# Modified from original source, available here:
# http://code.activestate.com/recipes/577624-orderedset/
try:
import collections.abc as collections # Python 3
except ImportError:
import collections # Python 2

This is all based on the [alpha release][1].

Properties

From the built-in help system:

For many settings, TextMate will look for a .tm_properties file in the current folder, and in any parent folders (up to the user’s home folder).

These are simple «setting» = «value» listings, where «value» is a format string in which other variables can be referenced.

@Zearin
Zearin / brew-more.rb
Created September 16, 2011 14:27 — forked from lwe/brew-more.rb
Try to scrape formula information from @formula.homepage.
# Small utility which uses the homepage and nokogori to get a description from the formula's homepage.
#
# As written in the homebrew wiki:
# > Homebrew doesn’t have a description field because the homepage is always up to date,
# > and Homebrew is not. Thus it’s less maintenance for us. To satisfy the description
# > we’re going to invent a new packaging microformat and persuade everyone to publish
# > it on their homepage.
#
# Too bad no packaging microformat has yet been invented, but brew-more just first looks for a
# `<meta name="description">` tag, then for an `a#project_summary_link` tag (which is used in
@Zearin
Zearin / icon-naming-spec.xml
Created May 31, 2011 15:29
Freedesktop.org’s icon naming specification, represented as XML. Intended as a convenience to XML devs.
<?xml version="1.0" encoding="UTF-8"?>
<!--
@source
http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html
@author
Zearin <zearin@gonk.net>
@license
I haven’t chosen a license yet. In the meantime, feel free to reuse this
@Zearin
Zearin / brew-more.rb
Created May 28, 2011 14:02 — forked from lwe/brew-more.rb
Try to scrape formula information from @formula.homepage.
# Small utility which uses the homepage and nokogori to get a description from the formula's homepage.
#
# As written in the homebrew wiki:
# > Homebrew doesn’t have a description field because the homepage is always up to date,
# > and Homebrew is not. Thus it’s less maintenance for us. To satisfy the description
# > we’re going to invent a new packaging microformat and persuade everyone to publish
# > it on their homepage.
#
# Too bad no packaging microformat has yet been invented, but brew-more just first looks for a
# `<meta name="description">` tag, then for an `a#project_summary_link` tag (which is used in