Weekly Head Voices #110: Satoshi.

This update contains carefully selected thought bubbles from the time span between Earth date Wednesday July 20 and Sunday July 24, 2016.

Actually, the majority of this post is taken up by my Poor Man’s Bitcoin Explanation. If you’re not a nerd and/or you don’t have any interest in fabulous new virtual currencies that manage to work around a whole constellation of systems and rules put in place by governments the world over (STICK IT TO THE MAN BY THE POWER OF MATH!!), just skip over the next section.

Bitcoin in 10 minutes

I finally got around to studying the math behind bitcoin.

If you more or less know what a hash is (the hash is as a short string, e.g. 32 characters, than can be calculated from a file of arbitrary size; if even one byte in the file changes, the hash will be completely different; read more on wikipedia, or ask me in the comments) and you more or less know how the public and private keys in asymmetric cryptography work (you can encrypt (encode) something with the public key, ONLY its matching secret private key can decode it; you can SIGN any file with a secret private key, the authenticity of that signature can be proven by anyone with matching public key; read more on wikipedia, or ask in the comments!) you can more or less understand bitcoin in particular and cryptocurrency in particular.

Let’s say you were to generate a completely random private key, you can then use a well-known procedure to derive its matching public key. By applying two successive hash functions to that public key, you have a bitcoin address!

If I were to owe you money, you could then give me that bitcoin address.

I could then pay you back by writing a specially crafted message called a bitcoin transaction, in which I describe that I am transferring some bitcoins TO the address that you gave me FROM another bitcoin address (henceforth the source address), of which I have the matching secret private key.

In that message, I cryptographically sign the input part, a modified version of the whole transaction, including source and destination address, with the (secret) private key matching that source address. The signature mathematically proves that I own the bitcoins I am about to transfer, and it mathematically locks in the whole transaction, so that the destination addresses also can’t be changed. I generally also allocate a very small amount (by leaving money unaccounted for) as a transaction fee. We’ll see why in a minute.

I broadcast the signed transaction to the bitcoin network, where it eventually gets picked up by one or more of the bitcoin miners. Miners batch together a number of transactions into a block, together with a hash of the last successfully mined block, and a piece of random data called the nonce. They then proceed to continuously hash the block, changing the nonce every time so that the hash changes, until the first few digits of the hash are zeroes.

Based on the nature of cryptographic hashes, this will statistically take a very long time. One could get lucky and get the correct hash early, but generally it requires a whole lot of number crunching, which means kilowatts, which means actual money. The special hash resulting from this number crunching is called the proof of work.

When a miner has hit the jackpot, they broadcast the block to the network, which recognises that it’s the next valid block by checking the hash, and then, in a peer to peer fashion, irreversibly records this as the next block in the globally shared block chain. The successful miner receives 12.5 bitcoins (currently worth about 7500 EURO; thank you Wayne Kitching for the correction in the comments! — on July 9 of this year, this reward was halved, for the previous period it was 25 BTC per block) as well as all of the included per-transaction fees.

Now you probably understand why so many people are mining so enthusiastically. (No, you can’t really participate anymore with your home PC like you could in the early days; you have to acquire a large room full of bitcoin mining ASICs, circuitry that has been purpose-designed for one thing: bitcoin mining, to make any kind of impact. On the other hand, if you play the lottery, you might as well fire up your PC.)

You could now go and print out your private key (or its QR code) and the matching bitcoin address (actually you only need the private key, the public key and address can be derived from it) and then destroy all of your computers. Whenever you need to send that bitcoin somewhere, you simply type in the private key or rather scan the QR code, and then repeat the process of creating a bitcoin transaction, using your private key.

The money is never actually stored anywhere, only transactions encoding the movement of money from one random virtual address to another are. The block-chain is mathematically unbreakable and unforgeable.

I find the relative simplicity of the whole thing utter genius: A usable and versatile currency backed by hard math. YEAH!

Further reading

The two sources that helped me the most were Bitcoin transactions, metaphorically (Part 1) and Bitcoin transactions, technically (Part 2), both on the What does the quant say? blog.

Hmmm, that blog title unfortunately reminds me of this:

The end of the internet

Last night I realised why it feels like there’s so much less happening on the internet these days. I seem to be able to go bed with the feeling that I’ve finished reading the internet. In other words, my usual hard-to-break cycle of reddit-inoreader-google+(yes I still use it!)-hackernews-twitter-facebook-reddit-argh-go-to-bed-reddit-reddit/r/emacs-reddit/r/strange-new-programming-language-ARGH-ARGH ARGH twitter ends at a more or less normal time, because the potentially dopamine-inducing-but-mostly-not-because-disappointing items stop flooding in.

