State Election Map now available!

My latest project, State Election Map, is now available! It’s a neat way to visualize US presidential election results from 1972 to 2016.

The coolest part is that you can look at each state’s result relative to the national popular vote, so you can see states becoming more Democratic/Republican over time. (check out California and Alabama going on opposite trajectories…)

Other interesting observations: Nixon won by a ton in 1972 (which means that whole Watergate stuff was really unnecessary!), Reagan won by a ton in 1984, and check out the 1976 bizarro-world map! I guess that’s what you get when you have a Southern Democrat running before the Southern Strategy had entirely taken hold…

From a technical perspective, the map is built in React,Β which I’ve used before, and TypeScript, which was new to me. And I’m a big fan! Using Visual Studio + TypeScript meant I got helpful syntax errors at edit-time, which I’m really not used to in a JavaScript-y language.

I did my best to separate the map/timeline parts into separate components, so I’m hoping to publish them separately and eventutally rewrite my same-sex marriage map to use them too. But that’s a ways down the line!

Upon Further Review: The Greatest What-Ifs in Sports History review

Upon Further Review: The Greatest What-Ifs in Sports History

Upon Further Review: The Greatest What-Ifs in Sports History by Mike Pesca

My rating: 3 of 5 stars


This book was…fine. I think I didn’t appreciate it as much as I could of because I’m not a huge sports fan (plus I have a terrible memory), so a lot of the chapters were, I’m guessing, very clever about mentioning things that didn’t really happen, etc. But a lot of it was lost on me.

I bought the book because I saw Jon Bois wrote a chapter, and as expected “What If Basketball Rims Were Smaller Than Basketballs?” was funny! Other chapters I particularly enjoyed were:
– “What If Billie Jean King Had Lost to Bobby Riggs?” – I grew up in Houston and had heard of the Battle of the Sexes, but didn’t realize it was such a big deal at the time!
– “What If a Blimp Full of Money Had Exploded over World Track Headquarters in 1952?” – this one wasn’t super interesting but the premise is pretty hilarious πŸ™‚
– “What If Baseball Teams Only Played Once a Week?” – I had read an article about this premise before (maybe by the same guy?) but it was still pretty interesting.
– “What If Nat ‘Sweetwater’ Clifton’s Pass Hadn’t Gone Awry?” – Lots of interesting stuff about the New York Renaissance, an all-black professional basketball team in the 1940’s that almost got to join the NBA.
– “What If Game 7 of the 2016 World Series Had Turned Into Every Sports Movie Ever Made?” – pretty funny, even if I’m pretty sure I only got like 20% of the references πŸ™‚


View all my reviews

How to Invent Everything: A Survival Guide for the Stranded Time Traveler review

How to Invent Everything: A Survival Guide for the Stranded Time Traveler

How to Invent Everything: A Survival Guide for the Stranded Time Traveler by Ryan North

My rating: 5 of 5 stars


Really fun read! Covers a wide range of technology, from domesticating animals to units of measurement to foods to chemistry to art. At first I was a little irritated that I didn’t think I could actually reinvent all this technology using just this book, but:
– some sections were more explicit than others in terms of “able-to-do-thisness”
– this is probably an unfair quibble for a book that’s telling you how to re-create civilization!

Some of the most interesting parts were technologies that humans totally could have invented way earlier if anyone had known about it, like using canaries in mines to detect carbon monoxide, vitamin C to prevent scurvy, and kilns. Turns out kilns are incredibly useful!

There’s even a real-life technology tree in the appendix (like in Civilization! but for real life!)

The book does strive for accuracy but as you might expect given the author, it is also full of jokes, which makes it more fun to read.

Since I have the paper edition of this, I read it in 20-minute or so segments at a time, which I actually recommend because otherwise I’m guessing it might seem like a bit much? But I enjoyed it a lot!


View all my reviews

wasting hours because gcc’s argument parsing is crazy (or: dude, where’s my library?)

After building my new computer, I’ve been going through all of my projects on gregstoll.com and making sure they work. I try to do this periodically anyway, and moving to a new machine broke some of them.

