2007/02/28

Spotlight, LaunchServices and backup volumes

When I select a file in the Finder and right click to "Open With ->", the system pauses, my backup hard drive spins up, and I get a menu showing 5 or 6 duplicate entries for, say, VLC.app.

My backup volume is often online, so it's visible to LaunchServices and Spotlight, et al. Maybe this is the root cause of my problem. But I need to leave the backup volume online because it shares a hard drive with other volumes that I need.

What to do? Is this a problem with Spotlight? With LaunchServices? Regardless of Finder misbehavior, I don't want Spotlight indexing my backup drive; it's just a mirror of my boot volume. Time for some googling.

Spotlight Indexing



From ~stevenf: Disabling Spotlight for a Volume: To see if indexing is on for a volume:
$ sudo mdutil -s /Volumes/Backup


To get rid of the index for a volume and ensure that it is not re-indexed in future:
$ sudo mdutil -i off -E /Volumes/Backup


I've just performed these steps and will see if it works following my next backup.

I'm using SuperDuper to do periodic, full backups. Their forum says that SD will honor Spotlight indexing preferences for a target volume:
As of v2.0, when used with Tiger 10.4.3 or later... just add the volume to the Privacy tab of the Spotlight preference pane. We'll automatically ensure that that state is maintained, and all should work fine.


Of course I can't figure out how to add the volume to the Spotlight preference pane. I've tried dragging it in, but it doesn't show up in the list. Hence the above shell commands.

LaunchServices Caching



Since LaunchServices is already caching redundant references to my backed-up apps, with apparent disregard for duplicate (Unix) pathnames. So I also need to clear its cache. I've used these steps:

$ cd /Library/Caches
$ sudo rm com.apple.LaunchServices-*.plist


I've also restarted my system, since I didn't know whether it would suffice to log out and back in, or to simply kill launchd from within Activity Monitor.

Just now everything is looking good.

2007/02/26

A Breath of Fresh Air: To Fight TB, Open a Window: Scientific American

A Breath of Fresh Air: To Fight TB, Open a Window: Scientific American: "Escombe says the riskiest areas of hospitals are waiting rooms and other places where people congregate before being diagnosed. In a prior study, he and co-workers found that 30 percent of emergency department staff in a Lima hospital became infected with TB during a year."

Installing mod_python for Python 2.5 on Mac OS X

Django wants to be served from behind Apache, using mod_python. I want to use Python 2.5, but the MacPorts/DarwinPorts mod_python port wants to use Python 2.4.

I downloaded mod_python 3.3.1 from the mod_python downloads page and was able to install in a few easy steps:

$ ./configure --with-apxs=/opt/local/apache2/bin/apxs
$ make
$ sudo make install
$ sudo vi /opt/local/apache2/conf/httpd.conf
# Add this line
LoadModule python_module /opt/local/apache2/modules/mod_python.so


Then restart the web server.

All of the warnings in the mod_python README about Mac OS X 10.2.x and Python and libtool and static libraries appear not to matter for OS X 10.4.

Testing w. Django



To test the installation I set up a virtual host pointing to my Django app, following the instructions in the Django docs.

The hardest part was realizing I needed a virtual host (the IP address for which I hardwired into my /etc/hosts file). That was the easiest way to let my app continue to use its absolute URL paths; learning how to adapt to different installation "mount points" looked a bit harder.

The next hardest part was putting the subversion workspace for my project where the web server user (www) had permission to traverse to it.

Integrating MacPorts Apache 2 with System Preferences

Just returned from PyCon 2007, and wanted to try out a few of the new web frameworks tools I'd seen. To get started I needed to be running my own installation of Apache, instead of the system default installation. The latter does not AFAIK include sources, and that makes it difficult to add things like mod_fastcgi.

Install Apache 2


I used the MacPorts/DarwinPorts version of Apache 2:
$ sudo port install mod_fastcgi


Configure /etc/hostconfig


