Skip to content

Instantly share code, notes, and snippets.

View pdxmph's full-sized avatar

Mike Hall pdxmph

View GitHub Profile
@pdxmph
pdxmph / kcrw_current_track_to_things.rb
Last active May 15, 2020 18:56
Save current KCRW Eclectic 24 track to a Things list
#!/usr/bin/env ruby
require 'json'
require 'date'
require 'net/http'
require 'rb-scpt'
include Appscript
# Set up things
list = "To read, etc."

February 6, 2010 at 2:02:28 AM PST

Taking the Dumb Pipe to China

Note: This story finally ended

webex.jpg

So, yesterday I tweeted:

Dialed an 866 WebEx number on my iPhone, getting charged by AT&T for calling China. idontevenknowwhotoblamefail

@pdxmph
pdxmph / increase_itunes_playlist_volume.scpt
Created August 9, 2019 19:39
Make the tracks in a playlist louder (experimental)
tell application "iTunes"
set myList to the user playlist "Ride"
set myTracks to the file tracks of myList
repeat with theTrack in myTracks
tell theTrack
set the volume adjustment to "75"
end tell
end repeat
end tell
@pdxmph
pdxmph / sprint_animal.rb
Last active April 1, 2019 17:53
Animal Sprint Name Generator: takes a letter and a sentiment as arguments. (e.g.`sprint_animal.rb a negative` or `sprint_animal.rb z positive`
#!/usr/bin/env ruby
require 'sentimental'
# takes two arguments (starting letter and sentiment, where sentiment should be 'positive,' 'negative,' 'neutral.')
letter = ARGV[0]
sentiment = ARGV[1] || "negative"
analyzer = Sentimental.new(threshold: 0.3)
analyzer.load_defaults
@pdxmph
pdxmph / mutt_scores.md
Last active March 24, 2019 03:11
Notes on mutt scoring, coloring, and macros

I spent a lot of time messing around with mutt this week. At first I was just trying to get a working config back in place, so there was some noodling with OfflineIMAP. Then I moved on to cleaning up my authentication stuff: Due to an inconsistency in names on my work and personal computers, I needed to get some hard-coded values out of a few scripts.

Today, I spent a lot of time working on scoring, which is where I think mutt diverges from most other mail clients in the way that's most meaningful to me.

mutt's scoring tools let you assign scores to mail based on just about any characteristic of an email. You can match patterns on subject, sender, recipient, age, read/unread status, attachments, etc. etc. and then use those patterns to increment scores on individual messages.

Here are a few examples:

# Bump people in my aliases
#!/usr/bin/ruby
account = ARGV[0] # account name, e.g. pdxmph@gmail.com
server = ARGV[1] # account server, e.g. imap.gmail.com
user = `whoami`.strip!
keychain_path = "#{ENV['HOME']}/Library/Keychains/login.keychain"
params = {'security' => '/usr/bin/security',
'command' => 'find-internet-password',
'account' => account,
@pdxmph
pdxmph / scoremail.rb
Last active March 23, 2019 05:15
Mutt scoring script
#!/usr/bin/env ruby
require 'mail'
# read STDIN in binmode to flatten out messages with encoding issues, weird attachments or whatever
mail = Mail.new STDIN.binmode.read
# should be a value like "+20" or "-10"
args = ARGV[0]
# assume you keep your scores file in the same directory as this script and call it `scores`

[The Homely Mutt][mutt] is still a pretty good resource for getting back up and running on mutt. I've had a versioned muttrc sitting around for a long while. Judging from the stuff I found in there when I dusted it all off over the weekend, and then looking into my scores file to see what I was nudging up or down in visibility over the years, I got serious about mutt and developed a pretty complex configuration sometime well before Ben was born.

I know exactly why I quit using it, too: it was a good thing when mutt made it possible to talk to IMAP and SMTP directly and introduced caching, but it also meant that search became a problem: The search tools needed a Maildir or mbox archive sitting on the disk, and all mutt provided was its own cache. I struggled on for a little while happy that I was liberated of the need to use fetchmail to get stuff down to the disk, but hating that I needed to go to the Gmail web interface to search for older messages.

The thing that made me wake mutt back up this time was

@pdxmph
pdxmph / Rakefile
Last active March 17, 2019 19:04
Resume generation Rakefile
#!/usr/bin/env ruby
require 'json'
require 'date'
require 'erb'
resume_json = File.read("resume.json")
@resume = JSON.parse(resume_json)
md_template_file = File.read('erb/resume.md.erb')
latex_template_file = File.read('erb/experience.tex.erb')
@jobs = @resume["work"]
@pdxmph
pdxmph / invisible_women_shoutout.md
Last active March 16, 2019 06:55
Invisible Women book shoutout

Hi. Happy Friday evening. I am three chapters in to [Invisible Women: Data Bias in a World Designed for Men][iw] by [@CCriadoPerez][].

Here are a few more words, but but don't read them until you at least bookmark that link, download a sample, or just go ahead and buy your copy: I'll refund the price if you don't like it, and give your copy to a friend.

I placed an advance order when I read a review, it arrived a few nights ago, and in two nights I have gone from "I want to read this,"