# C[omp]ute

Welcome to my blog, which was once a mailing list of the same name and is still generated by mail. Please reply via the "comment" links.

Always interested in offers/projects/new ideas. Eclectic experience in fields like: numerical computing; Python web; Java enterprise; functional languages; GPGPU; SQL databases; etc. Based in Santiago, Chile; telecommute worldwide. CV; email.

© 2006-2015 Andrew Cooke (site) / post authors (content).

## [News] 2019: The year revolt went global

From: andrew cooke <andrew@...>

Date: Thu, 12 Dec 2019 19:29:26 -0300

https://thefifthwave.wordpress.com/2019/12/10/2019-the-year-revolt-went-global/

https://www.bloomberg.com/opinion/articles/2019-10-21/protesters-worldwide-are-united-by-something-other-than-politics

Andrew

## Previous Entries

### [Politics] The world's most-surveilled cities

From: andrew cooke <andrew@...>

Date: Thu, 19 Sep 2019 17:23:23 -0300

https://www.comparitech.com/vpn-privacy/the-worlds-most-surveilled-cities

Andrew

### [Bike] Hope Freehub

From: andrew cooke <andrew@...>

Date: Sat, 31 Aug 2019 21:54:18 -0400

Some notes on the Hope specific freehub and related cassettes.  In
general, more force is needed than you might expect when manhandling
these things.

* The two-piece cassette is difficult to separate.  It helps to cool
the entire cassette (since aluminium has a higher thermal expansion
coeff than steel) and then lever them apart with something wooden.

* Putting them back together is similarly fraught.  The spot on the
aluminium spider aligns with the biggest gap in the internal
'teeth' of the steel part.  Aligned correctly you can see all teeth
should be OK (any other alignment and some teeth are 'blocked').
With that, place the alloy side down on a flat wooden surface and
then lean on the steel part (I used some stiff gloves to protect my
hand and a fair amount of weight).

* Removing end-caps on the front hub is easily done by pushing them
out with a pencil from the other side.

* Removing the existing freehub was possibly by clamping it in a
wooden vice and pulling the hub upwards.

* The replacement freehub goes on easily enough - you need to push
the pawls into place - but the green seal again needs a fair amount
of force from a wooden implement before it clicks inside.

* The funny looking endcap is QR; the shorter normal endcap is
12x135; the longer 12x142.

And hope are responsive (if not overly effusive) to enquiries at the

Andrew

### [Restaurant] Mama Chau's (Chinese, Providencia)

From: andrew cooke <andrew@...>

Date: Sat, 31 Aug 2019 21:10:22 -0400

https://www.instagram.com/mamachaus/

Really excellent food.  A refreshing change.

We went here Friday evening, a belated celebration of Paulina's
birthday.  Fairly early, because they close some time around 8pm.
Paulina ordered a selection of dumplings and a bao (stuffed steamed
bread); I ordered a crepe.  Sharing, so that we sampled as much as
possible, there was more than enough for us both.  Relatively healthy
food with plenty of taste that was still solid enough to leave you
contentedly full.

It has a very small eating area, but also does take-aways.  Everyone
else appeared to be half our age.  It was very popular, perhaps
because of this recent review -
http://finde.latercera.com/comer/mama-chaus-chino-providencia/ - or
perhaps because it's damn good.

Service is minimal - you order and receive a pinger.  When the pinger
pings you go collect your tray of food.  There's a fair amount of
packaging, but it's mainly paper-based.

Andrew

### [Politics] Brexit Podcast

From: andrew cooke <andrew@...>

Date: Sat, 31 Aug 2019 21:01:55 -0400

Not dumb.

https://fivethirtyeight.com/features/politics-podcast-is-britain-in-the-middle-of-a-constitutional-crisis/?ex_cid=trump-approval

Andrew

### [Diary] Pneumonia

From: andrew cooke <andrew@...>

Date: Fri, 30 Aug 2019 11:25:00 -0400

I want to make some notes (similar to those on the bike accident) to
help remember the sequence of recent events related to me being
hospitalized for pneumonia.

On Thu Aug 1 we flew to Edinburgh.  The day before (or two days
before?)  Paulina's brother had stayed in our flat, apparently quite
ill, coughing and vomiting.

In Edinburgh we were in good condition, walking a fair amount (I was /
am still recovering from the broken leg and ensuing problems).

On Tue Aug 6 my sister drove me down to my parents (Paulina stayed in
Edinburgh at a conference).  In the car I was coughing a lot.

