Pseudo-Numeric Identifiers

Let’s say you’re a programmer, and your application uses Library of Congress Control Numbers for books, e.g., 2001012345, or ZIP codes, like 90210. What data types would you use to represent them? Or maybe something like the Dewey Decimal System, which uses 320 to classify a book as Political Science, 320.5 for Political Theory, and 320.973 for “Political institutions and public administration (United States)”?

If you said “integer”, “floating point”, or any kind of numeric type, then clearly you weren’t paying attention during the title.

The correct answer was “string” (or some kind of array of tokens), because although these entities consist of digits, they’re not numbers: they’re identifiers, same as “root” or “Jane Smith”. You can assign them, sort them, group them by common features, but you can’t meaningfully add or multiply them together. If you’re old enough, you may remember the TV series The Prisoner or Get Smart, where characters, most of them secret agents, refer to each other by their code numbers all the time; when agents 86 and 99 team up, they don’t become agent 185 all of a sudden.

If you keep in mind this distinction between numbers, which represent quantities, and strings that merely look like numbers because they happen to consist entirely of integers, you can save yourself a lot of grief. For instance, when your manager decides to store the phone number 18003569377 as “1-800-FLOWERS”, dashes and all. Or when you need to store a foreign phone number and have to put a plus sign in front of the country code.

Advertisements
Posted in Hacking | Tagged | 2 Comments

Removing Magic

So this was one of those real-life mysteries.

I like crossword puzzles. And in particular, I like indie crossword puzzles, because they tend to be more inventive and less censored than ones that run in newspapers. So I follow several crossword designers on Twitter.

Yesterday, one of them mentioned that people were having a problem with his latest puzzle. I tried downloading it on my iPad, and yeah, it wouldn’t open in Across Lite. Other people were saying that their computers thought the file was in PostScript format. I dumped the HTTP header with

lynx -head -dump http://url.to/crossword.puz

and found the header

Content-type: application/postscript

which was definitely wrong for a .puz file. What’s more, other .puz files in the same directory were showing up as

Content-type: application/octet-stream

as they should.

I mentioned all this to the designer, which led to us chatting back and forth to see what the problem was. And eventually I had the proverbial aha moment.

.puz files begin with a two-byte checksum. In this particular case, they turned out to be 0x25 and 0x21. Or, in ASCII, “%!“. And as it turns out, PostScript files begin with “%!“, according to Unix’s magic file.

So evidently what happened was: the hosting server didn’t have a default type for files ending in .puz. Not terribly surprising, since that’s not really a widely-used format. So since it didn’t recognize the filename extension, it did the next-best thing and looked at the first few bytes of the file (probably with file or something equivalent) to see if it could make an educated guess. It saw the checksum as “%!” and decided it was a PostScript file.

The obvious fix was to change something about the file: rewrite a clue, add a note, change the copyright statement, anything to change the contents of the file, and thus the checksum.

The more permanent solution was to add a .htaccess file to the puzzle file directory, with

AddType application/octet-stream .puz

assuming that the hosting provider used Apache or something compatible.

This didn’t take immediately; I think the provider cached this metadata for a few hours. But eventually things cleared up.

I’m not sure what the lesson is, here. “Don’t use two-byte checksums at offset 0”, maybe?

Posted in Geek | Tagged , , , , | 4 Comments

Do You Even Science, Frater?

The other day, I went to a Thomistic Society talk about Aquinas’s views on the Problem of Evil and other topics. At one point, the presenter casually mentioned that humans engage in self-destructive behavior, like alcoholism, self-mutilation, drug addiction, etc., while non-human animals don’t.

That made my [citation needed] sense tingle, so I looked around. Among other things, I found Animal models of self-destructive behavior and suicide:

Research on nonhuman primates has demonstrated that self-mutilation is a common reaction to extreme disruptions of parental caretaking in other mammalian species as well. For example, isolated young rhesus monkeys engage in self-biting and head slapping and banging (21). Analgesia is also common in self-destructive animals.

