~/devreads

#useless trivia

10 posts

21 Aug 2017

Dave Cheney 2 min read

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 […]

historyuseless trivia

5 Jun 2015

Dave Cheney 3 min read

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 […]

goprogramminguseless trivia

11 Dec 2014

Dave Cheney 1 min read

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 […]

goprogramminguseless trivia

5 Dec 2014

Dave Cheney 1 min read

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 […]

gouseless trivia

Dave Cheney 1 min read

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 […]

gouseless trivia

28 Jun 2014

Dave Cheney 1 min read

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) […]

useless trivia

24 May 2014

Dave Cheney 1 min read

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 […]

goprogramminguseless triviatop tip

4 Dec 2013

Dave Cheney 1 min read

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 […]

small ideasuseless trivia

15 Nov 2013

Dave Cheney 1 min read

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 } […]

goprogramminguseless trivia

13 Nov 2013

Dave Cheney 1 min read

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 […]

goprogramminguseless trivia