Hi, I’m Sam

This is my blog. I also have a website thing.

Homebrew on Apple Silicon

Posted on

Today, my new 13-inch MacBook Pro arrived! I was super excited to get it out of the box and set it up. This thing is fast! I am already very impressed. When I started setting up my development environment, things started to get a little frustrating. Have no fear, it’s solvable!

The biggest issue for me was Homebrew. According to this issue “There won’t be any support for native ARM Homebrew installations for months to come.” No big deal though. Homebrew can work just fine with Rosetta 2 and some things work natively.

Rosetta 2 is Apple’s translation later. This lets you run Intel things with a little overhead. In Terminal, you can run any process with Rosetta by prefixing it with arch -x86_64.

Continue reading →

Debugging JSON Data in LLDB

Posted on

Recently, I added a snippet to my ~/.lldbinit for an easy way to print JSON in LLDB. It has saved me a ton of time, so I thought it was worth explaining.

Here’s the snippet:

command regex json 's/(.+)/expr let input = %1; print(String(data: try! JSONSerialization.data(withJSONObject: (input is String ? try! JSONSerialization.jsonObject(with: (input as! String).data(using: .utf8)!, options: []) : (input is Data ? (try! JSONSerialization.jsonObject(with: input as! Data, options: [])) : input as! Any)), options: [.prettyPrinted]), encoding: .utf8)!)/'

Continue reading →

Thirty-One

Posted on

Today, I’m 31 years old. Crazy.

That seems like such an old age. I remember thinking when I was 22 that I better get everything done by the time I’m 30 since my career or whatever will be over then. Hah, such a kid.

Last year, I wrote this:

Continue reading →

Home Assistant, Sonos, and Siri

Posted on

Lately, I’ve really been getting into Home Assistant. It’s a really fantastic way to connect everything in your house into one place and then control it however you want. I connect everything directly to Home Assistant and then add Home Assistant to HomeKit (Apple’s Home app). So HomeKit is just controlling Home Assistant which is controlling the real devices.

I plan to do a getting started with Home Assistant post at some point. For now, I just want to go over controlling Sonos with Siri. (I specifically want to play Apple Music on Sonos via Siri. Apparently you can do this with Alexa, but I want to use Siri.)

The key to using Siri to control things in Home Assistant that aren’t supported in HomeKit is the Shortcuts app. Since things you add here are accessible from Siri, you can create shortcuts for things you want to do and then ask Siri to do them for you.

Continue reading →

Quickly Opening Projects in Xcode

Posted on

I’ve used a little utility called x for several years now. Simply running x in a directory will open the directory in Xcode. Here’s an example:

$ cd my_project
$ x

Now the project is open in Xcode. So quick!

Continue reading →