2007/09/25

Stucco color matching for fun, if not profit

This summer I've bought two buckets of stucco patch for the house. I can't seem to hold a color chart up against the wall and have any chance of picking the right color.

Today I finally realized the digicam could do most of the work.

  1. Tape the color chart to the wall.
  2. Take a picture.
  3. Import it into iPhoto.
  4. Create a new OmniGraffle document.
  5. Create a big rectangle.
  6. Set its fill color by sampling the wall color from the imported photo.
  7. Create a bunch of little rectangles.
  8. Lay them out over the "wall" rectangle.
  9. Set their fill colors by sampling the swatches in the photo.

Stucco Color Matching 145 Solana.jpg

You don't even have to do any white balance correction. Everything in the photo should have its color skewed in roughly the same way.

Seempuhl. Wish I'd thought of this about ten dollars ago...

2007/09/24

Marching Morons

Getting ready to launch a glider at Kamuela/Weimea, Island of Hawaii. 1182 on Flickr.

The war on terror looks so often like a war on civil liberties. Our airports showcase the problem: law enforcement does its job literally and vigorously, enforcing "the law" without regard for whether enforcement is warranted or the law is even constitutional. Vision Aerie's experience at Kamuela airport is just one more example.

And when it turns out that the enforcers have over-reacted? Admit no wrong. Note the good fortune, of those detained in error, that law enforcement has shown such great self-restraint.

2007/09/20

Canon Scanners, Spotlight and OCR

When I scan receipts and invoices with my Canon LIDE 600F, OS X's Spotlight somehow, magically, is able to find them based on their text content. But I'm just scanning the documents, not running OCR software on them.

For example, this morning I scanned the receipt for my new MacBook, so I could send it in for a shipping rebate. Just for grins I then did a Spotlight search for "MacBook". There it was, near the top of the list.

mdls showed that "MacBook" didn't appear anywhere in the file's metadata. And the filename, "File0001.PDF", certainly didn't match. Yet somehow mdfind identified it as a match.

Searching for the string "MacBook" in the PDF turned up nothing. (Granted, I used 'strings -a' to extract the strings, and that command is ASCII only.)

Google, and David Creemer, provided the answer. Creemer also showed that the text in "CanoScanned" documents is selectable in Preview.app.

What's going on? It seems that the CanoScan Toolbox application is automatically performing OCR when it finishes scanning documents. For more info see zachary.com : Easy and cheap PDF Document Management (with OCR) on Mac OS X.

Synergy kudos to Canon and Apple!

2007/09/16

Water consumption in Santa Fe

Future Water, part 1: A big straw:

"Despite growth, the citywide annual demand for water is lower now than it was in most of the 1980s and '90s. Residents used 9,600 acre-feet last year. That compares to nearly 12,000 acre-feet in 2001."


The area's estimated population: 80,000, growing at 20% per year.

Maybe it's okay that I don't water the lawn :)

2007/09/15

Jon Udell: Discussing the re-invention of air travel with Ed Iacobucci

A conversation with Ed Iacobucci about the reinvention of air travel --
This article by Jon Udell ties together several items of significance to me: Eclipse Aviation; the Santa Fe Institute and the BIOS Group (now part of NuTech Solutions); complexity theory, Free Flight, general aviation and Byte Magazine (may it rest in peace).

2007/09/10

Viking ship resurfaces under Merseyside boozer | The Register

From
The Register -- too funny:

"A team from Nottingham University [...] believes it has rediscovered [...] an intact Viking boat under a Merseyside pub - originally unearthed in the 1930s [...], but quickly reburied because [the builders] feared 'an archaeological dig would disrupt their work'."

2007/08/29

www.neweurasia.net - Blogging Central Asia » Kiran over Mongolia: Interview with Joseph Spaid

www.neweurasia.net - Blogging Central Asia » Kiran over Mongolia: Interview with Joseph Spaid:

Q: What motivated you to shoot the documentary?

I was moved by the rugged and natural beauty of the eagle hunters and their lifestyle. Berkutchis [...] are just so damn strong and tough. They typically don’t even wear gloves, although it regularly gets below -25ْ F where they hunt. They are true ‘badasses’ by my definition.

2007/08/28

A'bit an hour of Stephen Fry

Stephen Fry just turned 50. BBC did a documentary on him:
http://www.snitchseeker.com/harry-potter-news/j-k-rowling-potter-stars-talk-stephen-fry-49899/

It seems as if everybody is involved with the man, including many of the folks behind Harry Potter.

Would I could write. A pun of Fry and (six degrees of) Bacon is trying hard to form in my head.


2007/08/23

Ted Leung summarizes Erlang

Some simple thoughts...:

Semantically, there is a lot to like about Erlang - the actor based concurrency model, hot code swapping, higher order functions, and (once one gets used to it) pattern matching. The OTP libraries have been refined by many years of production usage in demanding, commercial applications.

2007/08/20

Posting Syntax-Highlighted Code to the Web, Redux