On Fri Aug 9 I went to meet Paulina at the local train station and
wasn't feeling so good.

The plan was to take the family (including sister) to dinner on Sunday
evening.  I spent most of Sunday in bed, hoping I would be well enough
for the meal to go ahead; in the later afternoon I had a temperature
and we cancelled.

The next few days I thought I had the flu - intermittent temperature,
shivers, coughing, etc.  At one point I noticed that I was coughing up
phlegm that contained some blood.

On Tue Aug 13 the rest of the family insisted I go see a local doctor.
The doctor sent me directly to the local hospital, where I stayed for
two nights.  Initially there was concern I had TB (so I had a
'private' room), but test showed pneumonia (strep).  I was on a drip
for hydration (maybe 24 hours) antibiotics (48 hours).

I had been taking Ibuprofen-based flu medication to help with MS
symptoms, but apparently this raised the chance of Kidney problems so
I was switched to Paracetamol.

On Thu Aug 15 I was released with oral antibiotics (2 kinds, 6 days).

On Fri Aug 16 Paulina flew to Chile.  On the main flight (LHR - GRU)
she had a fever and was placed on a drip in the airport clinic at Sao
Paulo, but later flew on to Santiago.  She saw a local doctor on
Sunday, was diagnosed with pneumonia, and was prescribed antibiotics.

One motivation for Paulina returning (apart from work which was the
original reason for the early flight) was that her brother had
disappeared.  He was later found in a hospital in the South of Chile.
I do not know what his diagnosis was.

