Mark Grealish

the life and code of a crazy cat man


joke

The grimmest grim view that ever grimmed a grim

Taken from the shore at Blackrock.

Clearly a sushi lover

Rails 5 join table naming conventions

This is a stupid fucking thing, akin to Googling basic syntax for your language, but here we are. My underling and I wasted 40 minutes today re-figuring this out. Migration: class PluralSingular < ActiveRecord::Migration[5.0] create_join_table :plural, :plural end Model: app/model/foo.rb class Foo < ApplicationRecord has_many :plural_singular has_many :plural, through: :plural_singular end Join model: app/model/plural_singular.rb class […]

Winter tree, winter sky

Taken at Blackrock Park.

You can’t go home again

Time’s an arrow, one way, here to there, that you can’t turn back. Because that’d be nonsensical, to undo what makes you, you.

2016

Listos version: Lots happened, more yet to come. Stay tuned.

2005-era Linuxy desktop goodness

And by “retro” I mean “cringeworthy,” but that’s part and parcel with haxx0r Mark and his ghetto battlestation. In clockwise order: Gnome desktop environment on Fedora Linux, Wednesday August 18 2004. Gnome desktop environment on Gentoo Linux, Thursday February 16 2006. Fluxbox window manager on Gentoo Linux, Monday November 15 2004. Gnome desktop environment on […]

Typing right is hard

Something something legacy shoulder injury, proper ten-fingered touch typing is hard. I type fast in a ten-fingered style, but it is weird and left-dominant. Correctly keeping both hands on the home row is hard. Grumble.

Cookie, home from boarding

:3

What I did on my summer holiday

I finished with one programming job on Friday and I start my next Monday. That means it’s time for some good ol’ retrospection. I used to think I was a special snowflake because I fell into coding, but Stack Overflow says otherwise. I wrote a great sob story about my hard-luck, self-taught career, but I […]

Nucleosynthesis

There are times when I envy what gods give to their believers: a sense of identity and place in life, and a higher power you can call on in times of need. I grew up with a growing realisation that the godstuff made no sense. I’m logical and literal and limited by my fundamental lack […]

Dawn light

The view from our room leads to the production of many beautiful dawn photographs, whatever else you might care to say about it.

Eadaoin by the sea, November-December 2016

All hail Queen Eadaoin of Dublin Bay and Galway Bay.

Hacker Mark v2005

Sure what else did you expect when I had a shit battlestation?

Hackerstation v2005

You can just feel the Linux dripping off those nicotine-stained walls. Yeah, fuck parents who smoke in their own home.

Recursive hash operation in Ruby which fowards a block

Recursive hash operations were annoying as heck to puzzle out because, you know, functions aren’t just functions in Ruby: You have functions and procs/lambdas, all of which have subtle differences. Like a regular function cannot be passed as a block. Well, whatever, I had a problem where I had to walk, reject-from and then compact […]

Hello Newry, Goodbye Newry

I came, I mailed, I left. To paraphrase the problem: An Post will not accept any package with a battery or electronic device inside. No way, no how. Except when such a package comes in from outside the country, and then they’ll happily deliver it. But An Post still won’t accept such a package for […]

<3 Gentle Monday night cuddles with Cookie <3

My kitty cat loves me so. :3

Mindey Blindey

My life since the Autumn of Autism has become a chain “oh, huh” moments, little pieces of self-discovery that flow one into the next. Put together, they outline a substantial blindness in myself, of myself. It’s a thing called alexithymia, where I don’t know what I feel, when I feel it, even though I still […]

I’m not sure what kids consider hip these days, but I think it involves concussions

¯\_(ツ)_/¯

Mount Usher Gardens

Found during a cleanup of photographs from the summer. :)

Project Euler Problem #30

Problem #30 was solved on new ground: my first run through Project Euler was in rigid order of first to last ending at #25. The recent round of solutions mostly cover old ground, which works well for me by itself because it shows off how my code has improved since 2012. Also, the run of […]

Project Euler Problems #18 and #67

The new solution for Problem #18 (compared to the old one) is more elegant: I reverse and reduce the triangle in a manner that doesn’t require me to check. The solution for #67 is a bit more longform, so I turned the method I use here into an NPM package: Triangutron. const eighteen = ` […]

Project Euler Problem #36

function range(start, end) { return [...Array(end + 1).keys()].slice(start); } function palindrome(number) { return number.toString() === number.toString().split('').reverse().join(''); } function toBinary(number) { return (number >>> 0).toString(2); } function add(sum, current) { return sum + current; } const palindromes = range(1, 999999).filter(number => { return palindrome(number) && palindrome(toBinary(number)); }); console.log(palindromes.reduce(add));

Lexicographer

I went back and owned the fuck out of Problem 24. I present to you a fully-functional functional lexicographic permutation generator generator. Hail Satan! \m/ #!/usr/bin/env node const lexicographer = require('lexicographer'); const array = [...Array(10).keys()]; const breakpoint = 1000000; let permutations = 0; for (let value of lexicographer.permute(array)) { permutations++; if (permutations === breakpoint) { […]

Project Euler Problem #16

Ruby this time, and a wee bit shorter too. (2**1000).to_s.split(//).map(&:to_i).reduce(:+)

Project Euler Problem #24

#24 defeated the fuck out of me first time through: My solution to this was basically stolen elsewhere, and it took me a whole year to come back, sit down, and work through my own solution. The poor wording (I’ve since edited it) of the Wikipedia article didn’t help me. The specific piece of information […]

Project Euler Problem #22

Again, better. :) #!/usr/bin/env node const fs = require('fs'); const add = previous, current) => previous + current; const toNumbers = string => { return string.split('').map((_, index) => string.charCodeAt(index) % 64); } fs.readFile('./p022_names.txt', 'utf8', (_, data) => { const names = JSON.parse(['[', data, ']'].join('')).sort(); const reduced = names.map((name, index) => { return toNumbers(name).reduce(add) * (index […]

Project Euler Problem #12

Once again, it’s more readable than my last solution. I used a generator to get the next triangle. function divisorCount(number) { let end = Math.ceil(Math.sqrt(number)); let divisorCount = 0; for (let i = 1; i < = end; i++) { if (!(number % i)) { divisorCount += 2; } } return divisorCount; } function* triangleGenerator(number) […]

A karmic ditty for developers everywhere

Whenever you start to complain First take the time to git blame!