So I’ve been working on my Pretty Pictures with Genetic Algorithms project, which uses a C++ program on the backend to generate the images. It used to use tinyjson to parse the description of the picture, but that depends on some Boost stuff which was hard to install, so I decided to change to use rapidjson which has no external dependencies. Turns out my C++ is fairly rusty, but after an hour or so I was able to fix all the compile errors!

And then I started hitting linker errors, like:

writepng.cpp:(.text.startup+0x444): undefined reference to `png_create_write_struct'
writepng.cpp:(.text.startup+0x45c): undefined reference to `png_create_info_struct'

“OK”, I thought, I know what this means! writepng.cpp calls into libpng, and I’m including the header file correctly, but for some reason I’m not linking against libpng.so. I still remember some things!

This was kind of weird, because I hadn’t actually changed anything about the png code, but it’s a new machine so anything is possible. So I make sure libpng.a is installed and seems to be in a reasonable place.

Then I made sure the linker was finding it by specifying the directory with -L – same result. (although I later noticed if the linker doesn’t find a library you specify with -l, you get a different sort of error) Now I’m pretty confused, so I add -v to get more verbose info from g++, but nothing’s particularly useful.

Right now my command line is:

g++ -v -O2 -Wall -lpng -o writepng writepng.cpp

and I’m still confused. I’m wondering whether this is a name-mangling thing – if writepng.cpp is expecting the png functions to be C-style (as it appears to, since the missing symbols are just the name of the functions), but they’re actually exported as C++ functions, then this is the sort of error you’d get. So I use readelf to look at the symbols in libpng.a and libpng.so and writepng.cpp and they’re all looking for the plain C versions.

I’m basically out of ideas at this point, so I go to bed, and the next day try first compiling the .cpp into a .o file and then passing that to g++, which doesn’t work. Now I’m reduced to some frantic searching. After another hour or so, I read a page that implies that the order of arguments to g++ matters, so I try switching around the command to:

g++ -v -O2 -Wall -o writepng writepng.cpp -lpng

(notice the -lpng moved to the end) – and it works! The reason is that apparently g++ and gcc evaluate the .cpp, .o, and -l arguments in order and get rid of any symbols that don’t seem needed at that point. So when -lpng is first, g++ reads the library, sees a bunch of exported symbols and says “huh, nothing needs these yet so I guess I’ll forget about them”, and only after looking at the .cpp argument realizes that those symbols are undefined.

I would humbly submit that this is incredibly user-hostile. People don’t expect the order of arguments to a command-line program to make a difference! I’m sure it makes the linker a tiny bit faster or whatever, but coooooooome on.

Anyway, that’s two hours I’ll never get back, although at least I did learn something…

(see all my programming rants)

The City on the Edge of Forever: The Original Teleplay review

The City on the Edge of Forever: The Original Teleplay

The City on the Edge of Forever: The Original Teleplay by Harlan Ellison

My rating: 3 of 5 stars

So. Harlan Ellison wrote the original version of “The City on the Edge of Forever”, generally considered the best episode of the original Star Trek series (with “The Trouble With Tribbles” in a close second place), and a bunch of changes were made between the original draft and what aired. Gene Roddenberry said the original script was good but needed a lot of changes. This made Harlan Ellison extremely cranky, and so thirty years later(!) he wrote an essay about what happened.

People, his essay is 80 pages long (if the Kindle page numbers are to be believed, but let me tell you, it certainly felt that long!) and is quite the opening tirade. He’s very angry with Gene Roddenberry (who had passed away by the time the book was written, but Ellison holds nothing back), but also almost everyone involved with Star Trek. Except Leonard Nimoy. Leonard Nimoy was cool.

Ellison was a prolific scifi writer, and his original draft of the episode (which this book contains) is, in fact, quite good! But, to give one example, it starts with an Enterprise crew member selling drugs to another crew member and killing him shortly thereafter. It’s no surprise this got changed, because Gene Roddenberry’s/Star Trek’s vision of the future is pretty utopian.

Ellison brings up again and again that, after the fact, Gene Roddenberry said that his script had problems because “Scotty was dealing drugs”. While this is wrong (Scotty doesn’t actually appear in the episode), it’s not too far off from the truth, and I’m sure Roddenberry found them equally unacceptable. Which isn’t to say that this is an OK thing to say, it seems like a relatively minor point to me. But not to Ellison! He mentions it four separate times in the essay, and once in the endnotes.