Or this non-scholarly page about the effects of drugs, including addiction, in animals such as horses, goats, and even bees.

So apparently this speaker simply wasn’t aware of self-destructive behavior in non-human animals. I don’t remember what her point was, so it might have been a minor thing, but still, it wasn’t true.


But this brought to mind the previous Thomistic Institute talk I went to: there, the presenter casually mentioned that humans engage in abstract reasoning, while animals don’t.

Again, this didn’t seem quite right. This study from 2007 involved teaching dogs to push a button when shown a set of pictures of dogs, and another button when shown a set of pictures of landscapes.

Interestingly, presentation of pictures providing contradictive information (novel dog pictures mounted on familiar landscape pictures) did not disrupt performance, which suggests that the dogs made use of a category-based response rule with classification being coupled to category-relevant features (of the dog) rather than to item-specific features (of the background).

Or this paper, entitled simply Concept Learning in Animals, whose abstract says:

We suggest that several of the major varieties of conceptual classes claimed to be uniquely human are also exhibited by nonhuman animals. We present evidence for the formation of several sorts of conceptual stimulus classes by nonhuman animals: perceptual classes involving classification according to the shared attributes of objects, associative classes or functional equivalences in which stimuli form a class based on common associations, relational classes, in which the conceptual relationship between or among stimuli defines the class, and relations between relations, in which the conceptual (analogical) relationship is defined by the relation between classes of stimuli. We conclude that not only are nonhuman animals capable of acquiring a wide variety of concepts, but that the underlying processes that determine concept learning are also likely to be quite similar.

No one will deny that humans can perform mental feats that non-human animals can’t, as far as we can tell. Other animals can’t play chess, prove mathematical theorems, or form complex sentences, as far as I know. But at the same time, the issue isn’t a black-and-white “humans can reason abstractly and animals can’t.”


Lastly, I’ve written at length about Thomist Edward Feser, and his ignorance of science from Newton on up.

Individually, each of these mistakes are just that: mistakes. Or ignorance: philosophers can’t be expected to be masters of nuclear physics or animal cognition. Or simplifications that gloss over a complex idea in order to make a broader point.

But collectively, I do see a pattern of Thomists being wrong on matters of science in a thousand small ways. That suggests that either they don’t bother checking whether their beliefs are true, where possible, and correct their errors, or else they have other beliefs that lead them to erroneous conclusions. And either way, if I can’t trust them on the small stuff, why should I believe them on the big stuff?

 

Posted in Religion | Tagged , , , , , , | 2 Comments

Democracy Is Not Football

One of the many things that annoyed me in the wake of Trump’s upset victory was that for so many people on the winning side, this boiled down to “delicious librul tears“. And even a lot of Trump’s executive actions have been less about advancing his own plan, as about tearing down Obama’s legacy. We’ve also seen this with the ACA, where the GOP has been quite intent on repealing Obamacare, but has no idea what to replace it with, or how to get health care to everyone.

On the other side, I see people like the organizers of the March for Our Lives, and before them a thousand newly-hatched activists, whom Trump and the GOP awakened to the fact that government isn’t Them; it’s Us. You don’t have to choose among the two candidates that the major parties provide; you can run for office yourself. And if you can’t run and can’t vote, you can still write your representatives, and raise a fuss and bloody well make people care about the issues that you care about.

This is of a piece with the rise of prayer-shaming: a lot of the response to shootings like Parkland has been that offering “thoughts and prayers” is the same as not doing anything at all, and by now you are expected to know this. The young generation is the least-religious one yet in recent American history, and they know that praying doesn’t fix problems. Sitting down and fixing problems fixes problems.

This may turn out to be the silver lining of the Trump era: that so much stuff broke, that it woke people up to the fact that democracy isn’t a spectator sport.

(Originally started as a comment at chez Hemant.)

Posted in Politics | Tagged , , | Leave a comment

Hell Is a School, Apparently