Following up on July's post, I've modified my TextMate 'rawhtml' command so it no longer generates inline <style> sections. (They may work, but AFAIK <style> should appear only in a document's <head>.)

Instead, the command now wraps its output in a div of class SourceCode, and it expects the containing web page to include an appropriate <style> section.

Here's a test to see if this works :) I've added the following CSS to the Bottled Text template HTML:

div.SourceCode {
font-family: "Bitstream Vera Sans Mono", "Monaco", monospace;
font-size: 12px;
width: 500px;
overflow: auto;
margin: auto;
white-space: nowrap;
padding: 4px;
background-color: #ffffff;
border: 1px solid #777788;
}

div.SourceCode .comment {
font-style: italic;
color: #888;
}

div.SourceCode .keyword {
font-weight: bold;
}

div.SourceCode .string {
color: #00F;
}

div.SourceCode .entity {
text-decoration: underline;
}

div.SourceCode .storage {
color: #888;
}

div.SourceCode .support {
color: #0b0;
}

div.SourceCode .constant, div.SourceCode .variable {
color: #F0F;
}




The "rawhtml" command script now looks like this:
#!/bin/sh
cat <<HTML
<div class="SourceCode">
<div style="white-space: pre; -khtml-line-break: after-white-space;">
HTML


perl -pe 's/<\/[^>]+>/<\/span>/g' \
| perl -pe 's/<([^\/.>]+)[^>]*>/<span class="$1">/g' \
| perl -pe 's/\t/&nbsp;&nbsp;&nbsp;/g'

echo "</div></div>"


To get a realistic preview in MarsEdit, click the "Edit Template" button in the preview window and add a <style> section to the preview template for your blog. Paste in the CSS above and you're good to go.

2007/08/14

Sci Foo 2007 Gossip Liveblog (Aaron Swartz's Raw Thought)

Engrossing summary: Sci Foo 2007 Gossip Liveblog (Aaron Swartz's Raw Thought).

Dyson: Climate models are rubbish | The Register

Dyson: Climate models are rubbish | The Register:

"Dyson can expect another round of crucifixion with the predictable chorus that he's not a climate 'scientist'.
His contention, that the models aren't really science when they're programmed to produce the expected results, will no doubt be overlooked. ®"


I love the way Dyson writes. His article is full of thought-provoking observations and assertions, not all of them as directly concerned with global warming as you might expect. For example:
All our fashionable worries and all our prevailing dogmas will probably be obsolete in fifty years.

2007/08/06

Death, taxes and beyond

I thought bureaucracy could follow you only as far as the grave. But then there's eastern religion:
China tells living Buddhas to obtain permission before they reincarnate - Times Online

Via Ottmar Liebert

2007/07/19

Posting Syntax-Highlighted Code to the Web

Awhile back I noted some ways to copy syntax-highlighted text from TextMate to other applications like VoodooPad and MarsEdit. In some cases it was a simple procedure of two or three steps. But getting syntax-highlighted text into MarsEdit was comparatively tedious.

In all cases the procedure started with the Experimental -> View Document as HTML bundle. This morning I finally got around to browsing that bundle's definition and lo! it's just a simple Perl script invocation.

Better yet, it can act on either a complete document or just the text you've selected within that document. So if you want to post a code snippet? No problem.

It's also easy to make a copy of the bundle which, instead of creating a new HTML document, creates a plaintext document containing the HTML mark-up. You can copy the contents of this document and paste it directly into MarsEdit. (With a few caveats, i.e. you need to modify the stylesheet to avoid affecting the appearance of your entire post.)

The steps are simple:


  1. Select Bundles->Bundle Editor->Show Bundle Editor...

    Picture 4.png

  2. Browse into Experimental and select the View Document as HTML command

    Picture 5.png

  3. Click the "double-plus" button at the bottom of the window to make a copy of the command

    Picture 6.png

  4. Drag the command to some other bundle. I like to keep custom snippets, commands and templates in an @My Stuff bundle, which won't get overwritten when I upgrade TextMate

  5. Select the copied command. Rename it as you see fit, e.g. Format as Raw HTML

  6. Change the Output popup menu's value from Show as HTML to Create New Document

    Picture 8.png



That's it! Now you can select some code which you want to post, select your new command from the Bundles menu, and get a window with (almost) ready-to-post HTML markup.

Next Steps


Keyboard Navigation


If you come from (X)Emacs and wish you could invoke the bundle without having to navigate through a menu hierarchy, you can. Just use Control-Command-T to bring up the Select Bundle Item command window. Then type in the name of your new command, and hit return.

Picture 11.png

If you want to feel even more at home you can give your bundle a name which "feels like" an Emacs command. I've been trying single-word "command name" prefixes, like "rawhtml - Format as Raw HTML". The idea is to give your command both a quick-to-type "command" name, so you can get to it quickly in the command window, and a human-readable name so you can remember what it does :)

Limiting the Scope of the Styling


I haven't had time to do further customizations to the command. The next thing to tackle will be the stylesheet which it generates -- it's written to address an entire document, so it applies styles to e.g. the body element. I'd like to customize the generated HTML so it puts everything into a <div> with a unique timestamp for its id, and to modify the CSS so it applies only to that div. That'll make it easier to create markup that can be dumped directly into a blog regardless of what else might be on the blog page.


Update:
Turns out it was easy to modify the generated styesheet, and to wrap the output in a timestamped div. I'm not sure how righteous it is to include a <style> block inside the body of a blog post, rather than the head, but it renders okay in WebKit and Firefox 2.



Here's the source code for the command, as rendered by itself :)



#!/bin/sh
now=`date +'%Y%m%d%H%M%S'`

cat <<HTML
<style type="text/css">
#source_${now} {
font-family: "Bitstream Vera Sans Mono", "Monaco", monospace;
font-size: 12px;
width: 400px;
overflow: auto;
margins: auto;
padding: 4px;
background-color: #ffffff;
border: 1px solid #777788;
}

#source_${now} .comment {
font-style: italic;
color: #888;
}

#source_${now} .keyword {
font-weight: bold;
}

#source_${now} .string {
color: #00F;
}

#source_${now} .entity {
text-decoration: underline;
}

#source_${now} .storage {
color: #888;
}

#source_${now} .support {
color: #0b0;
}

#source_${now} .constant, #source_${now} .variable {
color: #F0F;
}

</style>
<div id="source_${now}">
<div style="white-space: pre; -khtml-line-break: after-white-space;">
HTML


perl -pe 's/<\/[^>]+>/<\/span>/g' \
| perl -pe 's/<([^\/.>]+)[^>]*>/<span class="$1">/g' \
| perl -pe 's/\t/&nbsp;&nbsp;&nbsp;/g'

echo "</div></div>"

2007/07/18

Firefox 2.x / Linux image scaling

Why does image scaling seem to be so bad in Firefox 2 on Linux?

For one of our web apps we want to show static pixmap images of chemical depictions. Depending on the context we want to show those depictions at different sizes, and we don't want to create and cache too many renderings. We'd rather create one fairly large rendering and have the browser scale it down as needed.

For users who are running Firefox/Win or Firefox/Mac this works fairly well, if the images aren't scaled down too much. (Otherwise lines get too thin, as you'd expect.) But for Firefox/Linux users, the results look horrible.

ff_mac.pngff_linux.png
Firefox/MacFirefox/Linux

What's up with that? Is there any way to control how Firefox downscales images, to get better quality?

