Skip to main content


Showing posts from 2020

All the symmetrical watch faces (and code to generate them)

If you ever look at pictures of clocks and watches in advertising they are set to roughly 10:10 which is meant to be the most attractive (smiling!) position for the hands . They are actually set to 10:09.14 if the hands are truly symmetrical. CC BY 2.0 image by Shinji I wanted to know what all the possible symmetrical watch faces are and so I wrote some code using Processing. Here's the output (there's one watch face missing, 00:00 or 12:00, because it's very boring): The key to writing this is to figure out the relationship between the hour and minute hands when the watch face is symmetrical. In an hour the minute hand moves through 360° and the hour hand moves through 30° (12 hours are shown on the watch face and 360/12 = 30). The core loop inside the program is this:   for (int h = 0; h <= 12; h++) {     float m = (360-30*float(h))*2/13;     int s = round(60*(m-floor(m)));     int col = h%6;     int row = floor(h/6);     draw_clock((r+f)*(2*col+1), (r+f)*(row*2+1),

The difference between parentheses and curly braces in GNU Make

One of the problems/perks of having written a book about GNU Make is that people ping me with questions. This morning someone said to me: " Especially curly braces vs parentheses is something that always confuses me ". As always the first port of call with GNU Make questions should be the FSF's manual . It says the following: " To substitute a variable’s value, write a dollar sign followed by the name of the variable in parentheses or braces: either $(foo)  or ${foo}  is a valid reference to the variable foo . " And that seems to work well: $ cat Makefile foo := $(info $(foo)) $(info ${foo}) $(info $(foo:world=everyone)) $(info ${foo:world=everyone}) $(info $(foo:hello.%=good morning.%)) $(info ${foo:hello.%=good morning.%}) $ make hello.everyone hello.everyone good good make: *** No targets.  Stop. You can see that simple variable references work, as do substitutions (where I changed world to ever