In any case, I had completely forgotten that the Northern Hemisphere (hi there everyone! enjoy your vacation! WINTER IS COMING.) is currently on vacation, whilst down South we’re all wondering if the internet is broken again.


A few mornings ago I had that wonderful guess-what’s-the-most-dangerous-animal-on-the-planet conversation with my six year old (Genetic Offspring Unit #2). It started with her explaining how afraid she was of certain insects (not all of ’em interestingly enough), at which point I, enthusiastically assisted by GOU #1 (with whom I had a similar conversation some years ago), started the guessing game with her.

It was fabulous seeing her widening eyes when, after guessing tigers, and elephants, and sharks, and whales, we guided her to the correct answer.

Perspective shift.

I did (and do) my best to contextualise as well as possible the fact that we humans are the most scary beings on the planet.


Spock, from the original Star Trek TV series which fortunately also aired in South Africa (must have been late 70s to early 80s), made a huge impact on me as a young boy, probably at role model level.

So when I saw the trailer of “For the Love of Spock”, a forthcoming documentary about Leonard Nimoy, the actor who really was Spock for almost 50 years, and who very unfortunately died in 2015, I was not able to remain completely tearless.

Live long and prosper!

Weekly Head Voices #109: GABA

  • From now on, I would like to limit WHVs to bullets (really) or to named sections, to ease reading. DOWN WITH WALLS OF TEXT!
  • After a multi-year, completely coincidental, break from medical imaging, I am back to The Real Business since the start of July. I am super excited about the plans we’re cooking up and executing. I can obviously not say too much, unless beer is involved, or you hang around here for muuuuuch longer. I think I am allowed to mention digital pathology and machine learning and beer.
  • Last week we road-tripped up the East Coast to St Francis Bay, via Oudtshoorn and the Cango Caves.
    • Pro tip: When road tripping with more than 0 (zero) children (babies count double; sick babies +5 hit points), and you have to stay overnight somewhere, invest extra in the biggest suite you (or your children’s college fund) can afford.
    • On the beach in St Francis Bay (right in the middle of winter, you still seem to get these lovely balmy beach days), it seemed that everybody was surfing. Whole families, with the mom, the dad, all the kids, and grandma and grandpa, were all on various sizes of surfboards in the sea catching some waves.
    • Here’s a photo from the furthest point on what I call “Not The Ugliest Jogging Route in The World” (in St Francis Bay):


  • Last night I accidentally discovered that I can pinpoint the exact weekend and location when and where I first tasted my favourite trappist beer (EVER), namely Rochefort #8. It’s all written up in this 2003 post.
  • When Google send me an email this weekend asking me exactly how I would like them to use my email (yes, a few months ago I migrated my mail empire back to Google because my self-hosting experiment had started to cost me time and money) to show me custom advertisements, I was reminded that I do actually find the machine learning models they’re building about me quite creepy, and that perhaps I would prefer not also handing them 12 years of emails to make their models more accurate. There and then I migrated said 12 years of emails from GMail to FastMail. So far I’m really impressed by the product, mostly due to the speed and the user experience of the web-app. There might be a more detailed post in the near future, let me know if you’re interested.
  • Most surprising and interesting (to me) new scientific discovery of the week: A team of scientists at Northeastern University in Boston have shown that one of the many kinds of bacteria living in your stomach eats exclusively GABA, a really important brain chemical (neurotransmitter) that plays a role in keeping you calm. Based on this and other work, it looks like the bacteria in your tummy, also known as your gastrointestinal microbiota, besides being crucially important to your digestive system and your general survival, probably also play quite an important role in your psyche. I find this slightly mind-blowing.

Have a great week kids, I hope to see you on the other side.

P.S. Those bullets made for quite an impressive wall of text, didn’t they?

Installing free Let’s Encrypt SSL certificates on webfaction in 3 easy steps

WARNING: High levels of NERD ahead.

I started using CloudFlare’s free tier on this blog, before Let’s Encrypt burst onto the scene, mostly for their universal SSL. However, as joepie91 recently pointed out, this means that by design, CloudFlare has to decrypt all SSL traffic, and then re-encrypt it to send it to your original site with its self-signed or generic certificate (in my case). Apart from this, CloudFlare is a bit of overkill for this low-traffic site.


Because I don’t need much of an excuse to try out something new, I used this as my excuse to try out Let’s Encrypt, a fantastic new(ish) service which issues free 90 day certificates to anyone who can verify their domains.

I was shocked with how easy this was on the webfaction shared (non root) hosting I’ve been using for years, and so I had to share.


Step 1: Install acme.sh

These two steps are to be performed whilst SSH’d in to your web host.

First we install the wonderful acme.sh by following the one-liner on its website:

curl https://get.acme.sh | sh

At this junction, as they say, it’s best to log out and in again, so that the acme.sh alias and environment variable can be setup.

Step 2: Issue shiny new SSL certificate

We then get acme.sh to verify the website using the webroot method, and to request a certificate for the two domains cpbotha.net and www.cbbotha.net:

acme.sh --issue -d cpbotha.net -d www.cpbotha.net -w ~/webapps/wp

The argument following -w is the directory exposed by the website http://cpbotha.net/. Note that this is still http; Let’s Encrypt queries a special file left there by acme.sh to confirm that you actually manage the specified domain.

After a few seconds of progress output, I was left with a shiny certificate (as well as the CSR, key, and so forth) in ~/.acme.sh/cpbotha.net/

Step 3: Install shiny new SSL certificate

On Webfaction, one has to file a support ticket for this. My request was formulated thusly, and was correctly acted upon in about 5 minutes:

Could you please install the following SSL certificate for the website cpbotha_SSL – reachable at https://cpbotha.net/:

  • cert is in /home/cpbotha/.acme.sh/cpbotha.net/cpbotha.net.cer
  • key is in /home/cpbotha/.acme.sh/cpbotha.net/cpbotha.net.key
  • intermediate CA cert is in /home/cpbotha/.acme.sh/cpbotha.net/ca.cer
  • full chain certs is there: /home/cpbotha/.acme.sh/cpbotha.net/fullchain.cer


Bonus level: In 90 – k days, simply re-run acme.sh

At any point, you can request certificates for any other domains that you may be hosting on your webfaction.

At regular intervals, or in slightly fewer than 90 days, simply run:

acme.sh --renewAll

To have acme.sh renew any of your certificates that are up for renewal. Just remember to create a new support ticket to have the renewed certificates installed for the relevant domains.

Boss level: htaccess-based redirect from HTTP to HTTPS

Now that I have my SSL setup, I would prefer for users who go to the HTTP site to be 301 forwarded to the HTTPS version. On Webfaction, I can do that with the following addition to the site .htaccess file:

<IfModule mod_rewrite.c>
RewriteEngine On
# we're behind nginx ssl proxy, hence the non-standard check for no-SSL:
RewriteCond %{HTTP:X-Forwarded-SSL} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Important: webfaction is using nginx as their SSL frontend, so we check for the X-Forwarded-SSL header.

Weekly Head Voices #108: Gaga.

I was reminded that future me really enjoys having written these things. (Present me knows about extrapolation.)

interested in time travel

Actually present me also enjoys this, but creating sufficient amounts of time to do so is often challenging. I have most recently convinced myself that I should see this as practice so that I will later be able to write really entertaining posts in minimal time. Until then my two readers, I hope to compensate with edification.

Genetic Offspring Unit (GOU) #3, the rapidly glowing cellular mega-city that first made contact with extra-wombular (I made that up) light slightly more than three months ago, suddenly started babbling a few weeks ago. To be honest, I thought that she was going to be really quiet to compensate for the immense amount of continuous talking in my house. It turns out that her reaction has instead been one of taking this bull by the horns. SHE WILL BE HEARD. (GOU#1 and #2 are able to produce speech with an intensity that is to be heard to be believed. I have no idea where they got that from.)

Speaking of babbling, I sometimes make videos of me trying to explain nerdy programming-related tricks, and then I upload them to YouTube. My most recent creation is about using the conan.io C++ package manager to get a small SFML-based GLSL example going (that’s GPU programming). It has a soundless explosion at the end!

I came across a really interesting bit of research performed at the Vienna University of Economics and Business (WU) on how really small, seemingly inconsequential rewards, can actually ignite people’s intrinsic motivation. This is interesting exactly because it has long been thought that extrinsic rewards diminish intrinsic motivation, a phenomenon called the overjustification effect.

In the recent study by researchers at the WU, students were encouraged to do extra homework assignments. However, this was done by allocating an amount of extra credit which was perceived by the students as being trivial (this was measured in a separate study). Lo and behold, this perceived trivial extra credit still jump-started that group’s extra assignment submissions, and the students in that group then showed evidence of autonomously (intrinsically) motivated behaviour.

The researchers hypothesise that this could be due to the fact that the students being jump-started could not internally explain their behaviour on the basis of the negligible reward, and hence automatically came up with more intrinsically-oriented motivations, such as personal importance, interest or enjoyment).

