Useful Python time formats for dealing with HTTP headers

Time-formats

  1. HTTP header format. HTTP headers use a particular format, involving abbreviated English names of the days of the week and the months, a comma (after the first of these), day before month before year, 24-hour:minute:second, and GMT. Examples:
    Thu, 01 Dec 1994 16:00:00 GMT
    Thu, 26 Jan 2006 15:01:16 GMT
    Tue, 12 Jan 2010 13:48:00 GMT

    Note that this is different from what is output by Python’s time.asctime() function.

  2. The struct_time object. Python represents time conveniently as a struct_time object, defined at http://docs.python.org/library/time.html#time.struct_time as “an object with a named tuple interface: values can be accessed by index and by attribute name” (accessed 20120523). Here is what the first of the three date-time strings above looks like composed as a struct_time object:
    time.struct_time(tm_year=1994, tm_mon=12, tm_mday=1, tm_hour=16, 
            tm_min=0, tm_sec=0, tm_wday=3, tm_yday=335, tm_isdst=-1)
  3. ISO 8601 standard format. The International Organization for Standardization (ISO) prescribes a standard format for date and time: YYYY-MM-DDThh:mm:ss. See the ISO’s informal description of the standard. (The 2004 revision of the actual specification, which costs money to download, is currently available at this site.)
  4. Compact sortable format. For appending to the names of output files when I need to generate multiple versions, and for use as a sortable but human-readable date-time string, I use a format YYYMMDD_hhmmss. The three dates initially listed above are shown in this format here:
    19941201_160000
    20060126_150116
    20100112_134800

    I haven’t seen this given a standard name in the Python docs, so I call it “compact sortable” format; it is more compact than the ISO 8601 standard format but still easy to read. In cases where it is impossible for there to be more than one output file generated in the same clock minute, I omit the two digits representing seconds.

Time-format conversions

  1. We can use time.strptime and time.strftime to convert to and from a struct_time object using a kind of formatting syntax using %, reminiscent of the more primitive of the string-formatting syntaxes, and similar to that used in C’s sprintf() function. Details are provided in the Python docs cited above.
  2. Examples:
    1. HTTP header format and a struct_time object
      1. generate HTTP header format from a struct_time object:
        time.strftime('%a, %d %b %Y %H:%M:%S GMT', time_struct)
      2. generate a struct_time object from HTML header time format:
        time.strptime(http_header_time, '%a, %d %b %Y %H:%M:%S GMT')
      3. as an identity, deconstruct and regenerate the original HTML header time format:
        time.strftime('%a, %d %b %Y %H:%M:%S GMT', 
                time.strptime(http_header_time, 
                '%a, %d %b %Y %H:%M:%S GMT'))
    2. ISO 8601 format and a struct_time object
      1. generate ISO 8601 format from a struct_time object:
        time.strftime('%Y-%m-%dT%H:%M:%S', time_struct)
      2. generate a struct_time object from ISO 8601 format:
        time.strptime(iso8601, '%Y-%m-%dT%H:%M:%S')
      3. as an identity, deconstruct and regenerate the original ISO 8601 string:
        time.strftime('%Y-%m-%dT%H:%M:%S', time.strptime(iso8601, 
                '%Y-%m-%dT%H:%M:%S'))
    3. produce compact sortable format from HTML header time format
      strftime("%Y%m%d_%H%M%S", time.strptime(http_header_time, 
              '%a, %d %b %Y %H:%M:%S GMT'))
  3. The following brief functions can be used
    def make_struct_time(http_header_time):
        '''Input HTML header-type time string and output struct_time'''
        return time.strptime(http_header_time, 
                '%a, %d %b %Y %H:%M:%S GMT')
    
    def make_http_time_string(time_struct):
        '''Input struct_time and output HTTP header-type time string'''
        return time.strftime('%a, %d %b %Y %H:%M:%S GMT', 
                time_struct)
    
    def make_iso8601_time_string(time_struct):
        '''Input struct_time and output an ISO 8601 time string'''
        return time.strftime('%Y-%m-%dT%H:%M:%S', 
                time_struct)
        
    def make_sortable_time_string(time_struct):
        '''Input struct_time and output a "compact sortable" time string'''
        return time.strftime('%Y%m%d_%H%M%S', 
                time_struct)