By now, you’ve all seen this T-shirt, which began circulating approximately several years before 17 people were killed at Stoneman Douglas High School, in Florida:

T-shirt: "Dear God, why do you allow violence in schools?" "I'm not allowed in schools. -- God"

As many people have pointed out, the implication is that, against all theology, God—or at least the God of sanctimonious T-shirt wearers—is not omnipresent. That a simple legislative measure is sufficient to banish God from a place.

But if you point this out, or indeed dare to make fun of a religious idea, institution, or person in a public forum, you’ll see veiled threats of hell:

godly comments

I’ve found that Christians far prefer veiled threats over overt ones. I think they’re uncomfortable with their own beliefs, and prefer to skate around them. Or maybe what they believe deep down isn’t what they believe in public. At any rate, the usual response I get is that Hell, in the afterlife, is simply an absence of God.

So, it’s like a school, I guess.

I’ve attended public school, and I still go there, for special events. I’ve never seen a pitchfork or smelled a lake of molten sulfur (and if there were, I’m sure there’d be railings so you didn’t fall in accidentally).

But really, if The Bad Afterlife is like being in an American public school, then sure, I’ll take that. It sounds an awful lot like ordinary life right now.

Posted in :-), Politics, Religion, Uncategorized | Tagged , , | 1 Comment

City Mileage

I’ve known forever that city mileage for cars is worse than highway mileage, but I never knew why. But it’s a bit like riding a bike.

When you ride a bike, you have to put in a lot of work at the beginning, getting up to speed. And after that, you can mostly coast. Assuming you’re on flat ground, you have to pedal a bit because friction is slowing you down, but it’s nowhere near how hard you had to work getting up to speed.

And then you stop at a red light, and you throw away all the energy you had, so that when the light turns green, you have to put in another burst of work getting up to speed. And, of course, in the city you’re stopping like this all the time. Every few blocks, you throw away all your accumulated energy, and have to start over. This applies to cars the same way as to bikes, except that on your bike, you immediately sense this in your legs, not at the end of the week when the tank is empty.

So it’s not that highways somehow enhance your mileage. Rather, it’s cities that make for wasteful driving. It’s a bit embarrassing that it took me this long to figure it out, but better late than never.

Posted in Science, Things I've Learned | Tagged , , , | 4 Comments

Your Child Died Because ________

Another week, another mass shooting. The biggest one in recent history, the headlines tell us. And while it’s awfully, tragically familiar, I draw some small portion of comfort from the fact that I’m not so numb that I don’t feel angry and disgusted.

In the TV series American Gods, there’s a scene where a faulty railing at a weapons factory gives way, a middle manager falls into the molten metal below, and eventually the insurance company settles with the victim’s family. All of this is because there’s a god of guns, and he needs the occasional human sacrifice. When it aired, some people lost their shit over it, because rawr rawr rawr Holy Second Amendment and how dare you bad-mouth guns, which have never done anything bad?
And then another shooting happens, in Las Vegas or Orlando or Blacksburg and you realize that the authors’ error lay in him only demanding one sacrifice, not twenty or fifty or a hundred.

I got into a discussion about this today. I say “a discussion” and not “an argument” because I did try to remain civil, to listen to the pro-gun side, and see what they had to say. I didn’t want to stereotype gun advocates, and I’ve been pleasantly surprised before, so who knows?

Unfortunately, what I got was long on rhetoric and short on facts. My interlocutor was apparently quite willing to have shooting after shooting after bloody shooting in order to preserve his right to have whatever kind of gun he deemed fit.

He kept bringing up self-defense, which is fair. But surely you don’t need a semi-automatic to defend yourself against muggers, rapists, and burglars, do you? So he pointed me at an article about why yes, you do.

The post starts out laying out some basics, including the fact that in the case of a burglary or home invasion, the main thing is to stop the intruder from intruding, and whether that involves him being shot or killed, well, that’s a secondary issue. But the point of the article is to explain why a handgun isn’t sufficient:

