Categories
Technology Tools

Automated Playlist Backup With Swift

I mentioned in my post about scripting with Swift that I’d been working on something that inspired this. Well, here’s what it was: a rewrite of my automated playlist backup AppleScript in Swift. That version ran every hour… ish. Partly that scheduling issue is because launchd doesn’t actually guarantee scheduling, just ‘roughly every n seconds’, and partly it’s because the AppleScript was slow.1
Then I found the iTunesLibrary API docs, such as it is, and thought “well, that’d be a much nicer way to do it.”
And then I remembered that Swift can be used as a scripting language, cracked my knuckles, and got to work. (I also had some lovely reference: I wrote up my very basic intro post, but this post goes further in depth on some of the concepts I touched on.)

Not the best API I’ve ever written, but not bad for something I threw together in a few hours. And I had fun doing it, more so than I did with the AppleScript one.
Oh, and it’s much faster than the AppleScript equivalent: this runs through my ~100 playlists in under a minute. So now I have it run every 15 minutes.2
(The configuration for launchd is about the same, you just replace the /usr/bin/osascript with the path to the Swift file, and make the second argument the full path to the directory where you want your backups going. See the original post for the details.)
I’m a bit tempted to turn this into a macOS app, just so I can play around with SwiftUI on macOS, and make it a bit easier to use. Of course, by ‘a bit tempted’ I mean ‘I already started tinkering,’ but I doubt I’ll have anything to show for a while — near as I can tell, SwiftUI has no equivalent to NSOutlineView as of yet, which makes properly showing the list a challenge. Still, it’s been fun to play with.


  1. I was going to cite this lovely resource, but since that website was built by someone who doesn’t understand the concept of a URL, I can’t link to the relevant section. Click ‘Configuration,’ then the ‘Content’ thing that’s inexplicably sideways on the left side of the screen, and ‘StartInterval’ under ‘When to Start’. 
  2. I’m also looking at the FSEvents API to see how hard it would be to set it up to run whenever Music (née iTunes) updates a playlist, but that… probably won’t happen anytime soon. 
Categories
Technology

Swift Scripting

I’m a bit of a fan of Swift, though I don’t get to tinker with it nearly as much as I’d like. Recently, though, I did some tinkering with Swift as a scripting language, and thought it was pretty fun! (I’m planning another blog post about what, exactly, I was trying to do later, but for now just take it as a given.)
The most important step is to have Swift installed on your machine. As a Mac user, the easiest way is probably just to install Xcode, but if you’re looking for a lighter-weight solution, you can install just the Swift toolchain. Swift is also available for Ubuntu, which, again, takes some doing. If you want Swift on Windows… well, it’s an ongoing project. Personally, I’d say you’ll probably have better luck running it in Ubuntu on the WSL.
Alright, got your Swift installation working? Let’s go.
Step 1: Make your Swift file. We’ll call it main.swift, and in true Tech Tutorial fashion, we’ll keep it simple:

print("Hello world!")

Step 2: Insert a Magic Comment in the first line:

#!/usr/env/swift
print("Hello world!")

Step 3: In your shell of choice, make it executable:

$ chmod +x ./main.swift

Step 4: Run!

$ ./main.swift
> Hello world!

No, really, it’s that simple. The magic comment there tells your interpreter ‘run this using Swift’, and then Swift just… executes your code from top to bottom. And it doesn’t have to be just function calls — you can define classes, structs, enums, whatever. Which is the real benefit to using Swift instead of just writing your script in Bash; object-oriented programming and type safety are lovely, lovely things.

My next post is going to go into some of the more interesting stuff you can do, with a lovely worked example, but for now I’ll add a couple other things:

  • By default, execution ends when it gets to the end of the file; at that point, it will exit with code 0, so Bash (or whatever) will assume it worked correctly. If you want to exit earlier, call exit(_:) with the code you want. exit(0) means “done successfully,” while any other integer in there will be treated as an error.1
  • print(_:) outputs to stdout, which can be piped using |. If you want to output an error (to be piped with 2>, or similar) you need to import Foundation, and then call FileHandle.standardError.write(_:).2
  • To explicitly write to stdout, it’s FileHandle.standardOutput.write(_:).

  1. Which is useful if your script is going to be called programmatically. ./main.swift && echo "It worked!" will print “Hello world” and then “It worked!” with exit(0), but just “Hello world” if you add exit(1) to the end of the file. 
  2. And note the types here – this expects Data, not String, so to write a string, you need to convert it by adding .data(using: .utf8)! 
Categories
Collection

Tamora Pierce is (Finally) Getting A TV Show

Peter White, Deadline:

Lionsgate and Little Women and King Lear producer Playground Entertainment have teamed on a major fantasy project – a television adaptation of Tamora Pierce’s expansive Tortall Universe series.

I absolutely adore Tamora Pierce, and I cannot overstate how excited I am about this.1

[The companies have] hopes of turning it into a tentpole series that crosses over between fans of Game of Thrones and YA novels.

Obviously, everyone hopes their show will be the next Game of Thrones, but I do think Tortall offers a large enough universe to pull it off. And, again, I would love to see Pierce’s work getting the big-budget approach.


  1. Did I sit down to write a blog post about it for the explicit purpose of making sure there’s some buzz about it online? Yes. Yes I did. I’m trying to encourage them to make it and make it well. 
Categories
Playlist

Playlist of the Month: October 2019