South Africa is a really strange and wonderful place. I don’t write about it that much, because in that respect it is my place to be quiet here in the background. However, sometimes someone else writes something that, if you’re interested in the perspective of South Africans who’ve lived abroad for a significant amount of time, and have then returned, somewhat the wiser, because the country in their blood called them back, you really should read. Disco Pants, or rather her blog, helped me a whole lot when we had to decide whether we would be coming back or not. She has a new post out titled “On Surviving the Madness of South Africa”, and it’s a beaut.

On the topic of beauty, Flume has new album out. It’s called Skin, and it gets the highly coveted but completely unknown Weekly Head Voices Album of Right Now award! Here’s the first track to whet your appetite (or not):

Have a fun week listeners!

Weekly Head Voices #107: Balance.


That’s how the African sun sets in Mpumalanga.


… and this is more or less what it looks like when a cheetah decides to grace you with its presence. We had it all to ourselves (this is quite unusual in the Kruger National Park with an animal of this level of celebrity) and were able to follow it until it wandered further away from the road, probably on the lookout for some dinner.

It was a brilliant week-long getaway with the newest little member of the family. The time is just long enough to allow for a complete switch-off (see the “you are turning into a cyborg” section of one of the previous KNP posts) with the balmy weather and the wild animal tracking just adding to the fun.

