Andrew Cooke | Contents | RSS | Previous

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.

Personal Projects

Choochoo Training Diary

Recent Threads

Surprise Paradox

[Books] Good Author List

[Computing] Efficient queries with grouping in Postgres

[Computing] Automatic Wake (Linux)

[Computing] AWS CDK Aspects in Go

[Bike] Adidas Gravel Shoes

[Computing, Horror] Biological Chips

[Books] Weird Lit Recs

[Covid] Extended SIR Models

[Art] York-based Printmaker

[Physics] Quantum Transitions are not Instantaneous

[Computing] AI and Drum Machines

[Computing] Probabilities, Stopping Times, Martingales

[Computing] Starlab Systems - Linux Laptops

[Computing] Extended Berkeley Packet Filter

[Green] Mainspring Linear Generator

Rummikub Solver

Chilean Poetry

[Bike] Fixing Spyre Brakes (That Need Constant Adjustment)

[Computing, Music] Raspberry Pi Media (Audio) Streamer

[Computing] Amazing Hack To Embed DSL In Python

Recent Replies

=?UTF-8?B?RXhjbHVzaXZlIEVhc2VGcmVpZ2h0IEZyZWlnaHQgU2VydmljZXMgdGFpbG9yZWQganVzdCBmb3IgeW91?=

=?UTF-8?B?RXhjbHVzaXZlIEVhc2VGcmVpZ2h0IEZyZWlnaHQgU2VydmljZXMgdGFpbG9yZWQganVzdCBmb3IgeW91?=

=?UTF-8?Q?Erinnerung:_Offene_Zahlung_f=C3=BCr_Ihr_SSL-Zertifikat?=

SSL Payment Reminder

=?UTF-8?B?RXhjbHVzaXZlIEVhc2VGcmVpZ2h0IEZyZWlnaHQgU2VydmljZXMgdGFpbG9yZWQganVzdCBmb3IgeW91?=

=?UTF-8?B?VGhlIGJlc3QgY3VzdG9taXplZCBmcmVpZ2h0IHNvbHV0aW9uIGZyb20gRWFzZSBmcmVpZ2h0?=

Bitte aktualisieren Sie Ihre Kreditkartendaten, um Unterbrechungen zu verme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MgdGFpbG9yZWQganVzdCBmb3IgeW91?=

=?UTF-8?B?VGhlIGJlc3QgY3VzdG9taXplZCBmcmVpZ2h0IHNvbHV0aW9uIGZyb20gRWFzZSBmcmVpZ2h0?=

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

Reddit Comment on Fascism + Trump

From: andrew cooke <andrew@...>

Date: Fri, 21 Feb 2025 16:03:31 -0300

Loved this and wanted to record it here in case it's deleted later.
Also, I need to sort out this place and get rid of all the spam, I
know.

https://www.reddit.com/r/Professors/comments/1iuqq6y/what_is_the_line_between_paranoia_and_preparedness/me0ejh0/

Credit to DerProfessor https://www.reddit.com/user/DerProfessor


[In response to an acacdemic worrying about the future]

Honestly, I would say--don't worry about it. I myself am not going to
adjust anything one single iota. In part, because staying the same is,
effectively, resistance.

I am a historian of Germany, including of the Third Reich (though it's
not my specific area of research). I know a great deal about how the
Nazis solidified power 1933-1934. This is not that moment.

One thing that has been consistent about Trump is that he bluffs on
everything. Everything. This has been his standard mode-of-operation
his whole life, from being a real-estate conman to posing as a fascist
strongman. His posing and bluffing has gotten him what he wants a lot
of the time. But equally, it is often hot air when he is ignored.

The key word here is posing. Neither he nor the Republicans have
mechanical structures (police, informants, allies in the academy, mass
movement) to ever "see" what you are doing, let alone impact you as an
individual professor.

Consider: what levers does he have? When you say "when they will come
for us"... who is they? And how will "they" even know who you are?

