Monday, October 9, 2018

Hello babies…

“Hello babies. Welcome to Earth. It’s hot in the summer and cold in the winter. It’s round and wet and crowded. On the outside, babies, you’ve got a hundred years here. There’s only one rule that I know of, babies-“God damn it, you’ve got to be kind.”

Kurt Vonnegut God Bless You Mr. Rosewater

Conservative statistics

I almost never agree with Bret Stephens, but this piece in the Times in one of his more Trumpian abuses of statistics. He argues that we should take false accusations of sexual misconduct seriously because "…false allegations of rape, while relatively rare, are at least five times as common as false accusations of other types of crime, according to academic literature." In the context of false accusation of rape, who cares about the rate of false allegation of arson, for example? The relevant statistic here is the difference between the true allegation of rape and the false allegation of rape. And given that rape and attempted rape is known to be under-reported^[Source U.S. Department of Justice data], an estimate of total true allegations has to be made. His statistical sleight of hand is sadly typical of conservatives.

Scripting thumbnail image file creation on macOS

One of the sites that I manage uses a jQuery-based image gallery to display images in a grid. The script decides which thumbnail to use based on how large and image is needed. A series of suffixes à la Flickr^[Well, sort of. I don’t think this is exactly what Flickr uses; and I made up the _q suffix for the less than 500px image.] is used to signify classes of image size. I wrote the following script to automate the process of scanning a source folder and creating four thumbnail sizes to an output directory.

It’s all pretty self-explanatory.

#!/usr/bin/python
# encoding=utf8

import os
import argparse
import glob
import subprocess

# instantiate argument parser
parser = argparse.ArgumentParser(description='Create thumbnails for YAPCA site')
# arguments
parser.add_argument('srcdir', help='Source directory to search')
parser.add_argument('outdir', help='Thumbnail output directory')
# parse
args = parser.parse_args()

extensions = [ ('t',99), ('m',239), ('n',319), ('q', 499)]

for imgpath in glob.glob(os.path.join(args.srcdir,"*.jpg")):
	imgname = os.path.basename(imgpath)
	imgbase = os.path.splitext(imgname)[0]
	for e in extensions:
		thumbbase = imgbase + '_' + e[0]
		thumbname = thumbbase + ".jpg"
		thumbpath = os.path.join(args.outdir,thumbname)
		if os.path.isfile(thumbpath):
			print "File: {0} exists".format(thumbname)
		else:
			# this thumbsize doesn't exist, so we must create it
			dimension = e[1]
			print "File: {0} does NOT exist. Creating for dimension {1}\n".format(thumbname,dimension)
			cmd = "sips --resampleHeightWidthMax {0} '{1}' --out '{2}'".format(dimension, imgpath,thumbpath)
			p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
			(output, err) = p.communicate()
			p_status = p.wait()

Friday, October 5, 2018

This article by Christopher Browning published in The New York Review of Books puts the unprecedented polarization of American political life in an eery historical context. As he puts it, “Trump is no Hitler and Trumpism is not Nazism” but certain parallels are inescapable. The article surfaces an old question that I’ve harboured for almost a decade - Is the chaotic concentration of all power the intentional end-game of the Republican party or did they simply provoke the worst darkest tendencies of voters, only later finding they couldn’t control what they started? Whatever the answer to that question, the piece is worth reading if only to observe how beautiful sentences are crafted. The essay is that well-written.

Thursday, October 4, 2018

This piece in The Atlantic by Adam Serwer is a reminder that for Trump’s supporters, cruelty isn’t just a side-effect of Trumpism. It’s a feature. That the current U.S. president chose to mock the victim of a sexual assault by a Supreme Court nominee is hardly surprising. But what little hope I had for Trump supporters, particularly those at the Mississippi rally who joined Trump in his mockery, is gone.

Monday, September 17, 2018

Oh, those fiscally-responsible Republicans

The president of debt

Axios has an article on Trump’s love of debt. He’d borrow the first installment from Russia.

Sunday, September 16, 2018

Regex 101 is a great online regex tester.


Speaking of regular expressions, for the past year, I’ve used an automated process for building Anki flash cards. One of the steps in the process is to download Russian word pronunciations from Wiktionary. When Wiktionary began publishing transcoded mp3 files rather than just ogg files, they broke the URL scheme that I relied on to download content. The new regex for this scheme is: (?:src=.*:)?src=\"(\/\/.*\.mp3)

Saturday, September 15, 2018

Interestingly, Fox News rejects requests from the Tor Browser. The New York Times loads perfectly normally via Tor. I don’t often visit Fox News but an article title caught my attention.

Thursday, September 13, 2018

Politico has a piece today about Trump’s outrageous claims in the face of weather disasters. In almost every context, he reveals himself to be an abject fool; but lurking beneath that idiocy is another layer of loathsomeness - the complete lacking in understanding of science. I want a reporter to ask him any of the following questions about hurricanes:

  • “Mr. Trump, can you describe for us your understanding of how hurricanes form?”
  • “What role do Coriolis forces play in the formation of tropical cyclones.”
  • “Given that hurricanes possess massive amounts of energy, what are the sources of that energy?”

An article from the Times on why yelling at children is comparable to physical punishment. Children who are subjected to yelling have lower self-esteem, and more depressive and anxiety symptoms.^[The article cites a study that shows a reciprocal amplifying effect of yelling and behavioural problems: “Mothers’ and fathers’ harsh verbal discipline at age 13 predicted an increase in adolescent conduct problems and depressive symptoms between ages 13 and 14. A child effect was also present, with adolescent misconduct at age 13 predicting increases in mothers’ and fathers’ harsh verbal discipline between ages 13 and 14.”]