Skip to content

Instantly share code, notes, and snippets.

View alexwlchan's full-sized avatar

Alex Chan alexwlchan

View GitHub Profile
@alexwlchan
alexwlchan / finduntaggedposts.py
Last active July 5, 2022 01:18
A Python script for finding untagged posts on Tumblr. See http://alexwlchan.net/2013/08/untagged-tumblr-posts/
#!/usr/bin/env python
import urllib2
import json
HOSTNAME = "example.tumblr.com"
API_KEY = "abcdefg"
URL = "http://api.tumblr.com/v2/blog/{host}/posts?api_key={key}".format(host=HOSTNAME, key=API_KEY)
@alexwlchan
alexwlchan / safeutil.py
Last active July 18, 2023 07:39
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
alexwlchan / README.md
Created December 10, 2015 08:33
drangReader – Python scripts for a simple RSS reader

drangreader

This is a set of scripts for aggregating RSS feeds. It's based on a script originally written by Dr. Drang: http://leancrew.com/all-this/2015/11/simpler-syndication/

Installation

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

@alexwlchan
alexwlchan / flickypedia_bot_minimal_example.py
Last active April 10, 2024 11:45
Flickypedia bot help question
import json
import httpx
import keyring
# 1. Retrieve the Wikimedia API token from the system keychain
api_token = keyring.get_password("flickypedia_backfillr_bot", "api_token")
# 2. Create an HTTP client
client = httpx.Client(