Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View patrickleweryharris's full-sized avatar
🤖

Patrick Harris patrickleweryharris

🤖
View GitHub Profile
@patrickleweryharris
patrickleweryharris / top_songs.py
Last active November 17, 2021 01:43
Top Played Songs Playlist Generator for Spotify https://lewery.ca/automation/spotify-top-songs/
#!/usr/bin/env python
import argparse
import spotipy
import spotipy.util as util
"""
top_songs.py
See https://lewery.ca/automation/spotify-top-songs/ for detailed
instructions.
alias vi='vim'
alias bim='vim'
# grep
alias g='grep -sr'
alias gg='grep -isr \!:1 *'
alias gx='grep -isr --exclude-dir=\!:! \!:2 *'
alias gp="grep --exclude='*[.py[~c]]"
# other
@patrickleweryharris
patrickleweryharris / docx_to_pdf.applescript
Last active November 13, 2021 22:22
Applescript to automatically export .docx documents to PDF using Pages https://lewery.ca/automation/docx-to-pdf
set _document to theFile
-- Open a docx document in pages and auto export to PDF
tell application "Finder"
set _directory to get container of file _document
set _documentName to name of _document
-- Figure out document name without extension
if _documentName ends with ".docx" then ¬
set _documentName to text 1 thru -6 of _documentName
@patrickleweryharris
patrickleweryharris / attachment-saver.applescript
Last active November 17, 2021 01:43
Automatically save all email attachments in Apple Mail https://lewery.ca/automation/autosave-email-attachments
(*using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule*)
-- Adapted from: http://www.markosx.com/thecocoaquest/automatically-save-attachments-in-mail-app/
-- For usage instructions, see: https://lewery.ca/automation/autosave-email-attachments
set MainFolder to "Dropbox" -- After the current users home dir
set subFolder to "mail"
-- The folder to save the attachments in (must already exist)
@patrickleweryharris
patrickleweryharris / reddit_to_pinboard.py
Created July 29, 2019 00:04
Convert all saved Reddit links to Pinboard bookmarks
#!/usr/bin/env python
"""
Convert all saved Reddit links to Pinboard bookmarks
"""
import os
import argparse
import pinboard
import praw
@patrickleweryharris
patrickleweryharris / top_songs.py
Created July 28, 2019 03:23
Automatically create a Spotify playlist based on your top tracks
#!/usr/bin/env python
import argparse
import spotipy
import spotipy.util as util
"""
top_songs.py
This script requires spotipy: https://github.com/plamere/spotipy
Automates creation of a 'Top Songs' playlist on Spotify.
@patrickleweryharris
patrickleweryharris / video-filer.py
Created July 27, 2019 21:02
Rename TV show video files automatically
#!/usr/bin/env python
import os
import re
import shutil
import argparse
"""
video-filer.py
Files TV shows in the format in the format
'$show$season$episode$garbage.$ext' to
@patrickleweryharris
patrickleweryharris / vf
Created July 26, 2019 02:00
Find a file and open it in vim
#!/bin/bash
# Find and open in vim (if more than one file vim will open each in it's own buffer
find . -iname "$1" -exec vim {} \;
"""
Delete all saved posts / comments on your reddit account with PRAW.
See: https://lewery.ca/automation/delete-all-saved-reddit-links
Needs Python 3+ and Praw 5.3.0
"""
import argparse
import praw
@patrickleweryharris
patrickleweryharris / keybase.md
Created September 10, 2016 04:42
Keybase verification

Keybase proof

I hereby claim:

  • I am patrickleweryharris on github.
  • I am patrickharris (https://keybase.io/patrickharris) on keybase.
  • I have a public key ASANTGdU4O7KRmtv-N7YRQOhVJjEOF3s02cILv4hgNrKBAo

To claim this, I am signing this object: