2007/12/28

Custom keybindings in OS X

Since I keep forgetting how to customize keyboard navigation, here's a pointer to the documentation:
http://developer.apple.com/documentation/Cocoa/Conceptual/EventOverview/TextDefaultsBindings/chapter_9_section_2.html

And here are the bindings I'm currently using in my ~/Library/KeyBindings/DefaultKeyBinding.dict file. Basically they cause the "Home" and "End" keys on the Apple keyboard to move the cursor to the beginning and end of the current text line. Hitting these keys while holding "Shift" will also select all text covered by the move. And the page up/down keys do what you'd expect.

{
"$\Uf729" = "moveToBeginningOfLineAndModifySelection:";
"$\Uf72b" = "moveToEndOfLineAndModifySelection:";
"\Uf729" = "moveToBeginningOfLine:";
"\Uf72b" = "moveToEndOfLine:";
"\Uf72c" = "pageUp:";
"\Uf72d" = "pageDown:";
}

2007/12/19

Twenty-year-old Civics got 57 miles per gallon - Dec. 19, 2007

Twenty-year-old Civics got 57 miles per gallon - Dec. 19, 2007:

"Even in its base HF trim, the CRX was considered a fun car to drive because it was small and responsive. Its zero-to-sixty time, though - about 12 seconds by some estimates - would put it well behind even a large, sedate family sedan like the Ford Taurus today."


I owned a red 1990 CRX HF for about 11 years. I drove it off the lot just a few days before Saddam Hussein invaded Kuwait. Boy, did I feel smug.

It was a great little car. On long trips it often averaged 60-62 mpg.

I finally gave it up after moving to Santa Fe. It had trouble climbing La Bajada. And it started pulling to the left after a local mechanic installed new front-end ball joints. Okay, and it had no air conditioning, which made for stinking hot desert travel.

But it was a great little car...

2007/12/12

CDK, Jython and chemical structure format conversion

These days I'm learning how to work with some new (to me) Java cheminformatics toolkits. Google, Jython 2.2.1, and VoodooPad are helping me get up to speed:


  • Google to find the documentation for the Java APIs

  • Jython to learn API nuances without an edit/compile/test cycle

  • VoodooPad as a scratchpad for sample scripts -- it's easy to save them in pages that sit alongside my worklog



During initial exploration I just bang up the script in VoodooPad, then repeatedly select all (Cmd-A), copy (Cmd-C), switch to a Terminal session running Jython (Cmd-Tab), and paste (Cmd-V).

The "learnings" are going into proper Jython scripts maintained with TextMate.

It's nice to be able to deploy using Jython instead of pure Java. Since almost all of the heavy lifting is being done inside the cheminformatics jars, I don't need to worry about the overhead of running a Python interpreter inside a JVM...

Here's a simple example using CDK, to transform an SD string into a SMILES string.
#! /usr/bin/env jython
# You must have set your CLASSPATH to pick up the CDK jar.
# encoding: utf-8

import java.io
from org.openscience import cdk

def getCDKMol(sdf):
reader = cdk.io.MDLReader(java.io.StringReader(sdf))
result = cdk.Molecule()
result = reader.read(result)
return result

def getSmiles(cdkMol):
result = java.io.StringWriter()
writer = cdk.io.SMILESWriter(result)
writer.write(cdkMol)
return str(result)

def sdfToSmiles(sdf):
return getSmiles(getCDKMol(sdf))

