Explore My Notes

Understand JavaScript closures in minutes | freeCodeCamp

I always forget what closures are, even if I continue to use them. The article makes a case for considering closures as stateful functions which is quite neat. Basically, closures allow a function to return another function (or functions); each returned function will also have access to any data that the original function had access to. In other words:

const add = function(x) {
    return function(y) {
        return x + y;
    }
}
const add10 = add(10);
add10(10); // 20

That will output 20 because the internal function has access to both variables. It's a bit freaky but it means you can define functions as reusable abstractions with preset variable values really easily. As the article points out, that can be a lot more secure and can help encapsulate sensitive data/functionality, like so:

const manageBankAccount = function(initialBalance) {
    let accountBalance = initialBalance;
    
    return {
        getBalance: function() { return accountBalance; },
        deposit: function(amount) { accountBalance += amount; },
        withdraw: function(amount) {
            if (amount > accountBalance) {
                return 'You cannot draw that much!';
            }

            accountBalance -= amount;
        }
    };
}

const accountManager = manageBankAccount(0);

accountManager.deposit(1000);
accountManager.withdraw(500);
accountManager.getBalance(); // 500

📆 15 Jun 2020  | 🔗

  • JavaScript
  • closure
  • JavaScript
  • stateful function
  • security
  • abstraction 

Airbridge

