Weekly Head Voices #103: Chips!

I thought that I had nothing for the two weeks from Monday January 18 to Sunday January 31, 2016, but my notes begged to differ. They suggested the following items for your reading, listening and viewing pleasure:

Party trick

If you’re like me, you stop two to three chips short of finishing the packet so that you can explain to your conscience that you didn’t finish the whole thing. However, once or twice in my life, I’ve been faced with the terrifying conundrum of a partially finished packet of chips, but no way to seal the packet for later utilisation. Readers, agonise no more! Learn from this animated demonstration:

View post on imgur.com


A musically inclined colleague recently suggested I try out In Colour, the 2015 studio album by Jamie XX. After multiple listens, I can only highly recommend that you too try this out on your favourite music source. I’m currently on Apple Music, because it is currently the best way for me and my whole family to get access to all the music we can eat. What a time to be alive! Below is one of my favourite tracks from the album:

Irrelevant miscellany, for my OCD

At Stone Three, as I have previously hinted, we have now switched to a self-hosted Mattermost. So far, this is going swimmingly, with some of the resident experts also getting the github integration going (when someone pushes to any of the linked github repos, we get a nicely formatted message on the relevant channels). If you’re curious about how exactly this compares to HipChat, Slack or Campfire (remember that?), let me know in the comments.

For the Saff Efricans reading this: When Afrihost announced that they were going to play MVNO (mobile virtual network operator), I jumped on them. Much more data, somewhat more airtime and contract-free for not very many peanuts sounded like a great deal to me. Let me know in the comments if you need more info.

Backyard linguistics

Millenials, or Generation Y, are humans that were born anywhere from the early 80s to the early 2000s. As a backyard anthropologist, one of my favourite articles about millenials is “Why Generation Y Yuppies Are Unhappy” by Tim Urban on the Wait but Why blog. However, I found this recent article by Jeff Guo titled “The totes amazesh way millennials are changing the English language” at the Washington Post even more fascinating.

It turns out that millenials have introduced new forms like totes delish (most delicious), abbreviash (abbreviation), appreesh (appreciate) and many more brilliant inventions into the English language. It’s fantastic seeing a language evolve like this, especially now that the internet and the hyper-connected humans on it are acting as such a powerful catalyst, and simultaneously as an instrument of observation, or should I say observash?

Inspiring quotes that you can repost if you want

This is from Soderbergh’s Solaris, which I thought was brilliant (I did read Lem’s book when I was much younger, could be that that did the trick). The quote was brought to my attention by @ckritzinger on the twitters as follows:

There are no answers. Only choices.

Let’s broaden the quote slightly. Remember, this is the dialogue between one of the last living characters on a space station, and a flesh-and-bones version of one of the other crew members that was resurrected (you know, from being completely dead) by the utterly strange planetary intelligence that is Solaris (you can also read this fine analysis):

If you keep thinking there’s a solution, you’ll die here. There are no answers. Only choices.

That sounds like an even more apt bit of advice for most of us here on Earth, except that it’s only going to make the difference between dying, or dying with the disappointing belief that there must have been a solution or final answer somewhere that you were just unable to find.

There is no why.

There is only how, and that’s awesome!

Fix the unusable window resize border in Gnome Flashback Metacity on Ubuntu

On Ubuntu I mostly use Gnome Flashback with Metacity, along with the brilliant Synapse app starter / file finder. I do this in spite of having a beefy NVIDIA GPU in this Core i7 workstation, because the OpenGL compositing on this 2560×1440 display makes video conferencing really slow, and because I do OpenGL development and need to have maximum performance for the app I’m working on.

However, it irritated me to no end that the window borders were so thin that I was not able to grab them for a resize. Adding insult to injury, there were only the four standard themes in Settings | Appearance, namely Adwaita, Ambiance, Radiance and High Contrast, none of which has usable borders.

The solution is to use the Gnome Tweak Tool (package gnome-tweak-tool) to change the Window theme to something with better borders. I used Watercolor (from the metacity-themes package), and set the rest up as follows on the appearance tab:


Once this is done, your window borders should look like this:


Now you can resize your windows again, AND you can enjoy the snappiness of Gnome Flashback with Metacity!

Weekly Head Voices #102: High on life.

The week of Monday January 11 to Sunday January 17, 2016 got off to a brilliant start with a business lunch at Bodega, a restaurant that finds itself on the Dornier Wine Estate. The view looked something like this:


… and the company was suitably awesome. (This is not the first time that Bodega makes its appearance on this blog, or in the blog-free suburbs of my social calendar. The company might be different every time, but so far its level of awesomeness has been quite consistent.)

The rest of the (work) week was consumed by extreme nerdery, which is of course the way I love it. Besides more GPU shader fine-tuning (at least once I exclaimed on the Stone Three HipChat, hopefully soon the Stone Three Mattermost,  WITNESS THE POWER OF MATH!, before showing a rendering that was marginally better than the one where the POWER OF MATH had not yet been invoked a sufficient number of times), there was Javascript, d3.js (d3 is another fantastic example of what you can do with vectorised thinking and computation) and Python.

