Hello! I studied Computer Science, now I live in Bath! I write code, design games, and occasionally tweet. Why not subscribe?

How to Make Jekyll Category and Year Pages Without Plugins

Posted March 20, 2019. Jekyll, Text. 346 words.

Jekyll is fantastic, easy to use, and extensible. However, some Jekyll hosts such as GitHub Pages do not allow people to use custom plugins - and I want category and year pages. But rightly so. Allowing custom plugins would require hosts to allow users to run arbitary Ruby code on their build servers and possibly create a mess. This problem is solvable, but it’s ultimately simpler to just ban them entirely.

This constrained environment forces you to get creative. On this blog I use the fantasic jekyll-compress-html template which minifies the very post you are reading. I have written by own template to automatically replace standard markdown or HTML images with lazily loaded ones. And finally, I have written a small (it’s only a hundred or so lines ;) ) Makefile to automatically, among other-things, generate year and category pages:

# Find categories and years
CATTARGETS  = $(shell grep -h '^categories:' -r _posts/ | awk -F ':' \
              '{print $$2}' | tr ' ' '\n' | sed '/^$$/d' | sort | uniq | \
              awk '{print "categories/"$$1".html"}')
YEARTARGETS = $(shell find _posts/ -regextype egrep -regex '.*/[0-9]{4}.[^/]*' \
              -printf '%P\n' | cut -c-4 | sort | uniq | \
              awk '{print "years/"$$1".html"}')

# Generate category pages
cat: cat-clean $(CATTARGETS)
categories/%.html: _templates/category.html
	cp $< $@
	sed -i 's/#####CATEGORY#####/$*/' $@

# Generate year pages
year: year-clean $(YEARTARGETS)
years/%.html: _templates/year.html
	cp $< $@
	sed -i 's/#####YEAR#####/$*/' $@

To use, simply create _templates/category.html and a _templates/year.html templates and run make cat year. The code assumes your posts start with the date and they are stored in the default _posts/. When run #####CATEGORY##### and #####YEAR##### will be replaced with the templated value.

Get an email each week I post, zero spam             


I̵n̵t̵e̵r̵a̵i̵l̵i̵n̵g̵, No Flying into Malaga

Posted March 11, 2019. Photos, Travel. 238 words.

I briefly flew to Malaga.

In The Sky

In The Sky

On The Streets

On The Streets

By The Beach Time To Sleep

By The Beach and Time To Sleep.

The Next Day Buried Remains

The Next Day and Buried Remains.

Hello There Towering Castle

Hello There, a Towering Castle.

Inside Are Gardens A View Of The City

Inside Are Gardens and a View Of The City.

A View Of The Town

A View Of The Town

Ugshot Squirrel Cats

Ugshot. Squirrel? Cats!

Obligatory Photo

Obligatory Photo

Reading Till Dusk Giraffes

Reading Till Dusk. Giraffes.

Watching A Protest Listening To The Drums

Watching A Protest. Listening To The Drums.

In The Market

In The Market

Towering Over Cramped Checking Out

Towering Over. Cramped. Checking Out.

Flying Home

Flying Home, the Question is Where Next?

Let it Snow!

Posted February 1, 2019. Photos, Snow, Text. 24 words.

Let it snow

Not a great photo, still alive. Have an avatar generator.

25 Days, 25 Languages

Posted December 1, 2018. Programming, Text. 226 words.

This year I am going to take part in the 2018 Advent of Code, where each day, two new programming challenges are uploaded to the site. But as I live in the UK and I don’t want to ruin my sleeping schedule for a month, competing for the leaderboard is out of the question. Instead, I am going to challenge myself to use 25 different programming languages.

For this I will treat different versions of the same language as the same language, so no Python 2 and Python 3 solutions. However, I can use C, C++, and C# as they are all different languages, even if they are rather similar syntactically. As for what language I pick on the day, it really depends how I am feeling. If the problem is simple, I am more likely to choose a more complex or unfamiliar language. I’ll be saving some language for when I am really struggling.

My solutions will be posted on GitHub.

Edit: Oops, so that didn’t happen. Not long after starting this challenge I broke my dominant wrist roller-skating, and just in time for Christmas! But anyway, this means that it is unlikely that I will finish this. While incomplete, I am glad I attempted it and will definitely consider using Rust in future projects - it is a nice language.

Reddit, Your Site is Terrible, Please Make it Worse

Posted November 15, 2018. Rant, Reddit, Text. 785 words.

Reddit, the 18th largest site worldwide is a fantastic site full of fun user-created content, amazing photos from around the world, and crazy far-right conspiracy theories. The web experience is great too. On desktop you can see several posts at a time amidst a sea of extraneous white-space. On mobile the site fills your browser until it is time to nag you, at least twice, to install their app. And then touch-events are registered 1​cm up the page for no good reason. Or images refuse to load no matter what you do. You get the picture.

And I find myself going back.