Perhaps not. Or not yet, at least. Acts of Volition has an entry comparing image resizing in Firefox 2.x and Firefox 3. Paraphrasing:
The Cairo graphics library will power Firefox 3.
In Firefox 2, if you tell the browser to resize an image it will do so, but not with any of the smoothness that you would see if you had resized the image in an application like Photoshop or the Gimp.

Now, in Firefox 3.0 Alpha 1, resizing an image like this actually produces a smoothly sized image.

2007/07/14

changelog: Parallels 3.0: breaking the network

changelog: Parallels 3.0: breaking the network:

Parallels Desktop for Mac installs a startup item, llipd, which delays network traffic of some forms as much as 5 seconds.


According to /Library/StartupItems/ParallelsTransporter/StartupParameters.plist llipd is a "Parallels Link-local IPv4 deamon" (sic).

I don't need Parallels Transporter, so it's outta there.

2007/07/12

JavaScriptTemplates

JavaScriptTemplates offers template-driven formatting of web-page content, using JavaScript.

It will be fun to try this out. I often need to build web pages in which some of the content is created dynamically, via Ajax requests. The JavaScript which transforms the incoming JSON data to HTML tables can be painful to maintain. But I can't use server-side templating because I don't want to reload the entire page.

JavaScriptTemplates seem to offer a way around this. Not sure how one goes about previewing the templates, which are embedded in hidden textareas. Much to learn...

It will be really interesting to see how this, together with Naneau or Jester, changes development of dynamic web apps.

After the First Blush

Hm, this is a little troublesome:

    var myStr = "Hello ${customer.first} ${customer.last}, Welcome back!";
// Using the process() method is easy...
result = myStr.process(data);

Do they really pollute JavaScript Strings with a process method?

Yes, they do...
String.prototype.process ( contextObject, optionalFlags )

As a convenience, the String prototype is enhanced with a process() method. It parses the String as a template and invokes process(). The arguments are the same as for templateObject.process().

2007/07/09

socket.getfqdn() ignores changes to /etc/hosts

I thought that was the problem, anyway. I'd edited /etc/hosts, changing the fake fully-qualified domain name of my host. Yet, when I launched Python and tried to get the domain name, it still returned the value which had originally been in /etc/hosts:

>>> import socket
>>> socket.getfqdn()


Short answer: after making a change to /etc/hosts, don't forget to flush the lookup daemon's cache:
sudo lookupd -flushcache

Safari Bookmark management

This Mac OS X Hint is helping me learn more about bookmark management in Safari.[1] For example, here's a JS bookmarklet that searches for the selected text in Google, displaying the result in a new window:

javascript:x=escape(window.getSelection().getRangeAt(0));window.open("http://www.google.com/search?q="+x, "_googTab");

I'm not sure about the easiest way to create a new bookmarklet in Safari's Bookmarks bar. So for now I just use the + button to add whatever web page I'm currently viewing; then click the Bookmarks icon, select the new bookmark, change its name, and replace its address w. the JavaScript for the bookmarklet.

Assigning Shortcuts

How do you assign shortcuts to bookmarks? Another hint shows how to do so without having to use the System Preferences => Keyboard and Mouse => Keyboard Shortcuts panel.
defaults write com.apple.Safari NSUserKeyEquivalents '{"Google in New Tab"="@$G";}'

Opening in New Tabs?

Hm... So by using JavaScript bookmarklets, could I implement the 'Search in Google in New Tab' feature for which I've been pining?

Alas, it may be possible, but I don't know how to do it. Once I've put the bookmarklet in my bookmars bar, it doesn't matter whether I left-click or right-click and select "Open in New Tab"; I always get a new window. And if I change the JavaScript to set the current location rather than open a new window, then it always overwrites the current page.

It's too bad that (AFAIK) JavaScript does not yet recognize that many browsers support tabs.



[1]I've missed years of hints and from all over the web that show how to create search bookmarklets, for a host of search engines.) And of course Firefox has a much cooler keymarks facility, which Bob DuCharme explained way back in 2004.

2007/07/07

Replicating iPhone Buttons the 'webkit' way! at LaunchPad Blog

Replicating iPhone Buttons the '-webkit' way! at LaunchPad Blog

This is pretty cool. I've had recent projects where distinct images had to be created for button links, even though they differed only in the button text. Here's hoping CSS 3's border-image catches on with all of the major browsers, soon.

2007/07/04

Wah, crawling is hard

Wired Science - Wired Blogs:

"The researchers say that fake crying, used to get attention though nothing is wrong, is a first step on the slippery slope to deception. The dishonesty, said lead investigator Vasudevi Reddy, can be detected when babies pause to see if they've been heard -- showing that they're 'clearly able to distinguish that what they are doing will have an effect.'"

Aiga taught us about this during our first week in Karaganda. As she crawled laboriously across the floor she made the most pitiful little cries. Yet, when we told one of the other adoptive parents that Aiga was the one, her response was, "Oh, you mean the busy little one who crawls so fast?"

2007/07/02

Saving the Saiga antelope

News from the Caravan: Wild Kazakhstan:
The Rise and Fall of the Saiga
:

One of the main species to be protected is the saiga, an ungulate (hooved mammal) that’s somewhere between a sheep and an antelope. It looks like a critter Dr. Seuss would think up, and the story of the saiga is like that of the truffula tree. From millions to rare, back to millions, and now endangered again, in little more than a century.
"Dr. Seuss" indeed! But it still reminds me of Zoidberg.

2007/06/28

Westinghouse Service - at last

Can it be that our Westinghouse service saga is finally at an end?

Yesterday Westinghouse finally sent us a replacement for our defective LVM37w3.

The new unit is probably a refurb. The serial number is definitely different from that of the one we sent in for repair, and it displays a different message when a new video source is detected.

For the record, it took 55 days for Westinghouse to repair/replace our broken monitor. With that kind of turn-around time, I'd have to advise any prospective buyer to go with a different brand.

2007/06/26

Subversion, Bazaar and Mac document bundles

Subversion has problems dealing with Mac applications which store their documents as bundles (directory trees). The first is that such bundles may contain an icon preview file, "Icon\r", whose filename contains a carriage return. The second is that the bundle may contain files representing e.g. pasted graphics, which come and go as the document is edited. Subversion cannot, as far as I know, add and remove such nested files without user intervention.

