python hacks
This page contains links to some of my python hacks. It is autogenerated from the comments (if any) at the head of each file.
- instapaper-to-bookmarks.py(updated Wed Dec 27 23:31:23 2023)
- # convert instapaper CSV export to a bookmarks file for import to other things
# run as: instapaper-to-bookmarks.py instapaper-export.csv > bookmarks.html
- macmail(updated Sat Jul 4 07:25:54 2020)
- Subdirectory
- upload-weight-data-to-fitbit.py(updated Sun Dec 20 19:17:45 2015)
- # Upload CSV data to FitBit
#
# CSV data is assumed to be in the form date, weight
# date is in the form YYYY-MM-DD (all numeric, so Jan 1, 1970 is 1970-01-01)
# if your date format is something different, adjust the date parsing to suit.
# weight is treated as a floating-point number; units are determined by config
#
# This script takes one optional parameter, which is the start date for data to
# post. The FitBit API is limited to 150 calls per hour, so if you've got more
# than 150 datapoints to upload there's a good chance it'll do the first 150
# then exit with a rate-limit error. It will include the date for the data it
# was trying to post; you can re-run the script at the top of the next hour
# with this date as the sole parameter, and it'll pick up from where it left
# off. Ideally the script would handle this, but the python library doesn't
# pass back the rate-limiting headers that would allow you to figure out how
# long to wait before running again, so I didn't bother.
#
# config file is $HOME/.api_keys (because I started out with a Perl library that
# used this path). Contents:
#
# [fitbit]
# fitbit_uploader_oauth_consumer_key=X
# fitbit_uploader_oauth_shared_secret=Y
# oauth_token=A
# oauth_token_secret=B
# unit_system=U
#
# set U appropriately per https://dev.fitbit.com/docs/basics/#units.
#
# X and Y you get by registering an application at
# https://dev.fitbit.com/apps/new
#
# A and B are messier; the python-fitbit code comes with a gather_keys_cli.py
# script which you can run with values X and Y as parameters; it'll open a
# browser window where you authorise access, then it'll dump out a bunch of
# values containing encoded_user_id and the two oauth_token values. Insert them
# into .api_keys and you should be ready to go.
#
- wordle.py(updated Sat Jul 1 10:29:32 2023)
- # Wordle in Python for Mac
#
# expects python3; uses ANSI colours, so expects a terminal that
# supports them; gets words from /usr/dict/share/words unless you've
# found a properly-formatted json dictionary and left it lying around.
# Wordle is intellectual property in some way, shape or form of Josh
# Wardle; this code is in no way intended to infringe that and should
# be considered "something I hacked out on a Friday night". Play the
# real thing here: https://www.powerlanguage.co.uk/wordle/
Waider |
Ugh. Did I write that? |