Writing

Here you’ll find some bloggin’ about business, design, and web development. And also whatever else I want to write about. Read on! (Or don’t. I think you’re cool either way.)

Custom queries in Laravel’s Eloquent relationships

Laravel’s relationship classes and methods cover like 90% of my use cases. But sometimes, there’s some weird distant relationship between a few models that doesn’t quite fit a HasMany or BelongsTo. For instance, I’ve been working with an app that has a few models, some of which are distantly related. The relationship looks like this: … Continued

Reviving an old printer with CUPS and Caddy

I just recently upgraded to an M2 Mac. I needed to print something not long after I set my new computer up, and — surprise! — our old Canon Pixma MX410 doesn’t work on the Mac anymore.

Canon has stopped supporting this printer entirely, and I guess Apple culled the printer’s driver from the kernel at some point. There was no Mac ARM version of the driver that I could find.

But all is not lost! Using CUPS and Linux, now I can print with my old printer from my new Mac — or even my iPhone or iPad. Here’s how I was able to turn my Raspberry Pi into a print server, and saved myself the trouble and expense of getting a new printer.

Stop Dropbox syncing node_modules with `find` and Hammerspoon

I’ve been a Dropbox customer for basically a decade. They’ve never lost my data! It’s been a good service, despite their growth and the frustration of dealing with their ever-noisier (and nosier) desktop client.

However, my main frustration with Dropbox is that there’s no way to tell it to ignore any file or folder that matches a particular pattern.

How to tell if an app is scriptable via AppleScript

Open Script Editor. Click Window > Library (or press ⌘+⇧+L). Click the + sign on the upper left. Choose an application and click “Open”. If the app is scriptable, it should have a library that you can add to this list. Otherwise, it’ll tell you you can’t script it! If you can add the app … Continued

Self-hosting an automation platform for free

Do you ever need to run simple automations for personal projects? What do you use? Zapier is terrific. It’s powerful and it provides a generous free tier. But when you need something more complex than simple if-then logic, like “send me an email when this event happens, but only if the event data contains an … Continued

Hold ON a minute

Let’s say you’re testing a function that: Does not accept callbacks (so you can’t use done as described previously) Is not async and doesn’t return a Promise Does not fire events or otherwise notify the outside world that something happened Does behave asynchronously, by e.g. calling external APIs or waiting on internal events Further, let’s … Continued

Testing async code in Jest

I’m in the process of learning Jest and doing my first TDD in Javascript. It’s hard! Jest is tough, even though it’s supposed to make JS testing a bit easier. Testing async code (literally, code that uses the async keyword), in particular, is tricky, especially when you have non-obvious calls to async functions.

New Skillshare class

Skillshare approached me recently to create a new class, after having seen my work on Codepen. They’re expanding their tech catalog pretty rapidly, so I’m sure I’m not the only developer they’ve contacted — but I still took it as a huge compliment. When we brainstormed ideas, Jessica from Skillshare suggested that, since my background … Continued

Modern JS in Legacy Projects, Part Three

Part one of this series discussed the why; part two introduced our “legacy” application and got its basic functionality hammered out with surprisingly little hoopla; now we can add a little somethin’ extra to make it magical. ✨

Our latest deploy is missing some key features that were part of the spec:

  • The “Reset” button doesn’t work, and
  • We’re not saving the state of the modal anywhere locally so that it persists across page reloads.

So in Part Two, I lied: we’re not turning this guy into a component just yet! Let’s knock out the rest of our basic functionality first.

Modern JS in legacy projects, part two

This is the second part in a series on modernizing your JavaScript incrementally, using Vue.js. Part one discusses why we might need to do this.


Shall we review?

  • Pretend you have an old project that’s built with jQuery
  • Your client’s needs have changed, and now they need advanced functionality that would be difficult to build with vanilla JavaScript and jQuery
  • You decide to build the new functionality with Vue.js, ’cause it seems good

Our project will end up with some fancy functionality for surprisingly little trouble. But we’re not there yet! Let’s write some code.