# Example:
print sdfToSmiles("""1-7


42 44 0 0 0 0 999 V2000
-0.8349 0.9908 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
-0.0502 1.2457 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
-0.0502 2.0707 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
-0.8349 2.3257 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
-1.3198 1.6582 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
0.6172 0.7608 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
-1.0898 0.2062 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
0.5310 -0.0597 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1.1984 -0.5446 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1.9521 -0.2090 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
2.0383 0.6114 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1.3709 1.0964 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
-1.8968 0.0346 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
-2.1517 -0.7500 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
-1.5997 -1.3631 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
-0.7927 -1.1915 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
-0.5378 -0.4069 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
-2.1448 1.6582 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
2.6195 -0.6940 0.0000 S 0 0 0 0 0 0 0 0 0 0 0 0
3.1044 -0.0265 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
2.1346 -1.3614 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
3.2869 -1.1789 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
-1.8546 -2.1477 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
0.6172 2.5557 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0
-1.0898 3.1103 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0
-0.2227 -0.3952 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0
1.1122 -1.3651 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0
2.7920 0.9470 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0
1.4571 1.9168 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0
-2.4488 0.6477 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0
-2.9587 -0.9215 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0
-0.2407 -1.8046 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0
-0.1632 -1.1420 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0
-2.1448 0.8332 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0
-2.1448 2.4832 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0
-2.9698 1.6582 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0
3.7719 -0.5114 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0
2.8020 -1.8463 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0
3.9544 -1.6638 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0
-1.0700 -2.4026 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0
-2.6392 -1.8928 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0
-2.1096 -2.9323 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0
1 2 1 0 0 0 0
1 5 1 0 0 0 0
1 7 1 0 0 0 0
2 3 2 0 0 0 0
2 6 1 0 0 0 0
3 4 1 0 0 0 0
3 24 1 0 0 0 0
4 5 2 0 0 0 0
4 25 1 0 0 0 0
5 18 1 0 0 0 0
6 8 2 0 0 0 0
6 12 1 0 0 0 0
7 13 2 0 0 0 0
7 17 1 0 0 0 0
8 9 1 0 0 0 0
8 26 1 0 0 0 0
9 10 2 0 0 0 0
9 27 1 0 0 0 0
10 11 1 0 0 0 0
10 19 1 0 0 0 0
11 12 2 0 0 0 0
11 28 1 0 0 0 0
12 29 1 0 0 0 0
13 14 1 0 0 0 0
13 30 1 0 0 0 0
14 15 2 0 0 0 0
14 31 1 0 0 0 0
15 16 1 0 0 0 0
15 23 1 0 0 0 0
16 17 2 0 0 0 0
16 32 1 0 0 0 0
17 33 1 0 0 0 0
18 34 1 0 0 0 0
18 35 1 0 0 0 0
18 36 1 0 0 0 0
19 20 2 0 0 0 0
19 21 2 0 0 0 0
19 22 1 0 0 0 0
22 37 1 0 0 0 0
22 38 1 0 0 0 0
22 39 1 0 0 0 0
23 40 1 0 0 0 0
23 41 1 0 0 0 0
23 42 1 0 0 0 0
M END
$$$$
"""
)

2007/12/05

SQLElixir/SQLAlchemy/SQLite3 and ISO-8859 content

See here for the full discussion. The upshot is that, if you are storing string data into an SQLite3 database via Python, and if you suspect that the data may contain non-ASCII characters, you need to ensure that it's properly converted to (Python) Unicode before inserting.

#!/usr/bin/env python
# encoding: utf-8
"""Explores a problem importing a chemical structure file into an
SQLElixir/SQLAlchemy/SQLite3 database.

The file was in SD format. One of the tags contained ISO-8859 characters.
Python read the file contents without trouble; SQLite3 stored the contents.
But on retrieval SQLite3 raised an OperationalError:
Could not decode to UTF-8 column '[...]' with text '[...]'

This script explores the problem, and demonstrates two successful
Unicode encodings: utf-8/replaced and utf-8/ignored.

NB: Only the latter actually worked with SQLElixir:
s = unicode(s, encoding='utf-8', errors='ignore')
"""

import unittest, sqlite3

class TestCase(unittest.TestCase):
def setUp(self):
self.conn = sqlite3.connect(":memory:")
self.conn.cursor().execute('CREATE TABLE demo (value TEXT)')

def insertAndDump(self, encoding, errors, expectFailure=False):
caseName = repr([encoding, errors])
data = 'K\xf6 1366'
try:
if encoding is not None:
data = unicode(data, encoding=encoding, errors=errors)
cursor = self.conn.cursor()
cursor.execute("INSERT INTO demo (value) VALUES (?)", [data])
cursor.execute('SELECT * FROM demo')
self.failUnless(len(cursor.fetchall()) == 1)
self.failIf(expectFailure, "Unexpected success for %s" % caseName)
except Exception, info:
self.failUnless(expectFailure, "Failed %s: %s" % (caseName, info))

