The Lear Siegler ADM-3A terminal is a very important artefact in computing history. If you want to know why your shell abbreviates $HOME to ~, it’s because of the label on the ~ key on the ADM-3A. If you want to know why hjkl are the de facto cursor keys in vi, look at the symbols above the […]
#useless trivia
10 posts
21 Aug 2017
5 Jun 2015
bytes.Buffer is a tremendously useful type, but it’s a bit large1. % sizeof -p bytes Buffer Buffer 112 … and that is just the overhead, we haven’t put any data into the buffer yet. This Friday’s2 challenge is to write a replacement for bytes.Buffer that implements io.ReadWriter and allows the caller to discover the length and capacity of the […]
11 Dec 2014
In this program, the size of variables of type x and y in memory varies by platform. package main func main() { const n = 4 type x [n]uint type y [n]int } By changing only one line can you ensure that variables of type x, and y always consume 16 bytes on all platforms […]
5 Dec 2014
It’s a little unfair to announce winners in some kind of order as I did post the quiz at an unfriendly hour of the day for most of the planet. With that said, Tim and William came up with a great map based solution at roughly the same time. You’ll have to split the winnings […]
This program is incorrect package main import "fmt" func f(a, b int) { var min = 0 fmt.Printf("The min of %d and %d is %d\n", a, b, min) } func main() { f(9000, 314) } By adding only one line can you make it print the correct answer ? The code must continue to be […]
28 Jun 2014
Like all children who grew up in the 80’s, I was, and still am a huge fan of Ghostbusters. While recently re watching Ivan Reitman’s homage to New York, I spotted something which has gone unnoticed on the IMDB trivia page. Shortly after being evicted from the University, Ray Stantz (Aykroyd) and Peter Venkman (Murray) […]
24 May 2014
Go has several ways to declare a variable. Possibly there are more ways than are strictly required but with the Go 1 contract in effect it’s not going to change. This short post gives examples of how I decide which variable declaration syntax to use. These are just suggestions, they make sense to me, but […]
4 Dec 2013
There is an apocryphal story1 during World War Two, of a squadron of bombers leaving on a sortie. Time passes and finally a few bombers struggle back to their base, the crew shaken, but alive, their aircraft riddled with bullet holes. Shocked by their losses, the reaction by Air Force was to order the areas of the […]
15 Nov 2013
At Canonical we’re increasingly invested in gccgo. While testing various packages built with gccgo we ran across test failures which we traced to an innocent looking piece of code. package main import "fmt" type T struct { i int } func (t *T) readInt32() int32 { t.i += 4 return 42 // not important } […]
13 Nov 2013
This is a brief post highlighting a curious aspect of the declaration syntax in Go. Most Go programmers know that the following of import declarations are equivalent import "fmt" import "math/big" // same as import ( "fmt" "math/big" ) The same applies to const declarations const FORTYTWO = 42 const TRUE = 1 // same […]