Mark Grealish

Cats and wizardry.


Coffee is Good

in code

Currently writing a client < => server HTTP service and added some test code along the lines of “When the application starts, please GET a list of all records from the server. After you receive them DELETE the first item in the list.”

Promptly forgot about it.

Why ever, I wondered ten minutes later, does the server spew 404 and RECORD NOT FOUND errors at me when I try to get the recor-oh.


Set Zsh Tab Title Automatically Based on Folder

in code

Pre-determined tab titles

My current task at work sees me rewriting an old application from scratch. A good part of this involves me going back and forth between the old and new project folders-call them “wigwam” and “spaklepony”-to compare code. This can be difficult to keep straight in tabs as a terminal user.

A quick walk of Stack Overflow and the ZSH chpwd hook led me to a two-step solution:

  1. Add hook function to set tab title.
  2. Add chpwd hook to evaluate folder name on shell initialisation and subsequent cd calls.

Set Window Title

# set-window-title 'Neenaw weewoo'
function set-window-title {
  echo -ne "\e]0;${1}\a"
}

Set Title on cd

function -set-project-folder-title {
    if [[ $PWD =~ "Projects/sparklepony" ]]; then
        set-window-title 'Sparklepony'
    elif [[ $PWD =~ "Projects/wigwam" ]]; then
        set-window-title 'Wigwam'
    else
        set-window-title $(basename $PWD)
    fi
}

chpwd_functions=(${chpwd_functions[@]} "-set-project-folder-title")
-set-project-folder-title

First Cycle Since…2008?

in me

The first cycle-cycle, that is, because trips to and from town in Galway don’t count. Back in Vegas I used to cycle to work: take the bus part way, cycle the balance. I stopped (no bicycle) after I got back to Ireland, so I’m looking forward to the route to Howth.

There are few words in this post, which I blame on being tired.

The shiny new bicycle
Obligatory narcissistic selfie

Replace Odd Numbers of Spaces Only

in code

Stolen from Stack Overflow, this bit of regex matches odd numbers of spaces only. Last week I retabbed a work project, but didn’t catch that I replaced \t with \s instead of \s\s. Whoops.

gsed -E -i -e 's/^\s(\s\s)*/& /g' src/**/*.*

Per the SO link, x(xx)* will match odd numbers of x.

It works.


Dwerja Bay, Gozo

in malta

I’m missing Malta today. :( Hope to go back for a week in September.

Dwerja Bay, Gozo

Slidescan Panorama of Dollymount Strand

in ireland

Taken on my way home from work in the rain last Wednesday. The effect came out great.

Slidescan panorama of Dollymount Strand, Dublin