Some applications, like OmniGraffle, offer a workaround for the hierarchical document structure. Other applications do not, e.g. LineForm, and VoodooPad, and Apple's own KeyNote and TextEdit.

(That's not quite true. The VoodooPad Lua Plugin Snippets page shows a Lua plugin which handles the hierarchical document problem by automatically adding new documents, removing deleted documents, and committing changes, for a designated directory.)

Does bzr handle either of these problems more gracefully than subversion?

Testing shows that bzr handles "Icon\r" with aplomb. However, it does not automatically add any new nested files to the repository. It's up to you to add them manually, just as in subversion.

2007/06/20

Bug with jQuery 1.1.2, Interface 1.2, Slider with fractions

I have a Slider with fractions and an onSlide handler. Sometimes when the handler is invoked, the reported value for xProc seems to be "lagging" -- it seems to be the value from just before the slider jumped to its current position.

Here's a fragment demonstrating the problem:


<div id="slider_frame">
<div id="bar">
<div id="indicator" class="Indicator"></div>
</div>
</div>
<p id="msg"></p>
...
onSlide: function(xProc, yProc, x, y) {
var fraction = x / this.dragCfg.containerMaxx;
var nearest = Math.round(x / 4) * 4;
var expected = Math.round(nearest * 100 / this.dragCfg.containerMaxx);
$("#msg").html("Expected " + expected + ", got " + xProc);


In the web app where I've encountered this problem, I'm working around it by recomputing the xProc value inside the onSlide handler:
    xProc = parseInt(x * 100 / this.dragCfg.containerMaxx);


Here's a more complete example:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>interactive_problem_demo</title>
<style type="text/css" media="screen">
#slider_frame {
border: 1px inset;
position: relative;
width: 300px;
height: 12px;
}
#bar {
position: absolute;
width: 300px;
height: 12px;
background-color: #99a;
}
#indicator {
position: absolute;
width: 6px;
height: 12px;
background-color: #eef;
}
#msg {
max-width: 300px;
}
.Good {
background-color: #0f0;
}
.Bad {
background-color: #f99;
}
</style>
</head>
<body>
<div id="slider_frame">
<div id="bar">
<div id="indicator" class="Indicator"></div>
</div>
</div>
<p id="msg" class="Good">Please click in the trough.</p>

<script src="../../../shared/js/jquery/jquery.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../shared/js/jquery/interface.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../shared/js/jquery/dimensions.js" type="text/javascript" charset="utf-8"></script>

<script type="text/javascript" charset="utf-8">
<!--
$(document).ready(function() {
var f = 5;
var slider = $("#bar").Slider({
accept: "#indicator",
fractions: f,
onSlide: function(xProc, yProc, x, y) {
var fraction = x / this.dragCfg.containerMaxx;
var expected = Math.round(100 * fraction / (f - 1)) * (f - 1);
$("#msg").html("Expected " + expected + ", got " + xProc);
$("#msg").removeClass("Good Bad");
$("#msg").addClass(xProc == expected ? "Good" : "Bad");
}
})
});
//-->
</script>
</body>
</html>

2007/06/19

Mail.app, pasted graphics, and Windows recipients

[Draft]

Summary

When composing in Mail.app:

  • if you attach a file, its format is preserved
  • If you paste a screen capture, some capture formats will be translated to TIFF
  • Some Windows users cannot view TIFF mail attachments
  • This behavior seems to apply to other OS X applications as well
Here's a table showing how Mail.app translates pasted graphics, under Mac OS X 10.4.9:
Screen CapturePasted Format
GIFTIFF
JPGTIFF
PDFPDF
PNGPNG
TIFFTIFF

Gory Details

If I paste screenshots into my Mail.app messages, some Windows recipients cannot see those screenshots. When sending to these recipients I have to use a much more tedious process:
  1. Save screenshot to file
  2. Compose mail
  3. Click "Attach"
  4. Browse to saved file
Others are dealing with the same problem. Witness this thread at macosxhints.com.

Is the problem that the pasted graphics are set to display inline? (Content-Disposition: inline) No. No matter how I make an attachment, whether through pasting or through the Attach button, Mail.app always sets Content-Disposition to inline. And Windows users can see some attachments.

Is there anything relevant in ~/Library/Preferences/com.apple.mail.plist? Not as far as I can tell.

I have changed my default screen capture format, following the instructions in this macosxhints article:
    defaults write com.apple.screencapture type format
killall SystemUIServer

My format is set to jpeg. That seems to be the problem. Mail.app translates pasted JPEG images to TIFF. Attached JPEG images retain their format.

I'm not sure about the reasons for this, but Preview.app seems to confirm the following weirdness: If you do a screen capture to the clipboard, some formats such as JPG get converted to PICT. If you do the screen capture to a file, then the format you specify is the format used in the capture file.

2007/06/14

Textmate: "Snippet Commands" and Placeholders

Draft

Textmate snippets are chunks of templated text, sprinkled with placeholders of the form

${1:default value}
When you invoke a snippet, it injects text into the current document, and it lets you tab through all of the placeholder fields and edit their values.

Sometimes you need to generate a lot of stubbed-out files in one go, e.g. when creating a Firefox extension. Snippets aren't so useful here, but Textmate commands are. At their simplest these are just scripts (pick a language; I like Python) which you invoke from within Textmate.

It sure would be nice to be able to use placeholders in those stubbed-out files, and to use Textmate as a sort of form editor. For example, the install.rdf file in a Firefox extension bundle has about eight fields which you might want to edit. You can generate default values for these fields when stubbing out the bundle, but several of them (e.g. the bundle ID, or your real-world name) might require customization.

There's a really simple way to create a Textmate command that lets you do placeholder editing on any file.

Open Textmate's bundle editor. Create a new bundle. Name it Fill in the blanks. In the command editor pane, set Save: to Current File. Put this text into the Command(s): text area:
cat "$TM_FILEPATH"
Set Input: to Selected Text or Document. Set Output: to Insert as Snippet.

Save your changes by selecting a different bundle in the bundle editor.

Now imagine you have written a script which generates a stub file. Wherever the file contains a value that you might want to change manually, put that value inside a placeholder, e.g.
${1:default value}
Run the script to generate your stub file. Open the stub in Textmate. Select all of the text, then invoke your "Fill in the blanks" bundle.

