Storybook is Amazing

I have recently added Storybook to one of the UIs that I am working on.

Storybook is an envitonment for providing a place to display UI components in a catalog. Typically this is used for development of a component library.

It is also useful slightly higher up the stack. Having entire forms or parts of forms testable in isolation is a big win. This allows you to show a form in all its possible states, even if some of them would require exotic conditions.

This can greatly free up development time while ensuring that the component can be refactored.

Having the components testable in isolation makes testing cross browser much easier. You can stand up Storybook locally without any backend services.

Given that I mostly work on an application with a React frontend with a GraphQL backend this reduces the effort on isolating changes to the frontend. So far I have not managed to use the fake GraphQL services, but by splitting the components into GraphQL layers and a pure function allows the pure function to be tested.

Magic The Gathering

I am just getting back into this game.
The last time I had played was 1997 so the modern game is very different.

The new restricted formats are an interesting twist.

Pauper – 60 or more cards, only if they have ever been common.

Commander – 1 Commander and 99 cards. No duplicated cards except for basic lands. There are a few exclusions.

The mana burn rule has been removed so you don’t need to have sinks for using up all of the spare mana you have floating around.

Mulligans help avoid the no land/all land hands.

The second step of the Mtg Online tutorial opponent could have been using my first Pauper deck, with Raging Goblins and Goblin Grenade!

I started to build my own commander decks from my collection. Only when checking the counts of the cards I found that the following two were banned:

  • Balance
  • Limited Resources

    I can see how devastating Limited Resources could be in multiplayer commander! Only having 10 lands across all of the players could mess up most decks.

Eyre’s First Law

If a utility is useful for testing it will eventually make its way into production.

I have seen this pattern many times.

You add a piece of code (possibly to help set up a test) that sets some state.
This then gets extracted from the test to a shared library.
It then gets added to the backoffice tool for development purposes.
This is then required for production.

Elixir Editor Fonts

The Fira font improves the Elixir Developer experience.

This is how to install it on a mac
`
brew cask install font-fira-code
brew install font-fira-code --cask

`For vscode in settings.json:
    "editor.fontFamily": "'Fira Code'",
    "editor.fontLigatures": true

This turns |> into an arrow. 

The Resignation That Wasn’t

Last Friday Boris Johnson announced that he was resigning with immediate effect and wrote a long resignation letter. The press have announced that he has resigned.

However there is as yet no date announced for the by election!

It appears that he has managed to announce a resignation without actually formally resigning as an MP.

The UK has a very odd system for MPs. The can’t technically resign. Insead they have to apply for one of the nominal positions that disqualify them from being an MP.

In this case it does not seem to have happened. This is also true for the other two that announced their resignations the same day.

Correction:

He did actually resign on Monday

Cat Psychology

Now starting week 4 of getting to know our 2 newly adopted cats.

One of the cats is happy to play string anywhere. The other works to strict zones. There are parts of the room that are for play and others for food/hiding. String will be played in a play zone, and ignored in others.

Understanding the cat zones makes communication easier

Dangers of inheriting config

I have just finished migrating a suite of Elixir projects from distillery to mix release. A key part of that change is that all environment variables need to be called from the runtime.exs rather than the various env.exs files.

This is part of a project to move to build once, deploy many times approach.

While working on this I found a few cases where the staging envitonment files inhereted from production. This is a big problem as you may turn things on in production later and not realise that the staging system (which can have a larger number of possible users) will also be using production.

I untangled the config into distinct files (keeping everything as it was) and only when it was reviewed it revealed certain production settings we don’t want in staging.

This relates to the talk Simple Made Easy.

Migrating from Distillery to mix release

Mix release became the offical way to release an Elixir project some years ago. Distillery had been the previous one.

Here are the steps needed to move across:

1. Move any config that uses environment variables into runtime exs.

2. Add a release section in your mix.exs

3. If you were using rel/config.exs to copy files into the release add this to a custom function in the mix.exs step

4. Remove distillery from your mix.exs and clean up the lock file.

5. Adjust your build process to call mix release instead of distillery.

This requires a lot of careful testing!

Learning New Languages

No matter how many ptogramming languages you know there is always another that you need.

Currently I am learning Elm with the next stop being Rust.

The Elm ecosystem is slightly broken on M1 Macs (including via Docker). My plan to reduce the pain is to use Storybook.