Current time

  1. The following generates our current, local time as a struct_time object:
    time.localtime()

[end]

An encounter with Google’s security rules

I attended a Google NYC Tech Talk yesterday evening, entitled “Doubleclick Ad Exchange: Connecting the World of Online Advertising“. It was the most interesting of the several I have been to (the sole exception is one highly technical presentation by Victor Miller a year ago on hashing functions). There was a reasonable amount of detail on some of Google’s strategies for ultra low-latency auctioning of internet advertising, and I was able to enjoy the special pleasure that you get from listening to smart people explaining something they know a lot about. If I was not completely won over by three references to the market’s “invisible hand” in various names, that is the result of my own failure to believe, and Google is not to blame for it.

A sideshow to the talk was a closer look than usual at some of Google’s security rules. Nothing extraordinary, and I don’t think I’m putting the company at risk in what follows, but the cumulative effect left me in a state of mellow reflection (possibly not my normal state).

In the large presentation theater, we were told we could take photographs of things within the theater itself but not of anything in the rest of the space, all of which was completely visible from the open-walled theater. Okay, I understand the “I shall avert my eyes” rule and am even able to observe it. But with something over two hundred strangers in the room, I wonder to what extent the company expects such a rule to be honored. Making a rule without enforcing it can weaken one’s authority if someone decides to test it, and that is a risk when the rule isn’t easy to enforce, surely a temptation to some of the contrary among us.

More interesting was the security downstairs. There were a number of people on line at the desk, waiting as a security officer tried to find someone on the phone to authorize a certain person to enter the building. We all had our IDs ready to show him. But a moment came when the officer let through someone who said he was going to be late to the Tech Talk, and then suddenly all of us who said we were going to the same place were waved through — without anyone looking at IDs, printed Meetup “tickets”, official name lists, or anything else. I was glad to get in without further delay, but I think the security officer must have felt the kind of pressure to which a weak functionary is most susceptible — fear that he might get in trouble for holding up something important. I hope the company asks itself what it says to the outside world when a security officer feels weak and is vulnerable to silly time pressure of this kind. For security to be respected, doesn’t it have to appear confident, patient, and utterly unruffled?

Inside security, I faced the familiar little desk with name badges on it, printed from Meetup’s name list. Google is now using a higher quality name badge than it used to. That gave a more professional feeling to the visit than used to be the case, certainly. What made me smile to myself is that, in the lobby of what must be the most technically innovative company now active in the US, these badges were still being sorted by hand, as they have been ever since I started attending the Tech Talks. And this time, the people who were passing them out actually gave me someone else’s badge, without looking at any of my credentials or even trying to pronounce the last name on the badge to me (I spelled mine out for them clearly). I didn’t realize I had gotten the wrong badge until I got home later in the evening and took it off. Only the first letter is the same as in mine.

I guess I should be glad whoever got my badge didn’t get me in trouble — he could have photographed the opulent buffet (in the off-camera section of the meeting space), or stayed behind past the no-peeing hour in the men’s room, or sneaked out of the building through an unauthorized exit stairway (these were accessible but we were warned away from them in tremulous gentleness by a junior employee).

I suppose it’s something to be grateful for when security, so frightening in our society in the past decade, is handled softly — rather than with the ill-concealed hostility that has become common elsewhere.

On the whole, though I’ve been irked with some of Google’s practices in the past weeks, I came away with a better overall impression of the company than I had when I went in, and that surprises me a little, and pleases me, too.

HTML headers for keeping track of updated webpages

