Mark Grealish

Cats and wizardry.

Remap a JavaScript Object

in code

Eh, gods, this one bothered me a fair bit. At work our API returns some data that I’ve found I have to remap. As it happens with any organically-grown system, there are a number of small inconsistencies between different objects with similar attributes. For example:

interface Foo {
  ices: {
    type: 'vanilla';

interface Bar {
   icecream: 'vanilla';

interface Fizz {
   confectionaries: {
    ice_cream: 'vanilla';

I want to map all of these consistently so I could call (say) foo.ices.type. For this I found schm’s translate method through a founder’s blog post. Using Lodash’s _.set to go with _.get, I can set arbitrary paths as well as being able to read from them:

import { get, isObject, set } from 'lodash';

function translate(source: object, map?: object): object {
  if (isObject(map)) {
    return Object.keys(map).reduce(
      (acc, key) => set(acc, key, get(source, map[key])),
  } else {
    return source;


const map = {
  'ices.type' = 'confectionaries.ice_cream',
  'ices.taste' = 'appraisal.deliciousness'

My next step will be to create a higher-order function that takes the map and translates the passed object.

And the Land Beyond

in ireland

Mayo countryside from Croagh Patrick
Mayo countryside from Croagh Patrick
Mayo countryside from Croagh Patrick

Taken on Croagh Patrick, Mayo, October 27 2018.

Clontarf Half Marathon

in running

Me tired but happy at the finish
Run route on Strava
  • Date: 2018-11-17
  • Time: 01:42:29
  • Distance: 21km
  • Pace: 00:04:53/km
  • Finished: 366/1605 (23/100 normalised)

Previous race: Gaelforce Howth Summit 10k

Went well. Flat course. Ran long and hard.

Yesterday I applied the lessons of the Phoenix Park half marathon:

  1. I wore warm clothes. Beanie, gloves and an over layer.
  2. I found my desired pacer in the starting pen and began from there.
  3. I carried more gels and used them at the halfway and three-quarters marks.
  4. I set and stopped my run timer as I crossed the start and finish lines.

Other than that, the run was a straightforward out-and-back to Sutton. I got ahead of the 1:45 pacer popped on a podcast and shut off for two hours.

Esjan and Þverfellshorn

in iceland

Looking toward Mosfellsbær from Þverfellshorn
The view west from Þverfellshorn
The view east from Þverfellshorn
Snowy plateau at the top of Esja
Þverfellshorn peak marker


in iceland

Panorama of Seljalandsfoss in southern Iceland
The rear of Seljalandsfoss waterfall
Seljalandsfoss waterfall

Another waterfall, another whistle stop tour, this time at Seljalandsfoss, right down the road from Skógafoss!

Seljalandsfoss Cloning Before/After

in design

Seljalandsfoss cloning before (with tourists)
Seljalandsfoss cloning after (with tourists)

In my post about Skógafoss, I mentioned that I spent a few tedious hours in Photoshop cloning out tourists. This led to some questions from my friend Duncan about the time I put in to remove the tourists, which in turn put it into my head to upload this. There really were a million of us tourists all over the place. :p