On the nerd front, I convinced my employer to get me a new Microsoft Sculpt Ergonomic desktop. As I spend 8 hours or more monkey-typing on some sort of keyboard every day, having one that works well is quite important. I might have found a new favourite in the Sculpt Ergonomic. It looks like this:


It’s probably the most strangely shaped keyboard I have ever worked on, but it has grown on me quite quickly. The strange shape helps keep my arms and wrists in an even better posture than with the Comfort Curve 3000 (my previous favourite), and the chiclet keys combine just the right amounts of finger travel economy and tactile feedback in my opinion. My only gripe is that the escape key, which as Emacs user I quite often use, is smaller than the other keys and has a completely different feel.

(An extremely brief final aside on the nerd front: I briefly tried Evernote again as my current note-taking strategy does not support a good web-clipper, and my all-singing all-dancing non-linear knowledge management prototype, now in its seventh complete rewrite, is not ready yet. They’ve updated the Evernote look, but even with 5 or 6 clipped web pages in total in my database, I had trouble getting the android app to sync up with the web version.)

During my compulsive daily RSS feed / twitter / Google+ reading, I came across this interesting summary of recent research on changes in the aging brain. It’s the type of article that interests one especially when one is in possession of such an aging brain, and perhaps also when it reflects one’s own experiences, all completely hypothetically of course.

In any case, in yet another one of those examples of youth being wasted on the young it’s long been known that your brain is at its maximum processing capacity and speed during one’s early twenties. In my early twenties, the last thing I was thinking about was my mental performance peaking. It’s a sobering counterpoint that my brain’s processing speed has been steadily declining since my late twenties.

As a sort of a consolation prize, it is starting to look like our brains, when we succeed in keeping them healthy, develop more balanced patterns of activity as we get older. We work smarter rather than harder, unlike those twenty year olds who refuse to get off my lawn.

The article mentions the hypothesis that there might be something that could be called the neuro-circuitry of wisdom, consisting of the dorsolateral prefrontal cortex (responsible for rationality, discipline, and self-preservation), the ventromedial prefrontal cortex (associated with “kind, supportive, social, and emotional behavior needed for survival of species”), the anterior cingulate (which mediates conflicts between parts of the prefrontal cortex), and the striatum with amygdala (part of the reward circuitry) . With age, brain activity between all of these regions reaches a sort of balance, leading to the owner of said brain demonstrating feats of wisdom which will probably be witnessed by exactly no-one, almost like trees falling in the forest, or almost like the posts on this blog, minus the wisdom.

Here’s to hoping that, as we all near our inevitable final sunsets, we do in fact become ever so slightly wiser, and ever so slightly more capable of contributing peace and kindness to our surroundings; even, or perhaps especially, when no-one is watching.

(I just reminded me of Reggie Watts… see below.)