Changing the formatting a little bit this month, as I’m working on an improved version of my playlist archiving script.1
Silhouette by Aquilo on Silhouettes
Cologne by Haux on Something to Remember – EP
Sober by Edwin Raphael on Sober – Single
Coincidental by Betcha on Coincidental – Single
How You’ll Be Remembered by Aron Wright on How You’ll Be Remembered – Single
Connor by SYML on SYML
Antidote by Mr Hudson on ANTIDOTE – Single
Without the Lights by Elliot Moss on Boomerang
Falling Down by Harrison Storm on Falling Down – Single
Drew Barrymore by Bryce Vine on Carnival
Angel by H. Kenneth on Angel – Single
Fk Collingwood by Hayden Calnin on Fk Collingwood – Single2
Bristol by Imaginary Future on Bristol – Single
The Sea by HAEVN on The Sea – Single
Hey, Ma by Bon Iver on Hey, Ma – Single
Haunted by Saint Claire on Haunted – Single3
Party by Jon Bryant on Cult Classic
Places by Portair on Places – Single
Silence Is Broken by Cal Trask on Silence Is Broken – Single
Cadillac by Joel Ansett on Cadillac – Single
Sh’Diah by Bon Iver on i,i
Piece Of Your Heart (feat. GOODBOYS) by Meduza on Piece Of Your Heart (feat. GOODBOYS) – Single
Why Do You Love Me by Charlotte Lawrence on Why Do You Love Me – Single
Crying at the Party by Harry Strange on Crying at the Party – EP
Something About You by Elderbrook & Rudimental on Something About You – Single
Byegone by Volcano Choir on Repave
Cars at Night by By The Coast on Cars at Night – Single
Holyfields, by Bon Iver on i,i
Feeling You by Harrison Storm on Falling Down – EP
Comrade by Volcano Choir on Repave
I’m Doing Everything I Can by Imaginary Future on I’m Doing Everything I Can – Single4
Oblivions by The National on I Am Easy to Find
5AM by Amber Run on 5AM (Deluxe) WEB
Hold On by Griffin Stoller on Hold On – Single
Electricity by Danny Bowens on Electricity – Single
Bad Line by The Hunter Express on Bad Line – Single
Fuzzy Teeth by Portair on Fuzzy Teeth – Single
Truths by bobbycrush on Truths – Single
Shortcut by Monica Moser on Shortcut – Single
Barrio by Mahmood on Barrio – Single5
On Our Last Day by Hayden Calnin on A Life You Would Choose – EP
All We Have Is Now by Ross Copperman on All We Have Is Now – Single
Lines by Scott Quinn on Lines – Single
Tonight by Thorin Loeks on Tonight – Single
Tonight by Thorin Loeks on Tonight – Single6
Hideout (feat. Zoe Maxwell) by Blewbird on Hideout (feat. Zoe Maxwell) – Single
Where the Shadow Ends by BANNERS & Young Bombs on Where the Shadow Ends
Paradox by Jaymes Young on Paradox – Single
Another Little Lie by Nick Wilson on A Face I’ve Never Seen Before – EP
Bikes by FLØRE on Bikes – Single
start over by RVRB on drift – EP
Don’t by Saint Claire on Don’t – Single7
I’ll Get You Home by By The Coast on I’ll Get You Home / World to Ourselves – Single
Ours to Lose by JacobNeverhill on Jacobneverhill
SICK by CXLOE & gnash on SICK – Single
Stay by OTR & WYNNE on Stay – Single
Carry Me Away by John Mayer on Carry Me Away – Single
You. by Lucy Daydream on You. – Single
Antes de Morirme (feat. Rosalía) by C. Tangana on Antes de Morirme (feat. Rosalía) – Single
Killing Me by Ed Prosek on Killing Me – Single
Beyond the View by Chance Peña on Beyond the View – Single
Bloody Mary by Lady Gaga on Born This Way (Special Edition)8
Monster by Mark Diamond on Hummingbird Two – EP
Cover Your Eyes by Black Match on Cover Your Eyes – Single
Lost by Portair on Lost – Single
Smiling When I Die by Sasha Sloan on Smiling When I Die – Single
sex by EDEN on i think you think too much of me9
Hard Lines, Hard Times by William Wild on Hard Lines, Hard Times – Single10
Worship by Amber Run on Philophobia
Tourner dans le vide (Slowed) by Unge Moped & Tuber on Tourner dans le vide : Man slowed down – Single11


  1. Technically, I have an improved version of it; now I’m tinkering with giving it the ability to do the links for me, too. 
  2. Been having fun with this one in the scripting – string manipulation in AppleScript isn’t my favorite, and I wound up switching to Swift. 
  3. I wish I could say this was in here because Halloween, but no, I kinda forgot that Halloween was a thing until the day of. 
  4. Singles like this are the downside to including the album title in here as well, but I kinda like having more data points to narrow down which specific version of a song I’m talking about. 
  5. This goes in with Billie Eilish on the “if you get a HomePod, play this on it” list. 
  6. So, this is on here twice, and missing a link in both cases, because there’s a Story about this. Loeks pulled the song from… everywhere, really, shortly after I published my playlist last month. I spent some time trying to figure out if it was a bug, found out it was gone from all the services, found his website, and sent him an email asking about it. He’s reworking it, and going to rerelease a new version at some point in the future, but was kind enough to send me a copy of the original version. That’s the second one here; I left the first, even though it’s not playable, as… part of the historical record, I suppose.
    Anyways, it’s a good song, I’m looking forward to hearing (and sharing) the new version, and in the meantime, go check out the guy’s other music. 
  7. Fun to sing along to! I have yet to get the lyrics right, but maybe eventually! 
  8. This one… is sort of a Halloween one, actually. 
  9. Listening to EDEN reminded me of how much I miss Majik. 
  10. This month’s winner for ‘favorite new addition,’ I think. 
  11. Surprisingly hard to track down – if you try to Shazam the bit of this that made it into the meme (and yes, I’ll admit it, that’s how I first heard it) you get a rap song that sampled it in the intro before making a joke about the meme. Shazam, you have failed me. 
Categories
Portfolio

Exercise – Collecting Clippings