Following hints from elsewhere on the web, I tried to ensure Apache 2 would start at system boot by adding this line to /etc/hostconfig. (Haven't tested this yet.)
WEBSERVER=-NO-

APACHE2=-YES-



Fake Out System Preferences


To tell System Preferences Sharing->Personal Web Sharing to start Apache 2 rather than the system default Apache 1.3:
$ cd /usr/sbin
$ sudo mv apachectl apachectl-1.3
$ sudo ln -s /opt/local/apache2/bin/apachectl apachectl
$ pushd /opt/local/apache2/conf
$ sudo cp httpd.conf.sample httpd.conf
$ sudo vi httpd.conf
# Add this line somewhere near the DocumentRoot directive
PidFile "/private/var/run/httpd.pid"


Move Static Content and CGIs


I made sure System Preferences was able to start the new web server, and then double-checked that I actually was getting content from my new document root :) Then it was time to move static content from /Library/WebServer/DocumentRoot to /opt/local/apache2/htdocs, and cgi-bin executables from /Library/WebServer/CGI-Executables to /opt/local/apache2/cgi-bin.

Copy CGI-Bin Configuration Directives


Finally I had to copy the configuration section for my Trac projects to /opt/local/apache2/conf/httpd.conf.

All done.

Update



Oops, not quite. I want the log files to be under /var/log/httpd, where Console.app expects to find them. So CustomLog and ErrorLog need to be fixed up in all of the *.config files under /opt/local/apache2/conf/.

2007/02/04

New Scientist: Vaccine zaps allergy in record time

Vaccine zaps allergy in record time - health - 04 February 2007 - New Scientist

I've often wondered why an effective treatment for an allergy is to expose the sufferer to more of the allergen. According to the article (emph. added):

Existing vaccines for allergies involve three to five years of regular injections with increasing amounts of allergen... All the while the immune response slowly changes from a predominance of T-helper 2 (TH2) cells, immune cells responsible for triggering allergic reactions, to T-helper 1 (TH1) cells, which stimulate the production of protective antibodies.


So the trick is to make sure the vaccine contains only a small dose of the allergen -- so as not to kill the subject? And yet, as the article says,
Because nothing is directing allergens to the right place in immune cells, it takes a lot of allergen to generate a response.


The new vaccine is structured to deliver the allergens/antigens to the right places.
"[Components in the new vaccine] lower the dose needed to induce a T-cell response by a factor of about 100," says Reto Crameri of SAIF, lead author of the study.

2007/02/02

What made the 1918 flu contagious?

Pandemic flu may be only two mutations away - health - 01 February 2007 - New Scientist Space

What a virus needs to spread, the CDC team concluded, is an ability to bind 2,6 sugars, whether or not it needs this to replicate... One clue, they speculate, is that ferrets with non-contagious viruses... do not sneeze. Contagious ferrets do.

“The cells with 2,3-sialic acid receptors have been associated with the bronchial mucins,” Tumpey told New Scientist. This viscous secretion might inhibit these viruses, and prevent the irritation that causes sneezing, which “may contribute to the spread of influenza, at least in ferrets”.

...the CDC results suggest finding out what mutations make H5N1 bind to 2,6-sialic, as those could make it contagious.

2007/01/14

Multi-touch

One of the most interesting traits of the upcoming Apple phone is its multi-touch user interface. I'd never heard of multi-touch until about a year ago, when Jeff Han's NYU website made the blog rounds.

This evening I finally tripped across the first public demonstration of NYU's multi-touch interface, from last February's TED conference. It's a fascinating presentation, especially when Mr. Han begins musing on data visualization applications. (And it's pretty cool when the audience "gets" it.) He makes it easy to imagine new ways of interacting with molecular depictions and n-space grid projections.

The NYU website carries a new teaser:

Yes, we saw the keynote too! We have some very, very exciting updates coming soon- stay tuned!

Fun times.

2007/01/04

27B Stroke 6

27B Stroke 6:

"When President Bush signed a long overdue postal reform bill on December 20, 2006, he added a few footnotes, including one that exempted the government from needing to get a court order to open mail when there was a 'need to conduct searches in exigent circumstances, such as to protect human life and safety against hazardous materials, and the need for physical searches specifically authorized by law for foreign intelligence collection.'

That led to this AP story, which said that the move 'might have opened the way for the government to open mail without a warrant.' I think clearer language would be that the move clarifies that the government believes it can open mail without a warrant.


These buggers are nibbling away at our freedoms. I wonder if mine will be the generation which finally lets them have it all.

