Mark Grealish

the life and code of a crazy cat man


The Irish Sea from Blackrock

I wanked around with some sliders in Photoshop because I liked the net effect.


Hackoberfest has made Tic-tac-toe a thing in my life. tictactoe-server opened an issue for a ES6 refactor of the solution checker. I kicked around the lengthy imperative code check and found I wanted to expand the solution, that I wanted to drop in Tic-tac-toe boards of arbitrary size, and to check them in an efficient […]

Moody me

Taken by Eadaoin in Brussels, Belgium.

We’re on a plane!

To Brussels!


Reddit jokes aside, holy shit: I wooed Eadaoin with space facts. We would spent hours on Skype at night when we first went out, where I’d talk about the universe to help get her to sleep.

Decadent kitty comfort

You can’t fake this level of luxury.

Get the prime factors of a given number

This solution uses the Sieve of Eratosthenes and the range() functions I detailed a while back. Hurray for function composition! function factors(number) { const primes = sieve(range(2, number >> 1)).filter(n => !(number % n)); return primes.length ? primes : [number]; } The code is simple: Generate a list of primes in range 2-(n / 2) […]

Rogue One cinematography

It doesn’t matter to me if the rest of Rogue One is awful, not when this is how Gareth Edwards’s presents the Star Wars universe. See, I’m a written science fiction fan. While I don’t keep count of what books I’ve read, I put the count somewhere in the mid hundreds. Some novels I’ve read […]

October at the Digital Hub

Git branch name

It’s a greatly stupid-simple alias: git config alias.branchname '!git branch | grep -E "^\*" | tr -d "* "' git config alias.dammit '!git push -u origin $(git branchname)' git dammit

Recursive Sieve of Eratosthenes

Call me stupid, but the Sieve defeated me for years-I could never quite seem to make it click. TL;DR: Return the first element of the array, joined with the rest of the array with all multiples of the first element removed. A non-zero value is truthy in JavaScript, which is coerced into true, so non-multiples […]

Even occurring element in an array

This solution employs the previous solution. With the XOR method explained, you invert the array: Find the unique elements in the array. Concat the new array to the original. This makes the even (even count) numbers odd, and the odd numbers even. Use the XOR method as before. Behold: function evenOccurring(array) { return [].concat(array, array.filter(unique)).reduce(xor); […]

Odd occurring element in an array

I dug into the problem and discovered that any number XOR’d with itself an odd number of times equals zero, whilst an even number of times equals the number itself: 7 ^ 7 = 0 7 ^ 7 ^ 7 = 7 The trick here is: Numbers which appear in the array an even number […]

Right-cyclic array rotation

The solution is ugly, but fuck it: the code works. Also, code Zen. ;) TL;DR: Create a new array by plucking the last element from the array and making it the first. def rotate(array, count) return array unless (count >= 1 && array.present?) rotate(cycle(array), count - 1) end def cycle(array) [array[-1]] + array[0..-2] end And […]

La chat noir

Twilight at Sandymount Beach

We missed the best of the golden hour, but I for one am satisfied with the twilight we caught.

The best kind of Saturday morning

Eadaoin and Cookie both cuddled up while I study.

Coding Zen in all the strange places

I continue to return to Zen as a way to reach peace with myself. Zen encourages introspection and meditation alongside expressive acts such as calligraphy. The core of Zen calligraphy, such that I understand it, is to cultivate the beginner’s mind. The expert mind is packed with presumption; while an expert mind has a powerful […]


Simple recursive array each method. function each(array, callback) { if (array.length) { callback(array[0]); each(array.slice(1), callback); } }


Recursive factorial in one line. function factorial(number) { return number < 2 ? 1 : number * factorial(number - 1); }

I went full hacker

Friends don’t let friends friends go full hacker. It turns out that a 76 centimetre monitor turned to portrait is completely unusable for teh hax0ring-I had a neck ache inside of a half hour, and I went back to a single screen before lunch. Years of Openbox with powerful keyboard shortcuts have ruined my ability […]

Lough Glenicmurrin

I close my eyes now, and open them two years ago. The sun is on my face. There are only two colours in the world, green and blue. Water laps, insects buzz, and the wind sighs soft in my ear. The only things I see are the lake, the mountains, and my friends. Eadaoin’s by […]

Dump (and pretty print) all function arguments to the console

A Lodash-infused variant of this function is my lifeline at work (ALL the ES6 syntaxes!): function dump() { [...arguments].forEach(arg => { console.log(JSON.stringify(arg, null, '\t')); }); } For example: dump({ messages: { hello: 'World!', goodbye: 'Moon!' }}, ['Apples', 'Oranges', 'Peaches', 'Pears']); { "messages": { "hello": "World!", "goodbye": "Moon!" } } [ "Apples", "Oranges", "Peaches", "Pears" ]

with recursion

today i solved a problem with recursion today i solved a problem with today i solved a problem today i today solved i recursion i today with^C^C^C

Cookie says hi!

This is my life meow

I’m a Cookie cot.

Like three times worse

Overheard today at work: God keeps killing unicorns. This is worse than kill_orphans.


Simple recursive array map. function map(arr, callback) { return !arr.length ? [] : [callback(arr[0])].concat(map(arr.slice(1), callback)); }

Dublin skies, September 2016

Cloud iridescence and lenticular clouds in one day!

Spanish Point Eadaoin

Taken at Maria and Adrian’s wedding in September 2016. :)