I recently started a Master’s in Human-Computer Interaction and Design. While the main goal of the program is, obviously, learning, one of the side goals is to build a portfolio; as such, I’m going to be making an effort to post some of what we’re working on in class here.

One of our assignments was to start collecting images and clippings, and doing some annotations of them. The idea is to build up a library; something like Quiver, but for design instead of development. It was actually very fun; a lot of my classmates did it handmade, and I considered it, but I’ve also been meaning to try Adobe XD and figured, why not?

Source: Paprika

It’s a pretty neat tool, it made it very quick to put these all together. Much more focused than my other digital go-to, PhotoShop, where I probably could’ve accomplished the same thing, but would’ve spent more time digging around in the ‘draw a line’ settings and whatnot.

Source: Windows Task Manager (Windows 10)

A lot of what I did for mine were mobile apps – that is, after all, my main area of interest – but I also made an effort to branch out to other operating systems and even (gasp) physical devices.

Source: the office Keurig. No, I don’t know how to work it.

A big part of the assignment was giving feedback to our classmates on what they’d collected. The goal wasn’t “hey, that’s a cool interface you were looking at,” but “oh, that’s a good point about the interface.” The exercise, after all, was about the act of collecting and annotating.

Source: Overcast

It was interesting to see how everybody did theirs – most of the people I talked with had done them by hand, although somebody did a lovely blended style one by collecting screenshots and photos and then annotating them with an iPad and Apple Pencil.

Source: Hazel

I’m not sharing all of what I’ve collected here – I’m proud of my annotations of the to-do list app I use, but I don’t actually want to share the contents of my to-do list. And while I had fun marking up Dark Sky, I don’t feel the need to share my home address with the internet.

Source: Calory

I’ve got some pieces from my sketchbook that I might post sometime soon, and I’ll hopefully continue to have interesting things to share as the program goes on!

Categories
Playlist

Playlist of the Month: September 2019

Built entirely without Shortcuts, because while they made many very impressive strides this year, they still didn’t give me a ‘filter’ action.1
Silhouette – Aquilo
Cologne – Haux
Sober – Edwin Raphael
Coincidental – Betcha
How You’ll Be Remembered – Aron Wright
Cocoon – Tommy Ashby
Connor – SYML
Antidote – Mr Hudson
Before You Knew It Was Me – SYML
Without the Lights – Elliot Moss
99 – Elliot Moss
Bad for You – Billy Raffoul
Spoke Too Soon – Jake Scott
Caves – Haux
Falling Down – Harrison Storm
To the Rhythm – Mattis
Drew Barrymore – Bryce Vine
Angel – H. Kenneth
Fk Collingwood – Hayden Calnin
Up, Up & Away – Chance Peña
Bristol – Imaginary Future
Coyote – Mako
Affection – Amber Run
The Sea – HAEVN
Slept on Me – Mr Hudson2
Hey, Ma – Bon Iver
Soothsayer – Of Monsters and Men
Haunted – Saint Claire
Bigger Things – Imaginary Future
Stuck in Gravity – Of Monsters and Men
Party – Jon Bryant
Made of Bones – James Quick
Places – Portair3
Reach – Robert Shirey Kelly
Without You (feat. H. Kenneth) – Alle Farben
Quicksand Arms – Adam Agin & Watts
Silence Is Broken – Cal Trask
Cadillac – Joel Ansett
Sh’Diah – Bon Iver
Faith – Bon Iver
Salem – Bon Iver
For My Help – Hayden Calnin
Oceans – Noah Mac
Piece Of Your Heart (feat. GOODBOYS) – Meduza
Levee – Bo Baskoro
Why Do You Love Me – Charlotte Lawrence
iMi – Bon Iver
Breathe – Mako
Hairpin Turns – The National
Crying at the Party – Harry Strange
Something About You – Elderbrook & Rudimental
Byegone – Volcano Choir
Cars at Night – By The Coast
Holyfields, – Bon Iver4
Wonder – JacobNeverhill
Same Place (feat. Keelan Mak & Thomas White) – Fossa Beats
Jelmore – Bon Iver
Feeling You – Harrison Storm
Llt – Leo Islo5
Comrade – Volcano Choir
I’m Doing Everything I Can – Imaginary Future
Nowhere – Black Match
Oblivions – The National
Light Years – The National
Nothin’ – Navincii
Meant to Stay Hid – SYML6
5AM – Amber Run
Hold On – Griffin Stoller
Electricity – Danny Bowens
Not Giving It Up – JacobNeverhill
Bad Line – The Hunter Express
How to Help – Harrison Storm
Fuzzy Teeth – Portair
Naeem – Bon Iver
Truths – bobbycrush
Wonder (Stripped) – JacobNeverhill
Do You Remember (feat. Death Cab for Cutie) – Chance the Rapper
Shortcut – Monica Moser
I Found – Amber Run
Barrio – Mahmood7
Heavy St
– Blake Rose
On Our Last Day – Hayden Calnin8
All We Have Is Now – Ross Copperman9
Lines – Scott Quinn
Tonight – Thorin Loeks10
Hideout (feat. Zoe Maxwell) – Blewbird
Hallelujah – Oh Wonder


  1. For the list, though, I’m just using the output of my iTunes automation
  2. Just now realizing that I have no evidence for strongly assuming Mr. Hudson lives in New York City other than the name, and like… that’s not necessarily how names work. 
  3. the musical equivalent to the Dr. Seuss book 
  4. Sometimes I’m a little mad that Bon Ever exists, because the whole “disappear into the woods for a while, then reappear with an album of wonderful, weirdly-titled music” niche is one that definitely used to be one of my life goals. 
  5. I don’t want to admit to how long it took me to figure out what “Llt” stands for. 
  6. I’m slowly building an entire playlist around this song; it’s a good one. Very calming. 
  7. I originally found this one via the music video, which I also recommend, it’s kinda fun. 
  8. I have a strong desire to recommend this to all my music major friends. 
  9. Fun fact, if you use the full title and artist’s name in the iTunes search system, it just… stops working. It’s a great platform with no problems whatsoever. 
  10. My brain keeps replacing this with “Thorin Oakenshield” and I would like to clarify that I’ve never read nor seen Lord of the Rings
