Skip to content

Instantly share code, notes, and snippets.

View keybase.md

Keybase proof

I hereby claim:

  • I am alexwlchan on github.
  • I am alexwlchan (https://keybase.io/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:

View reset_taskpaper_list.py
#!/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) {
View word_count.py
#!/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
View unique_filenames.py
#!/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
View guess_filename.py
#!/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.
"""
View dynamo_injector.py
#!/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
alexwlchan / myurlparse.py
Created Aug 30, 2016
Helper functions for dealing with query strings in URLs
View myurlparse.py
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
Utility functions for dealing with URL query strings in Python,
i.e., URLs of the form
http://example.net?field1=value1&field2=value2
This module includes a pair of helper functions: one for getting the values
associated with a particular field; another for setting the query string
View download_files.py
#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
"""
download_files.py
~~~~~~~~~~~~~~~~~
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.
@alexwlchan
alexwlchan / settern_rss.py
Created Feb 14, 2016
Python script for creating a per-author RSS feed from iMore
View settern_rss.py
#!/usr/bin/env python
"""
This script can be used to get a per-author RSS feed on iMore.com. It will try to
cache the entries, so the last 40 entries from an author will show up, even if
they're no longer in the main feed.
To invoke, just call this script at the command line:
python settern_rss.py
You can’t perform that action at this time.