def testCannotRetrieveUnencoded(self):
self.insertAndDump(None, None, True)

def testCannotEncodeStrict(self):
self.insertAndDump("utf-8", "strict", True)

def testCanRetrieve8859Strict(self):
self.insertAndDump("8859", "strict")

def testCanRetrieveUTF8Ignored(self):
self.insertAndDump("utf-8", "ignore")

def testCanRetrieveUTF8Replaced(self):
self.insertAndDump("utf-8", "replace")

unittest.main()

2007/11/29

Wired News - Late Shift Work Linked to Cancer

Wired News - AP News

Linked because I like the improbable, but simple, hypothesis:

"Back then, [Richard Stevens] was trying to figure out why breast cancer incidence suddenly shot up starting in the 1930s in industrialized societies, where nighttime work was considered a hallmark of progress. Most scientists were bewildered by his proposal."


Richard Stevens is a cancer epidemiologist, which is interesting in its own right. He is a professor at the University of Connecticut Health Center.

Apparently, this is old news. From his bio:
"He proposed in 1987 a radical new theory that use of electric lighting, resulting in lighted nights, might produce "circadian disruption" causing changes in the hormones relevant to breast cancer risk. Accumulating evidence has generally supported the idea, and it has received wide scientific and public attention. For example, his work has been featured on the covers of the popular weekly Science News (October 17, 1998) and the scientific journal Cancer Research (July 15, 1996)."

Government H5N1 Sites

CDC and government sites concerning H5N1:



The map at bottom left of the Pandemic Flu site provides links to

  • state pandemic planning info

  • state pandemic web site info

  • local state contacts


Technology Review: Liver Models Go to Market

Technology Review: Liver Models Go to Market:

'Only one of every ten compounds tested by pharmaceutical companies becomes a product, says Shuler, and half of the failures are due to toxicity.'


(There's the bottleneck which cheminformatics has not been able to widen.)

'"The liver is a complex organ that has many different cell types," says Tannenbaum. These cells exchange chemical signals and even exert mechanical forces on each other that help maintain their function...'

'"In order to get any functionality [in a model], you have to have multiple cell types organized into a structure like a liver," he says. When cells are taken out of the liver and cultured using traditional means, their gene-expression profiles change very quickly, and they begin to deteriorate in a few days.'
'For four to six weeks, [Hepregen's] cells maintain gene-expression profiles comparable to those of liver cells in the human body; they continue to produce the enzymes that break down and modify drugs; and they even form functioning bile ducts, important transport systems in the liver.'


MIT's News Office has a similar article.

Drug brings hope for a universal flu vaccine - health - 27 October 2007 - New Scientist

Drug brings hope for a universal flu vaccine - health - 27 October 2007 - New Scientist

Ordinary flu vaccine contains dead influenza A viruses from the H1 and H3 families. When the researchers put this, plus the RNA-like drug Ampligen, into the noses of mice, the mice made antibodies not only to the vaccine viruses but also to H5N1 bird flu - without ever having been exposed to it. Better, when groups of nasally vaccinated mice were exposed to different strains of live H5N1, [at least half] of each group survived... The team think antibodies in mucus reacting with proteins in the virus could be key.

2007/11/13

UK bird flu outbreak confirmed as H5N1

From New Scientist: UK bird flu outbreak confirmed as H5N1

To go along with this news, some useful terms from Dictionary.app:

A disease that quickly and severely affects a large number of people and then subsides is an epidemic.

A disease that is continually present in an area and affects a relatively small number of people is endemic.

A pandemic is a widespread epidemic that may affect entire continents or even the world.

2007/11/08

Volcanic clay found to kill 99 per cent of MRSA superbugs

Volcanic clay found to kill 99 per cent of MRSA superbugs:

[Researchers] said that the clay was found to wipe out bug colonies in a day during laboratory experiments. They also revealed that control samples of MRSA, which were not treated with agricur, grew 45-fold over the same period.

The World health Organisation welcomed [the work of French doctor Line Brunet de Course] when she approached it in 2002 with 50 case studies. However, it denied her funding because of a lack of scientific evidence.
"It is possible that it is not one single element that is toxic to the bacteria."
The researchers also backed the possibility that the clay worked through a physical rather than a biochemical process, meaning that bacteria could never develop resistance. "It's fascinating. Here we are bridging geology, microbiology, cell biology. A year ago, I'd look at the clay and say, 'Well, that's dirt,'" Dr Haydel, a microbiologist, said.

