Jul
26
Right-click to Copy File Contents to Clipboard on macOS with Automator
Filed Under Computers & Tech, Automation on July 26, 2019 | Leave a Comment
How often does someone email you a file who’s content you need to copy-and-paste into a web form of some kind? Maybe it’s just me, but I find I need to do it a lot!
What I wanted was the ability to right-click any file with plain-text content (text, markdown, XML, JSON, Certificate Signing Requests, …) and send its content to the clipboard.
By combing Automator, the cat
and pbcopy
terminal commands, and a little JavaScript, I was able to build a nice service that can be accessed by right-clicking any file in any app that reports its outcome using a standard OS notification.
Download the Quick Action here, extract it, and copy it to your ~/Library/Services
folder.
Jul
13
PBS 81 of X — The JavaScript Promise Utilities
Filed Under Computers & Tech, Software Development on July 13, 2019 | Leave a Comment
So far in our exploration of promises we’ve learned the core concept — a promise is an object that represents the status and/or result of an asynchronous task. Asynchronous tasks are inherently parallel, but we’ve learned how to use .then()
and .catch()
to create so-called promise chains, allowing promises to be executed in series. What we’ve not looked at yet is JavaScript’s native Promise
class. This class is primarily used to create promises, but it also provides some useful utility functions. For now at least, we’re focusing on using promises rather than creating them, so we won’t be digging into how the Promise
class’s contractor works. However, some of the utility functions are designed to help developers use promises in more powerful ways, so those will be our focus for this instalment. The most powerful of these utilities is Promise.all()
, a function that allows us to create promise chains that perform some tasks in series, and others in parallel, allowing us to efficiently manage our asynchronous tasks.
You can download this instalment’s ZIP file here.