For a scraping project, I wondered if there was a way to find out whether a webpage had been updated or not, without keeping track of it myself. Someone suggested the “last-modified” header that supplies a time and date of last modification; there is also an “etag” header that supplies a hash of the page content.

How do you examine HTML headers? I wrote a little piece of code to report them: on line at https://bitbucket.org/dpb/report_headers .

Conclusion: There are no headers that are always reliable for keeping track of updated webpages. Some sites provide both “last-modified” and “etags”; some provide only one of the two. Some provide none — even major US sites like the Wall Street Journal (wsj.com) don’t send “last-modified”. As a matter of fact, WSJ doesn’t even report “content-length”. So all bets are off with headers. One can use them with sites where they are known to be supplied, but other tools are still needed for sites where they are not.

And when headers are indeed supplied, there’s also the question of whether they are accurate.

William Hung 洪業 (1893–1980) on Confucianism (1980)

Speaking in 1980, the 86-year old William Hung 洪業 (1893–1980) gave voice to one of the main views of Confucianism among twentieth century Chinese intellectuals:

以前中國的考試制度目的是為政府培育順從聽話的官吏,雖然孟子說“天視自我民視、天聽自我民聽”這些好聽的話,但一般來說中國的政府不是為人民的,所以皇帝政權一定得推翻,要建立一個民主的政府。

The goal of the Chinese examination system of the past was for the government to breed compliant, obedient officials. Even though Mencius said “through our people, Heaven sees; through our people, Heaven hears” and other such fine-sounding things, China’s governments did not normally act for the people, and so it was inevitable that Imperial power would be overthrown and a democratic government established.

Quoted in Susan Chan Egan 陳毓賢, Hóng Yè zhuàn 洪業傳 [biography of William Hung], (Taipei: Linking Books [Liánjīng] 聯經, 1992), p. 264.

David Daniels on one’s “other voice” (1998)

For writers and translators struggling to find the right mode of expression, the example of the singer David Daniels holds penetrating promise:

Upset that he couldn’t control the higher tenor-range tones — “I couldn’t sing in the top part of my voice,” he says, “everything would flip and crack, flip up into the falsetto” — he sought the help of a therapist who’d worked with singers with stage anxieties.

“I told her about my other voice,” said the affable Daniels, 31, chatting at the Opera House recently, “how it felt so natural, how I could do anything I wanted to do with it: sing high and low, soft and loud, and never worry about making an ugly, horrible sound. She didn’t understand what I meant by ‘other voice,’ as if it were separate from me, (when) it’s not, it’s part of me, who I am.”

Daniels decided to “make the switch” to countertenor after consulting with his teacher, George Shirley, who wasn’t entirely surprised: Earlier, Daniels had brought him a tape of himself singing a Verdi aria but told him it was a female friend. Shirley loved the sound and after a few minutes realized who it was.

“Everything about me changed,” says Daniels, who grew up in a musical family in South Carolina and sang professionally as a boy soprano. “I had a complete air of confidence and security.” Switching to countertenor, he says, freed him to do “everything I felt dramatically, musically, technically and emotionally that I couldn’t get out as a tenor. I can let myself concentrate on things that are really important — portraying a character and communicating emotion to an audience.”

Jesse Hamlin, “Countertenor of His Times: David Daniels puts muscle into high-voiced roles” San Francisco Chronicle, Sunday, May 31, 1998, p. PK-35. On line at http://www.sfgate.com/cgi-bin/article.cgi?f=/c/a/1998/05/31/PK54634.DTL&ao=all (accessed 20120520).

There are some NPR interviews posted of Daniels discussing this, for instance https://www.npr.org/templates/dmg/dmg.php?prgCode=ATC&showDate=22-Nov-2002&segNum=15&NPRMediaPref=RM

Elia Kazan and questions of betrayal