2007/10/29

CherryPy 3: interpreting error messages

I'm stubbing out a method in a nested CherryPy application object. I keep getting error messages of the form


File "/path/to/CherryPy-3.0.2-py2.5.egg/cherrypy/_cprequest.py", line 551, in respond
cherrypy.response.body = self.handler()
File "/path/to/CherryPy-3.0.2-py2.5.egg/cherrypy/_cpdispatch.py", line 24, in __call__
return self.callable(*self.args, **self.kwargs)

TypeError: 'Data' object is not callable


And the cause? Almost every time, in the browser I've mistyped the URL for my server's Ajax method. I might be invoking foo instead of bar, and the result is always this sort of error message.

Why don't I instead get the old "We didn't find anything"? Dunno. It's probably something in my configuration.

2007/10/26

Exhibitionist spiny anteater reveals bizarre penis - New Scientist Environment

Science can be funny.

New Scientist Environment:

The spiny anteater ... is notoriously difficult to observe in the wild and shows little enthusiasm for breeding in captivity...

Four-headed phallus

Then Steve Johnston of the University of Queensland in Gatton, Australia, and his colleagues inherited a male spiny anteater that ... had been ‘retired’ from a zoo as it produced an erection when being handled at public viewing sessions.


This reminds me of a Panda exhibit at the Cincinnati Zoo in the late 80s. We were ushered into the viewing gallery in groups, at regular intervals. There we stood gazing in reverent silence upon an artificial bamboo forest -- a quiet, still forest, in the midst of which lay an inert black and white lump.

Minutes passed. The lump stirred. The crowd gasped.

The lump rolled over. The crowd went "Aahhhwww," and broke into applause.

They seemed not to care that they were now facing a leering, semi-conscious panda, sprawled on its back, legs spread wide like a drunken flasher.

Er, anyway... when doing science, one must be careful with electricity:

The spiny anteater's four-headed phallus had been puzzling scientists. "When we tried to collect semen by [electrically-stimulated ejaculation] before, not only did we not get a single drop, but the whole penis swelled up to a four-headed monster that wouldn't fit the female reproductive tract..."


2007/10/19

New Scientist: Cold weather really does spread flu

Cold weather really does spread flu - New Scientist Environment

Flu virus can spread without the aid of coughing/sneezing -- you just gotta breathe. It stays in suspension longer in cold, dry air than in warm, moist air. And it doesn't help that mucus flows more poorly in cold weather.

"...Virtually no lab animals get it the way humans do... The most useful animal has been the ferret... “They’re big, they’re expensive, and they bite,” Peter Palese of Mount Sinai Medical School in New York City told New Scientist.

In 1919, US Army doctors at Camp Cody in New Mexico reported (Journal of the American Medical Association, vol 72 p1056) that the 1918 flu pandemic had killed their guinea pigs – kept at the time for medical tests. “We didn’t know guinea pigs got flu,” says Palese. They are no longer popular lab animals, and no-one had tried them."


Bad news for air travelers:
"“It spread just in the air they exhaled,” says Palese. “Guinea pigs with flu don’t cough or sneeze.”"


2007/09/27

Thank Goodness for the Judiciary (again)

Oregon judge knocks down part of Patriot Act:

"SEATTLE (Reuters) - An Oregon judge on Wednesday ruled that two provisions of the Patriot Act violated the U.S. Constitution's protection against unlawful searches and seizures.

U.S. District Judge Ann Aiken ruled in favor of Brandon Mayfield, a lawyer wrongly arrested by the FBI in 2004 for possible ties to the Madrid train bombings, who challenged the secret searches of his home and office.

The judge said the amendments made by the Patriot Act to the Foreign Intelligence Surveillance Act allows the government to conduct searches and monitor American citizens without probable cause, which is typically required by the Fourth Amendment to the U.S. Constitution.

'The defendant here is asking this court to, in essence, amend the Bill of Rights by giving it an interpretation that would deprive it of any real meaning. This court declines to do so,' Aiken wrote in her ruling."

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.