Let us imagine that, over the next two years, an office is set up
somewhere, to collect syllabi and thereby try to police teaching. How
would the office be set up? (especially when the Dept of Education is
being dismantled?) Who would be hired to work there? How would they
"demand" the syllabi? If your university already posts them publicly,
how would they collect them? There are millions of classes
taught. They'd need to hire thousands just to read the ones that AI
flags for words like "race". Then, what would be the mechanism for
enforcement? Would this department call up your local police
department and say, "We see that Professor Fit_Inside2339 at the
University of Innuendo is teaching a class on race and ethnic
relations... we need you to go arrest him." Any police officer, even a
dyed-in-the-wool Trumpy, would laugh in their face.

You're safe. You're fine.

The Nazis could terrorize professors because 40% of professors were
themselves Nazi supporters. That is crucial. Do you have a single
colleague who is a Trump supporter? Even one? (The redneck dumbasses
in their lifted trucks don't even know where the university is, let
alone your classroom.)

The Nazis also had the Gestapo. But recent literature reveals how
incredibly ineffectual the Gestapo was on its own. They relied
entirely on denunciations, they were reactive only. Who would denounce
you? We ALL hate that orange motherfucker. No one is going to go
running to denounce you as Unamerican... and even if you got a
politicized student in your class who wanted to, who would this
self-destructive student denounce you to? There's no infrastructure of
oppression.

Trump has no Gestapo. He has no control over police. He has no
supporters in the academy. MOST importantly, he has no mass
movement. (He has a bunch of passive, flag-waving supporters. that's
different. that's just normal politics.)

The one area that he does have control over is ICE/immigration
structures, which already exist, and are already staffed with people
predisposed to obey Trump's orders, legal or not. So, people who are
undocumented are, indeed, facing a serious personal threat. Those
folks are in trouble (and they therefore need our help and
protection). But you're fine.

Trump's "power" vis-a-vis academia is twofold: 1) to bluster loud
enough, and play-act the fascist enough, so that people (like you and
me) comply preemptively. THAT's not gonna happen. (unless you let it.)

And 2) to disrupt money flowing to Universities, to try to pressure
your Provost/Dean etc. into become stooges to force faculty to
comply. Honestly, I don't think that's going to happen either. Sure,
maybe a particularly craven Dean will come to your department and say,
"look, I support you, but you need to retitle your classes so we can
get our NIH grants back." And yes, that will be "complying". I
honestly hope that doesn't happen. But if it does... so what? You
retitle "Race in American Politics" to "Varieties of Identities in
American Politics"... teach the same course... and then savagely mock
that cowardly dean behind his back. (and remember his cowardice in the
future.)

There will be some rough times, don't get me wrong. For instance,
there will be NO more Federal grants for your type of research for the
foreseeable future. But your teaching? You'll be fine. I'll be fine.

And the more we just keep doing what we've been doing all along, the
"finer" we ALL will be!

In solidarity.

Permalink | Comment on this post

Previous Entries

For comments, see relevant pages (permalinks).

Surprise Paradox

From: andrew cooke <andrew@...>

Date: Thu, 25 Jan 2024 16:43:27 -0300

https://en.wikipedia.org/wiki/Unexpected_hanging_paradox describes a
paradox I've heard various times that has always frustrated me.

A discussion somewhere (reddit?) pointed to
https://www.ams.org/notices/201011/rtx101101454p.pdf which is really
interesting - in short their argument is that it assumes consistency
in the theory in which it is dervied, coming up against Godel's second
theorem.

Andrew

Permalink

[Books] Good Author List

From: andrew cooke <andrew@...>

Date: Tue, 17 Oct 2023 21:07:36 -0300

https://www.reddit.com/r/literature/comments/17a7e1o/literary_superstars_of_today/

Andrew

Permalink

[Computing] Efficient queries with grouping in Postgres

From: andrew cooke <andrew@...>

Date: Fri, 29 Sep 2023 12:54:40 -0300

I have finally understood a problem that has been worrying me for a long
time.  The key information is here -
https://dba.stackexchange.com/questions/170860

In my case I have tables that look like:

   publisher | rowid | other data
   ------------------------------
   puba      | 1     | ...
   puba      | 2     | ...
   puba      | 3     | ...
   pubb      | 1     | ...
   pubb      | 2     | ...

