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 […]

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. https://xkcd.com/1746/

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) […]

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 […]

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 […]

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); […]

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 […]

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 […]

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 […]

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 […]

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 […]

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" ]