Other social-networks simply don’t grab me the same way that Reddit does. Reddit is a never-ending fire-hose of content, you can keep scrolling, and keep scrolling, and keep scrolling, and keep scrolling, and I do. Facebook is a useful tool, but I never find myself scrolling through the news feed. Twitter is an endless feed of announcements, politics, and small things taken out of context. LinkedIn is a professional waste of time. Twitch is background noise, I listen to it, I don’t watch it, and I don’t feel that I waste the little time I spend there. YouTube, well I spend a fair amount of time on YouTube. There are great videos published near daily, but my subscription-feed is curated, and the front-page is limited.

Reddit just keeps going.

I only have finite time in a day, in a year, in a life, and I don’t think Reddit is a good way to spend any of it. I set perpetual Cold Turkey blocks on Reddit and other distractions on my computers. I do not have a Reddit app installed on my phone, but I do have a web-browser. I try to not use Reddit on my phone, I do it anyway. I clear my history from time to time to clear Reddit from my suggestions, it comes back. I definitely need to try harder.

I think I would block Reddit entirely if I could.

As far as I know, there is no perfect method to block Reddit on a non-rooted Android phone (I like Google Pay and similar applications) like there is on a regular computer. Cold Turkey has an Android app, but it blocks the phone instead of Reddit. It is still a useful app but it’s not what I am looking for. You can use an app to setup an Accessibility, VPN, or DNS blocker but doing so is finicky. Either it needs a persistent notification, drains what little battery life my old phone has left, or needs to be configured for every single WiFi network you connect to. I recently found BlockSite which seems promising, but I am a little concerned about how easy it would be to uninstall.

This isn’t great, but there is a solution.

Reddit, you keep making your site worse on a near weekly basis. Mobile used to be fantastic, fast, and worked well. First adverts and sponsored content were added which is fair, a site needs to earn money to survive. Cookie banners came next, but they are commonly thought to be required by law (I am not a lawyer). Then the site started to nag you to install the app, which is annoying but only seemed to appear once per tab. The touch-events bug came after, stopping browsing sessions in their tracks. Next Reddit added the blue pill at the bottom of every page, it’s really annoying to close. And now, Reddit has added yet another prompt to install their app. On every page you now need to confirm that yes, you want to continue using Google Chrome. If you make a mistake, or the touch-events bug strikes you will be whisked away from your dark Reddit experience into the stark white Play store.

So thank you Reddit, and please keep up the good work.

Continue Reading...

The Consto Family of Fonts

Posted October 24, 2018. Fonts, Text. 141 words.

Something I have been wanting to do for a while, is to make a handwriting font. Doing seemed like a fun thing to do, and useful for me to use.

The four fonts

  • Consto Ballpoint - The first of four fonts. A sharp font that is too the point.
  • Consto Marker - A softer font, made using your favourite brand of permanent markers.
  • Consto Pencil - A sketchy font made using a pencil. A rough and jagged font with lots of bumps.
  • Consto Pixel - A three by three pixel font, it is surprisingly legible, it could not be any smaller.

Now while this is something I want to share, I would rather not share to liberally. So, I have chosen to license these fonts under the Creative Commons Attribution-NonCommercial-NoDerivatives license.

Download from GitHub

Post 100!!!

Posted October 21, 2018. Celebration, Text. 133 words.

Somehow I managed to reach 100 posts! Here is to another 100! See the Swedish Army Band to celebrate!

The Swedish Army Band

Okay, the video is rather shaky. YouTube has removed the enhancement and ffmpeg is really, really, slow on my laptop. Sorry.

BBC Radio Playlists

Posted October 18, 2018. Music, Playlists, Text. 25 words.

Sticking with the music theme, here are three playlists each containing every single BBC Radio station in 320kbps, 128kbps, and 94kbps.

Maikovsky: Composing Folk Music with Markov Chains

Posted October 14, 2018. Music, Text. 154 words.

This week I used Markov Chains to create folk music. It is output in ABC and rendered using ABCjs.

Turnpike To Martindale's Trip

The music it makes is a little bit strange and it doesn’t really understand how many beats should be in a bar, but if that is a problem up the iterations. Keep raising the iterations and eventually you might even hear a tune that you know!

Under the hood, it is relatively simple. I started by downloaded about 300 folk tunes from sourceforge. After making an Ajax request to load them, it “parses” each tune into a data structure that is easy to work with. Then two Markov Chains are generated for the title and for the music, the other attributes are just chosen randomly.

Tunes can be played back with or without chords, and on any instrument. Click here to start.

Bring the Light

Posted October 7, 2018. Games, Text. 349 words.

I teased with an idea, and here is a very basic demo of it complete and released. Just a warning, it runs poorly, looks bad, and isn’t fun to play. Enjoy!

Bring the Light

On a more serious note, while this is not the result I wanted I have definitely learned, or at least re-learned a few things. Looking over it, a project like this is likely too big for me, at my current skill level, with the short amount of time I gave myself.

Continue Reading...

1 / 11 Next Page »
StatCounter Pixel