I have been reading Elia Kazan’s autobiography, A Life. Overall, I like his brashness. But he insists a little too often that he is telling the frank truth, whatever the cost, and that leaves me with a strong impression of defensiveness. How often should someone who is telling the truth sound defensive, after establishing at some point that the truth is what he is going to tell? Kazan also tries to prevent the reader from judging him by asserting that moral standards are mostly hollow and that no one is any more honest than he (Kazan) is. That is a weak tactic, familiar to me from conversations with bullies and manipulators over many years: it can be effective against an individual, but not against all readers in the abstract.

I grew up hearing that Kazan was a bad man who had betrayed his former friends to HUAC. Much more recently, I saw documentary interviews with Kazan and Budd Schulberg, both of whom said that since the Communists and the McCarthyists were equally gangsters, how could there be any question of taking sides with either one? That strikes me as basically correct, whatever qualifications may be necessary. It’s true that there was a conspiracy to numb U.S. public opinion to the brutality of the Soviet Union, and it’s also true that Joseph McCarthy and the company surrounding him were self-promoting bullies. Both camps were indeed gangsters and unworthy of the allegiance of decent people. And beyond that, it’s true that for you or me to give expression to our originality, we have to find ways to get free of the pressure that bullies and manipulators can impose on us. That seems to be the core of what Kazan and Schulberg were talking about, and it’s a good point in any era.

So I got interested in reading what Kazan has to say for himself more broadly.

I was dismayed to find that self-righteous betrayal is indeed a big part of his story — he was monumentally unfaithful to his wife and you can see over and over again that he is ashamed of it, exactly because of his many attempts to excuse it or neutralize the reader’s disapproval.


And then, after all, there is this, which dates from the actual composition of the memoir:

I thought what a terrible thing I’d done: not the political aspect of it, because maybe that was correct, but it didn’t matter now, correct or not; all that mattered was the human sied of the thing. I said to myself, “You hurt another human being, a friend of yours and his familiy, and no ‘political aspect’ matters two shits.” (Elia Kazan, A Life, [N.p.: Da Capo Press, 1997], p. 685)

Two limitations of call-forwarding on Google Voice

It seems that as currently configured, Google Voice does not allow more than one of their numbers to be forwarded to any particular phone number. That means that if I have several visitors staying with me, no more than one of them can have his calls forwarded to my home number via Google Voice.

A second restriction is one I described in an earlier post: that call-forwarding cannot cross national boundaries. I can see that that prevents people from getting around international phone charges, but the rule applies even between the US and Canada, and at the moment US-Canada phone calls are subject to no charges on Google Voice. So in this respect call-forwarding is actually more restricted than ordinary phone service is.

I ran into both of these problems when trying to set up Google Voice as a way of avoiding long-distance charges for someone without computer or cell-phone skills.

Student protests in Montréal and thoughts about tuition

While in Montréal last week, I heard a lot of unsympathetic comments about the protesting students, who have been upset about what my interlocutors describe as a very small tuition increase — much smaller than the 25% per year that CUNY is going to be undergoing starting in a few months.

There were smoke bombs thrown in the subway one morning we were there — the entire system was shut down during rush hour — and earlier there had been bags of bricks thrown on the tracks, with the same result. Riot police used tear gas and percussion grenades against protesters some weeks before we got there. Faculty and students tell me they have been heckled by protesters, some wearing masks, while trying to enter buildings. (The Montréal city government has proposed banning the covering of one’s face during a protest, and the Canadian government is considering a similar law.) So much class time was lost at some institutions that exams have been postponed and at least one campus (Université de Montréal) has canceled graduation ceremonies.

What is most interesting about this is the clear divide between linguistic-cultural affiliations of the students involved — it is “the French” who are said to believe they are entitled to free education, while some (only some) of the others whose opinions I heard in person or read in the papers want to see the army brought in to deal with the situation.

Feelings about free tuition were once high at CUNY, too. Here is a 2010 description from the New York Times:

CUNY colleges once were known as theaters of unrest. In 1970, students shut off elevator service at Hunter College and liberated the cafeteria by serving free food. Helmeted police officers were called, and classes were suspended. In 1976, as CUNY finally faced an end to free tuition, students marched in the streets of Harlem and boycotted classes for three days, while 13 members of the English faculty started a hunger strike.