where:

 - there is a composite primary key (publisher, rowid)
 - the number of distinct publishers is small
 - the total number of entries is large

And the particular problem I had was in the query:

   select publisher, max(timestamp) from table group by publisher;

where timestamp is part of "other data".

This query was slow and NOT using an index on (timestamp, publisher)
(and the problem persists if the order in the index is swapped).

This was a big surprise, because the index seems perfect for the job -
it has ordered timestamps "grouped by" publisher (in a sense).

The problem is that Postgres does not exploit the knowledge that there
are only a few publishers.  So it decides to do a full scan to find
all publishers (simplifying a little).

Since my publishers were actually listed in the publisher table the
following query was much (100x) quicker:

   select p.publisher,
          (select max(t.timestamp) from table as t
                  where t.publisher = p.publisher)
          from publisher as p;

because it forces Postgres to look at each publisher in turn (instead
of scanning many many duplicates).


An extra detail is that I had to pull a more complex calculation based
on the timestamp into an outer query so that the "max" was clear
enough for the index to be used).  The final query was

   with x as
        (select p.publisher as publisher,
                (select max(t.timestamp) as timestamp from table as t
                        where t.publisher = p.publisher)
                from publisher as p)
        select publisher, extract (epoch from (now() - timestamp)) from x;

to give the number of seconds since the latest timestamp.

Andrew

Permalink

[Computing] Automatic Wake (Linux)

From: andrew cooke <andrew@...>

Date: Wed, 6 Sep 2023 08:04:55 -0300

I want my computer to hibernate (or even to power off), but also to
wake automatically to check for email.  To do this I:

1 - configure Gnome to hibernate after some period (eg 1 hour)

2 - add the following cronjob:

    30 * * * * sudo rtcwake -u -m no -t `date -d 'tomorrow 00:00' '+\%s'` >& /dev/null

    which at half-past every hour sets an alarm to wake the computer
    at midnight.

This means that at midnight the computer starts and runs for an hour.
During that time, the alarm is set for the next day, then the computer
hibernates.

In this way the computer cycles every 24 hours (this starts even from
soft power off).

Obviously you could do something similar with smaller intervals if you
wanted, as long as you remember that only one alarm can be set at any
one time.

Andrew

Permalink

[Computing] AWS CDK Aspects in Go

From: andrew cooke <andrew@...>

Date: Tue, 22 Aug 2023 11:02:26 -0400

In theory go (golang) has first class support in AWS CDK.  In practice
there are often missing examples.  Support for Aspects was particularly
poor, so here's a simple example.

This adds a permission boundary to all roles, so you don't have to do
it explicitly (and includes implicit roles).  The ARN for the boundary
includes the account name which is read from the environment.

In examples for other languages there's an issue with "instanceof"
operators (or similar) and multiple javascript packages.  The same
problem may exist here, so treat with care.

The code is very simple, once it's there...

Andrew


package main

import (
    "os"

    "github.com/aws/aws-cdk-go/awscdk/v2"
    iam "github.com/aws/aws-cdk-go/awscdk/v2/awsiam"
    "github.com/aws/aws-sdk-go-v2/aws"
    "github.com/aws/constructs-go/constructs/v10"
)

func main() {
    app = ...
    env = ...
    ...
    awscdk.Aspects_Of(app).Add(&AddPermissionsBoundary{Account: env.Account})
    ...
    app.Synth(nil)
}

type AddPermissionsBoundary struct {
    Account *string
}

func (this AddPermissionsBoundary) Visit(node constructs.IConstruct) {
    role, ok := node.(iam.CfnRole)
    if ok {
  	role.SetPermissionsBoundary(aws.String("arn:aws:iam::" + *this.Account + ":policy/my-boundary"))
    } else {
	// not a role - the aspect is applied to all nodes in the tree (visitor pattern)
    }
}

Permalink

[Bike] Adidas Gravel Shoes

From: andrew cooke <andrew@...>

Date: Fri, 18 Aug 2023 10:53:37 -0400

