Skip to content

Instantly share code, notes, and snippets.

View willjobs's full-sized avatar

Will Jobs willjobs

View GitHub Profile
@willjobs
willjobs / Extract_PDF.py
Last active March 27, 2020 20:21
Extract PDF - Python script to extract pages of PDF into separate files
import os
from PyPDF2 import PdfFileReader, PdfFileWriter
orig = input("enter path to file:\n")
pages_at_a_time = int(input('how many pages per file?\n'))
path, filename = os.path.split(orig)
path += '\\split'
filename = filename[:-4]

Software Preferences (and why)

This is meant to be an ongoing list of software alternatives I've evaluated, the pros and cons of each, and which I ultimately favored. It's mostly meant to remind me why I did or didn't switch so that I don't waste time re-evaluating in the future when I get annoyed by a bug or UI issue in the one that I chose. In case this helps others, I've posted it here too.

GoodNotes vs Notability

Winner: GoodNotes, for now

GoodNotes
@willjobs
willjobs / gpx_merge.py
Last active January 27, 2021 22:05
Merge (and possibly rename) GPX files
########
# This code is useful for combining many GPX files, each with a single <trk>, into
# a single GPX file containing one <trk> that has one <trkseg> per input GPX file.
#
# This is necessary for animating GPX files using GPX Animator: https://gpx-animator.app/
########
import shutil
import glob
from datetime import datetime
@willjobs
willjobs / photo_exif_rotate.py
Created January 31, 2021 02:26
Autorotate images based on EXIF data (iOS)
##############################
# Script to autorotate all images in a directory based on EXIF data.
# Background: iOS devices have a bad habit of saving images with a rotation stored in the
# EXIF data, which is ignored by other applications, resulting in these images
# looking rotated 90 degrees or 270 degrees in many apps. This fixes that.
## CAREFUL - this removes the EXIF information like date taken
##############################
from PIL import Image, ExifTags
import glob
import os.path
@willjobs
willjobs / medium-public-comments-01.py
Created July 25, 2021 16:03
medium-public-comments-01
from comments_downloader import CommentsDownloader:
downloader = CommentsDownloader(api_key="DEMO_KEY")
@willjobs
willjobs / medium-public-comments-02.py
Last active July 25, 2021 16:07
medium-public-comments-02
downloader.gather_comments_by_docket("FDA-2021-N-0270", db_filename="my_database.db", csv_filename="my_csv.csv")
@willjobs
willjobs / medium-public-comments-03.py
Created July 25, 2021 16:07
medium-public-comments-03
my_dockets = ["FDA-2009-N-0501", "EERE-2019-BT-STD-0036", "NHTSA-2019-0121"]
for docket_id in my_dockets:
print(f"\n********************************\nSTARTING {docket_id}\n********************************")
downloader.gather_comments_by_docket(docket_id, db_filename="my_database2.db")
print("\nDONE")
@willjobs
willjobs / medium-public-comments-04.py
Created July 25, 2021 16:09
medium-public-comments-04
for docket_id in docket_ids:
params = {"filter[docketId]": docket_id}
downloader.gather_headers("documents", params, csv_filename="EPA_water_documents.csv")
@willjobs
willjobs / medium-public-comments-05.py
Created July 25, 2021 16:09
medium-public-comments-05
for object_id in object_ids: # taken from EPA_water_documents.csv
params = {"filter[commentOnId]": object_id}
downloader.gather_headers("comments", params, csv_filename="EPA_water_comments_header.csv")
@willjobs
willjobs / medium-public-comments-06.py
Created July 25, 2021 16:10
medium-public-comments-06
# download the comments
comment_ids = downloader.get_ids_from_csv("EPA_water_comments_header.csv", data_type="comments")
downloader.gather_details("comments", comment_ids, csv_filename="EPA_water_comments.csv")