This post is part 44 of 92 in the series Programming by Stealth

In the previous instalment we started our exploration of the new features ES6 brought to JavaScript with a look at block scoped variables. We learned that var will continue to work as it always has, defining function-scoped variables, but that we can now use let and const to define block-spoped variables and constants.

We’ll continue our exploration of ES6 today by looking at how function arguments have been improved, and learning about a new type of loop designed to make looping over object properties easier.

There is no ZIP file for this instalment, instead, I’ve published my solution to the challenge from the previous instalment (which is also the starting point for the next challenge) as a tagged release on GitHub. You can download it using the big green button labeled Clone or Download.

Read more

Tagged with:

Note: This is an improved version of my original solution to this problem.

As a reminder, the problem to be solved is to have screenshots automatically appear in Yoink as they are taken. Again, as a reminder, on macOS, screenshots are saved to the desktop as files with names of the form Screen Shot YYYY-MM-DD at HH.MM.SS.png, e.g. Screen Shot 2017-11-22 at 22.30.10.png. And one final reminder — Hazel is an app that watches the filesystem for events, and executes actions in response. Hazel rules are added to folders.

My original solution was to add a Hazel rule to the desktop folder with the condition Name starts with Screen Shot and a single Shell script action which used the open terminal command to send the screenshot to Yoink. The good people at Hazel replied to my tweet about the original post with a suggestion: I think you can do the same thing without a script. Try using the “Open” action.

Unsurprisingly, the Hazel suggestion proved to be spot on.

Read more

Tagged with:

Note: based on feedback from Hazel via Twitter I’ve improved on this original Hazel rule, described separately here.

One of my favourite app discoveries of 2017 has been Yoink — a Mac an iOS app that revolutionaries drag-and-drop by simply providing a shelf where you can temporarily store anything drag-and-dropable as you switch between windows, apps, and even spaces. I reviewed Yoink on episode 496 of the Chit Chat Across the Pond podcast.

Anyway, I use the Yoink all the time, but, it’s missing what I believe would be a fantastic feature — the automatic addition of screenshots to the Yoink bar as you take them.

I contacted the developer to suggest/request this as a feature, and he didn’t seem all that interested in adding it, but, he did make two suggestions for how I could go about getting the functionality I wanted indirectly. He made two suggestions — buy a different app of his, ScreenFloat, which is specifically for managing screen shots, or, build an automator script to take screenshots and send them to Yoink.

This week I finally found a simple solution I’m happy with — Hazel combined with a simple terminal command.

Read more

Tagged with:

This post is part 43 of 92 in the series Programming by Stealth

Because its been a while since we focused on JavaScript, the bulk of this instalment will focus on solving the challenge set at the end of the previous instalment. We’ll work through the solution in detail, step-by-step.

We’ll finish the instalment by making a start on moving from JavaScript version 5, to JavaScript version 6, or ECMAScript 6, usually just called ES6. When we started our look at JavaScript about a year and a half ago it made sense to use JavaScript 5, but now it’s time to upgrade our knowledge. ES6 was a very big change indeed, so we won’t bit it all off at once. Instead, we’ll focus on just one very important change in this instalment — ES6’s new take on variables.

There’s no zip file for this instalment as such, instead, I’ve published my sample solution as a tagged release on GitHub instead. You can use the big green clone or download button to either copy the code using GIT, or download it as a ZIP file.

Read more

Tagged with: