Skip to content

Instantly share code, notes, and snippets.

Alex Chan alexwlchan

Block or report user

Report or block alexwlchan

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

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) {
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""Returns a human-friendly word count of the string passed to stdin.
Example outputs:
* 5 words
* 100 words
* 1.5k words
* 10k words
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""Generate unique filenames for a file you're about to create.
The functions in this snippet are useful for ensuring you don't inadvertently
create a file that replaces an existing file. Given a name, they try to
find a similar name that doesn't already exist on the disk.
This code isn't safe from race conditions -- if a file pops into existence
between the check and the write, you could still lose data -- but it's a
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""Guess a filename from a URL.
Suppose you want to download a file from a URL, and you want to preserve
the name of the original file as closely as possible. This snippet
provides a function for doing so.
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
A script for quickly injecting records into DynamoDB.
Useful for testing apps that hang off a DynamoDB event stream.
import itertools
import sys
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
#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
This is a file downloader for Python with a few special features:
* If the user doesn't supply a filename, try to infer a filename and
file extension from the URL.
You can’t perform that action at this time.