Voila! The contents of your stub file have not changed, but now you can tab from one placeholder field to the next, editing the values which your stub generator provided.

*sigh*

So many words for a simple procedure. I should put up a screencast on the Om OS X blog...

Procedure expects parameter '@statement' of type 'ntext/nchar/nvarchar'.

I just re-factored an SQL Server stored procedure to use sp_executesql. Lots of cut and paste. It looked almost identical to a sibling stored procedure, at least in terms of local variable declarations and parameter list declaration. So why, where the sibling stored procedure returned results, did this stored procedure generate this error message?

Procedure expects parameter '@statement' of type 'ntext/nchar/nvarchar'


Richard Dudley had the answer. I had inadvertently declared my @queryStr variable as varchar instead of nvarchar.

Implementing file download links

It's amazing how many basic web developer techniques I still don't know.

I want to provide a file download link. But the URL is not a static path like

http://some.server.com/some_file.csv

Instead it points to an ASP.NET or PHP page, e.g.
http://some.server.com/Download.aspx?item=blah
http://some.server.com/download.php?item=blah

And it returns dynamically-generated, plain-text, comma-separated-value content.

How do I convince Safari to download the file, rather than simply loading it in the browser window? How do I convince Firefox that the downloaded content is really text/csv and not a file of type php or aspx?

The answer, courtesy of the online PHP manual: use a content-disposition header.

To find the details, go to the PHP manual page and search for "Content-Disposition".

Safari / WebKit Feature Request

Google has this nice feature: select "some text" in a web page, right-click, and you see a menu item:

Search current search engine for "some text"
When you select the menu item, Firefox performs the search and presents the results in a new tab.

This behavior is really useful. For example, when you're reading a forum post in which someone cites an API or software product you've never heard of, you can go off and learn more about the citation without losing your place in the forum.

WebKit (and Safari3?) have a similar menu item. Of course, unless you've installed some 3rd-party extensions the search engine is always Google. But the really unfortunate thing is that the search results replace the current page.

Maybe there's a magic key combination which lets you override this behavior, but I haven't found it yet. It sure would be nice if Safari implemented this feature in the same way as Firefox.

2007/06/12

Where's the Clipboard Viewer in Windows XP?