A new calendar app without an implicit bias towards iOS is always worth celebrating. Airbridge certainly ticks the aesthetically-pleasing box and I quite like the idea of just defining time blocks as you go, rather than fitting things to a grid (which so often isn't flexible enough). Colour coding also looks great. No mention on whether you can sync calendars between accounts (a feature that would be incredibly useful to me), nor how much it is likely to cost once out of beta, but one to keep an eye on.

📆 15 Jun 2020  | 🔗

  • Technology
  • calendar
  • app
  • Android
  • PWA
  • organisation
  • to do list 

Our skulls are out-evolving us | Katherine Reynolds Lewis

Over the last 250 years, our skulls have morphed in dangerous and troubling ways.

Nasal passages and jaws are narrowing, overbites are becoming more extreme, palates are rising, skulls are shrinking. The result is less face to fit everything into, meaning crowded dentition, breathing problems, and potentially insufficient space for growing brains. It could even be a root cause of elevating asthma rates, joint pain (particularly in the young), and allergies, whilst sleep disruption caused by narrow air spaces is already well documented at causing anxiety, depression, and behavioural disorders in people of any age.

Narrowing of facial features, in particular, seems linked with industrialisation; less-industrialised nations suffer from these issues less and the anthropological record show these conditions to be incredibly rare throughout human history. From about 250 years ago, morphological changes away from a consistently "broad, straight, wide" skull shape seems to have accelerated. One possible reason is the sudden introduction of bottle-feeding and soft "baby" food that may cause our chewing muscles to underdevelop. Environmental pollutants are a second potential factor (obviously).

The impact is most serious in children. Studies cited have shown links with sleep issues in young kids can reduce their functional abilities by the equivalent of two years (!) and result in lower average lifetime earnings. It increases mood swings and makes kids cranky, less able to focus, retain information, or be creative. It's also a key risk factor in childhood obesity.

Parents know sleep is important, but they rarely realize how proper sleep relies on a wide dental arch, tongue on the roof of the mouth, and long lower jaw.

Treatment using centuries-old techniques has positive results:

Within a month, Micah’s sleeping improved and his behavior transformed. Previously, he cried at doctor’s appointments, balked at going to school, acted cranky, and hid behind his mom around guests. Now, he smiles freely and runs up to his grandparents for hugs.

Lbry

On the face of it, Lbry is a YouTube competitor based on privacy and community. You can tip creators directly, but otherwise it basically works as you'd expect, only with fewer features (no subtitles, for example). They're also proud freedom of speech advocates. Which might explain why their homepage at time of browsing included conspiracy videos, Bitcoin pyramid schemes, and men's rights activism. It does appear to have quite a few educational YouTubers (MinutePhysics and XKCD are both advertised on the home page, though searching Minute Physics got me a top hit of a conspiracy video dissecting an MP vid, above the actual channel content).

To be clear, I support any competition for huge industry juggernauts like YouTube. If that is done in an open manner that embraces the distributed web and respects user's rights, all the better. I may have been left a little cold by Lbry, but I want to keep an eye on it and hope it goes somewhere interesting (hence making the note).

A designer's life with colour vision deficiency | A List Apart

Noah explains what it's like working in web design with colour vision deficiency (CVD). Gives a great overview of what CVD covers and why some people can see more/fewer colours than the average person; basically it boils down to whether you have all three (or four!) kinds of cones in your eye and if they have greater/lesser sensitivity, allowing them to understand a wider/narrower range of wavelengths. It can also be caused by brain signal interference and other cognitive phenomena.

This means that those colors in the spectrum effectively “drop out,” but since the light is still there, the brain translates it into a color based on peripheral data picked up by the other cones, combined with its brightness level.

Our cones are split between short, medium, and long wavelengths, but their exact calibration is determined by a lot of nuanced genetic and environmental variables. What's more, other biological variance impacts the light that ever reaches the cones:

The lens and cornea physically block very short wavelengths; it’s why we can’t see ultraviolet light directly, even though we have the sensor capability.

Which is why people who lack lenses (or have them removed as part of cataract surgery or other vision corrections) can see UV to some extent.

When something is only conveyed with color, that’s a gap where information can get lost on a large group of people.

Form factors are important. If colour is a major signal/indicator in a design (e.g. a traffic light) then there should be a secondary signal. That could be iconography or animation or, as with traffic lights, just always being a specific order i.e. form.

Color can enhance the message, but shouldn’t be the messenger.

Trello has a neat feature where colour labels can also have explicit background patterns, like zigzags and dots.

You can Shift + Click any colour in dev tools to cycle through colour formats. Super useful!

It's baffling to me that colourblindness has been something that has been used against Noah to skip him for promotion or reject his progression at work. Sigh. Still, I've definitely been guilty of the hundred-questions approach to finding out someone was colour blind (sorry Sam) so will need to internalise that.

As of February 2020, 86.3% of home pages tested had insufficient contrast. So, what does that mean? It means that the information on those sites is not being conveyed equally, to everyone.
I like that I can bring a singular perspective to the table and a voice for others like me; I am able to offer insights that others don’t necessarily have.

📆 14 Jun 2020  | 🔗

Pine.blog

Pine is an interesting tool for curating information. It acts as a feed reader, importing content from RSS, Atom, mf2 etc. That means you can subscribe to Tumblogs, YouTube channels, subreddit feeds as well, then get all of that information presented as a timeline. The gimmick is that the service also operates as a Medium-like blog platform, allowing you to quickly curate information, right posts, and publish them all in one place. Plus it obviously hooks into the webmention API and allows you to like, comment etc. from a variety of other platforms and display them in Pine. Interesting stuff.

CSS custom properties and the cascade | adactio

CSS variables (aka CSS custom properties) do not have access to the cascade. That means they can't fall back to earlier rules, so if your variable is invalid, the browser will simply unset that property. Huh. Jeremy explains the logic behind why this needs to be the case but it's still interesting. I understand that dynamically generated variables should probably work this way, but on initial render I'm still surprised it doesn't hold on to the current cascade value whilst it checks the variable and just fall back to that if the variable is invalid.

But if I store the background colour in a custom property, I can no longer rely on the cascade.

The beauty of progressive enhancement | Manuel Matuzovic

Manuel wanted to see how a new site he'd built worked on the updated Nokia 3310, which rocks a paired-down version of Opera Mini (yikes!). The answer? Surprisingly well, thanks to some clever fallbacks:

  • If no JS, use a DuckDuckGo search query instead (very neat) using the type="module" trick;
  • Allow grid to work with just one column;
  • Use <picture> with both WebP and JPEG options.

Not so sure about the lazy loading implementation but otherwise solid tips.

CSS variables for React devs | Josh W. Comeau

You can do things with CSS variables that are not possible with JS.

Josh breaks down why and how you can use CSS variables more easily in React, specifically using styled-components. Honestly it feels a little terrifying how much is needed just to get basic browser functionality to work...

Invisible insulation | Seth Godin

It’s almost impossible to make a list of all the things I didn’t have to worry about yesterday. We need to work overtime to make that true for more people.

Easily rename Git master branch to main | Scott Hanselman

Turns out it's pretty simple to rename any branch in Git. Scott has a full step-by-step guide, but there are a few pointers:

git branch -m master main
git push -u origin main

Then just go into your GitHub settings for the repository and change the root value under branches. You're done 👍

📆 13 Jun 2020  | 🔗

Made By Me, But Made Possible By:

CMS:

Build: Gatsby

Deployment: GitHub

Hosting: Netlify

Connect With Me:

Twitter Twitter

Instagram Instragram

500px 500px

GitHub GitHub

Keep Up To Date:

All Posts RSS feed.

Articles RSS feed.

Journal RSS feed.

Notes RSS feed.