Now you can shoot somebody once with a feeble handgun round, and instantly incapacitate them.  Great.  You won.  But on the same token, we’ve got people that have been shot a dozen times with duty ammo who walk under their own power into the ambulance.   Humans are amazing.

So if people can be so amazing, and I want to stop them right now, then I want to maximize the amount of trauma I inflict on them.  This is where rifle caliber carbines and shotguns rule.

This is where I call bullshit. This is an action movie plot, not a real-life category of crime that we should be worried about. This isn’t a thing. If it is, show me the stats. Show me the stats on burglars who take two or five or ten bullets and keep coming. From the FBI or CDC, not your Walking Dead fanfic.

Which leads me to my gun debate challenge: If you’re going to argue for gun rights, do it in the form of a letter to the parent of one of the children killed at Sandy Hook. Begin with “Your child died because …”, and make your case for who should be able to own which weapons, and how you propose to prevent abuse, and deal with the inevitable mistakes. And if you’re not a garbage human, you’ll at least try to end with “… so that fewer parents have to endure the heartbreak that you did.”

I also got the inevitable “guns are for shooting at government representatives in case of “tyranny” line. But while I’m not unsympathetic to this line of reasoning, the fact is, that ship sailed long ago. It may have been possible, in the XVIII c., to envision a citizen militia posing a serious threat to the federal government, in the 21st century, the idea is laughable.

Look at Ruby Ridge. At the Branch Davidian compound in Waco. At Afghanistan. At Iraq. At Cliven Bundy, and at the Malheur National Wildlife Refuge. As much as people complain about needless violence and death, and rightly so, still, in every case, the US government is holding back.

I think the closest analogy to what the people arguing “tyranny” have in mind is Afghanistan: loosely-organized, highly-motivated coalitions of citizen fighters waging a guerrilla war against the US military. And yet, the US does not engage in Dresden-style carpet bombing. It uses memes (what used to be called propaganda) to try to win hearts ad mind. It uses satellites and reconnaissance to try to distinguish friend from foe, and limit civilian casualties. But all that is thousands of miles away from the average mainland American, who hasn’t been asked to help the war effort by planting a victory garden or collecting scrap iron, as in World War II.

Now, imagine that, by some miracle, the rebels grow stronger, and the “tyrannical” Government decides that its very survival is at stake so it stops holding back, stops trying to take them alive. The rebels hold Fort Knox, and have all of the Uzis and Kalashikovs they think Obama confiscated, and who knows how many buildings full of bullets?

Against that, the US military has several thousand Tomahawk cruise missiles, just to name one off the top of my head. And bombers, and drones, and nukes. What I’m getting at is that the US military is very very powerful, and very very good at its job when it wants to be, and its job is to ruin your day in the worst possible way.

So yeah, I’m not buying your argument of shooting at federal employees because of “tyranny”. Power fantasies are not a solid basis for public policy. You’d think that would be obvious, but apparently it needs to be repeated:

Power fantasies are not a solid basis for public policy
, you fuckers.
I get standing for principle. I do it all the time. I even agree with Ben Franklin’s dictum that “Those who would give up essential Liberty, to purchase a little temporary Safety, deserve neither Liberty nor Safety”. But note that he didn’t say, “don’t give up an inch of Liberty”. It doesn’t even say, “don’t trade Liberty for Safety”. What it does say is, if you’re giving up some measure of liberty, make sure it’s worth it.
Yeah, I get that you want to protect yourself and your family. I also get that it’s fun to shoot guns. But if that Liberty means a permanent loss of Safety such that we have to endure one mass shooting after another, until the pictures of dead children all run together, then the price is too damn high.
To quote The Onion, “‘No Way To Prevent This,’ Says Only Nation Where This Regularly Happens”. Literally every other first world nation on the globe has figured this out.
So that’s where I now stand: if you’re going to argue for gun rights, you have to explain yourself to the parents of a dead child. Have at it.
Posted in News | Tagged , , , , | Leave a comment