Skip to content

Instantly share code, notes, and snippets.

View alexwlchan's full-sized avatar

Alex Chan alexwlchan

View GitHub Profile
@alexwlchan
alexwlchan / example.tfstate.step1
Last active October 27, 2021 06:59
Terraform bug repro information
{
"version": 4,
"terraform_version": "1.0.9",
"serial": 1,
"lineage": "693cb572-091c-756e-8b64-65f51416d352",
"outputs": {},
"resources": [
{
"mode": "managed",
"type": "aws_s3_bucket",
@alexwlchan
alexwlchan / Screenshot 2019-09-22 at 18.04.32.png
Last active September 22, 2019 17:06
Script for an Alfred shortcut to open PyPI docs
Screenshot 2019-09-22 at 18.04.32.png
@alexwlchan
alexwlchan / keybase.md
Created October 12, 2017 13:42
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:

#!/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.
"""
// 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
alexwlchan / myurlparse.py
Created August 30, 2016 20:33
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
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