Meantime (sorry, don't have exact dates) my parents were also
diagnosed with bronchitis and given antibiotics.  My sister was OK.

I was intending to fly back on Mon Aug 19, but the local doctor felt
until that date.  After some discussion with my doctors in Chile we
decided to delay the flight a week and skip the Betaferon (the risk of
an MS outbreak was low and the drug is not commonly available in the
UK).

I increased the spacing of my final two injections, so the final
injection history was:

August 2019
Mo Tu We Th Fr Sa Su
-  2  -  4
-  6  -  8  - 10  -
12  - 14  -  - 17  -
- 20  -  -  -  -  -
- 27  - 29  - 31

I flew back on the 26th, arriving 27th (injection on arrival).

Currently we are all easily tired, with coughs, but otherwise OK.

Andrew

### [Politics] Britain's Reichstag Fire moment

From: andrew cooke <andrew@...>

Date: Fri, 30 Aug 2019 11:21:39 -0400

https://www.prospectmagazine.co.uk/magazine/britain-proroguing-boris-johnson-parliament-suspension-richard-evans-weimar

Andrew

### [Programming] GCC Sanitizer Flags

From: andrew cooke <andrew@...>

Date: Thu, 16 May 2019 15:35:19 -0400

https://lemire.me/blog/2016/04/20/no-more-leaks-with-sanitize-flags-in-gcc-and-clang/

Andrew

### [GPU, Programming] Per-Thread Program Counters

From: andrew cooke <andrew@...>

Date: Mon, 8 Apr 2019 19:37:14 -0400

https://medium.com/@farkhor/per-thread-program-counters-a-tale-of-two-registers-f2061949baf2

Andrew

### My Bike Accident - Looking Back One Year

From: andrew cooke <andrew@...>

Date: Mon, 11 Mar 2019 09:39:13 -0300

One year ago today, Sunday 11 March 2018, just after breakfast, I was
looking for my favorite cycling shirt, getting ready to ride a route I
hoped to share later in the week with a friend.

That is all I remember.

https://www.strava.com/activities/1458282810/overview

Then, in a warm haze, I am thinking "this could be serious;" "maybe I
should pay attention;" "focus."  Sometime around Tuesday or Wednesday,
in Intermediate Care at Clinica Alemana, with nurses and beeping
machines, and Paulina explaining to me (patiently, every hour or so
for the last few days - I had been "conscious but absent" since Monday
morning) that a car had hit me; that I had been injured and operated
my leg; that I was now OK.

- Fractured right clavicle (collarbone)
- Exposed, fractured left femur (thigh)
- Fractured metatarsal (hand)
- Fractured right ribs (3rd, 4th, and 5th)

I was in hospital for 7 days.  The last few in normal care.  Final day
I asked to have a shower.  When I saw blood running with the water I
fainted.

The ambulance that took me home had the same crew that had taken me
in.  I asked how I had been - the EMT said "in some pain."

Final cost $17.894.596 (CLP - around$30k USD).

Home, Paulina had the bed raised, an extra seat on the toilet, a seat
in the shower, a wheelchair.  I remember my first shower - it was a
huge effort to lift my foot over the (4 inch) shower wall, and I
collapsed, twitching, on the seat.

I was high as a kite - even back home - on opioids for a couple of
weeks.

My recovery was slow but steady.  A physiotherapist came to visit and
taught me some exercises.  After a month or two I was walking with
crutches.

Paulina was exhausted from caring for me while still trying to work.
For a while we had someone visit, a few times a week, to clean and
prepare some food.

On Sundays many roads here are closed to cars, given over to cyclists,
runners, inline skaters.  A week after my accident a friend returned
to the intersection.  He found a witness, someone who flagged when
traffic could or could not pass through the ciclovia, who said I was
hit by a pickup that had run a red light.

I later learned that the driver stopped (to his credit).  Someone
called the police and an ambulance.  I was on the ground, dazed,
trying to stand but unable.  The police asked me where I lived -
apparently I replied "Europa," which is the name of our street, but
also, literally, "Europe."  So they assumed I was a tourist - a
wealthy gringo with travel insurance - and sent me to the best
hospital in town.

An investigation was opened by the police.  My medical records include
a blood test showing no alcohol.  We informed the investigating
magistrate of the witness but later, when called to the police station
to give evidence, they had not received the information.  We gave it
again.  By the time it was investigated video records from street

After the accident my bike was in a police compound; Paulina collected
it and I started repairs.  The front wheel was tacoed, so I bought a
new rim (which Paulina collected - I am so grateful for all the
legwork she has done over the last year) and spokes, and laced it to
the old hub.

Mounting the new wheel on the bike, I realized that the thru-axle was
bent, so I ordered a new axle.  When I received the axle I realized
the hub itself was bent, so I ordered a new hub.  Given how Shimano
thru-axle hubs work, I only needed to replace the inner sleeve (so I
didn't need to rebuild the entire wheel).

Mounting the new wheel again, I realized that the fork was bent, so I
ordered a new fork.  This was delivered to the UK, because mid August
I felt good enough to travel home and see my parents.

I also replaced the handlebars, although the (slight) damage there was
caused by me over-tightening the brakes, not the accident.  In
addition I had to replace the rear light (stolen while in police
custody) and my helmet.

The weekend of September 8/9 I was feeling good enough to travel with
Paulina to La Serena.  We wanted to check on my old flat, where a
friend had been living rent-free, to make sure it was OK for Paulina's
father to move there.

The flat was a mess.  So bad we did not sleep there, but instead
walked into town and stayed at a hotel.  The next day we returned, to
continue cleaning.  By the end of the weekend the place wasn't too
bad, but my leg was painful.

That was the high point of my recovery.

Post operation, my thighs were asymmetric - on the left hand side was
a "bulge" which, clearly visible in the X-rays, enclosed the end of
the rod that held my femur together.  The rod was "too long."  It
appeared to be "rubbing" on the inside of the leg, placing a limit on
how far I could walk.  As it became more inflamed, I could walk less
distance.  The upper limit was around 3,000 steps a day (a few km).

The day after returning from La Serena (Sept 10) I asked the doctor
what could be done.  The answer was: nothing, until the bone had
healed, which takes a year.

On September 11 I attended court.  The police claimed that the driver
had illegally run a red light.  Chilean law is different to UK law -
for a "light" infraction like this (running a red light and not
killing me) the emphasis is on compensating the victim.  In general
terms, either we agree some kind of compensation, or the driver is
prosecuted.  The driver has to balance the amount of compensation
against the inconvenience of being prosecuted, the likelihood of being
convicted, and the possibility of any sanction.

To start negotiations over compensation we needed to know the amount
outstanding after (the driver's) accident and (my) medical insurance,
but we still had not been billed by the hospital.

So the case was postponed and we returned home to chase up the
paperwork.  Once we had the bill Paulina took it to the driver's
insurers, who agreed to pay $5.854.407. Then she went to my medical insurance, who eventually (December 21) agreed to pay$8.327.938,
leaving a balance of $3.712.251. And this is where we stand. The case appears to be stalled pending further police investigation. Since it was difficult to walk I tried cycling again. This was clearly better for my health, and I could manage around 20 minutes without hurting my leg too much. But, perhaps related to this exercise, a new problem surfaced. The rod appeared to get "caught" on something (tendon? muscle?). This hurt, I froze and slowly wiggled my leg to "undo" the blockage. Afraid to walk, I hobbled slowly round the house. Despite my reduced movements this repeated, more severely. Frustrated, and now nearly a year after my operation (February 18, 2019), I returned to the doctor. He was, I think, surprised. The next day I received a call from the hospital - someone had canceled an operation, there was a free slot Fri February 22. I agreed immediately. The operation to remove the rod went smoothly. I entered theater late in the day and was kept for observation overnight. The leg had two dressings - one near the knee (incisions to remove screws) and another on the upper thigh (more screws and the rod itself). These were the usual clear plastic sheets, with external padding for protection, to be left in place as the wound heals. Thursday, February 28, I was feeling good enough to be sat at the computer, working, when I felt a drop of liquid hit my leg. Removing the padding, visible through the dressing, were blisters. One had burst. Back at the hospital, the dressings were removed, the skin wiped clean. I was sent back home with basic antibiotics and anti-histamines. Life with exposed wounds and stitches is boring and uncomfortable (although the anti-histamines meant I slept much of the time). The stitches catch clothing and the wound has to be kept clean and open to the air, so you're either lying in bed or wandering cold and naked through the house. It was uncomfortable to be seated for any length of time, making work difficult (credit to my employers for their support). Monday March 4 I returned to hospital. Although I felt things were improving (no blood / pus stains on the bedsheets on the last night, for example) it still didn't look good (quite frankly, it looked terrifying - red, yellow and blistered - but it was not painful and did not smell). A nurse (a nice nurse - senior and smart and friendly) thought it looked more like an infection than an allergy, and the doctor agreed, changing the antibiotic to something more specific. The next few days, although still boring and uncomfortable, showed real improvement. On Wednesday March 6 my stitches were removed. Since then, the skin has continued to heal. Importantly, the pain from the rod - at least the worst, when it got "hooked" around tendons - has gone. There is still some pain when walking, but it is difficult to know if it the old soreness, or associated with the bruising from the operation. A year after the accident, I still do not know if I will be able to walk, or cycle, as before. Andrew ### [Python] Geographic heights are incredibly easy! From: andrew cooke <andrew@...> Date: Sun, 13 Jan 2019 20:47:20 -0300 Wanted to add heights to bike rides in Choochoo, given the GPS coordinates. At first I considered stealing the data from Strava, but their T&C don't like it and anyway I couldn't find it in the API. Then I considered Google's Elevation Service, but it's$5 for 1,000
values.  Then I considered the free OpenStreetMap equivalent, but that
seemed to be broken.  Then I realised it's pretty damn easy to do by
hand!

Turns out that the Space Shuttle scanned the entire Earth (except the
Poles) at a resolution of one arcsecond (about 30m on the equator) and
the data have been publicly released.

The project is called SRTM, and the 30m data are "v3" or SRTM3.  More
info at https://wiki.openstreetmap.org/wiki/SRTM and

http://dwtkns.com/srtm30m/ and there's an excellent (although buggy)
blog post on how to parse the data at
code at https://github.com/aatishnn/srtm-python

Because the coords are in the file name there's no need for any kind
of RTree or similar index - you just take your coords and infer what
stick it in an array, and return the array value!

My own code to do this is at
https://github.com/andrewcooke/choochoo/blob/master/ch2/sortem/__init__.py
and includes bilinear interpolation (you could cut+paste that code
except for the constructor which is specific to Choochoo - just replace
the messing around w Constant with a literal directory string).

The tests are at
https://github.com/andrewcooke/choochoo/blob/master/tests/test_sortem.py
and from the contours there, which are plotted across 4 tiles, it's
pretty clear that the interpolation is seamless.

So easy!  I thought this would take a week of work and I did it all
this afternoon....

Andrew

From: andrew cooke <andrew@...>

Date: Tue, 25 Dec 2018 17:30:46 -0300

125g butter
1 egg
60g sugar (or more?)
45g cocoa
130g flour (w raising powder)
120g chocolate

Mix butter, egg and sugar.  Sieve in and mix cocoa and flour.  Add a
little water if necessary - want a thick, sticky mix, as solid as
possible, but not powder.

Break the chocolate into pieces and add.

Cool in fridge.  Pre-heat oven to 180C.

Place blobs of dough on lightly greased baking paper on tray.  Cook
for 15m.  Should flatten but not spread much.

Not very sweet, except for the chocolate.  Very cocoay and good
texture.  Good w ice-cream?

Variations: more sugar?  vanilla?

Andrew