Andrew Cooke | Contents | RSS | Previous


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).

[Bike] Gearing On The Back Of An Envelope

From: andrew cooke <andrew@...>

Date: Mon, 4 Oct 2021 21:28:20 -0300


If you + bike weigh 100kg and you can put out a steady 100W then you can
ascend vertically at 0.1m/s (work against gravity if g=10m/s^2).

On a 10% incline (steep, but possible where I ride in the Andes foothills)
that means you can move forwards at 1m/s.

The circumference of a 700C wheel is about 2m and the slowest comfortable
cadence while seated is around 60rpm.  So with 1:1 gearing that's 2m/s.

So you need 1:2 gearing for the climb.

That kind of gearing is pushing the low end of available MTB gears.  In other
words, pretty much no-one has gearing that low.  Pretty much all entry-level
riders would have real problems climbing a 10% grade for any distance.


Air resistance increases as v^3.  That has a sharp "bend" - either it's not
important or it's a brick wall.  So basically everyone (whatever their power
output) is limited to a similar top speed.  From experience it's roughly

Faster / steeper than that you need to get seriously aero and pedalling
efficiently isn't really an option.

You can probably manage 100rpm if you have to, in your top gear, all out.
With a 2m circumference wheel that's 200m/min.

60km/h is 1km/min.  So you need 5:1 gearing for the descent (to go from
200m/min to 1,000 m/min).

This is consistent with the top end of traditional "race" gearing (maybe 53
teeth at the front and 11 at the rear).

Gear Range

The above implies a gear range from 1:2 to 5:1.  That's a factor of 10, or

In practice, pro riders can put out around 4x the power / weight used above.
Compared to inexperienced riders they are absolute monsters.  That shifts the
lower gears needed up by a factor of 4.  So instead of a 1,000% range they
need a 250% range, which is well within typical "race bike" gearing.

Non-pro riders (and people with loaded touring bikes) that have the technical
understanding compromise at both ends.  At the top, 4:1 is generally enough,
and at the bottom they can live with maybe 1:1.5.  That gives a 600% range
which is possile with a Rohloff IG hub, or a frankenstien mix of road and MTB
components (as on my own road bike).

Currently fashionable 1x road / gravel can reach maybe 500% range.  Exactly
where that is "centred" depends on the front ring - there will likely be
significant compromise at both the high and low ends.


Permalink | Comment on this post

Previous Entries

For comments, see relevant pages (permalinks).

[Computing] Okular and Postscript in OpenSuse

From: andrew cooke <andrew@...>

Date: Thu, 9 Sep 2021 10:13:20 -0300

Wow.  PS is so old-fashioned now that support in okular is in a separate
package (okular-spectre) that is not installed by default.



[Computing] Fail2Ban on OpenSuse Leap 15.3 (NFTables)

From: andrew cooke <andrew@...>

Date: Fri, 30 Jul 2021 09:58:50 -0400

Couldn't find this documented anywhere, but it works just fine.

  localhost:/etc/fail2ban # cat jail.local

  bantime = 1h
  maxretry = 3

  enabled = true
  backend = systemd
  banaction = nftables

  localhost:/etc/fail2ban # cat fail2ban.local

  loglevel = INFO

Typical log output:

  localhost:/var/log # tail fail2ban.log
  2021-07-30 08:19:02,184 fail2ban.filter         [16653]: INFO    [sshd] Found - 2021-07-30 08:19:01
  2021-07-30 08:19:02,249 fail2ban.actions        [16653]: NOTICE  [sshd] Ban
  2021-07-30 08:28:00,927 fail2ban.actions        [16653]: NOTICE  [sshd] Unban
  2021-07-30 09:05:49,815 fail2ban.actions        [16653]: NOTICE  [sshd] Unban
  2021-07-30 09:19:02,048 fail2ban.actions        [16653]: NOTICE  [sshd] Unban
  2021-07-30 09:23:52,935 fail2ban.filter         [16653]: INFO    [sshd] Found - 2021-07-30 09:23:52
  2021-07-30 09:23:54,934 fail2ban.filter         [16653]: INFO    [sshd] Found - 2021-07-30 09:23:54
  2021-07-30 09:24:52,933 fail2ban.filter         [16653]: INFO    [sshd] Found - 2021-07-30 09:24:52
  2021-07-30 09:24:53,125 fail2ban.actions        [16653]: NOTICE  [sshd] Ban
  2021-07-30 09:24:54,434 fail2ban.filter         [16653]: INFO    [sshd] Found - 2021-07-30 09:24:54