In break time I finally took a closer look at C++14 and beyond and came away super impressed. There’s a blog post in the pipeline on generic lambda expressions, because I think they’re brilliant. I don’t know why I love different programming languages so much, but I do.

On Saturday,  I got really high with one of my besties, a superb gentleman who also goes by the name of A Very Flat Cat. We reached this altered state by the old-fashioned but extremely reliable (and cheap!) method of physically increasing our altitude via ambulation up the west peak of the Helderberg. The walk (a few hours in 35 degrees Celsius…) was exhilarating, and the view from the top awe-inspiring. Check it (click for high-res):


I’ve often wondered about the effect of one’s surroundings on one’s mindfulness. This was one of those cases where mother nature, without asking for permission or anything like that, simply brute-forced the being switch with her astonishing beauty. Very grateful I was.

Have a great week friends, see you on the other side!

Weekly Head Voices #101: Welcome to the centre of the universe!

The entire observable universe as visualized by Pablo Carlos Budassi. Click on the image to go to the sciencealert article, including a link to a high-resolution version of this beautiful image.

In the week of Monday January 4 to Sunday January 10, at least the following things happened:

See you next week peeps, have fun!

Closure expressions in Swift

Swift is a new high-performance compiled language designed by Apple. I’ve had some experience using it for an IOS development project, but the language is open source and is already available for Linux.

Some of you are probably able to appreciate the irony of me writing a blog post about Apple’s new programming language Swift, but here we are. :) I am, grudgingly, really impressed by Apple’s good work.

In this post I’m going to chat about closure expression syntax, in the process showing you IBM’s Swift Sandbox, an online tool for experimenting with Swift.

Let’s start with a simple example (slightly modified from Apple’s documentation on Swift closures) for sorting a list of strings in reverse alphabetical order:

// names will be constaint, so we use let and not var
let names = ["Chris", "Alex", "Ewa", "Barry", "Daniella"]

// function taking two parameters and returning boolean
func backwards(s1: String, _ s2: String) -> Bool {
    return s1 > s2

let reversed = names.sort(backwards)

print("Reversed alpha:", reversed)

That’s a complete compilable program in Swift, which you can run directly in your browser by clicking here.

We use let to define a list of strings. Swift is strongly-typed, but in this case it simply infers the type of the names variable from the value that’s assigned to it. MAGIC!

If we were planning to change the value of the names list at some point, we would have had to use var (mutable) instead of let (immutable).

We then define a function called backwards that takes two strings, and returns the true value if the first is larger than the second. In the final let statement, we call the sort() method on the names list, but we pass it the backwards() function, which it will use to compare elements during sorting. Because we have flipped the s1 and s2 variables, we get our list back in reverse alphabetical order.

sort() can be seen as a higher order function that takes the backwards() function as one of its inputs, and uses it to do its work.

Since we’re only using the backwards() function once, it would have been pretty convenient if there were some way to define it more compactly and in-place.

This is exactly what Swift’s closure expression syntax is for. Here’s the above code, with the backwards() function written as a closure expression:

let names = ["Chris", "Alex", "Ewa", "Barry", "Daniella"]

// closure expression syntax for inline anonymous function:
// { (args) -> returnType in statements }
var reversed = names.sort({ (s1: String, s2: String) -> Bool in return s1 > s2})

print("Reversed:", reversed)

(You can run this Swift code in your browser by clicking here.)

Instead of having to define and name a separate function, we can specify a function in the exact spot where it’s needed, using closure expression syntax i.e.: { (parameters) -> returnType in statements }.

For you Python-heads out there (MY PEOPLE!), the above code can be written in Python as follows:

names = ["Chris", "Alex", "Ewa", "Barry", "Daniella"]

reversed = sorted(
    cmp=lambda s1, s2: 0 if s1 == s2 else (-1 if s1 > s2 else 1))


In Python, lambda is used to specify anonymous function objects (our closure expression syntax, in other words). The compare function is defined differently, which is why it’s somewhat more complicated, but the principle is the same.

Whilst typing this blog, I downloaded Swift 2.2 from the open source download site and installed it on my Ubuntu 14.04 laptop (the internet is so slow over here, we have to multi-task to stay sane). After compiling both the examples using swiftc whatever.swift, the resulting binaries are about 21 Kbytes each (they are dynamically linked to a number of system libraries, and the 5M libswiftCore.so).


The Swift language is open source, is already available for Linux, has a number of really compelling modern language features of which closure expressions are just one example (other interesting examples include optional types and protocol extensions), is statically typed with good type inference, and has a good compiler. For these reasons, it should be strongly considered for a permanent spot in your compiled language toolbox!

P.S. Yes, I do know that C++ has lambda and auto. I like them too!