Categories
Writing

Guest Appearance: Buildable Blog

Related to my recent post on Angular libraries, I wrote an article for the company blog explaining why you’d want to do that. Check it out!

Categories
Review

“Meddling Kids,” or, “alright, who gave Shaggy a gun”

Edgar Cantero
I am a big fan of Scooby-Doo. It’s got something of that James Bond aesthetic to it — every few years, there’s a new one, and we get to see a new take on the tropes. The recent series have been pretty good — What’s New was, basically, a straight modernized version of the original; Mystery Incorporated did some interesting things with the characters; Be Cool is one of the funniest shows I’ve ever watched; and Guess Who is a love letter to the people who watched the original series.12 The movies are a bit more hit-or-miss, but growing up in the 90s meant I had Zombie Island, Witch’s Ghost, Alien Invaders, and Cyber Chase; Alien Invaders is a hilarious concept, Zombie Island is, I’d argue, the best Scooby-Doo media to date, and Witch’s Ghost is part of why I was so excited to visit New England.3
In short, I love the different takes on the same story; there’s nothing new on Earth, but the different ways people combine ingredients are still creative and interesting. So when I saw that somebody had written a Scooby-Doo book with Lovecraftian influence? Alright, I’m interested.4
The writing style is interesting — Cantero switches back and forth between a more conventional novel style and something inspired by a movie script, with labelled dialogue and annotations for Scooby.5 Where it really shines is the occasional action scene; the sentences get longer, flow together, and it feels like a choreographed fight in a movie.
It’s also definitely creepier than anything in my usual reading; the book is set roughly a decade after the gang broke up, and Fred having died in the interim doesn’t stop him from showing up when Shaggy forgets his meds. The interactions between Shaggy and his hallucination of Fred range from hilarious, through bittersweet, and occasionally into the grotesque.
Plot-wise, the book is enjoyable; it gets a bit weird in places, but eventually pulls itself back together, while leaving room for Cantero to come back and write more if he wants.
Which leads me into something that I felt he did excellently: tie-ins. Because, yes, it’s a Scooby-Doo book that can’t say “Scooby-Doo,” or “Fred,” “Daphne,” “Velma,” or “Shaggy.”6 It’s also a Lovecraft book, though — the Necronomicon is explicitly mentioned, and there’s a passing reference to Miskatonic University, as well as several scenes in Arkham. And other bits and pieces makes appearances — Cantero has certainly read more Lovecraftian horror than I have, but based on what I could pick out as references, there were quite a few that I missed. And it’s tied together to give the book the feeling of being part of a larger universe — you could pick up one of Lovecraft’s books, read it, and mentally slot it in to this same continuity without an issue.
So hey, if you want a creepy, fun little romp in the Pacific Northwest, watching Shaggy, Daphne, and Velma try to deal with PTSD and the results of living in a world that has both “some guy dressed up in a costume to scare people away” and the Necronomicon, I can heartily recommend Meddling Kids.


  1. Seriously, it’s artistically gorgeous, and whoever is doing the soundtrack? Give them a raise, it’s excellent. 
  2. Yes, I know I left one out; we don’t talk about Get a Clue
  3. Zombie Island also made my time in Louisiana more enjoyable, and Cyber Chase is set in an amalgamation of MIT, Stanford, and UC Berkeley, two of which I’ve visited. The moral of the story is, I need to go to Roswell to finish my Scooby-Doo Tour of the United States. 
  4. Admittedly, it’s not an official Scooby-Doo book, so everybody has different names, but it’s also clearly meant to tie in to the same “hey, recognize this trope?” pattern, and gains a lot by then subverting them. 
  5. As mentioned in the previous footnote, the dog isn’t named Scooby, but I don’t feel like writing a conversion chart for what’s meant to be a short review, so I’m just going to do the name-swapping myself. 
  6. It’s possible they could get away with “Scrappy,” but didn’t try. 
Categories
Playlist

Playlist of the Month: August 2019

