Fine-tuning caching for S3-hosted static blogs using AWS CLI

Because the blogging system that I use doesn’t apply finely grained object-level caching rules, I end up with objects such as images that cache appropriately but an index.html page that does not. I don’t want client browsers to hang on to the main index.html page for more than an hour or so because it should update much more frequently than that as its content changes.

It’s possible that I could dig around under the hood of hexo and create a version that applies customized caching rules. Instead, I make a second pass over the content, adjusting the Cache-Control and other metadata according to my needs. For this task I use the Amazon Web Services command line interface AWS-CLI.

Modern textbook design: an architecture for distraction

The design of textbooks in common use at all levels from elementary school through high school are appallingly bad. I’ve come to this conclusion after several years of carefully looking at my sons’ books as they went through public middle and high school. What follows is a critique of very common design “features” in these books in reference to visual information design principles. Since I’m not a subject expert in the content of the disciplines presented, I’ll just refer to the visual design, typography and information design principles in general.

I’ll start with a mathematics textbook used in Canada in Grade 6, the Pearson “Math Makes Sense” text. A sample page is depicted below.

Improved page

The most obvious design abuse is the heavy graphical “fluff” on the page. When the margin is included, the top banner takes up 19% of the vertical extent of the page and its sole purpose is to identify the page as the beginning of the third lesson which is about multiples.

Within the body of the page, the most egregious offense is an enormous photograph of a radio announcer with a speech bubble that says nothing about the mathematical concept being presented. This gratuitous figure takes up about 18% of the content area of the page. It would be a minor offense if it wasted only the paper, but it wastes a far scarcer resource - the student’s attention. The figure adds nothing to the concept that the authors are trying to present, so it should be removed. This is a textbook for 6th graders who are in no need of infantilization. Unnecessary silly graphics degrade the importance of the content and invariably lead students to conclude that the content is as unimportant as a radio call-in contest.

The sections of each lesson are demarcated by a heavy section graphics connected to bold garish leader lines. The cheap three dimensional effects, garish colors and unnecessary boldness are distracting. This is a poignant example of the structure of the content overwhelming the content itself. The section header graphics are probably meant to resemble buttons on a web page circa 1994, but printed material has a mode of consumption different from that of the web and its format should respect the difference.

The page footer is less intrusive by unnecessarily complex. There is no need for the strangely fading, amateurish blue lozenge behind the “Lesson focus.” If this is the focus of the lesson, shouldn’t the student be aware of it first? Placing the goal at the bottom of the page hides the purpose from the reader and leads him to assume that it’s busy work. The goal should be obvious before the student begins the section.

Other examples of violations of good taste in typography and color can easily be cleaned up. A more serious issue is how the authors chose to present the identification of common multiples. Look closely at the following chart:

Table errors

It depicts a “one hundred board” - a graphic that will be familiar to most students. But no key is provided. It takes a bit of detective work to figure out that the multiples of 6 are circled and the multiples of 4 are embedded in a green background. But what about the numbers with a yellow background? They mean nothing. The yellow was used gratuitously to give a splash of color to the page. But again, it’s worse than gratuitous, it could be misleading or just slow the student down in understanding the concept. We can easily reformat the table to remove extraneous signals and to apply the principle of minimum necessary difference:

Improved table

The new table is not alarmingly large. Its grid is just distinct enough to see the structure without making the figures appear to be imprisoned at Alcatraz. And the typeface is the more legible Gill Sans. Instead of using the mixed signals for cell color, I’ve used a consistent white background color with only multiples of 4 colored medium red. I don’t have a problem with the ragged edge border, although a more authentic representation would should the last row of the standard table with figures to 100. But this redesign will suffice.

By cleaning up the typography, removing gratuitous graphics, simplifying the table and linking it more logically to the text, the page has a less distracting appearance.

Improved style

Trump, the conspiracy theorist

One of the most striking features of the GOP front-runner is his special fondness for conspiracy theories. From the (non-existent) connection between vaccines and autism to the “real culprits” behind 9/11, he shows the typical clustered endorsement of multiple conspiracy theories.

The question about whether this a form of pandering or a genuinely held set of perspectives is interesting, though barely relevant. In the former case, the abandonment of reason to achieve a political goal is an egregious fault. In the latter case, it sheds considerable light on crucial decision-making capacities. Endorsement of conspiracy theories requires a set of cognitive biases that fundamentally hobble evidence-based decision making.

The spread of anger in social networks and its implications for political violence

An ingenious study using the massive Weibo network revealed insights into the spread of certain emotions through social networks. Weibo is a social network platform not unlike Twitter. It is also hugely popular in China with millions of users making it an ideal platform for understanding how emotional states between socially-connected users correlate with each other.

But the highest correlation by far was among angry users. Rui and co say anger strongly influences the neighbourhood in which it appears, spreading on average by about 3 hops or degrees. “Anger has a surprisingly higher correlation than other emotions,” they say.

anki_tool: low level manipulation of Anki databases

Speaking of Anki, here’s a Swiss Army knife of database utilities that provides searching, moving and renaming functions from the command line.

On GitHub.

You can do things like this to rename and collect tags:

$ anki_tool mv_tags '(dinosaur|mammal)' animal

Looks cool.

JavaScript in Anki cards

[N.B. 2016-03-26 Nathan Ifill pointed out that it is possible to use Anki’s built-in conditional replacement feature to do what I’m illustrating. I’ll have to work on another example!]

Anki is a widely-used flashcard application. If you’re learning a foreign language and you’re not using Anki, you should be.

If you are using Anki and are picky about the appearance of the cards, you should know that JavaScript can be used in the card template. This opens up a number of possibilities for dynamic cards. I’m just touching on the technique here.

Organizing knowledge for memorization

Memorization has a bad reputation in education today, but it underpins the abilities of all sorts of high-performing people. I often refer to this article from 1999 about how to better organize information for memorization.

My favorite pieces of advice:

  • Do not learn (memorize) if you do not understand.
  • Stick to the minimum information principle.
  • Use imagery
  • Avoid sets and enumerations
  • Use mnemonic techniques.

Observation: Facebook groups don't work

Web
I’m reluctant about using Facebook. Recently I returned after a 5 year sabbatical. It seems about the same as it was when I left. But I had never really used Facebook groups before. So when a friend launched a group around a topic of interest to me, I joined enthusiastically. While watching the numbers grow quickly in the first few days, I realized what a difficult platform it is for having any kind of meaningful discussion.

Detecting Russian letters with regex

How to identify Russian letters in a string? The short answer is: [А-Яа-яЁё] but depending on your regex flavor, [\p{Cyrillic}] might work. What in the word does this regex mean? It’s just like [A-Za-z] with a twist. The Ёё at the end adds support for ё (“yo”) which is in the Latin group of characters.

See this question on Stack Overflow.

Scalia and the secret society

It was recently reported in the Washington Post that the late Supreme Court Associate Justice Antonin Scalia had ties to a secret society of hunters called the International Order of St. Hubertus and that several of the guests at the Texas ranch where Scalia died were members of this group.

Surely I’m not the only one that finds this a bit weird. A secret society of hunters? I don’t know the first thing about hunting but from I’ve seen, the only thing secret about hunting is sneaking up on an animal so you can kill it.