Saturday, May 21, 2011
I Think I Figured It Out....
Tuesday, May 17, 2011
Unix sort Insanity (Or is it Just Me?)
I just discovered (after way too much time poking about) that Unix sort does not split fields the way I naively assumed. I had thought that it split on whitespace, the way that awk does, but it does not. It splits on the zero-length "character" between a non-space and space character -- and then the space characters become part of the next field.
The nasty consequence of this is that whitespace-tabulated data that have a varying number of spaces (or tabs) between fields -- as opposed to fields separated by a single space, or a single tab, or single comma if you use '-t,' -- will not sort the way you might think.
For example:
$ STRING="fibble ab de\ngorkle bc cd\n" $ printf "$STRING" fibble ab de gorkle bc cd $ printf "$STRING" | sort -k 2,2 gorkle bc cd fibble ab de
— i.e. the two spaces in front of 'bc' make ' bc' sort ahead of ' ac'.
And
$ printf "$STRING" | sort -k 3,3 fibble ab de gorkle bc cd
— where the two spaces in front of 'de' make ' de' sort ahead of ' cd'.
This explains a great deal of bizarre behavior I've dealt with over the years, stuff I never had the time to drill down and deal with.
My usual fix for this sort of situation is to collapse whitespace into a single space character, sort, and then use my ~/bin/tabulate script on the end:
$ printf "$STRING" | perl -pe 's/[ \t]+/ /g' | sort -k 3,3 | ~/bin/tabulate gorkle bc cd fibble ab de
I hope someone might find this useful. In other words, I hope I'm not the only one who took this long to understand this. :-)
From 'info sort' on Ubuntu:
`-t SEPARATOR' `--field-separator=SEPARATOR' Use character SEPARATOR as the field separator when finding the sort keys in each line. By default, fields are separated by the empty string between a non-blank character and a blank character. By default a blank is a space or a tab, but the `LC_CTYPE' locale can change this. That is, given the input line ` foo bar', `sort' breaks it into fields ` foo' and ` bar'. The field separator is not considered to be part of either the field preceding or the field following, so with `sort -t " "' the same input line has three fields: an empty field, `foo', and `bar'. However, fields that extend to the end of the line, as `-k 2', or fields consisting of a range, as `-k 2,3', retain the field separators present between the endpoints of the range. To specify ASCII NUL as the field separator, use the two-character string `\0', e.g., `sort -t '\0''.
Sunday, April 10, 2011
Imperial Cities
I'm coming more and more to the conclusion that Washington DC is an Imperial City. >
I not making the argument here that the US is an empire (although the argument can certainly be made). I'm talking about what it means to HAVE an Imperial City.
I would suggest the following as archetypal Imperial Cities: Versailles, Beijing, and Edo (now Tokyo). (Given China's long history, Beijing is merely the most recent of its Imperial Cities.) I would contrast them with other Imperial Capitals like London and Rome. (Interestingly, Delhi/New Delhi forms an instructive hybrid.)
Imperial Cities are those that were built from the ground up to be capitals; they aren't centers of commerce or art or scholarship, except secondarily. They were often built to avoid commerce and art and scholarship, in fact. Usually they were explicitly created by a strong central ruler (Chinese Emperors, Louis XIV of France, the Tokugawa Shoguns) as a place to hold hostages — nobles would be required to send some members of their families to be in residence at all times in the Imperial City, or be themselves in residence.
Another major feature of these Imperial Cities is that the Court became its own society to the exclusion of almost everything else. Court Society dictated what people did, what they wore, who was in, who was out, usually in obsessive detail. This was directly or indirectly to the benefit of the central ruler, as anything that distracted the courtiers kept them from doing anything to take away from the center of power.
This is not to say that Court life in London, or its equivalent in Rome or other large capitals was not intellectually inbred or navel-gazing. But as an instructive contrast, if you were a courtier in the British government in the 17th century, you could physically leave the court and be watching a play, or in a coffee house discussing the events of the day with Samuel Pepys, or dining with the founders of modern science at the Royal Society, within a matter of minutes. There was nothing comparable at Versailles.
Washington DC was built from the ground up to be the capital city of the United States. There was little or nothing there before the current city was laid out. Whatever art and commerce that is there is a follow-on to the government.
If the capital of the United States had stayed in New York, or Philadelphia, instead of moving to a constructed city that had no other existence before the government arrived, what might have happened? Would various government functionaries feel closer to the people whose lives they affect, closer to some of the modes of life that exist outside of government?
Most importantly, would the press be so much like Versailles courtiers, dependent for their existence on the people they are, in theory, supposed to be challenging and whose statements they are supposed to be verifying instead of merely repeating?
Cynically, I wonder if having our capital in our primary commercial city would actually make that much of a difference. The New York Times certainly has failed in its duty often enough (they pursued the Whitewater "scandal" long after it was clear that there was nothing to find; they were slack-jawed credulous in the runup to the Iraq War, and so on, and they certainly participate in Broderism at a high level, although not quite at the pitch of the Washington Post). But I'm pretty sure that it wouldn't be worse than what we've got now.
I think the biggest sign that we have an Imperial City on our hands is the signal failure of the press "corps" to actually look at the substance of policy proposals, and their propensity to go with the conventional wisdom (especially when it is dependent purely on superficialities), and to go with horse-race or Inside Baseball-type coverage. ("Democrats say Earth is round; Republicans disagree.") And it's quite sad that this hasn't changed much, or has possibly gotten worse, in the five years since Stephen Colbert nailed them at the 2006 White House Correspondents' Dinner.
Monday, October 18, 2010
Take this GUI and Shove It
Here's a great explanation of why GUI's suck and should only be built on top of command-line interfaces.
Thursday, September 16, 2010
Sunday, September 12, 2010
Dan Savage May Be On To Something Here
Dan Savage has this to say about September 11th (while walking around Manhattan):
On some level I think social conservatives are angry that the terrorists attacked New York City and not Branson, Missouri. Al-Qaeda wanted to attack real America—and real Americans—and they knew that here is where you find both. So in addition to murdering 3,000 innocent people in New York City on September 11, 2001, the terrorists insulted the vanity of America's social conservatives and demonstrated that they shared their prejudices. They're still reeling from the blow.
Friday, September 10, 2010
Not Scared Yet of Atmospheric CO2? You Should Be
It's my impression that most people, even those fully convinced by the science of global climate change, picture the changes that are coming as being pretty gradual, and being such that we (even if only the "we" in high-tech Western countries that don't share borders with low-lying poor countries) will be able to adapt to them to some degree, whatever (nasty) pain they inflict. I've pretty much been thinking that way.
That is: we'll see hotter summers, changing rainfall patterns, more and more powerful storms (Minnesota beat Texas this year in number of tornadoes), beach erosion, and so on. Not to mention the social and political and military implications of climate refugees (the Pentagon is taking this very seriously). But, we think, life will go on, and the human race will survive -- even if life is a lot harder and there's a lot of suffering.
I am no longer so sanguine.
This Scientific American article, How Acidification Threatens Oceans from the Inside Out, is one of the scariest things I've ever read. (The full article is not available online; it's in the August 2010 issue.)
The oceans are getting more acidic due to dissolved carbon dioxide, which forms carbonic acid. (Dissolved carbon dioxide one of the main reasons that Coca-Cola has a pH around 3 in the can.) Not coincidentally, the oceans have been absorbing huge amounts of carbon dioxide from the air -- keeping the atmospheric CO2 levels from increasing even faster than they already are.
Ocean acidification is seriously problematic because most plants and animals in the ocean have evolved to live in a given range of acidity -- and changing that acidity can seriously mess up body chemistry. We're already seeing corals damaged by it, and experiments have shown that small shifts in acidity levels can have big effects on ocean life — reducing reproduction rates, impairing immune system function, and so on: even before acidity gets to the point of simply destroying life, cells and systems in oceanic life forms have to work harder to maintain their internal acidity levels, which takes more resources and impairs their ability to reproduce and thrive.
We're nearing the acidity range where we'll see serious impairment for a large range of sea life — and it might happen quickly, rather than gradually.
The REALLY scary thing about this is that if the acidity messes with phytoplankton (the source of half our atmospheric oxygen), then it's quite simply game over. We're not just talking about a lot of pain and suffering. We're not talking about merely the end of human civilization, or even the end of the human species: we're talking about the end of the biosphere as we know it. Game over, we took off and nuked it from orbit — but we forgot to take off first.
The thing about ocean acidification is that there's no wiggle room at all for global warming denialists. We've got the data on ocean acidity. We've got the experiments on various sea life and the effects of acidity change. There's no remediation possible — no giant space mirror or sulfur in the stratosphere is going to help this. (Sorry, Space Cadets.)
We simply have to lower (or eliminate) our carbon dioxide output. End of story — or end of us.
Thursday, August 12, 2010
Whiskey Tango Foxtrot, Over
In what world is it a reasonable Sysadmin action to stop cron entirely, just to avoid an (otherwise-harmless) email alert from one cron job out of 30+ jobs on a host?
I am not sure why this particular insanity is boggling my mind so much today. (Perhaps some of it is due to the Sysadmin in question first trying to use 'svcadm diable cron' -- FOUR TIMES -- before realizing their typo.)
Tuesday, August 03, 2010
Friday, July 30, 2010
What would the Earth Look like if it didn't Rotate?
Via BoingBoing, scientists calculate what the oceans and land masses would look like if the Earth stopped spinning. It's a lot weirder than I thought.
I love this kind of stuff!
Wednesday, July 28, 2010
Funny and Bizarre
I saw this bizarre and hilarious blog post about TV shows and, well, bizarrity linked last week from Facebook. It's well worth a read. (The author was a writer/producer for The Sarah Connor Chronicles amongst other things.)
Monday, July 12, 2010
The History Channel is SOOO unrealistic!
Via boingboing, a hilarious rant on why the History Channel's World War 2 season is so unrealistic -- even more so than Doctor Who!
Thursday, June 17, 2010
Emo, How'd You Get out of the Attic?
(Emo Philips, that is.)
Emo Philips has posted a bunch of videos on his site, which were otherwise unavailable. This makes me very happy.
My favorite, I think, has to be the Golden Gate Bridge bit. (This is the "Northern Conservative Fundamentalist Baptist, Great Lakes Region, Council of 1912" bit.) Absolutely brilliant.
How Many People Moved Where?
Forbes has an interactive map that shows how many people moved from between US counties based on 2008 data from the IRS. This is very cool.
Friday, June 11, 2010
Caffeine Helps You Get Over Caffeine Withdrawal
Bristol University researchers found that drinkers develop a tolerance to both the anxiety-producing and the stimulating effects of caffeine, meaning that it only brings them back to baseline levels of alertness, not above them.
"Although frequent consumers feel alerted by caffeine, especially by their morning tea, coffee, or other caffeine-containing drink, evidence suggests that this is actually merely the reversal of the fatiguing effects of acute caffeine withdrawal," wrote the scientists, led by Peter Rogers of Bristol's department of experimental psychology.
Wednesday, June 09, 2010
New Favorite Blog
New Favorite Blog: You Are Not So Smart, "a blog devoted to self delusion and irrational thinking."
Especially The Just World Fallacy, which explains a lot about certain political types, and The Duchenne Smile, just 'cause it's neat.
Monday, June 07, 2010
LOST explained in a 3-second Animated GIF
This is hilarious, but if you haven't seen the end of LOST, don't click through.
Animated GIF explains LOST in 3 seconds.
(Via BoingBoing.)
Saturday, June 05, 2010
Flabbergasted
Arizona School Demands Black & Latino Students’ Faces On Mural Be Changed To White.
What the fuck is going on in Arizona?
Meanwhile, in South Carolina, a State Senator describes an Indian-American candidate for governor[1] (and President Obama) as a "raghead".
What the fuck is going on in South Carolina?
(I do realize that idiotic and appalling racism is not limited to Sunbelt states full of cranky white retirees and the state which was the epicenter of the Confederacy. I will not be surprised -- saddened, but not surprised -- if I have to ask what the fuck is going on in Massachusetts in the near future. My point is: what the fuck?)
[1]This is the same Family Values candidate who appears to have had an affair with a political blogger. Yes, she's a Republican.