Trivial, but related: Bobi, Aigerim and I tried to visit our parents during the holidays. We made it to Denver. Our luggage got all the way to Lincoln. When it returned, the gift wrap on the presents in my checked bags was torn. Re-wrapping the gifts to send by mail, I found they'd been opened and re-sealed with cheerful "TSA" tape.

All for our safety and security.

2006/12/30

Global Voices Online » Blog Archive » Kazakhstan: where are we going to be in 15 years?

Global Voices Online » Blog Archive » Kazakhstan: where are we going to be in 15 years?.>

Interesting synopsis of the recent past of Kazakhstan, with several guesses as to the future.

Leila Tanayeva:

15 years ago we were different: we had huge lines to the shops that had nothing to sell, we experienced electricity black-outs, lack of heating, state monopoly on everything and huge inflation.

15 years have changed us: we now have polite salespeople in Gucci stores, we go to corporate parties with our colleagues from multinationals, and we travel around the world (that is when we are asked about Borat’s film!).


When Bobi and I were in Karaganda, our translator Olga explained to us that many of the signs of commerce we saw -- a business in practically every building, cell phones everywhere, fresh bananas from Ecuador in every shop, supermarkets reminiscent of the Åhlens in Linköping -- had not existed even seven years ago.

She remembered her first cell phone and its volatile signal strength. "Sitting in the back of my classroom I could get a signal, moving away from a window I could not." (Sounds like every cell phone I've ever had...)

She laughingly remembered the sudden appearance of oranges. They didn't have much else, she said, but they all carried oranges because they could.

For a few days in September (and, I hear, again in the spring), parts of Karaganda still have electricity black-outs. And the whole city has no water during that same period, while the city engineers switch the hot water on. But these are planned outages, probably not what Leila referred to.

Adam Kesher:
...those in the middle were waiting for democracy and money, poor were waiting for money and democracy, and [those having] oil-riches - for money, without democracy...


That's a noteworthy detail for those engaged in rebuilding countries: when you lack food, shelter, clothing and democracy, you may be least interested in the last of these. Let's eat, then let's talk about voting rights.

I guess we could stand to remember that democracy is a luxury here, too, one easily lost through neglect.

2006/12/22

Where news stories go to die

Where news stories go to die:


By Marc Hedlund


The Homeland Security Department admitted Friday it violated the Privacy Act two years ago by obtaining more commercial data about U.S. airline passengers than it had announced it would...


Even so, in a report Friday on the testing of TSA's Secure Flight domestic air passenger screening program, the Homeland Security department's privacy office acknowledged TSA didn't comply with the law. But the privacy office still couldn't bring itself to use the word 'violate.'


There's no better way to try and bury [this story] than to release it on the slowest news weekend of the year.



They must really not want you to know about it. I want the opposite, so I'll post this again in the New Year.




Go get 'em, Marc.

2006/12/16

The Mummies of Xinjiang and the Amazons

Too busy to yammer at length -- getting ready for Christmas.

From Discover Magazine, 1994: The Mummies of Xinjiang, comes another reference to the Golden Warrior:


...also, in 1970 in Kazakhstan, just over China's western border, the grave of a man from around the same period yielded a two-foot-tall conical hat studded with magnificent gold-leaf decorations. The Subashi woman's formidable headgear, then, might be an ethnic badge or a symbol of prestige and influence.


This week the local PBS HD station aired "Secrets of the Dead: Amazon Warrior Women", about archaeological investigations related to the legend of the Amazons. It focused on the work of Drs. Jeannine Davis-Kimball and Leonid Yablonsky, and showed that there could be something to Herodotus's claims that the Amazons married into tribes on the steppes.

At the conclusion of the story Davis-Kimball and her colleagues analyzed the mtDNA of Meiramgul Khoja, a nine-year-old Kazakh nomad living in western Mongolia. They found a direct link to a 2500-year-old warrior priestess whose body was buried beside the Ilek River near the Russia-Kazakhstan border.

The show left a few questions. For example, how did the German forensics experts determine that their reconstruction of the warrior princess should have dark hair? The decision must have had some rational basis, because it was enough to make Davis-Kimball question her efforts to find a light-haired woman among the Kazakh nomads.

Questions aside it was an interesting episode. Makes me want to go a-Googling in several directions at once -- nomads, steppes, the Circassians, less-relevant topics like Bukar Zhirau...

2006/11/28

Copying Syntax-Highlighted Text from TextMate

TextMate has great syntax highlighting skills. Sometimes I'd like to copy code snippets from TextMate to VoodooPad, and I'd like to bring along the text highlighting. A simple copy-and-paste from the TextMate edit window doesn't do the job -- after all, it's a text editor.

Fortunately it is possible to copy with syntax highlighting. The procedure is pretty simple, if a bit obscure.


  1. Select the text of interest in TextMate.
  2. Select Bundles->Experimental->View Document as HTML
  3. A new "View Document as HTML" window should appear.
  4. Select the text in the window and copy it to the clipboard (Command-C).
  5. Switch to Voodoopad and paste (Command-V).

What About MarsEdit?


With a little more work you can paste syntax-highlighted snippets into MarsEdit.

Start out as above. Once the "View Document as HTML" window appears, select View->View Source. Another new window should appear which contains raw HTML.

Select it all (Command-A), copy it (Command-C), switch to your MarsEdit window and paste (Command-V). But first you'll need to re-work the content a bit, since it includes a <style> section which applies to your entire post.

Be sure to collapse the entire style section onto a single line, lest Blogger should insert a bunch of <br/> tags.


Here's an existence proof:



def geoMean(x, y):
"""Get the geometric mean of x and y."""
return math.sqrt(abs(x * y))



2006/11/26

Changing Mac OS X File Icons

I thought that, if you wanted to set the icon for a non-application file in OS X, you had to go through a convoluted process that involved copying the icon from another document. But it turns out you can just compose your icon with your favorite graphics tools, then copy and paste it into place.

For example, I wanted to change the icon on a QuickTime movie file. Here's what I had to do:


  1. Draw the icon graphics in OmniGraffle.

  2. Select the icon graphics.

  3. Edit->Copy (Command-C).

  4. Switch to the Finder.

  5. Select the QuickTime movie file.

  6. File->Get Info (Command-I).

  7. Select the document icon in the top left of the info window.


  8. Paste in the new imagery (Command-V).



Sweet!

2006/11/21

Lonely Planet finally discovers Kazakhstan

When we were preparing for Bobi's first adoption trip to Karaganda, we were surprised at the dearth of travel information for Kazakhstan. Even Lonely Planet seemed to know nothing of the world's ninth largest country.

Thanks in part to Sacha Cohen they're finally catching up.
Lonely Planet | On the Road.

2006/11/12

Midterms

Many of my friends are downright gleeful about the outcome of the mid-term elections. Some are registered Democrats who vote a straight party line (how can thinking people do that?), so of course they're happy. But even those of independent persuasion act as if they've steered our country onto a new course. I'm betting we've just jumped out of a Ford and into a Chevy, and have resumed driving down the same road.

Lemme try to persuade myself otherwise.

Good leaders can emerge from the two-party system. Harry Truman was a devoted Democrat who came to national politics by way of the Missouri political machine. Ironically, he was a student of world history who revered democracy. By most accounts he did good things for our country and for the world.

The two parties can effect change. In 1994 the Republicans took control of the House of Representatives. They had made a list of specific things they'd accomplish in the bargain. They delivered on one promise which most people could agree was good: they balanced the Federal budget.

(Granted, the budget didn't stay in balance long enough to make a dent in the national debt, and we're still going to be in a world of hurt when the baby boomers retire. But as a frustrated member of the Concord Coalition I was encouraged.)

It is still possible to choose representatives, not brands. From Doc Searls:

"Some of the best evidence of voter independence comes from the Lieberman election in Connecticut. Forget how you feel about the candidate. Look at what the voters did. They elected an independent candidate who had lost the primary of the party that 'won' the national race for seats in Congress. Something independent was happening there. It was bigger, and deeper, than partisanship. As Dave puts it, we've never had so much power."

Hm. Feeling a little better... Still, I'm going to set my expectations low. If this congress can weaken the Military Commissions Act of 2006 I'll call the midterms a success.

2006/11/10

Welcome to Mountain Standard Time

For her first 11 days in New Mexico little Aigerim had a really hard time getting to sleep. If somebody was awake and in the room with her she would squirm and play through the middle of the night, just as if it were mid-day. (Which, of course, it was, in Kazakhstan.) And if she were put in her crib? She would howl like a wounded beast. Didn't matter whether the lights were on or not. Of course she'd sleep soundly during the day.

This week we tried something different. I'd come over every morning at 8 to bring hot coffee to Mom and warm formula to Aigerim. Bobi would sneak in a quick shower while Aigerim topped off her belly. Throughout the day Bobi's mantra was, "Keep the baby awake," (except for one short nap).

It worked. Aigerim has slept through the night for four nights in a row. And she has been getting sleepy earlier and earlier. Last night she was lights-out by 8:30, which puts her almost on her Malutka schedule.

It helps enormously that she's bonding so well with Bobi. Before, unless she was totally exhausted, she would start crying the instant she touched the crib. Now she knows everything is okay. Mom is there for her, to sing lullabies and rock her to sleep, and again to greet her with hugs and kisses (and a bottle) in the morning.

The baby loves hanging out with us in the living room in the evenings, playing and grunting and making little babbling sounds. She gets so happy at our noises that she has to stand up, big tongue-lolling smile, and bounce vigorously for a few seconds. We know she's getting sleepy when her head suddenly plops down on the back of the couch, or on Mom or me. A few rounds of bouncing and plopping and she's ready to snooze.

It's pretty wonderful to see her happy again, just like the baby we met in Kazakhstan.

2006/11/09

Kazakhstan: Rules of the Road

Bobi and I live in Santa Fe, where many drivers seem to be either oblivious to their surroundings or just plain incompetent. But after a few weeks in Karaganda we realized how dull Santa Fe's driving is. Here are some rules of the road for Kazakhstan, as deduced from the back seat of an Audi.

Rules

Seat belts look stupid. Do not wear them.[1]

Horns are communications devices, not just blame throwers. A short "toot toot" means "I'm behind you / just to the left of you," or (when addressing a pedestrian) "I've just arrived to drive you somewhere". A short but full honk means "I don't care if there's oncoming traffic. Turn already." A long blast means "Thank you for stalling your vehicle on the road. Even though you cannot move, get out of my way!"

All vehicles have the right of way over pedestrians. Always.

A pedestrian within a cross-walk, if she or he will impede your motion, is a fair target for honking. If you can possibly squeeze through in front of the pedestrian, e.g. while turning right through a cross-walk, do so. Use short horn toots to further intimidate the pedestrian.

Almaty Amendment: If a pedestrian is within a cross-walk which has no dedicated traffic light, stomp on the accelerator and see if you can tap his or her kneecaps with your bumper.

If a pedestrian is walking away from you in an apartment courtyard, and if she or he veers within five feet of your intended lane of travel, honk at him or her.

Painted lane markers are for making the road pretty. Put the car any place that will give you the biggest advantage. If another driver might interfere with your plans, honk at him or her.

If you are at a red light but can see that the light may turn green within the next minute, start creeping into the intersection. If the light will turn green within the next 15 seconds, get a move on.[2]

Other Observations

Some cross-walks are displaced about 30 feet from the nearest intersection, and are equipped with their own traffic lights. This can be a blessing for pedestrians, as it means they need to expect danger from only two main directions.

There are lots of collisions on multi-lane freeways. We saw five or six accidents on the stretch of Gogol which runs past the Afghan war memorial. I'm not sure if they all involved left turns or not.

The preceding may imply that Karaganda roads are full of reckless drivers. But the situation is more complex. For example our driver, Vladimir, obeyed most of the rules noted above. But he also shifted gears much more smoothly than I ever will. And no matter how abrupt his initial braking needed to be in order to avoid a collision, he always modulated the brake pressure so that we came to a stop with no forward/backward bobbing of the head. In short, he was aggressive and good.



[1] Actually, I admire this "rule". Despite my exaggeration, seat belts are a personal choice in Kazakhstan.

I remember when seat belt laws were passed in Ohio, by then-governor Richard Celeste (D). He spoke at my university shortly afterwards and took questions from the audience. When asked why he had chipped away yet another personal freedom, the Governor explained that he had passed the weakest law possible. ("You can't be pulled over for not wearing a seatbelt, but you can be cited for not wearing one if you are pulled over for another reason.") And he explained that, if he had not passed some form of seat belt law, the Reagan administration would have denied highway funds to the state of Ohio.

[2] This is almost the exact opposite of the rule in Santa Fe. There, if the light has turned red any time within the past 15 seconds you should just keep going, la lala lala.

2006/11/08

Firefox 2.0 and display:inline-block

If you want to use <span> markup to define CSS-styled buttons with background gradients, and if you want to control the heights of those buttons, and if you are using Firefox 2.0, you have to jump through some non-standard hoops.

Firefox 2.0 doesn't support display:inline-block. If you have the Web Developer extension installed, it will report "Error in parsing value for property 'display'. Declaration dropped." And instead of getting a button with the right height for your background image, you'll get something silly looking, like this:



(I know, the colors look silly too. But that's not important right now.)

Yahoo! search turned up some background information, and a workaround for those who want to make links (<a href="...">) look like buttons:

NCZOnline - Pain with inline-block

Basically, you need to do this in your CSS:


.BtnClass {
display: inline-block; /* Firefox 2.0 ignores this */
display: -moz-inline-stack; /* Firefox picks this up */
}

The comments say that this bug has been logged in Bugzilla, and there's hope it will be fixed in Firefox 3.0.

Works for me with Firefox 2.0 and Safari 2.0.4, both on Mac OS X 10.4.8. Almost:



I'd like the span's text to be centered vertically on a background image.

Here's the cleanest solution so far. Suppose the background image is 24 pixels high and the font size is 14 pixels. Then, doing the vertical centering manually, the y offset is (24 - 14)/2 = 5px. So pad the top of the span by 5 pixels, and set its height to the total height minus the padding.

.BtnClass {
...
background-image: url(some_image.png); /* 24 pixels high */
font-size: 14px;
height: 19px;
padding-top: 5px;
}

In other words, add vertical padding to push the text down from the top of the span, then subtract that padding from the overall span height; apparently the final height of the span is height + padding-top + padding-bottom.

This works reasonably well for both Firefox and Safari.

2006/11/05

Fevers Help the Immune System

(Pardon the "duh" headline.)

Helpful fevers come in from the cold - health - 05 November 2006 - New Scientist

I found this article interesting mainly because I like to let my fevers run -- "bake out the infection". Works for me, but then I've never had a really high, convulsion-inducing fever.

Anyway, interesting tidbits from the article:

It has been found that fevers help the body’s immune system identify an infection and raise an army of white blood cells (lymphocytes) against it.

...[Researchers] artificially created a fever-like state in a group of mice... This had the effect of doubling the number of lymphocytes visiting lymph nodes...

Lymphocytes arriving at the nodes are screened for "killer efficiency" using fragments of potentially infectious material. Lymphocytes that respond to the fragments are found, are then selectively multiplied, and then swarm into the bloodstream to seek out and destroy the invader.


Apparently the extra heat of a fever activates high endothelial venule cells ("gatekeeper" cells, as the article calls them) in lymph nodes. They produce extra surface proteins that capture passing lymphocytes and draw them into the lymph nodes.

Evans says that although it fell out of fashion with the development of modern medicine, the idea of treating disease with heat has a long history: "Hippocrates used to heat patients with cancer," she says. And a century ago the physician William Coley discovered a cocktail of bacteria, dubbed "Coley's toxins", which appeared to combat cancer by producing a fever.

2006/11/04

Six Things Americans Should Know About Kazakhstan

From The Roberts Report on Central Asia and Kazakhstan comes a mini-lesson for geography class:


  1. Kazakhstan is a major oil producer and is assisted by U.S.-based companies in producing 1.5 million barrels of oil a day, with ambitions to raise this production to as much as 3.5 million barrels a day by 2015

  2. In its fifteen years of independence, Kazakhstan has not held one election that European observers could reasonably call “free and fair”

  3. Since 2000, Kazakhstan’s economy has grown at an average of 9% a year, and the U.S. trade volume with the country has doubled since 2004

  4. Kazakhstan continues to arrest opposition figures for political reasons, and two of its most vocal opposition politicians were found dead within the last twelve months under suspect circumstances

  5. Kazakhstan has a majority Muslim population with pro-western orientation, and its well-financed and sophisticated banking sector has the potential to be a critical foreign investor in such fragile states as Afghanistan, Kyrgyzstan, and Georgia

  6. The Kazakhstan government regularly violates the rights to free speech and assembly by strictly controlling its media sector and by continually harassing and curtailing the activities of opposition political parties.