I ran git pull upstream develop
and was quietly relieved to see that no-one had changed anything over xMas
. I ran git push
just to make sure my fork was in sync. The package.json
file has a preprocessor step when running git push
that lints and tests everything before it pushes.
And damn the tests failed.
And why did the test fail?
Because now it’s 2021, and the Copyright
component’s snapshot still said 2020, cursed be its name.
The component:
const Copyright = ({ holder }) => (
<Typography>
{'Copyright © ' + holder}
{new Date().getFullYear()}.
</Typography>
)Copyright.propTypes =…
It’s almost xMass and typically, each year, I like to get over to Adelaide, South Australia to catch up with family and friends during that period of enforced annual leave. Normally I’d fly. This year however I’m very keen to attempt the drive, having finally bought myself my first car.
When I was about 14 years old my father asked me what kind of car I thought I’d get when I grew up. My response was that I didn’t think I really wanted a car, so much as I wanted a robot to carry me around at high speed, and…
The map
function is something offered by all Iterable
objects (Arrays
, Sets
, Lists
, etc) and allows you to iterate through the items, apply a transformation to the item, and returns a corresponding collection of the transformed items.
export const VERBS = ['start', 'stop']
export const ACTIONS = VERBS.map(verb => import(`acts/${verb}`))
That’s handy for lots of things, but the above isn’t terribly useful. To get to a function you have to do something like:
import { VERBS, ACTIONS } from 'acts'export default function action(verb) {
const i = VERBS.indexOf(verb)
return ACTIONS[I]
}
What’s more useful is if you took the…
Symptom: I am calling a function, getCommonData
, loaded from a module called feedScanner
. Calling getCommonData()
ought to return actual data. It does in unit tests, but, in practice, it’s coming back in its initialised state.
// This fails as it thinks the scanner has not started.const commonData = getCommonData();
console.debug('commonData', commonData);
Investigation: It looks like my hunch was right, there are two feedScanner
modules! WTF.
*** Hey I’m a feedscanner ***
*** Hey I’m a feedscanner ***
Javascript imports are cached so why am I seeing two ditinct
feedScanner
modules?
Investigation: It must be something to do with thewebpack
…
Update 2019–12–11
: Apple has released Catalina 10.15.2
and iOS 13.3
which, between them, restores the ability for the iOS Remote
app to control your Mac based Music
library. The instructions below about enabling Home Sharing
for Media Sharing
still apply.
Update: This works to a point, in that you can actually see your music library in the Remote app, but you can’t actually play anything. This must be a bug. Come on Apple! You’ve really dropped the ball here.
I upgraded my Mac to Catalina (aka macOS 10.15) and amongst the many little changes, iTunes
was finally pulled apart and…
This article assumes you are already reasonably familiar with React.
Hooks are JavaScript functions that let you interact with React components’ state and lifecycle features from plain function components, rather than having to write a class, or wrap components in higher-order components.
Hooks were introduced in React 16.8 and are now a stable feature. Hooks also work in modern versions of React Native.
React provides a number of built-in hooks, and gives you a simple set of rules for writing your own hooks.
The useState
hook is probably the…
A standard trope of the climate change denier is that “they”, some unnamed shadowy cabal, stopped referring to “global warming”, and instead rebranded it as “climate change”. While there is some evidence to suggest that this rebadging was attempted by elements of the fossil fuel lobby, the fact is that global warming is not the same thing as climate change; global warming is a driver of climate change.
It’s been understood for over a hundred years now that Earth’s atmosphere traps heat by what’s known as “The Greenhouse Effect”. While the physics are not exactly the same as in an…
A while ago I wrote a small utility called amqp-delegate
that uses the standard amqplib
library to allow the easy creation and invocation of remote workers via an aqmp
message bus such as Rabbit MQ
.
I wrote an article about this called ‘Delegating Work using NodeJS and AMQP’.
I was at the beach when I wrote it and was feeling pretty lazy. In order to get a nice green 100%
coverage badge on my repo I cheated and used /* istanbul ignore next */
to completely ignore my work delegator’s invoke
function.
In my tests I added a little TODO
…
A slug
is a human-readable, unique identifier, used to identify a resource instead of a less human-readable identifier like an id
. You use a slug
when you want to refer to an item while preserving the ability to see, at a glance, what the item is.
Typically slugs are used when making search-engine optimised urls, so for example the url of this post is https://medium.com/@davesag/whats-a-slug-f7e74b6c23e0. There are actually two slugs in that url, my username
, @davesag
and the slug for this specific post, whats-a-slug-f7e74b6c23e0
. Of that the whats-a-slug
part comes from the title, and, for reasons only known to the…
I argued in an earlier article, ‘Shit Javascript Coders Say’, that no-one should use ever Typescript, and I thought it best if I expanded on why I believe that is.
This is part two of a two part article. Jump to the previous part in which I take a massive dump on Object Oriented software, especially as it relates to Javascript.
Typescript is a strongly typed (hence the name) superset of Javascript. It’s a great way for developers coming from strongly-typed OO languages like Java or C# to develop Javascript applications with the security blanket of strong-typing and IDE code…