Skip to content

Instantly share code, notes, and snippets.


Alex Chan alexwlchan

View GitHub Profile
alexwlchan /
Created Dec 10, 2015
drangReader – Python scripts for a simple RSS reader


This is a set of scripts for aggregating RSS feeds. It's based on a script originally written by Dr. Drang:


Download all the files from this Gist. Put them all in a directory, create a virtualenv and install requirements:

alexwlchan /
Last active Jul 5, 2022
A Python script for finding untagged posts on Tumblr. See
#!/usr/bin/env python
import urllib2
import json
API_KEY = "abcdefg"
URL = "{host}/posts?api_key={key}".format(host=HOSTNAME, key=API_KEY)
alexwlchan /
Created Dec 22, 2014
Prints human-readable, friendly strings to measure elapsed time
""" - a script for providing a human-readable string of how much time
has elapsed since a given date, implemented only using the standard library.
Modelled on the style of dates used on Stack Overflow posts.
from datetime import datetime, timedelta
def print_date(date, incl_year=True, short_months=True):
"""Prints a datetime object as a full date, stripping off any leading
alexwlchan / example.tfstate.step1
Last active Oct 27, 2021
Terraform bug repro information
View example.tfstate.step1
"version": 4,
"terraform_version": "1.0.9",
"serial": 1,
"lineage": "693cb572-091c-756e-8b64-65f51416d352",
"outputs": {},
"resources": [
"mode": "managed",
"type": "aws_s3_bucket",
alexwlchan /
Last active Dec 3, 2020
Non-destructive file copying/moving in Python
#!/usr/bin/env python
This is a script designed to be "safe" drop-in replacements for the
shutil move() and copyfile() functions.
These functions are safe because they should never overwrite an
existing file. In particular, if you try to move/copy to dst and
there's already a file at dst, these functions will attempt to copy to
a slightly different (but free) filename, to avoid accidental data loss.
alexwlchan /
Created Aug 30, 2016
Helper functions for dealing with query strings in URLs
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
Utility functions for dealing with URL query strings in Python,
i.e., URLs of the form
This module includes a pair of helper functions: one for getting the values
associated with a particular field; another for setting the query string

Keybase proof

I hereby claim:

  • I am alexwlchan on github.
  • I am alexwlchan ( on keybase.
  • I have a public key whose fingerprint is 82FE A59D 07EE 6274 20D7 E85D F859 A49F A148 6C23

To claim this, I am signing this object:

#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""I have a TaskPaper file I keep in Dropbox that contains some tasks for my
daily routine.
This script runs once a day and resets every item on that list, removing
the @done tag and replacing the file.
View auto_collapse_deferred_taskpaper_items.js
// auto_collapse_deferred_items.js
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// This script collapses any projects with the @defer tag in the frontmost
// window. Useful for tidying up the window, so I don't have to see the
// detail associated with those projects.
'use strict'
function TaskPaperCollapseDeferredItems(editor, options) {