All under systemd control.



[Cycling, Computing] Power Calculation and Brakes

From: andrew cooke <andrew@...>

Date: Sat, 24 Apr 2021 16:20:34 -0400

It's common (eg Strava) to estimate a cyclist's power output from their GPS
and elevation (barometric) data.

The basic idea is fairly simple: we can calculate the power required for the
bicycle to behave as recorded at each point in time using mass / gravity /
height, CdA / speed, and rolling resistance / speed.

This ignores wind, which makes the effective speed for wind resistance (CdA)
different from the measured speed, and so introduces errors.

Also ignored, but not commonly discussed, is braking.

If the cyclist does not use the brakes then all we have discussed so far is

If the cyclist brakes *and* pedals then we will underestimate their power
output because they are expending additional energy we do not "see" in the
data (assuming that there is no power meter data).

If the cyclist brakes when not pedalling then we *should* (if we have
sufficient resolution, perfect parameters, etc) see a negative input power.

In practice, when you estimate power, you do see negative spikes.  I had
assumed that these were noise, but the above suggests that it is also
reasonable to interpret them as braking.

In conclusion, then, braking may be visible in the output from modelling and
is not inherently a source of uncertainty *unless* the cyclist brakes when
also pedalling.  That exception is more likely than it sounds since "when
also" does not, in practice, mean (only) concurrently, but also at any time
within the "time step" used in the calculation (eg 10s).



[Hardware, Computing] Amazing Pockit Computer

From: andrew cooke <andrew@...>

Date: Thu, 18 Mar 2021 21:02:15 -0300

I am not sure I really believe this is real.

Watch the top video in the timeline.




From: andrew cooke <andrew@...>

Date: Thu, 18 Mar 2021 04:59:59 -0300

I was buliied recently.  I am a 53 year old, white, male, successful
professional.  It was a bit weird.

I don't want to give details, because they would identify the people involved,
which would be complicated socially.  But I was harassed by email over a
couple of weeks by two people, who also contacted my partner, Paulina.

At first it just seemed like odd behaviour, but when I asked them to stop, and
they did not, I recognised the similarities with episodes in childhood.  Like
then I was confused but resistant (so you might call it an attempt at
bullying, rather than the real thing, because I never felt intimidated).  Like
then, the people involved were - I think (I can find no other explanation) -
resentful that I have a better life than they do.

There's really no word other than weird.  It was damn weird.

They apologised later and we haven't communicated since.



How I Am - 3 Years Post Accident, 8+ Years With MS

From: andrew cooke <andrew@...>

Date: Fri, 26 Feb 2021 21:28:47 -0300


My back was fixed by yoga and a harder mattress.  The legs (no idea what was
wrong with the right) have now healed enough that I am generally able to sleep
on my side (although not always after exercise - sometimes it is more
comfortable to switch to the softer sofa).  There can be some discomfort (not
pain) on the sides of the legs when walking and the tendon at the back of my
left leg (which interfered with the rod, I think) can get a little sore.

Recovering fitness post-accident has taken longer than expected.  Covid didn't
help - there was a time when we were allowed out for just a few hours twice a
week (time spent shopping, mainly).  I am now, almost three years on, capable
of climbing to Yerba Loca, but not to Farellones.  My power and endurance are
still not as they were - I suspect it will be another 6 months work.  On the
other hand, Yoga on days off the bike seems to have improved my core.

MS has been pretty steady for years.  In fact, a few months ago I was feeling
like I had 6 months almost symptom-free.  Unfortunately that ended with
intermittent "white noise" in my right leg, the muscle above the knee.  This
has been coming and going a month or more now - it is disturbing, but seems to
have no effect on strength or balance.

In a few weeks I may be due for the Covid vaccine.  This will likely be
Sinovac and my doctor is a little worried (something to do with the underlying
carrier and my borked immune system, not the Covid part).  We will see what

We've spent, what, maybe a year pretty much isolated.  Paulina is working from
home.  We go out only to buy supplies or exercise.

Hello to future self.  Good luck.



[USA Politics] In America's Uncivil War Republicans Are The Aggressors

From: andrew cooke <andrew@...>

Date: Mon, 8 Feb 2021 16:48:13 -0300

An important article from Perry Bacon Jr.



[Programming] Selenium and Python

From: andrew cooke <andrew@...>

Date: Sun, 24 Jan 2021 09:14:51 -0300