I couldn't find a clipboard viewer anywhere in my XP Start Menu hierarchy. Once again, the web provides. From Where's the Clipboard Viewer in Windows XP?



  1. Click the Start menu button and open My Computer.

  2. Open your C drive. (It's listed in the Hard Disk Drives section.)

  3. Double-click on the Windows folder. (You might have to tell it to let you see what's inside.)

  4. Double-click on the System32 folder. (Again, you might have to tell it to let you see what's inside.)

  5. Scroll down the page until you locate a file named Clipbrd.

  6. Drag and drop the Clipbrd file onto your Start button.




2007/06/11

Shrinking your Visual Web Developer project databases

It's annoying that my web app's SQL Server 2005 database file is less than one megabyte in size; whereas the internal application database created by Visual Web Developer, with which I've never mucked directly, is over 10MB.

Of couse the blogosphere has known about this problem much longer than I have. And here's a handy solution:

Shut-Up and Smile : ASP.NET Membership Database Squish

This script does the equivalent of the SQL Server Management Studio's "Tasks->Shrink" menu item. I have a hard time using that menu item on my application's database file, perhaps because of file ownership issues. Whatever: this script smooshed things right down to size.

2007/06/08

Soot responsible for over 90% of polar warming?

Scientific American reports that soot - from smokestacks, vehicle tailpipes, and even forest fires[1] may be a major factor in polar warming.

Impure as the Driven Snow: Scientific American:

DIRTY TRICK:  Soot is three times more effective than carbon dioxide [...] at melting polar snow, triggering feedback loops that further accelerate polar warming.

In the atmosphere, such aerosols [as soot] can significantly cool the planet by scattering incoming radiation or helping form clouds that deflect incoming light. But on snow [...] such dark carbon [...] may be responsible for as much as 94 percent of Arctic warming.


[1] Why do they say "even"? Let them spend a typical summer in the southwest, and be amazed at the amount of soot a wildfire can dump into the air...

Seriously, the researchers cited in the article say that about 80% of the observed soot comes from human sources. I bet a lot of that comes from around Karaganda :)

Smokestack

2007/06/07

Modifying a wrong commit message in a svn/trac combo

Sometimes I screw up a commit comment in subversion, and need to fix it. I can never remember how to do so. 'svnadmin setlog' seems obviously the way to go, but when I try to use that command I get an error message:

svnadmin: Repository has not been enabled to accept revision propchanges;
ask the administrator to create a pre-revprop-change hook


Here's the right way to do it, including extra steps which make Trac aware of the change:
modifying a wrong commit message in a svn/trac combo

The need for the trac-sync step implies that trac uses a subversion commit hook to record the details of each subversion commit.

2007/06/05

SQL Server: Avoiding multiple record sets

I have a stored procedure which needs to execute other stored procedures in order to generate its results. Unfortunately, those nested stored procedures can perform SELECTs. The end result is that, instead of returning one record set, my stored procedure may return multiple record sets.

How to prevent this? According to http://databases.aspfaq.com/database/using-stored-procedures.html :

After the BEGIN command, we SET NOCOUNT ON -- this prevents interim statements from being returned as recordsets.


Does NOCOUNT really affect whether or not multiple record sets are returned? Not when you're dealing with nested execution of stored procedures...

The only solution I can find is to create a temporary table, in the calling stored procedure, and to dump the results of the called stored procedure into that temporary table, then to delete it.


CREATE TABLE [#unused] (foo REAL, bar REAL);
INSERT INTO [#unused] EXECUTE my_nested_sp @arg1, @arg2;
DROP TABLE [#unused];

Westinghouse service (?)

Last year we bought a Westinghouse LVM37w3. It's a great monitor, and it does a great job of displaying output from a Sony HD camcorder.

Well, it used to. Early this spring it started flaking out. After it had been on for awhile the backlight would suddenly go out, leaving us with audio and a pitch-black screen. To get the picture back we had to cycle the thing off and on again.

After reading a few anecdotes online, which claimed that others had cured this problem by resetting to factory defaults, we gave it a try. The change was noticeable. Now, as soon as the monitor was powered up, the backlight would go out.

Luckily the monitor was still, barely, under warranty. We called Westinghouse tech support (1-866 -287-5555), who said they would call us with an RMA number within a couple of days.

After a week, tired of waiting, I called them again. They had the RMA number and claimed they had left it on our answering machine. I wonder whose answering machine they really left it on, but no matter: we shipped off the unit at considerable expense (a couple hundred dollars).

It has been gone since May 3rd. Checking the status of the unit has been painful: call Westinghouse tech support, ask for a status update, hear the poor staffer on the other end explain that (s)he needs to submit a status request to the warehouse and to call back in two or three days.

For the past two weeks the answer has come back that the monitor has been repaired, but is still listed as "processing" by the warehouse. They will call me as soon as they have a UPS Ground tracking number. (They haven't called yet.) If I don't hear from them within a week, please call again for an update.

Something sure seems fishy here. Or at least incompetent.

MarsEdit 1.2: Growl, Picasa and Vox!

MarsEdit1.2.jpg

MarsEdit 1.2: Growl, Picasa and Vox!:

MarsEdit 1.2 is now available for download (or just ‘Check for Updates’ from the app). This is a free update for all registered MarsEdit users.

Three relatively big changes in this release: [...]

Picasa image uploads for Blogger.com. This is pretty transparent. Just select your Blogger blog as the upload target from Images & Files, and MarsEdit will pop the images into a MarsEdit album in your Picasa Web Albums account. Note that Picasa only accepts JPG format images for upload.



Woohoo! I've been wanting this for a long time. And it looks like it works just fine!

Thank you, Daniel Jalkut.

2007/06/04

"REPLACE INTO" for SQL Server

MySQL has handy syntax which lets you look for a record by primary key and, if it exists, update its fields; otherwise insert a new record.

I wish something similar existed for SQL Server. If it does, I can't find it. But there is another way to achieve a similar effect, without too much typing:

BEGIN TRANSACTION;
DELETE FROM my_table WHERE prim_key = @prim_key_val;
INSERT INTO my_table (prim_key, other_field)
VALUES (@prim_key_val, @other_field_val);
COMMIT;

I'm probably missing something; haven't thought this through very carefully.

Cottonwood Rumble


Cottonwood Rumble 1
Originally uploaded by Mitch Chapman
I've been meaning to call a tree trimmer. But I really thought the dead branches were the biggest threat.

2007/06/02

One smart baby

When Bobi brought Aigerim home from Kazakhstan she was not quite nine months old -- way too young to talk.

Aigerim has a stuffed pig of whom she's very fond. Almost from the moment she saw it she's been calling it "n'Goita" or "Nyáh-do" or "Nyáh-da". (We live in New Mexico, so of course we've been repeating this as "Nacho" or "Puerco Nacho".)

But she also uses this word for other things. Typically, she'll repeat it insistently, arms outstretched, while leaning way out from whomever's holding her, as she tries to reach some object.

Lately Bobi has begun to think this might be a word from the Baby House. So this morning we pulled out the Langenscheidt Russian to check. A search in the English section for "want", "give", etc. turned up nothing. But then I flipped over to the Russian section, and there it was:


Надо - need, want


What an awesome little girl.

2007/05/31

China's Solar-Powered City: Rizhao : MetaEfficient

China's Solar-Powered City: Rizhao : MetaEfficient:

"
In Rizhao [City, China], 99% of households in the central districts use solar water heaters, and most traffic signals, street and park lights are powered by photovoltaic solar cells. In the suburbs and villages, more than 30% of households use solar water heaters, and over 6,000 households have solar cooking facilities.

The achievement was the result of an unusual convergence of three key factors: a government policy that encourages solar energy use and financially supports research and development, local solar panel industries that seized the opportunity and improved their products, and the strong political will of the city's leadership to adopt it.

Mayor Li Zhaoqian explained: "It is not realistic to subsidize end users as we don't have sufficient financial capacity." Instead, the provincial government invested in the industry to achieve technological breakthroughs, which increased efficiency and lowered the unit cost.


Found via Ottmar Liebert.

2007/05/22

Did a comet wipe out prehistoric Americans? - space - 22 May 2007 - New Scientist Space

Did a comet wipe out prehistoric Americans? - space - 22 May 2007 - New Scientist Space:

The Clovis people of North America, flourishing some 13,000 years ago, had a mastery of stone weaponry that stood them in good stead against the constant threat of large carnivores, such as American lions and giant short-faced bears. It's unlikely, however, that they thought death would come from the sky.

According to results presented by a team of 25 researchers this week at the American Geophysical Union meeting in Acapulco, Mexico, that's where the Clovis people's doom came from."


These claims are pretty wild, but they're interesting. If the researchers are right, the Clovis people didn't kill off all the big North American mammals and then starve to death. Instead the lot were wiped out by hellfire and brimstone. Or, rather, by ice, rock and dust that started some very big fires.



Update: If you have an online subscription to Scientific American, the New Scientist article above might make an interesting contrast to this recent article on restoring Pleistocene-era big mammals to North America.
The theory--propounded 40 years ago by Paul Martin of the University of Arizona--is that overhunting by the new arrivals reduced the numbers of large vertebrates so severely that the populations could not recover.


Also see the Pleistocene Rewilding website. It looks like White Man's Burden with a paleontological twist.

2007/05/17

ONLamp.com -- Tools for Geographically Distributed Software Development

ONLamp.com -- Tools for Geographically Distributed Software Development.

Lots of familiar stuff. Some items, such as writewith, are news to me and worth investigating, since all of my projects now involve distributed teams.

2007/05/05

n'Goita

"n'Goita" is one of Aigerim's favorite words. Google didn't turn up any matches, so I thought I should create a definition page for it here.

Sometimes she says "n'Gah'ta" instead. We think this is her name for Ceniza.

2007/05/03

Real ID: Mark of the beast

National ID card a disaster in the making | CNET News.com




I wonder why those who are charged with national security so often converge on solutions which destroy the freedoms they are supposed to protect.

In a recent CNET article Mssrs Forno and Schneier summarized the Real ID national identity system system, which was approved by Congress after having been buried in a 2005 "must pass" military spending bill.

There is something in the system to worry everyone. Christians may see aspects of the mark of the beast. Jews may see reminders of sufferings they have already endured. IT types will note the increased risk of identity theft inherent in a national identity database.

... the functionality of a single database remains intact under the guise of a federated data-interchange environment.

...the very last paragraph of the 160-page Real ID document deserves special attention.,, DHS declares that states are free not to participate in the Real ID system if they choose--but any identification card issued by a state that does not meet Real ID criteria is to be clearly labeled as such, to include "bold lettering" or a "unique design" similar to how many states design driver's licenses for those under 21 years of age.

In its own guidance document, the department has proposed branding citizens not possessing a Real ID card in a manner that lets all who see their official state-issued identification know that they're "different," and perhaps potentially dangerous, according to standards established by the federal government. They would become stigmatized, branded, marked, ostracized, segregated. All in the name of protecting the homeland; no wonder this provision appears at the very end of the document.

2007/05/02

Hacking Your Body's Bacteria for Better Health -

Wired recently ran an article on probiotics. It had so many interesting observations that I've had a hard time summarizing it.

Okay, the summary is that we need bacteria in order to stay healthy.

Hacking Your Body's Bacteria for Better Health:

We assassinate microbes with hand soap, mouthwash and bathroom cleaners. But some scientists say ... all this killing may actually cause diseases like eczema, irritable bowel syndrome and even diabetes.

"Probiotics have resulted in complete elimination of eczema in 80 percent of the people we've treated," says Dr. Joseph E. Pizzorno Jr., a practicing physician and former member of the White House Commission on Complementary and Alternative Medicine Policy. Pizzorno says he's used probiotics to treat irritable bowel disease, acne and even premenstrual syndrome.

"After the Second World War, when our lifestyles changed dramatically, allergies increased. Autoimmune diseases like diabetes and inflammatory bowel disease are increasing," says Kaarina Kukkonen, a University of Helsinki allergy expert.

Microbial exposures early in life, scientists believe, cause mild inflammation that calibrates the body's responses to other pathogens and contaminants later in life. Without exposure as infants, researchers say, people can end up with unbalanced immune systems.

"Many of the most difficult problems in medicine today are chronic inflammatory diseases," says Blaser. "These include rheumatoid arthritis, lupus, atherosclerosis, eczema and multiple sclerosis. One possibility is that they're autoimmune or genetic diseases. The other possibility is that they are physiological responses to changes in microbiota."

2007/05/01

Microsoft's Silverlight

Microsoft has announced details of their competitor to Flash -- and to JavaScript, and to ... It's called Silverlight.

To me the most interesting thing about it is that it allows developers to build browser-side web apps using Python and Ruby instead of JavaScript.

Silverlight apps can use a subset of the .NET framework. Embedded video can run at HD revolutions up to 1280x720.

It all looks pretty interesting. It'd be more interesting if it provided a 3D API; but so far I see no evidence of that.

2007/04/27

Sun eyes a JavaScript alternative to AJAX

Sun eyes a JavaScript alternative to AJAX:

"

(InfoWorld) - Sun Microsystems is working on Web application development technology that presents an alternative to AJAX (Asynchronous JavaScript and XML), a Sun official said on Thursday.



The company's Project Flair is an open-source project now in development... A version of Flair for developers to experiment with is eyed for release later this year.


Small and simple, Flair presents a 'great vehicle for experimenting with [what] I guess what you would call, sort of, collaborative object development, that kind of thing,' said Ingalls.


'AJAX sort of deals with all of the old way of doing things. It makes it simpler ... but underneath it’s still all this junky HTML, Document Object Model, CSS, all that stuff, where 30 years ago, we knew how to do that stuff cleanly with a dynamic programming language and a simple graphics model,' Ingalls said.


'Flair takes us back to that simple model and adds the collaboration [and] Web access to it,' he said.




Anybody have links to more details on Project Flair?

2007/04/23

American's imprisonment in Kazakhstan sends chilling message - International Herald Tribune

American's imprisonment in Kazakhstan sends chilling message - International Herald Tribune:

"Despite all the Western donor money and American-financed projects aimed at reforming the judiciaries here," said Michael Hall, an analyst in Bishkek, Kyrgyzstan, with the International Crisis Group ... "this is all part of a bigger Central Asian trend to make their judicial systems subordinate to their presidents."

"The result is a significant retreat in America's ability to project its public and business interests in the region," he said.

"Plus, the U.S. has suffered a massive loss of credibility when it comes to talking about the rule of law and independent judiciaries in the wake of the abuses we've been hearing about in places like Guantánamo." (emphasis added)


The last paragraph is a sideline to the main story. But it shows again that it's in the best interests of the United States to treat its prisoners humanely. Any abuse we lay on our prisoners (call them what you will) can be used as a justification for the mistreatment of U.S. citizens.

Duck and Cover: Ancient Mass Extinctions Caused by Cosmic Radiation

Ancient Mass Extinctions Caused by Cosmic Radiation, Scientists Say:

"Cosmic rays produced at the edge of our galaxy have devastated life on Earth every 62 million years, researchers say."


Not all mass extinctions are explained by this theory. For example, the KT boundary event probably has another cause.

But what an interesting idea: our galaxy is moving "flat-faced", like a pie in a pie fight, relative to surrounding material. A shock wave is generated where galactic matter comes into contact with the surrounding hot gases, and cosmic radiation is generated at that same point.

Periodically on its 225-million-year galactic orbit, our solar system rises up out of the galactic plane, closer to the shock wave, where it is exposed to more of the incoming cosmic radiation than normal.

Researchers aren't sure about the consequences of the increased radiation. Greater ozone depletion may allow more of the radiation to reach the earth's surface and into its oceans. Other effects may include changes in cloud cover, etc.

One possibility is that organisms receive harmful doses of radiation from high-energy particles known as muons, which are produced by cosmic rays colliding with Earth's atmosphere.

"Cosmic rays themselves are not really that dangerous," said Medvedev. "They create [charged particles] that propagate down through the atmosphere—especially muons that can go below the sea level."

Russia's former president Yeltsin dies: Kremlin | Reuters

Russia's former president Yeltsin dies: Kremlin | Reuters:

Many Russians initially viewed Yeltsin as a hero for dismantling Communist rule. His finest hour came when, in 1991, he clambered onto a tank and raised his fist in defiance of hardline coup plotters who wanted to turn back the clock.

...in 1989 he was elected to the new Soviet Congress of People's Deputies and in June 1991 he was elected president of Russia -- still within the Soviet Union -- in a landslide.

Two months later, he faced down tanks in the Moscow streets...


2007/04/18

Make your own Ghost Map

From Paul Kedrosky: Twitter for Hypochondriacs:

Who is sick? is a clever idea, and similar in many ways to my 'what's going around?' idea. It allows people with symptoms of something or another -- bloody stool! sniffles! cough! muscle ache! -- to add their location and symptoms to a map.

Why clever? Because it is the data-rich beginnings of grassroots epidemiology via capturing the kinds of conversations that usually only happen in doctors' offices. You, know, 'You have a cold. That's going around'.


Gee, it's like a modern, collaborative version of The Ghost Map.

2007/04/04

Why it's called "good" cholesterol

Technology Review: Imaging Cholesterol Buildup in the Heart: " Normally, HDL passes through arteries and attaches to low-density lipoprotein (LDL), or 'bad' cholesterol, carrying it out of arteries to the liver."

'Course that's not what the article is about. Researchers have found a way to attach markers to segments of unstable arterial plaque, using altered HDL. As a result, they can better see where unstable plaque has built up in a patient and can better identify problems which increase the risk of heart attack.

2007/04/02

Light Therapy Spares the Scalpel and the Chemo -

Light Therapy Spares the Scalpel and the Chemo -


Imagine you could treat cancer by taking a pill, then directing a laser light toward the location of the tumor. The growth would dissolve with no chemotherapy, and no harm to healthy tissue.

It might sound futuristic, but a select number of cancer patients already benefit from the method, called photodynamic therapy. An upgrade for the procedure could save thousands more cancer patients from the horrors of chemotherapy.

Although chemotherapy has improved over the past decade, the treatment still damages healthy tissue and causes other unpleasant side effects like nausea and a weakened immune system. The researchers hope their work will spare patients from chemo's ravages and even the surgery usually necessary to remove a tumor.

2007/03/27

TI demos its movie projector in a phone | CNET News.com

TI demos its movie projector in a phone | CNET News.com


At the CTIA Wireless 2007 show, TI is providing public demonstrations of its digital light processing (DLP) 'pico' projector, a tiny movie projector that can fit inside a cell phone.

TI showed off the components and a prototype at the Consumer Electronics Show earlier this year to a few reporters. Now the company is touting a working prototype in a phone. The phone is fake, but the projector works.


I expect someday this is what laptop displays will look like. Why waste physical space and weight, provided you can find or create a flat viewing surface?

2007/03/05

TextMate, Parallels, and Visual Web Developer 2005 Express Edition

I've been using TextMate for the past two years, and like it so well that I have a hard time adjusting to most other text editors. Even my old favorite, XEmacs, is now painful to use.

I recently started work on my first ASP.NET project. The customer wants the whole thing to be done with VB.NET -- another first for me.

Lots of bundles are available for TextMate, and among them is an "ASP vb.NET" bundle. Yippee! Since my Windows XP "machine" is a VM hosted under Parallels, I can develop my project in a shared folder. [Edit 2007/03/06] On the Mac side I can use the Finder's "Network" sidebar entry to connect to my VM and mount the shared folder. TextMate sees it just fine. I get to use all of the toys at once.

Almost... I think it's because of filename limitations in NTFS, but I can't check out a working copy of my subversion repository into such a shared folder -- not from the Mac side. Trying to do so fails when subversion tries to check out a file whose name contains more than one period (".").

The simplest solution seems to be to to install the excellent TortoiseSVN under XP, and to check out the working copy from Windows. In order to avoid entering my ssh password 400 times, I've also installed PuTTY and used it to generate a private/public key pair for use with the subversion server.

Parallels really makes for some head-twisting fun. Recently I attended a web meeting using GoToMeeting, running in a Parallels VM. Instead of scrambling madly to keep notes on paper, I recorded the whole thing as a QuickTime movie using iShowU, running natively on Mac OS X. Let's see, that's a screencast recorded on a Mac, of a web conference running in a Win XP virtual machine hosted on the Mac.

2007/03/01

Mars Melt Hints at Solar, Not Human, Cause for Warming, Scientist Says

Mars Melt Hints at Solar, Not Human, Cause for Warming, Scientist Says: "Simultaneous warming on Earth and Mars suggests that our planet's recent climate changes have a natural—and not a human-induced—cause, according to one scientist's controversial theory."

"Man-made greenhouse warming has made a small contribution to the warming seen on Earth in recent years, but it cannot compete with the increase in solar irradiance," Abdussamatov said.


Abdussamatov is not alone in his beliefs. Last fall a group of German researchers also concluded that the sun was the primary cause of the historically recent increases in global mean temperature. [insert URL here]

Humans have a significant effect on this planet. Pick a satellite image, any image, and it's obvious that we've been here :) And of course we could soil our environment so badly that we die out.

Still, the hand-wringing over climate change often sounds like an oblique claim to importance. Dominion over the animals, created in God's image, etc. It's an anthropocentric world-view that even atheists can embrace. So reminders of the relative importance of the sun are good for our humility.

Unfortunately, the article notes several reasons why Abdussamatov's claims are met with skepticism. Mars has much bigger orbital wobbles than Earth, so it endures bigger climate swings. Greenhouse gases are important to our climate; without them life probably wouldn't have flourished here. Etc.

Abdussamatov does offer a way to test his claims, but it will take some time:
"The solar irradiance began to drop in the 1990s, and a minimum will be reached by approximately 2040," Abdussamatov said. "It will cause a steep cooling of the climate on Earth in 15 to 20 years."

N. Korea vows to denuclearize in talks - Yahoo! News

N. Korea vows to denuclearize in talks - Yahoo! News: "SEOUL, South Korea - North Korea's No. 2 leader pledged his country's commitment Thursday to giving up its nuclear program amid intensifying diplomacy aimed at implementing Pyongyang's pledge to disarm."

Based on seismic readings, North Korea's nuclear test last fall might have been a dud. Could this be one reason (coming as a distant second to the prospect of mass starvation) for the North's commitment to disarmament?

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.