In 1989, the possibility of tuition increases led students at City College to pour glue and stick toothpicks into the locks of 400 classrooms. Students seized administration buildings and blocked traffic across the city. In 1991, another series of protests prompted classes to be canceled and commencement to be delayed. (The New York Times, December 20, 2010, p. A23)

There are some other documents here:

  • The 26 September, 1967, issue of The Campus, the CCNY paper, reporting and commenting on the decision to end free tuition. See “Compromise Termed ‘Sellout’ by Head of Alumni Group” (pp. 1-2) and “A CU Grows in Brooklyn” (p. 2). More issues of The Campus may be found at the same site.
  • “When Tuition at CUNY was Free, Sort of,” a 2011 account of the older tuition system and its replacement by financial aid. This account appeared as CUNY was preparing to announce tuition increases.

My view is that when something good — education, for example — has a cost to me, I tend to take it more seriously. That goes for both tuition and homework. I am not arguing in favor of exorbitant tuition or unreasonable workloads, though.

I have also found that people who audit my classes never do all the work assigned, even when they’re strongly motivated, and almost always stop attending before the end of the term. It seems to me that the absence of grade-pressure prevents most people from exerting themselves as much as they might.

Call-screening in Google Voice has a problem

According to the current version of its call-screening help page , Google stores callers’ spoken names the first time they leave them, and then reuses those names when a call arrives later from the same number.

But that assumes it is the always same person calling from a given number. That is not a safe assumption by any means, and in effect, it disables the call-screening function because you can’t rely on it.

If many different people call from a single phone number — from an organization, say, or a shared phone — you have no way of screening by caller, only by number. That’s not really call-screening — it’s essentially just the same thing as caller ID. Call-screening is when I decide whether I want to take the call depending on who is actually calling, not what number they’re using.

Cortlandt Alley’s Chinese name

Cortlandt Alley, a short and very narrow passage running south of Canal Street, is one of New York’s most widely seen streets, having been the scene of innumerable film shoots. It may not be well known that the alley has a Chinese name: Tán Mǐnshēng dào 譚閩生道 “Hon. Thomas Tam Way”. The name was added in late 2009.

Thomas Tam (1946–2008, whose Chinese name means “born in Fújiàn”) was a CUNY trustee and community activist. He held a degree in film-making as well as public health and was the director of many short films. So it is fitting that Cortlandt Alley, a film veteran in its own right, should have had his name added.

Chinatown shorthand

Phonetic simplifications in use in New York’s Chinatown — all are in use this month, though I’ve seen them for years:

  • 反 ‘to overturn’ for 飯 ‘cooked rice’
  • 介 ‘to interpose’ for 雞 ‘chicken’ (these have the same segmentals in Cantonese, [kai])
  • 交 ‘to have contact’ for 餃 ‘dumpling’
  • 九 ‘nine’ for 韭 ‘Chinese chive’
  • 才 ‘talent’ for 菜 ‘cooked food; vegetable’

I can’t remember having seen these in actual printed forms — all appear only in handwriting, though sometimes on signs intended to be read by customers.

The ceremonial gateways of Montréal’s Chinatown

Montréal has four páilou 牌樓 ‘ceremonial gateways’ — two small ones on Rue de la Gauchetière and two big ones on Boulévard Saint-Laurent. The small ones are older; their writing (Mǎndìkě Huábù 滿地可華埠 ‘Montréal Chinatown’) runs right to left and they were already erected when we last visited this city, in 1998. The new ones date from 1999 and bear heavy metal plaques listing many dignitaries involved in their erection, including the Mayor of Shanghai at the time, Xú Kuāngdí 徐匡迪. Now 75 years old, Xú has had a long career as a professor of engineering but remains active in Chinese political life.