If you ever want to feel extremely hipster about your taste in music, try to find anything you listen to with the iTunes Search API. “Billie Eilish? Never heard of her!”
Silhouette – Aquilo
Cologne – Haux1
Sober – Edwin Raphael
Coincidental – Betcha
How You’ll Be Remembered – Aron Wright
Power Over Me – Dermot Kennedy
Cocoon – Tommy Ashby
Me, The Prodigal – Lane Norberg
Connor – SYML
Bed – SYML
Antidote – Mr Hudson
Before You Knew It Was Me – SYML2
Let Me Hold You – Nick Wilson
Without the Lights – Elliot Moss
99 – Elliot Moss
Snowblind – Saro
You There – Aquilo
I Won’t – Richard Walters3
Bad for You – Billy Raffoul
Spoke Too Soon – Jake Scott
Caves – Haux
Hold Me While You Wait – Lewis Capaldi
Falling Down – Harrison Storm
To the Rhythm – Mattis
Loverboy – Mattis4
Must Have Been the Wind – Alec Benjamin
Drew Barrymore – Bryce Vine
Angel – H. Kenneth
Heaven – Avicii
All Time Low – Jon Bellion
F**k Collingwood – Hayden Calnin
Up, Up & Away – Chance Peña
Visible – Hayden Calnin
The Chain – Mattis
Bristol – Imaginary Future
Coyote – Mako
Affection – Amber Run
The Sea – HAEVN
Real – Majik
Smoke Filled Room – Mako
One with the Mountain – Firewoodisland
O.C.C.D. – Abra Taylor
Slept on Me – Mr Hudson
Murder (Acoustic) – Mako
Maybe We Shouldn’t Be Friends – Marshall
Hey, Ma – Bon Iver5
Soothsayer – Of Monsters and Men
Wars – Of Monsters and Men
Glass House – LIEZA
Haunted – Saint Claire
Bigger Things – Imaginary Future
Decisions – Sidi
Taken By the Sky – Dalli
22 (OVER S∞∞N) – Bon Iver
Mars – Alexander 23
Stuck in Gravity – Of Monsters and Men
Under a Dome – Of Monsters and Men
When Love Was Easy – VACAY
Party – Jon Bryant6
Touch the Sky – OLIPHAUNT
Leader of the Landslide – The Lumineers
Made of Bones – James Quick
Bones – JC Stewart
Show Me – Gavin Haley
Places – Portair7
Reach – Robert Shirey Kelly
Without You (feat. H. Kenneth) – Alle Farben
Quicksand Arms – Adam Agin & Watts
Silence Is Broken – Cal Trask
Cadillac – Joel Ansett8
Sh’Diah – Bon Iver
Faith – Bon Iver
Salem – Bon Iver
For My Help – Hayden Calnin
Oceans – Noah Mac
Piece Of Your Heart (feat. GOODBOYS) – Meduza9
Levee – Bo Baskoro
Why Do You Love Me – Charlotte Lawrence10
iMi – Bon Iver
Breathe – Mako
Hairpin Turns – The National11
Crying at the Party – Harry Strange
Something About You – Elderbrook & Rudimental12
Byegone – Volcano Choir
Laura No Està – Nek
Cars at Night – By The Coast13
Imagine – JV Jumpin’
Holyfields, – Bon Iver
Wonder – JacobNeverhill
Same Place (feat. Keelan Mak & Thomas White) – Fossa Beats
Jelmore – Bon Iver
Feeling You – Harrison Storm
Llt – Leo Islo
Comrade – Volcano Choir14
I’m Doing Everything I Can – Imaginary Future
Nowhere – Black Match
Oblivions – The National
Light Years – The National
Nothin’ – Navincii
Meant to Stay Hid – SYML
5AM – Amber Run15


  1. This song was, in part, the inspiration for my playlist backup automation – I wanted to have a ‘nostalgia’ playlist, sorta built around Cologne, but my “gotta have history” thing wouldn’t really allow it. So: git. 
  2. Similarly to Cologne, I’ve now got a playlist built around Before You Knew It Was Me. It’s good for late at night, when you want to be tired but not fall asleep. 
  3. I like this song, but the album art doesn’t really work for me; it looks like a screengrab from a lyrics video on YouTube. 
  4. Still very fun to sing along to. 
  5. So far, my favorite off the new album, but I haven’t finished listening to the whole thing yet, so we’ll see. 
  6. This album art gives me some serious JVN vibes. 
  7. It’s like the Dr. Seuss book, if Dr. Seuss had been on antidepressants. 
  8. Forewarning: this will probably get stuck in your head at least once. 
  9. The opening bit here, “wait, sorry, what if it went-“ is amazingly catchy. 
  10. I recommend listening to the lyrics, they’re fun. 
  11. So far this is the song off this album that gets stuck in my head most. 
  12. This link is to the YouTube video, which I rather liked; here’s the iTunes link 
  13. Ed Tullet/Novo Amor vibes, obviously I’m a fan. 
  14. In the ‘Haux’ vibe, though a little more electronic. 
  15. Thought about this song halfway through a swim and had to hop out, dry off my hands, and add it to this playlist before I forgot again. 
Categories
Technology Tools

Automatic OCR with Hazel: The Easy Way

I have previously written about how to run OCR (Optical Character Recognition) on a PDF using Hazel and… a complicated pile of Python scripts and other software. Since I wrote that post, several of those pieces of software have been updated, and the core component has been, apparently, entirely abandoned.
Recently, while I was waiting for yet another keyboard replacement on my MacBook, I took another look at the OCR thing and found that there’s a much easier way available: OCRmyPDF.
It’s easy to install, assuming you’ve already got brew: brew install ocrmypdf
From there, it’s just a single action in Hazel. “Run embedded shell script: ocrmypdf $1
Admittedly, you can use some of their many settings to get something a bit nicer than just OCR; personally, I’m using --rotate-pages --deskew --mask-barcodes – the first two to help with variations in the input because I sometimes use a bed scanner, and the latter to help Tesseract, which can have issues with barcodes..
I’ve also paired it with a couple additional actions, just to keep everything organized:

I also took the time to stop using Dropbox as the go-between for my scanner and the Mac running Hazel; I’d forgotten that the scanner has a USB port. Plug in a cheap flash drive, and it’s available as a (very slow) file server. Mount the drive, add it as a Login Item so it’ll auto-mount on boot, and you can set Hazel automations to run right there. I’m not OCRing them there, though — like I said, it’s a very slow server, so it tags them ‘for OCR’ and moves them to my desktop.1


  1. With iCloud Drive handling my desktop, I’ve found it to be a pretty great ‘intake’ folder for all of my Hazel automations. It’s quite nice to be able to save a PDF from my phone, add a tag, and watch it disappear again as it’s auto-sorted, or throw a PDF on my desktop with a tag and see it pop in and out as the OCR runs. 
Categories
Technology Tools

Automatic Playlist Backup

