George V. Reilly

Alembic: Data Migrations

We use Alembic to perform schema migrations whenever we add (or drop) tables or columns from our databases. It’s less well known that Alembic can also perform data migrations, updating existing data in tables.

Here’s an example adapted from a migration I put together this afternoon. I added a non-NULL Boolean stooge column to the old_timers table, with a default value of FALSE. I wanted to update certain rows to have stooge=TRUE as part of the migration. The following works with PostgreSQL.

Note the server_de­fault=sa.false() in the de­c­la­ra­tion of the stooge column, which is needed to initially set all instances of stooge=FALSE. I then declare a table which has only the two columns needed continue.

Review: Flashman and the Angel of the Lord

Title: Flashman and the Angel of the Lord
Author: George MacDonald Fraser
Rating: ★ ★ ★ ★
Publisher: Plume
Copyright: 1994
Pages: 400
Keywords: historical fiction, humor
Reading period: 27 August–4 September, 2016
Flashman Papers X: 1858–59

Flashman and the Angel of the Lord finds Flashy back in America where everybody wants him to be the aide-de-camp to the abo­li­tion­ist John Brown, who’s plotting a raid on the federal armory at Harpers Ferry. The Un­der­ground Railroad want him to help Brown to start a slave rebellion; Kuklos (a proto KKK) want Brown to start a civil war to cause disunion; and finally the secret service want Flashman to sabotage Brown so as to continue.

Review: In For The Kill

Title: In For The Kill
Author: John Lutz
Rating: ★ ★ ★ ½
Publisher: Pinnacle
Copyright: 2007
Pages: 477
Keywords: thriller
Reading period: 20 Aug–3 Sep, 2016

The “Butcher” is leaving dis­mem­bered corpses of women all over New York City and he seems to want to get Frank Quinn’s goat. Quinn is a former police captain, who’s been called back from retirement along with two of his former team members, Pearl, his ex-girlfriend, and the slovenly Fedderman. The “Butcher” is brilliant and the body count is climbing.

While the book is properly sus­pense­ful, I couldn’t suspend my disbelief at the notion that the NYPD would have little more than Quinn’s tiny team working on such a major continue.

Productivity Hack: Do Nothing

I read an in­ter­est­ing pro­duc­tiv­i­ty hack: Writing or Nothing. It’s attributed to Raymond Chandler who set himself the goal of writing for four hours every day but often found himself goofing off. To curb himself of this, he set two rules about how he could spend those four hours.

  1. I may write, but it is not mandatory,
  2. Not do anything else.

The first rule is simple. The second is the key. If he’s not writing, he may not do anything else. No reading, no bill paying, no modern dis­trac­tions like surfing the web or playing a game on a phone. Self-enforced idleness. Nothing else.

I haven’t tried it yet but I think it might be effective for continue.

Kindle Monthly Deals: $3.99 or Less

Every month, Amazon offers hundreds of Kindle ebooks at $3.99 or less. As well as the dross, there are always a number of books that are great value at such a price. I just bought several from the September crop, including Bloodchild (Octavia Butler), The Con­fes­sions of Nat Turner (William Styron), Magic Bitter, Magic Sweet (Charlie Holmberg), Follow the Rabbit-Proof Fence (Doris Pilkington), and Schis­ma­trix Plus (Bruce Sterling).

New Compression Formats

You might think that data com­pres­sion is a solved problem, lossless or lossy. But, no. Gzip and related formats like zlib, Zip, and PNG that use the DEFLATE algorithm were great 25 years ago, still do a decent job, and are completely ubiquitous and in­dis­pens­able, but there are better, smarter algorithms now.

Google has announced two new com­pres­sion formats in the last couple of years, Zopfli and Brotli. Zopfli does a better job of generating Deflate-compatible data, although it’s very slow. Brotli gives ~20% better com­pres­sion than Deflate, but at about the same speed. Then there’s xz, which grew out of 7-zip, and also works well.

Zstandard has just been announced by Facebook and continue.

USB Charge-Only Cables and Condoms

Thanks to Tom Limoncelli, I became acutely aware of USB charge-only cables and condoms. If you plug your phone into an unknown computer to charge the battery, you run the risk of having your phone hijacked by malware. USB transfers data as well as elec­tric­i­ty and you’re es­sen­tial­ly giving the computer un­re­strict­ed access to your phone.

Certain USB cables are charge-only and will not pass data. There are also “USB condoms”, which are inserted between the cable and the computer. They not only block data, but they can po­ten­tial­ly charge the battery faster, as they can switch the device into a fast-charging mode. I’ve ordered a pair from Amazon, as we’re going continue.

HTTPS for GitHub Pages Custom Domain: Not Yet

This website, http://www.georgevreil­ly.com/, is hosted at GitHub Pages. It’s actually https://georgevreil­ly.github.io/ but I’ve configured the former as the “custom domain”, so the latter is un­con­di­tion­al­ly redirected to the custom domain.

GitHub Pages gives me free, fast hosting and an easy pub­li­ca­tion model: I commit the latest changes to my master branch, I push the branch to GitHub, and seconds later, my site is updated. I’m using Acrylamid to generate the content from re­Struc­tured­Text source on the blog branch and ghp-import to commit the HTML to the master branch.

GitHub Pages supports HTTPS as of June 2016, but not for custom domains. There are some hacks but I don’t feel like using them. I’m hoping continue.

Plums

The cen­ter­piece of our back yard is an aging Italian plum tree. We moved in to our house in late August 2000, right as the fruit was fully ripe. We didn’t have a ladder and the former owners didn’t have time to deal with the tree either, so most of the fruit that year ended up in the yard waste. I dragged one enormously heavy yard waste can up the back steps into the alley that year. I like to say that it weighed as much as I did, but it probably didn’t.

We bought ladders and we’ve picked the fruit thereafter. The tree is old and no longer gives continue.

Review: Flashman in the Great Game

Title: Flashman in the Great Game
Author: George MacDonald Fraser
Rating: ★ ★ ★ ★
Publisher: Plume
Copyright: 1975
Pages: 322
Keywords: historical fiction, humor
Reading period: 16–25 August, 2016
Flashman Papers V: 1856–58

Flashman in the Great Game finds Flashy back to India, sent there by prime minister Lord Palmerston to look into worrying rumors of mutiny amongst the Indian troops and to sweet talk the re­cal­ci­trant Rani of Jhansi. After an attempt upon his life by Thugees, Flashman goes undercover in the native cavalry at Meerut, where the Sepoy Mutiny begins soon after. He then finds himself in the Siege of Cawnpore and the Siege of Lucknow and imprisoned at Gwalior before being almost continue.

Previous » « Next