Dec
20
PBS 46 of x – ES6 Spread Operator, Arrow Functions & Classes
Filed Under Software Development, Computers & Tech on December 20, 2017 | 1 Comment
We’ll start this instalment by having a look at my sample solutions to the previous two instalments, and then we’ll move on to looking at three ES6 features, two of which are extremely significant. We’ll start by addressing an accidental oversight from the previous instalment when we looked at arrays. I had intended to cover the so-called spread operator together with Array.from()
and the for...of
loop, but it slipped mind. Once we’ve dealt with my little oversight we’ll introduce an entirely new type of function that removes the need for the const self = this
kludge for callbacks. So-called arrow functions greatly simplify the use of callback in JavaScript, and in modern JavaScript, callbacks are everywhere!
Finally, we’ll make a start on my personal favourite new feature in ES6 — classes. This major change brings JavaScript into line with the other C-style languages, and, more importantly, into line with how most programmers are used to working. This takes JavaScript objects from weird esoteric things only those initiated into the JS cult can understand at a glance to intuitively understandable constructs. For those of you for whom JavaScript is your first language, classes will be nice, but for those of you coming to JavaScript form other languages, classes will be a blessed relief!
We’ll only be covering the basics of the class keyword in this instalment. In the next instalment we’ll take things up a notch when we finally explore the concept of polymorphism, the heart and soul of object oriented programming.
Dec
10
PBS 45 of x – ES6 Arrays & Strings
Filed Under Software Development, Computers & Tech on December 10, 2017 | 2 Comments
We’ll start this instalment be re-visting the question of when to use let
and when to use const
for variable declarations. My initial advice was to default to using let
, but based on some great feedback from the the community, I’ve changed my mind, and will be defaulting to const
going forward. I’ll explain why I changed my mind.
Next we’ll have a quick look at my sample solution to the challenge set at the end of the previous instalment, before moving on to some new material. Specifically, we’ll look at some of the ways in which ES6 has improved arrays and strings.
Nov
26
PBS 44 of x – ES6 Arguments & Objects
Filed Under Software Development, Computers & Tech on November 26, 2017 | 1 Comment
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.
Nov
24
Automatically adding Screenshots to Yoink with Hazel (Improved)
Filed Under Computers & Tech, Automation on November 24, 2017 | 3 Comments
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.
Nov
24
Automatically Adding Screenshots to Yoink with Hazel (Take 1)
Filed Under Automation, Computers & Tech on | 2 Comments
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.
Nov
12
PBS 43 of x – Introducing JavaScript ES6
Filed Under Computers & Tech, Software Development on November 12, 2017 | 3 Comments
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.
Oct
29
PBS 42 of x – Playing the Game of Life
Filed Under Computers & Tech, Software Development on October 29, 2017 | 1 Comment
In this instalment it’s finally time to bring our Cellular Automaton prototypes to life by implementing Conway’s Game of Life. By the end of this instalment we’ll have reached a real milestone — our first web app! Granted, it won’t be a very feature-rich web app, but you have to start somewhere!
As usual, I’ve collected the code files for this instalment into a ZIP file which you can download here. As well as the ZIP file, I’ve also published a tagged release of the bartificer.ca.js code on GitHub which you’ll need for this instalment’s challenge.
Oct
13
PBS 41 of x – Form Events
Filed Under Software Development, Computers & Tech on October 13, 2017 | 1 Comment
In this instalment we’ll tie up the last few loose ends related to web forms. With web forms under our belts, we’ll then be ready to pick up where we left off with our cellular automata JavaScript prototypes, and combine our HTML, JavaScript, and CSS skills together to make our first web app – an implementation of Conway’s Game of Life.
This instalment breaks down into two distinct parts – our first look at keyboard interaction with web forms, and a final look at form-related events.
When it comes to keyboard interaction we’ll start by looking at how browsers treat regular web forms, and then we’ll move on to supporting keyboard interaction with custom web form UI elements like the star-rating example from instalment 36.
Finally, we’ll wrap up with a handy reference table summarising the most important webform-related JavaScripts events, giving some guidance on their use.
There’s just one sample file associated with this instalment, and it’s available for download as a ZIP file here.
Sep
29
PBS 40 of x – HTML5 Custom Validations with jQuery
Filed Under Computers & Tech, Software Development on September 29, 2017 | 3 Comments
At the end of the previous instalment I promised we were done with HTML form validation, and insisted we were ready to move on to finishing our Cellular Automata, but it turns out that was a little premature. While working on my sample solution for the previous instalment‘s challenge I realised I’d forgotten to cover something very important – the fact that you can use jQuery to deal with situations where the HTML5 form validation attributes are not powerful enough for your needs. So – we need to rectify that oversight, and that’s going to take this entire instalment to do.
Then, while doing her homework, Allison discovered another oversight that needs to be remedied before we move away from HTML forms – we need to look at how to support keyboard-only interactions. Why? In a word – accessibility. So, in the next instalment we’ll start by looking at the narrow case of supporting keyboard input in forms, but we’ll then move on and look at keyboard interactions a little more broadly, and we’ll learn how to add keyboard shortcuts to our web apps. This will come in useful when we do then finally move on to getting our cellular automata working the following instalment.
As usual, I’ve collected all the files for this instalment into a single ZIP file which you can download here.
Sep
15
PBS 39 of x – HTML5 Form Validation
Filed Under Software Development, Computers & Tech on September 15, 2017 | 2 Comments
In this instalment we’ll be taking a break from our parallel approach, and focusing almost exclusively on HTML5 form validation. We’ll dedicate the entirety of the next instalment to getting our cellular automaton prototypes up and running so we can actually ‘play’ the game of life.
While we won’t be continuing work on our Cellular Automata prototypes this time, I will share my solution to the challenge I set way back in instalment 36.
Also, before we get stuck into new content I’ll be taking a small diversion to explain a slight change in my approach to HTML coding, and how that will affect the sample code you see for the remainder of this series.
As usual, I’ve collected the example file for this instalment and the starting point for the challenge together into a ZIP file which you can download here.