You may have seen my monthly playlist posts on here; I put those together with a Shortcut that grabs the playlist, runs through all the songs, and makes a spirited attempt to fill in all the links off the iTunes Store Search API without hitting their mysterious rate limits.1
It’s not the be-all end-all, though — I’ve been wanting more and more lately to start making more and smaller playlists, things to match different moods. Y’know, the way normal people do playlists.
But, of course, I’m me, and I want to have the history of my music tastes, because, hey, sometimes you feel like reminiscing.
So, what to do? Well, I’ve done some work with the iTunes Library XML file, and while it’s sorta true that just wrapping that in, like, Git or something for version control could work, there are three problems with that:
1. iTunes is a weird, weird piece of software, and I don’t want to mess with its files too much.
2. The result is not at all human-readable.
3. It isn’t an excuse to learn something new.

So, what else can I do? Well, I’ve done a very light bit of tinkering with AppleScript,2 so I know it can interact with iTunes pretty well; there’s gotta be a way to do it there, right?
There is! I’ll share the script in a moment, but the functionality I wanted was “clear out the folder I give you, replicate my playlist hierarchy as directories, and spit out each playlist as a markdown file listing the title, artist, and album for each track, then commit the changes to a git repository.”
It took a while to get working — I’ve learned that AppleScript’s repeat with in loop is hilariously slow, unless you change it to repeat with in (get). I’ve also found out that the way it works with paths is super annoying, and that while it can write to a file, it can’t conceptualize creating a directory. There’s some great workarounds for that.
Now, here’s the script: I’ve left a couple {replace me} type things where you should fill in variables – namely, the path to your home directory (or wherever else you want it), and your own username, to fix some permission issues that can crop up.3

But wait, there’s a caveat: it’ll fail if the folder you gave it isn’t a git repository. Considering that I wanted this as a ‘set it and forget it’ sort of thing, I figured it wouldn’t be worth the effort to write a bunch of conditional code to do the setup. Do it yourself: git init && touch temp.txt && add temp.txt && git commit -m "Initial commit" takes care of all you need.4
Oh, and if you want it to be pushing the changes somewhere, because you’re paranoid and want everything in someone’s cloud, at least, add the remote and set it as the default upstream: git remote add origin {remote URL} && git push --set-upstream origin master

Set It and Forget It

So that’s pretty neat, but it isn’t really “set it and forget it,” now, is it? You’ve gotta open up Script Editor, pull up the script, and run it every time you want it to back up your playlists. Possibly workable for some people, but I don’t have a home server for nothing. Let’s make this truly automated.
From my prior experience with AppleScript, I know that you can set it off through a shell script by way of /usr/bin/osascript, so my first thought was to add a cron job. After a bit of research, though, I found out that Apple would prefer we use launchd instead, so I set about figuring out how to do that.
Now, if this wasn’t all an excuse to learn how to do something, I’d probably have just bought one of the GUI clients for launchd; Lingon looks pretty nice, and seems to work well.5
The process for writing your own launchd process is actually pretty simple: create a .plist file containing some XML, add it to the launchd queue with launchctl, and you’re off to the races!6
(Hint: if you want an easier way to see if your script runs than waiting and checking git log, you can add a line to the start of the AppleScript: display notification "Running playlist export".)
So, creating the XML: you want it to live in ~/Library/LaunchAgents/, and the convention is the usual reverse-TLD. (You can also use local.{your username}.{your script name}, but I’m so used to using net.twoeighty. in bundle identifiers that I just went with that.)
The important parts are the ProgramArguments array and the StartInterval integer. For ProgramArguments, give it the path to osascript,7 and as your second argument, the full path to the .scpt of the AppleScript.
Then, set the StartInterval to the number of seconds between runs; I’m using 3600, because hourly change tracking seems frequent enough for my purposes.
The result:

(You can skip the StandardErrorPath and StandardOutPath – they help a little with debugging, more so if you’re running a full shell script and not a wrapper on an AppleScript.)
Finally, add it to the queue:

launctl load ~/Library/LaunchAgents/net.twoeighty.backupPlaylists.plist

And there you go – every hour, your iTunes playlists will get backed up to your Git repo, and you’ll have a nice history of your music tastes over time.


  1. iTunes Search is a really fun API to use, because via Shortcuts you only get a single input to it, and it is really bad at finding anything. Seriously — try to find anything off the top charts. As far as iTunes Search is aware, Billie Eilish doesn’t exist. 
  2. In lieu of Shortcuts having a way to set the volume on a HomePod, I’ve achieved a similar result with “run SSH script: osascript -e tell iTunes ...”. 
  3. Related: don’t put this anywhere with weird macOS access control things. Y’know, places like “Documents”, “Desktop”, anywhere in iCloud Drive or Dropbox, or even “Downloads”, which apparently is a much worse work directory than I thought it was. I eventually configured it to run out of and into my Public directory, because I figured that’d be easier than trying to mess around with the permissions somewhere else. 
  4. Without a file there, the git rm -rf . && git clean -fxd bit at the beginning is unhappy. 
  5. I used the ‘free trial’ version as a viewer for my works in progress; I figured if I’d done something really wrong, it’d complain about it being an invalid file or something. 
  6. He said, glossing over the couple hours of “fight me, macOS, why isn’t this working” 
  7. Probably /usr/bin/osascript, but you can use which osascript in Terminal to check. 
Categories
Review

“Radicalized,” or, “this just keeps getting more upsetting”

Cory Doctorow
One of my favorite concepts in science fiction is making one change and extrapolating it forward. What if Tesla and Edison’s war of the currents had resulted in most of the world outlawing electricity and doubling down on steam power? What if Superman had landed in Soviet Russia? What if somebody invented a machine that let you step between parallel worlds?
What Doctorow has done here is that, but instead of making one change, he doesn’t make a change, and extrapolates. What if we never fix copy right law? What if Juicero hadn’t collapsed? What if we never sort out healthcare?
The result is terrifying, because it feels… so very possible. It’s not the first time he’s done it, either — Little Brother was my first introduction to Doctorow, and it remains a poster child for the concept.
Reading both Little Brother and Radicalized, I didn’t feel like I was reading a novel; I felt like I was reading a warning. “We’re on a path that leads to this, or something just like it,” he’s saying. “I’m worried, and you should be too.”
Worry with me; it’s a good read, and well worth the time.1


  1. It also contains a great take on Superman, and a strangely uplifting story about the apocalypse; seriously, read it. 
Categories
Technology

Publishing a Private Angular Library via Git

So, you’ve built yourself a nice new Angular library and you’re excited to put it to use in your apps! It’s an exciting time. But wait: the code you used is proprietary, and you can’t upload it to NPM.1
Good news: thanks to some features of Git, NPM, and most Git hosts, there’s a way to bypass NPM, and you don’t even need to set up your own repository. Sound good? Let’s go.
Now, I’m assuming that you’ve already (a) created your Angular library, and (b) have it in Git. If you haven’t done (a), there’s a pretty good guide on Angular’s site; if you haven’t done (b), allow me to evangelize source control to you: Git is awesome, and you should be using it. This book, available online for free, is an excellent getting-started guide.
So, you’ve got a version-controlled library; how do we make it available?
1. Build the library. ng build {YourLibrary} spits out your library as a ready-made NPM package.
2. Track the built files. git add dist/{your-library}. If you’ve got that in your .gitignore, you’ll need to remove it, or git add -f. I’d recommend the former; you’ll need to do this every time you update the library. Wrap it up with git commit and a nice message explaining what you’ve changed.
3. Set up a second repository. This is where the NPM package version of your repository will live. Leave it empty; we’ll push to it in a moment.
4. Push the subtree. This is the the magic part: we’re going to treat the built files as their own separate repository. git subtree push --prefix dist/{your-library} {path to the second repository}2
5. Tag the release with a semantic version number.3 While it’s possible to do this via the command line, it’s not fun, so I’d recommend using the GUI for your Git host of choice.
6. Generate a read-only token for the second repository. In GitLab, this is under Settings > Repository > Deploy Tokens. Configure it as you’d like, but be sure to enable read_repository.
7. Add the library to your app’s package.json. Give it the Git address for your second repository, and follow it up with either a tag or branch name to pull from. (For example: "your-library": "git+https://{GitLab token username}:{GitLab token password}@gitlab.com/{your username}/{your-second-repo}#master would pull the latest version from master.)

Et voilà; you’ve got a private Angular library, ready for use.


  1. Or maybe you’ve got issues with the fact that NPM is a private company, and can remove, un-delete, or hand over your packages without your permission
  2. i.e.: git subtree push --prefix dist/my-own-library https://github.com/grey280/my-own-library.git 
  3. This isn’t strictly necessary – I’ll explain a bit more in step 7. 
Categories
Playlist

Playlist of the Month: July 2019

I’ve got a little bit of free time right now, which means I’m spending it desperately trying to stop myself from signing up for a bunch of new things. Like, please remember that you’re starting grad school in September, I promise you won’t have too much time on your hands at that point.
Silhouette – Aquilo
Cologne – Haux1
Sober – Edwin Raphael
Coincidental – Betcha
How You’ll Be Remembered – Aron Wright
Power Over Me – Dermot Kennedy
The Bird – SYML
Cocoon – Tommy Ashby
Gentle Punches – Jack in Water
Leave a Light On – JacobNeverhill
Me, The Prodigal – Lane Norberg
Killer Queen – FIL BO RIVA
Connor – SYML
Bed – SYML
Antidote – Mr Hudson2
Before You Knew It Was Me – SYML
Let Me Hold You – Nick Wilson
Without the Lights – Elliot Moss
99 – Elliot Moss3
Snowblind – Saro
You There – Aquilo
BITCH (takes one to know one) – Lennon Stella
Until We Meet the Dust – Jack in Water
I Won’t – Richard Walters
Bad for You – Billy Raffoul
Spoke Too Soon – Jake Scott
Wake Up – The Native Sibling
Caves – Haux
Waves – Dean Lewis
Hold Me While You Wait – Lewis Capaldi
Falling Down – Harrison Storm
To the Rhythm – Mattis
Signs – Leon Else
Pteryla – Novo Amor & Ed Tullett4
New Stories – Steve Benjamins
Loverboy – Mattis5
Rich, White, Straight Men – Kesha6
Must Have Been the Wind – Alec Benjamin
Stay (Don’t Go Away) [feat. Raye] – David Guetta
Drew Barrymore – Bryce Vine
Angel – H. Kenneth7
Something Good (feat. All Tvvins) – EMBRZ
Slow Down – Joel Ansett
Heaven – Avicii8
Enemy – Sandro Cavazza
All Time Low – Jon Bellion
Nostalgic – A R I Z O N A
F**k Collingwood – Hayden Calnin9
Never Really Over – Katy Perry
Up, Up & Away – Chance Peña
Down – Marshmello
Visible – Hayden Calnin
The Chain – Mattis
Bristol – Imaginary Future10
Cuando Me Miras (feat. Enry-K) – C. Tangana
lowercase – Luna Shadows
Someone You Loved – Boyce Avenue
Electric Touch – A R I Z O N A
Coyote – Mako11
Cross My Mind – A R I Z O N A
Affection – Amber Run12
The Sea – HAEVN13
Real – Majik
Smoke Filled Room – Mako
One with the Mountain – Firewoodisland
scared – Jeremy Zucker
O.C.C.D. – Abra Taylor14
Slept on Me – Mr Hudson
Murder (Acoustic) – Mako
Green Light – Lorde
Neon Circus – Amber Run
Maybe We Shouldn’t Be Friends – Marshall
Those Three Words – Portair
Hey, Ma – Bon Iver15
Thinkin Bout You – Emily Afton
Powerline – Phangs
Soothsayer – Of Monsters and Men
Wars – Of Monsters and Men
Sorry – Tyrone Wells
Glass House – LIEZA16
Haunted – Saint Claire17
Bigger Things – Imaginary Future
Decisions – Sidi
Taken By the Sky – Dalli18
Down – Marian Hill

  1. One of my favorite things about iTunes is that it can show me play counts for songs; I think it’s neat to see what my Clear Favorites are. ↩︎
  2. Two songs by Mr. Hudson on this list now, and I only started listening to him because I hit the wrong thing while trying to play Coldplay one day. Gotta love random chance. (Or a good marketing strategy, I suppose.) ↩︎
  3. Found this song by way of Elementary, who usually have pretty good final songs. And speaking of Elementary, it’s ending this season, I believe. I’ll be needing a new Sherlock Holmes show soon… ↩︎
  4. A bit more from my nostalgia break last month. ↩︎
  5. I really enjoy this one; Mattis has a good voice for it. ↩︎
  6. Gotta love Kesha. ↩︎
  7. One of my top two favorite additions this month; not the album art I chose, though, because Elliot Moss had an excellent design. ↩︎
  8. I… do not want to admit to how long it took me to figure out that this was Chris Martin singing. Just a lot of “wow, I didn’t know Avicii sounded so much like the Coldplay guy!” ↩︎
  9. My other favorite addition this month; some serious Bon Iver circa 2016 vibes. ↩︎
  10. If you like Haux, you’ll like this one. ↩︎
  11. Very catchy, also an excellent pick. ↩︎
  12. I’ve been getting more and more excited for this album over the past month, I’m quite looking forward to it. ↩︎
  13. Again, an excellent addition in the Haux vein. ↩︎
  14. Eventually I’m gonna have an entire playlist of songs that I picked because they reminded me of the excellent sound design in the opening to Passengers. ↩︎
  15. Hey, Bon Iver is back! Bon Iver is great. ↩︎
  16. Lyrically, at least, this is sorta… Evanescence-y? ↩︎
  17. Similar song on this list: “How You’ll Be Remembered.” Sadness and piano, definitely my aesthetic. ↩︎
  18. Reminds me of when I used to listen to Noon Pacific. I wonder if they’ve stopped doing the whole “Spotify-only” thing?
    Follow-up, having taken a break to go check: no, they’ve gone deeper into it and won’t even show song names now. Exclusivity: it’ll reduce your audience!
Categories
Playlist

Playlist of the Month: June 2019

All of these links point to music.apple.com instead of itunes.apple.com now, but the tool I use to get them is still at itunes.apple.com. It’s a slow death that iTunes is having.
Silhouette – Aquilo
Coldplay (feat. Vic Mensa) – Mr Hudson
Cologne – Haux
Sober – Edwin Raphael
Coincidental – Betcha
bury a friend – Billie Eilish
How You’ll Be Remembered – Aron Wright
Power Over Me – Dermot Kennedy1
A Big World – Joel Adams
The Bird – SYML
Cocoon – Tommy Ashby
Gentle Punches – Jack in Water
listen before i go – Billie Eilish
Leave a Light On – JacobNeverhill
Me, The Prodigal – Lane Norberg
WHEN I WAS OLDER (Music Inspired by the Film “ROMA”) – Billie Eilish
High Beams (feat. slowthai) – Flume & HWLS
Killer Queen – FIL BO RIVA
I Make Sparks – Novo Amor
Connor – SYML2
Bed – SYML
Antidote – Mr Hudson
Before You Knew It Was Me – SYML
Find Someone – A R I Z O N A
Rebota – Guaynaa
Let Me Hold You – Nick Wilson
Denim Darlin’ – Edwin Raphael
I Of The Storm – Of Monsters and Men
Where Your Secrets Hide (feat. Katie Garfield) – Klergy
Big Yellow Taxi (feat. Vanessa Carlton) – Counting Crows
Girl – SYML
Without the Lights – Elliot Moss
99 – Elliot Moss3
Snowblind – Saro
You There – Aquilo
BITCH (takes one to know one) – Lennon Stella4
Half a Man – Dean Lewis
Until We Meet the Dust – Jack in Water
I Won’t – Richard Walters
Bad for You – Billy Raffoul
Saturn – Sleeping At Last
Gold – JacobNeverhill
Spoke Too Soon – Jake Scott
Wake Up – The Native Sibling5
Amor Genuino – Ozuna
So Called Love – Melis
I Found – Amber Run
Three Strikes (feat. Jack McManus) – Afrojack6
Caves – Haux
Silence (feat. Khalid) – Marshmello
Big Jet Plane – Angus & Julia Stone
Waves – Dean Lewis
Hold Me While You Wait – Lewis Capaldi
Falling Down – Harrison Storm
To the Rhythm – Mattis7
Signs – Leon Else
This Song Reminds Me Of You – Jai Wolf
Do You Mean (feat. Ty Dolla $ign and bülow) – The Chainsmokers
Oceans Away – A R I Z O N A

  1. I heard this playing on the radio the other day and was thoroughly confused, and then confused about why I was confused. I think the moral of the story is that I don’t really understand the concept of radio anymore. ↩︎
  2. This one keeps getting more fun to sing along to. ↩︎
  3. About two weeks after I’d added both of these songs to this list, I was like, “oh, maybe I should try listening to the rest of the album.” So, y’know, look for that next month. ↩︎
  4. Pretty catchy, but I do have to ask: is this actually something people say? ↩︎
  5. This would actually work pretty well in one of those ‘gentle alarm clock’ type apps. ↩︎
  6. This pops up whenever I’m in a nostalgic mood, because I just go to the folder of playlists from a past year, and iTunes sorts by artist first, so this is up a the top. ↩︎
  7. I think this is the catchiest addition this month. ↩︎