Both of the large gateways read Tángrénjiē 唐人街 ‘Chinatown’ on the outside. Inside the northwestern one it says zhǒngshì zēnghuá 踵事增華 ‘to inherit a [great] task and increase the level of talent [applied to it]‘ and inside the southeastern one it says zhōnglíng yùxiù 鍾靈毓秀 ‘for concentrated spiritual power to cultivate excellence’.

Resounding phrases are cheap; I would have preferred to find better cooking in this Chinatown. Only Mai Xiang Yuan was actually good enough to recommend (as I have done in a separate post). Mai Xiang Yuan’s sister establishment Délicieux Xiang (满城飘湘) was memorably dreadful and we wondered if the normal cook was off duty, or perhaps the menu was directed at tourists who don’t actually like Chinese cooking.

May the values of sound engineering be applied to all branches of human endeavor!

Nailset = chasse-clou

After some effort, I recalled not only the English word nailset (a punch for sinking a nail below the level of the wood holding it) but also its French equivalent chasse-clou. This tool was needed in the room where we stayed in Montréal recently.

Google Translate was, as usual these days in cases of difficult vocabulary, essentially useless.

Restaurant Mai Xiang Yuan [Màixiāngyuán cānguǎn 麥香園餐館] in Montréal

In preparing for a trip to Montréal, my accomplice and I had trouble finding the names of Chinese restaurants with unalloyedly good reviews on Chinese discussion sites. There were many references to all-you-can-eat dives, where one pays bottom dollar for strong-tasting recipes cooked using ingredients of the lowest possible quality. Obviously, anyone who would recommend such a place is not serious about getting good food. One commentator even said “没有一间好吃” [there isn't a single good place] in Montréal. However, with some persistence we found Màixiāngyuán cānguǎn 麥香園餐館, an excellent dumpling parlor in Chinatown. The name Mai Xiang Yuan means “the garden of wheaten aroma”.

Owned by people from Dàlián 大連 in the former Manchuria, Mai Xiang Yuan offers some 30 varieties of boulettes (shuǐjiǎo 水餃 ‘dumplings’, rendered ravioles by the francophone press). These dumplings may be ordered boiled or pan-fried, as well as cooked in soup, and you get fifteen to an order. There is a smaller range available at lunch.

We ordered the lamb and onion and the beef and celery dumplings, both of which were delicious, with a good balance of animal and vegetable flavors, dumpling-skins cooked to perfect al dente texture, and apparently meat of decent quality. These are philosophically sound boulettes Chinoises, in my judgment.

The lunch menu also has a vegetarian offering, and beyond that there are some salads. Of these, we had the jièwèi sānsī 芥味三絲 [three mustard-flavored shredded things] combining slivers of bokchoy (dàbáicài 大白菜), fried egg, carrots, and rice vermicelli (mǐfěn 米粉), in a mild white vinegar-and-wasabi dressing with a hint of sesame oil apparent, and barely sweetened. This little salad was so good at the start of the meal that we ordered it again at the end, and it left us wishing only to be hungry once more so we could go back to try more kinds of boulettes.

Mai Xiang Yuan’s address is 1084 Boulévard Saint-Laurent and its phone number is the distinctively Chinese (514)-875-1888. At the moment, Google Street View shows a previous tenant of the space, Épicerie Thiên Phat 天發雜貨, but the address is not hard to find. The proprietress suggests visiting outside of the hours 5:30-7:00 pm, when the place is mobbed. We counted 34 seats at 17 small tables; on our arrival at 2 pm on a weekday there were perhaps ten guests already engaged in boulette-demolition. We put away thirty dumplings and two small plates of the salad, paying about CA$25 for everything, including a generous contribution of 15% sales tax to the Canadian economy.

We will be back before long, I feel sure.

A bon mot of Peter Carey about reviews of one’s work (2012)

Peter Carey:

Do you read reviews of your work still?

I try not to. It’s stupid. It’s only driven by ambition and vanity, insecurity.

Nothing good comes from reading reviews. … I’ve had … lots of really lovely reviews full of praise, I can still remember that [bad] review from 1974.

What did it say?

It said, “Broken-toothed, rhythmless prose.”

Why don’t you quit reading them?

It’s hard. Never underestimate the self-absorption of a writer.

Alexandra Alter, “A Mechanical Duck as a Trojan Horse”, Wall Street Journal, on line at http://online.wsj.com/article/SB10001424052702304451104577392430992501296.html, accessed 20120509.

A bon mot of Peter Carey about New York (2012)

Peter Carey:

I feel of two worlds, and New York’s a good place to have your heart in two places. I love New York. I go out and get bad tempered at the crowds on Broadway and start snarling at the taxis.

Alexandra Alter, “A Mechanical Duck as a Trojan Horse”, Wall Street Journal, on line at http://online.wsj.com/article/SB10001424052702304451104577392430992501296.html, accessed 20120509.

Identifying the active bridge adapter for use with a headless virtual machine on VirtualBox

I mentioned in an earlier post that it is possible to use the command line to set the particular bridge adapter required to run VirtualBox, resolving an error that aborts start-up of the virtual machine.

Which adapter is in use depends on how the host machine is expecting to connect to the internet, even if it is not actually connected at the moment. Different airport and ethernet cards identify themselves using (in theory) different MAC addresses and will be assigned different BSD interface names, “en0″, “en1″, and so on. (These names are always of the format [letters][integer].) Since interface names are assigned at system start-up, they may occasionally be different from what you are used to seeing, so it is not a good idea to treat them as fixed.

To direct VirtualBox to use a particular interface — en0, for instance — for a virtual machine “himself”, use

vboxmanage modifyvm himself --nic1 bridged \
--bridgeadapter1 en0

at the command line.

But sometimes it isn’t easy to figure out which interface to use. On models of MacBook Air that have no built-in ethernet card, an external (USB) ethernet adapter is needed, and different USB adapters will have different MAC addresses, meaning that they will each be assigned different interface names. How do you know which interface name should be passed to VirtualBox?

Active interface names are reported by the network interface configuration tool ifconfig when run without options. You can pipe that output through awk to return just the active en- interface name to standard output:

ifconfig | awk -F: '/^en/ { print $1 }'

If you like, you can pass the output of that whole expression to vboxmanage in a one-line instruction:

vboxmanage modifyvm himself --nic1 bridged \
--bridgeadapter1 `ifconfig | awk -F: '/^en/ { print $1 }'`

That should configure VirtualBox correctly so that the virtual machine will boot successfully. The only caveat is that if the virtual machine is already running, you will get an error. Occasionally, when even running ipconfig getifaddr does not return an IP address for the active interface name, I have found it helpful to reboot my hardware and run the filesystem consistency check, fsck.

Doubts about l’affaire Chén Guāngchéng 陳光誠

I wonder if I am the only China-gazer who is puzzled by this whole adventure.

A few weeks ago, the U.S. administration was carefully raising the possibility of selling weapons to Taiwan. There are reasons to think the U.S. no longer trusts the independence of Taiwan’s military, and if so, then that was surely intended to be a bargaining chip to be ceded to China during the upcoming military discussions. Well, that whole set of preparations has been scuttled by Chén Guāngchéng’s move.

I have the impression that Chén’s gambit now leaves the US on the defensive in its military negotiations. Having been obliged to take up a pro-human rights position reminiscent of the first Cold War, it now has no capital left for other gambits. The timing of Chén’s adventure couldn’t have been more effective.

So I suspect his escape from house arrest and somewhat hysterical attacks on the US after leaving the embassy were engineered by some third party. His playing of US actors against each other — the Republicans against the Democrats and the Congress against the Administration — does not look like the way a powerless asylum-seeker would behave. What it looks like is manipulation, and I suspect forces much more skilled and cynical than Chén were behind it.

I wonder if those forces were not in fact Chinese.