I am testing user registration (including email confirmation) and it's this

    def test_registration_flow(self):

        with self.record_error():


            with self.smtpd():

            match = re.compile(r'(http[:/a-zA-Z0-9\-_]+)', re.MULTILINE).search(

            self.assertTrue('Your email has been confirmed.' in self.driver.page_source)
            self.assertTrue('You have signed in successfully.' in self.driver.page_source)

            with self.app_context():
                users = User.query.all()
                self.assertEqual(1, len(users))
                user = users[0]
                self.assertEqual('andrew', user.username)
                self.assertEqual(, user.email_confirmed_at)
                self.assertTrue(len(user.password) > 20)

Obvs there's some infrastructure in there (smtpd, etc), but I still find it
amazing that a browser starts, email is sent, and the user is registered.

Also, if an error occurs, I leave the database on disk and the browser open,
to make debugging easier.



[Bike] How Fast Before Walking More Efficient Than Cycling?

From: andrew cooke <andrew@...>

Date: Thu, 21 Jan 2021 22:52:02 -0300

Cycling is generally more efficient, per km travelled, than walking.  However,
someone just pointed out to me that if you go fast enough this is not the case
(since losses to air resistance increase rapidly with velocity).

So what velocities are we talking about?

A typical walking speed is 3.5 mph.  That's roughly 1.5 m/s.  Looking at that correponds to roughly
300 W.

So walking burns 300 / 1.5 J/m = 200 J/m.

Now let's consider cycling.  A typical CdA on a road bike is 0.3.  Force is
CdA x p x v^2 where p is air density (1.2kg/m^3).  So F = 0.36 v^2 N.  The
energy required to travel 1m is then 0.36 v^2 J (force x distance).  Setting
this equal to 200 (above) we can find the break-even velocity: 200 = 0.36 v^2
so v = 23 m/s (50 mph).

I may have made a mistake, but that ties in with my intuition, so I'll go with
that for now.



[COVID] Coronavirus And Cycling

From: andrew cooke <andrew@...>

Date: Tue, 12 Jan 2021 17:52:10 -0300

There's a long and infamous tradition of physicists / engineers using simple
mathematical models to say something about complex systems (biology,
economics) and getting things horribly wrong.

I'm hoping to avoid that here by not drawing any strong conclusions.  Instead
I just want to throw some light on possible factors that people should take
into account when trying to decide what to do.

OK, so the question people keep asking in various places is: with Coronavirus
being a risk, is it safe to go cycling in a group?

If we assume that transmission is via someone breathing out virus-laden
particles that you breath in (which is, I think, roughly accepted) then you
can try to assess your risk yourself:

* The more people, the more likely someone is to be infected, so the higher
  your risk.

* Breathing out more energetically may increase the number of particles (if it
  increases as the volume increases, for example), which is likely a higher

* Wearing masks hopefully filters out some of the particles, so other people
  not wearing masks increases your risk.  The type of mask is likely also

* How diluted the particles become as they move through the air is also going
  to be important.  In a closed, poorly ventilated space they will collect.
  In the open air they are more likely to be dispersed by the wind.  What
  happens when riding in a group?  Is the air 'captured' by the flow through
  the group or does it get dispersed?  Presumably a more coherent flow
  increases risk.

* Increased spacing between people gives more chance for the particles to be

* Wearing a mask is also important when breathing in, so you not wearing a
  mask increases your risk.  And again the type of mask is likely important.

* Breathing in more deeply - as during exercise - may draw more of the virus
  more deeply into the lungs, increasing your risk.

Putting all this together, individuals riding separately, well separated,
wearing good quality masks, and not exerting too hard are likely pretty safe.
Change any of those variables and you increase risk.  So, at the other
extreme, many people in a compact group, without masks, working hard, hoping
to drag a "bubble" of air along for efficiency, are going to be more at risk.

Again, I am not a virologoist or an infectologist.  The above is just what
seems like common sense to me.

One example of how I may be incorrect is that, in the argument above, it
doesn't seem to matter who wears the mask (if only one person wears it, and it
filters out 90% of particles, it filters out 90% of particles either when
breathing out, or when breathing in).  This contradicts what I have read
elsewhere, which emphasises that masks are more important on "other people"
and less important for self-protection.



[Programming] Docker on OpenSuse

From: andrew cooke <andrew@...>

Date: Tue, 29 Dec 2020 13:07:46 -0300

* Install docker package(s)

* Start sservice

    systemctl enable docker
    systemctl start docker

* Add current user to docker group (check it ecxists in /etc/group)

    usermod -aG docker username

* Check that things are OK

    docker ps