Oh, did I mention the endnotes? His angry screed has no fewer than eleven endnotes.

So then you can read the first draft of the story and the next draft with more details, and then Act One of the final version of the script. Like I said, Ellison’s drafts are good and made for good reading.

Then there are eight afterwords by various people involved in Star Trek, presumably chosen because they side with Ellison. Although some of them, notably Water Koenig and Harlan Ellison, wrote pieces that are more along the lines of “hey, that first draft was really good! And then I guess there was some unpleasantness or something?”.

Anyway, it did not come as a surprise to me that the first sentence of Ellison’s Wikipedia page is “Harlan Jay Ellison was an American writer, known for … and for his outspoken, combative personality.”


View all my reviews

built a new computer!

My desktop computer is now 8 years old, and has been getting a bit slow, so I decided to bite the bullet and build a new one. This time I was going to install Linux from scratch to hopefully get rid of the weird Linuxy issues that were building up.

And I’m declaring it a moderate success! The website is back up and running and most of the important things are working. I ordered the parts from PCPartPicker (here’s my build) although I didn’t do a ton of research – for example, I didn’t realize that the SSD is a fancy M2 thing that really does look like a stick of gum! (or, more boringly, a stick of RAM)

Due to kiddos roaming the house I couldn’t leave any parts out while they were around, so my plan was to slowly put it together over a series of evenings, then take a day of vacation to copy files over and get it set up. This also minimized downtime which was a minor goal.

Stuff to remember for next time:

  • One advantage of putting the hardware together beforehand was that I could make sure I had everything. For some reason, the hard drives I ordered didn’t come with SATA cables – luckily the case came with a few and I scrounged a few others up.
  • The biggest hardware things that I think will make a difference are more RAM (8 GB -> 32 GB, although maybe RAM speed makes a difference too?) and CPU speed.
  • Because I was able to get dramatically bigger hard drives I was able to just install a clean Ubuntu on the new system and then copy everything over – /home just went over the existing stuff, everything else went in a parallel place that I could copy over as needed.
  • I predicted that getting the databases copied over (I have stuff in Postgres _and_ MySQL :-\ ) would be the hardest part and I was 100% correct. Part of the problem was that I somehow forgot the difference between databases and tables which I think cost me an hour! But my plan was to upgrade the old machine to have the same versions of Postgres/MySQL so I could just copy the files on disk over. This was not a good idea, and I should have just used pg_dumpall and whatever the MySQL equivalent is – would have gone much smoother!
  • When “upgrading” my old computer to try to do this I managed to break things badly enough that it wasn’t able to connect to the network anymore. While this was good motivation to get the move done (akin to Cortes burning his ships), it was just another reminder that I’m getting crotchety and just want my computer to work right.
  • cp --archive is exactly the command to copy stuff between drives (assuming the user IDs match up), although there was some weirdness with files that start with a period that I never quite figured out.

Power Ball: Anatomy of a Modern Baseball Game review

Power Ball: Anatomy of a Modern Baseball Game

Power Ball: Anatomy of a Modern Baseball Game by Rob Neyer
My rating: 5 of 5 stars

I heard about this book and downloaded a sample because it sounded pretty interesting to take a deep look at a single baseball game – I hadn’t read the previous books like this (Daniel Okrent’s Nine Innings, for example) but it seemed like a good framing device.

Then I saw the game in question was an Astros game and immediately(*) bought it πŸ™‚

And it’s a fascinating book! I stopped flagging particularly interesting parts of the book because it was basically all interesting – it uses the game as a jumping-off point to talk about spin rate and Statcast, roster size, tanking, defensive shifts, Moneyball, juiced baseballs, modern pitcher management, utility players like Marwin Gonzalez, steroids, pace of game, and a bunch more.

Highly recommended if you’re at all interested in baseball – and for goodness sake, don’t read the summary because it spoils the outcome of the game!

(*) actually I downloaded the sample before Christmas, so I didn’t buy it then, but I bought it the next time I remembered about it afterwards πŸ™‚

View all my reviews