My old Shimano CX shoes started to separate from the sole (making
unclipping difficult).  The Adidas gravel shoes were on offer from
199.990 to 139.990 (60% off) and when I added an offer code I found
via google I got them down to around 103.000 (CLP), which seemed like
a reasonable price, so I bought a pair.

Since they are only available online I neded to guess the size.  I
have two pairs of adidas trainers - size 10.5 and 10 US.  Since I
thought a cycling shoe should be a fairy snug fit I ordered size 10
and it seems fine.  My feet are perhaps slightly wider than normal,
and they are still comfortable (but don't want to be any smaller!).

They are black with white stripes and they look awfully like football
boots.  The white stripe is a bit much for a cycling shoe IMHO, but
that was the only choice in stock.

I've just come back from a ride and they seem fine.  The elastic strip
to trap the laces could be higher, but works.  They're the most
comfortable to walk in cycling shoes that I've owned and the soles are
deep enough to avoid "clicking" on ceramic floors.  The sole seems
very rigid (no hot spot, but I have never had problems with that).
They're easy to clip in, but if you don't the "arch" area is very hard
and slippy, so you can easily slide off the pedal.

Some other reviews mentioned that they are not well ventilated.  I was
hoping that might mean that they were warm, but they didn't seem any
warmer than my previous shoes.  The "sock" is really just a collar
round the ankle and doesn't cause any problems, but I wonder how
stretchy it will stay after a few years of use.

So far they seem fine, but I wouldn't have wanted to pay full price...

Andrew

Permalink

[Computing, Horror] Biological Chips

From: andrew cooke <andrew@...>

Date: Fri, 21 Jul 2023 21:49:51 -0400

https://newatlas.com/computers/human-brain-chip-ai/

Andrew

Permalink

[Books] Weird Lit Recs

From: andrew cooke <andrew@...>

Date: Thu, 8 Jun 2023 10:16:14 -0400

https://www.reddit.com/r/literature/comments/142yf0y/latin_american_lit_suggestions

Andrew

Permalink

[Covid] Extended SIR Models

From: andrew cooke <andrew@...>

Date: Thu, 1 Jun 2023 22:09:34 -0400

I just went to see a talk on mathematical modelling of pandemics.  It
was largely a rehash of the SIR model along with simulations (although
I got lost near the end, so may have missed what was new).

Anyway, I got to thinking, and really it seems like the SIR approach
really misses the heart of the poblem.  I mean, we know that if
everyone isolates then infection rates will drop.  It's fucking
obvious.  The reason why it's controversial to actually put that into
practice is because there's a large collective cost.

When you see the word "collective" you start to look at the SIR model
and think how "free market" it is.  Lots of independent little people
all doing their own thing.

So I started wondering how you could extend it to include social cost.

The simplest solution I can see is to have a global state that
represents "common good" that is incremented on every interaction,
but that decays over time.

In addition, it seems that you need to add some kind of consequence
for this good becoming lower.  The simplest I could think of was that
you randomly kill individuals (so this would need to be SIR + births
and deaths I guess) at a rate connected to how low that gets.

I imagine that if you ran this then for most reasonable death
probability functions you get little happeninn until some threshold,
and then collapse.

So maybe it wouldn't be very interesting.

One extension might be to have two groups (in the same overall
population) with different functions / probabilities (eg rich and
poor).  Maybe that would show something more interesting.

Has anything like this been done?

Andrew

Permalink

[Art] York-based Printmaker

From: andrew cooke <andrew@...>

Date: Sat, 29 Apr 2023 08:28:49 -0400

https://thecuriousprintmaker.co.uk/

Near home - must visit next time I am back.

Lots of practical (and beautiful) advice in the blog.

Andrew

Permalink

[Physics] Quantum Transitions are not Instantaneous

From: andrew cooke <andrew@...>

Date: Fri, 31 Mar 2023 19:43:10 -0300

Incredibly subtle work, at least for me.

https://www.quantamagazine.org/quantum-leaps-long-assumed-to-be-instantaneous-take-time-20190605/

Andrew

Permalink