2008/12/09

Unintended Consequences

Op-Ed Contributor - The Terrorists Want to Destroy Pakistan, Too - NYTimes.com:

"The world worked to exploit religion against the Soviet Union in Afghanistan by empowering the most fanatic extremists as an instrument of destruction of a superpower. The strategy worked, but its legacy was the creation of an extremist militia with its own dynamic."

2008/11/26

The government crash

Doc Searls:

The amazing thing about crashes is that you can see them coming...
Now we’re about to see the U.S. government crash, for the same reason.


The U.S. government is about to spend roughly 1/2 GDP to "fix" the economy.

It was a surprise this autumn to see foreign investors rushing to buy up more of our debt. Will we still look like a good bet after we've taken out a loan this big?

2008/11/20

Waxman topples Dingell for key panel chair - Yahoo! News

Waxman topples Dingell for key panel chair - Yahoo! News:

"Rep. Henry Waxman — a liberal ally of Speaker Nancy Pelosi — has wrested the chairmanship of the powerful House Energy and Commerce Committee from veteran Rep. John Dingell when the new Congress convenes in January."


I'm no fan of Waxman, but this could portend positive changes for the U.S. auto industry. Presuming, of course, that the best solution to our oil and carbon-emissions problems entails continued use of automobiles.

2008/11/18

LIFE photo archive hosted by Google | Photodoto

LIFE photo archive hosted by Google | Photodoto:

"LIFE has released over 10 million images on a new hosted image service from Google and in Google Image Search. They claim [...] that the collection contains ‘some of the most iconic images of the 20th century.’
LIFE is selling fine art prints (in partnership with Qoop it seems) of the collection and the photos are only available online as 1 megapixel scans."


Outstanding.




(I've seen a large print of this Margaret Bourke-White photo in a local gallery. A computer screen can't do it justice, not by a long shot.)

“New chapter” on climate change

From President-elect Obama promises “new chapter” on climate change | Change.gov:

The Global Climate Summit is a "2-day event arranged by California Governor Arnold Schwarzenegger to break gridlock on the issue ahead of next month's United Nations Climate Change Conference in Poznan, Poland."

President-elect Obama posted a short video expressing enthusiasm for the summit:

"...too often, Washington has failed to show the same kind of leadership. That will change when I take office."


Interesting times. It's easy to imagine this bit of cross-party consensus as the beginning of Friedman's e-tech economy.

Can't debug after updating to Flex Builder 3.0.2

I'm evaluating FlexBuilder 3, and have just installed the Flex Builder 3.0.2 update. All of a sudden I can't debug my AIR project.

The error dialog displays a lengthy message which ends with:

error while loading initial content


Thanks to Google and Adobe's public bug database, the fix is straightforward: edit the project's *-app.xml file and change the namespace (2nd line) to 1.5:


<application xmlns="http://ns.adobe.com/air/application/1.5">

2008/11/17

Prophesy of economic collapse 'coming true' - environment - 17 November 2008 - New Scientist

Prophesy of economic collapse 'coming true' - New Scientist:

Changes in industrial production, food production and pollution are all in line with [the predictions in "Limits to Growth"] of collapse in the 21st century, says Turner.
According to Herman Daly of the University of Maryland, Turner's results show that we 'must get off the growth path of business as usual, and move to a steady state economy,' stopping population growth, resource depletion, and pollution."

2008/11/14

.:: Aero-News Network: The Aviation and Aerospace World's Daily/Real-Time News and Information Service ::.

.:: Aero-News Network: The Aviation and Aerospace World's Daily/Real-Time News and Information Service ::.:

"United Airlines will become the first US carrier to demonstrate how next-generation technologies could save more than two thousand gallons of fuel and cut up to 55,000 pounds of carbon emissions on a single, trans-Pacific flight."
Within minutes of landing, United will calculate and publish the actual savings realized on this flight.


As a recovering private pilot I find this fascinating...

A former colleague has been working on a related software project, using genetic algorithms and frequently updated weather data to help commercial flights decide how to alter their routes — diverting in all three dimensions as necessary &mdash to find the cheapest path between two points. I wonder if he's involved in any way in this test flight.

2008/11/12

Why it's hard to reduce gross energy use

un_pop.png


Good news: we appear to be near an inflection point:)

Our numbers are huge, and a good fraction of us are trying to improve standards of living in a way which increases per capita annual energy expenditure. But at least our population growth is slowing.

Stewart Brand in Technology Review:
...in 2002, [the UN] adopted a new theory that shocked many demographers: human population is leveling off rapidly, even precipitously, in developed countries, with the rest of the world soon to follow...

The world's women... had fewer kids because they moved to town.

Cities are population sinks-always have been... A global tipping point in urbanization is what stopped the population explosion...

The environmentalist aesthetic is to love villages and despise cities. My mind got changed on the subject a few years ago by an Indian acquaintance who told me that in Indian villages the women obeyed their husbands and family elders, pounded grain, and sang. But, the acquaintance explained, when Indian women immigrated to cities, they got jobs, started businesses, and demanded their children be educated.

Solving for the Unknowns: The Pickens Plan

This Yahoo! News article has me wondering again about the pros and cons of the Pickens Plan:

"Billionaire T. Boone Pickens expects to know within 100 days of Barack Obama taking over as president in January whether the U.S. government is going to adopt part of his ambitious and controversial energy plan.
The plan calls for an eventual overhaul of the power grid and Pickens is also betting on huge growth in wind power. But he said, as a start, the United States can move toward using natural gas in trucks as well as more renewable power."

A couple of months ago the Climate Progress blog posted a criticism of the Pickens Plan. According to the author, Earl Killian, the proposal to build out a wind energy infrastructure is attractive, but converting ground transportation to compressed natural gas makes no sense.

CNG Trucking

For Pickens, converting long-haul trucking to CNG is probably the most attractive part of the plan. Killian asserts that, in order to make a dent in foreign oil dependency, we would also need to convert small cars to alternative fuels.

I think Killian may have set up a strawman, although he does provide evidence that Pickens is talking about both trucks and small cars. Regardless, his analysis is really interesting.

Killian finds that plugin hybrids would get more range from a given volume of natural gas, converted to electricity by a power utility, than would cars which ran directly on CNG:
It seems pretty straightforward that electric vehicles beat CNG vehicles almost 2:1, even using existing NG power plants. If the US upgraded its NG power plants to be 60% efficient, instead of 39% efficient, we would have 54% more TWh, or even better, use less 35% less NG.

As noted, Pickens is focusing on big trucks, not small cars. It would be interesting to see an assessment based on data from existing CNG truck and bus fleets.

Wind

Killian and others have a more favorable view of Pickens' wind power proposal. They are concerned that wind power could be unreliable and unpredictable since, well, wind varies. The Pickens Plan addresses this problem by building excess capacity into the wind grid, and by pointing out that it's unlikely the entire midwest wind corridor would be calm at any given time.

This seems reasonable given the experiences of other countries. For example, Wikipedia notes that Denmark, which derives 20% of its electricity from wind power, has suffered "no major problems" with wind variability.

Killian focuses on energy potential, so he doesn't assess the environmental consequences of building out the wind corridor. Aside from the wind turbines themselves, we'd also need lots of long-distance transmission lines, much of it running through land which has so far escaped damage by humans.

Sideline: Rail

I thought that rail was more fuel efficient than trucking for long-haul shipment of goods, and that trucking came to prominence by way of regulation. If so, that would beg questions:
  1. What would be the benefits of changing those regulations to reward efficiency?
  2. Would we be better off building up rail infrastructure, than converting trucking fleets to CNG?

Google says my memory of regulatory history is wrong. From "Basic Economics", by Thomas Sowell:
[The I.C.C.] sought — and received from Congress — broader authority under the Motor Carrier Act of 1935, in order to restrict the activities of truckers [emph. added]. This allowed railroads to survive under new economic conditions, despite truck competition that was more efficient for various kinds of freight hauling.

The CSX website claims that rail freight is three times more fuel efficient than long-haul trucking.
Since 1980, through technology and innovation, the railroad industry has improved locomotive fuel efficiency by over 80%.

So question 2 is still worth asking.

2008/11/06

TextMate CamelCase

Because I keep forgetting: In TextMate, you can toggle the selected text from lowercase_with_underscores to camelCase by typing Control-Shift-Minus (^_).

At last, an antidote to USA Today

When the lights go on at the New York Times, our work can start:

"But the Times is attracting an all-star team of information architects, interactive graphics designers, programmers, and media producers. And according to Gabriel Dance and Shan Carter, these folks are increasingly collaborating with reporters to marshall complex information in ways that make the newspaper’s stories deeper and more open to independent analysis and interpretation."

Jon's statement made me realize: NYT is providing an antidote to USA Today.

When USA Today first appeared, it was criticized for emphasizing glitz over substance. Its articles often oversimplified complex issues. Its graphics were colorful and, almost always, misleading.

USATodayParody.png


NYT is getting it right, especially with interactive graphics. Sure, they're often glitzy. But they also communicate clearly. And they make it easier to understand the data which they present, in part by making it easier to explore.

2008/11/05

One-line web server in Python

From Ed Taekema's weblog, a reminder[1] about how to create a web server in one line of Python:

python -c 'import SimpleHTTPServer;SimpleHTTPServer.test()'


This starts a server listening on port 8000, serving files from its launch directory. If you just hit the server (http://localhost:8000/) it will by default serve index.html; if index.html doesn't exist, it will give you a directory listing. Also, the server will provide only those files residing in or below the current working directory; e.g. http://localhost:8000/../ resolves to the default document.

Wish I'd seen Ed's note this morning...

This is handy when you want to experiment with things like interactions between Flex applications and JavaScript, or other situations in which you can't get by with simple file:/// URLs. This would be handy as a jqUnit test, as well.



[1] Reminder? It's been a long time since I read "Internet Programming with Python" :-)

2008/11/01

Removing old man pages from OS X Leopard

Back in January I posted about Leopard, 'ls -l' and extended attributes. The gist was that my man pages were out of date, so they didn't explain what the @ character represented, in 'ls -l' output.

Some threads on the Apple discussion boards have investigated why the man pages don't get updated. The conclusion is that Leopard installs a lot of gzip-compressed man pages without deleting the corresponding uncompressed man pages. (It may be that this is true only for upgrade installs.) A recommended workaround was to scan through the man page directories with a shell command, re-locating all uncompressed man pages which had corresponding compressed man pages.

I decided to be cowardly in doing this. Here's a Python script which moves each uncompressed man page only if it is older than its corresponding gzipped man page.

The script must be run with superuser privileges, e.g.

sudo python mv_old_man_pages.py

It processes all of the man pages under /usr/share/man, moving old, uncompressed man page files to ~/tmp/old_man_pages.

I would post this to the Apple discussion forums, but it's really overkill. The short shell scripts already posted should work fine, if you ignore the harmless error messages and process each man/man* directory manually.


#!/usr/bin/env python
# encoding: utf-8
"Remove obsolete uncompressed man pages on an OS X Leopard system."

import sys, os, logging

def candidateOldManPages():
os.chdir("/usr/share/man")
for dirpath, dirnames, filenames in os.walk("."):
for f in filenames:
if f.endswith(".gz"):
fOld = f[:-3]
if fOld in filenames:
yield os.path.join(dirpath, f), os.path.join(dirpath, fOld)

def findOldManPages():
for p, pOld in candidateOldManPages():
s = os.stat(p)
try:
sOld = os.stat(pOld)
except os.error, info:
# Some man pages may be broken symbolic links
logging.warn("Can't stat (%s, %s): %s" % (p, pOld, info))
if os.path.islink(pOld):
yield pOld
else:
if s.st_mtime > sOld.st_mtime:
yield pOld

def mvOldManPages():
topDestDir = os.path.expanduser("~/tmp/old_man_pages")
for relpath in findOldManPages():
dirname = os.path.dirname(relpath)
filename = os.path.basename(relpath)

destDir = os.path.join(topDestDir, dirname)
if not os.path.exists(destDir):
os.makedirs(destDir)
logging.debug("mv %s %s" % (relpath, os.path.join(destDir, filename)))
os.rename(relpath, os.path.join(destDir, filename))

def main():
"""Mainline for standalone execution"""
logging.basicConfig(level=logging.DEBUG,
format="%(levelname)s: %(message)s")
mvOldManPages()

if __name__ == "__main__":
main()


2008/10/24

Let Google do the syntax highlighting

Guido recently posted some sample code to his new blog. The first comment complained that the code was "really crappy", improperly indented and hard to read.

Surprisingly, something good came of the rude complaint. Subsequent commenters described how to make simple changes to the blog template which would delegate code syntax highlighting to a Javascript library, google-code-prettify, which is hosted on Google Code.

This looks a lot simpler than the procedure I've been using, which involves embedding a lengthy blog template stylesheet and, whenever I want to post highlighted code, a 2-3 step incantation from within TextMate.

Anyhoo, this post is a test to see if I can incorporate google-code-prettify into this blog.

def genURLs(station):
tmpl = ("ftp://ftp.ncdc.noaa.gov/pub/data/asos-fivemin/6401-"
"{year}/64010{station}{year}{month:02d}.dat")
today = datetime.date.today()
year = 2004
month = 6
while True:
d = datetime.date(year, month, 1)
if d > today:
return
yield tmpl.format(year=year, month=month, station=station)

month += 1
if month >= 13:
month = 1
year += 1

And another -- this time in C++
#include "test_qt_sample.h"

void TestQString::toUpper() {
QString str = "Hello";
QVERIFY(str.toUpper() == "HELLO");
}

QTEST_MAIN(TestQString)

One more, with long source lines.
#!/usr/bin/env python
# encoding: utf-8

msg = "Surprisingly, something good came of the rude complaint. Subsequent commenters described how to make simple changes to the blog template which would delegate code syntax highlighting to a Javascript library, google-code-prettify, which is hosted on Google Code."

print len(msg.split())

I love the Python community. It is filled with people who respond to every complaint and criticism with courteous, useful solutions. (Google Code ain't bad, either :)

2008/10/22

FRONTLINE: nuclear reaction: Why the French Like Nuclear Energy

FRONTLINE: nuclear reaction: Why the French Like Nuclear Energy:

"French technocrats had never thought that the waste issue would be much of a problem. From the beginning the French had been recycling their nuclear waste, reclaiming the plutonium and unused uranium and fabricating new fuel elements. This not only gave energy, it reduced the volume and longevity of French radioactive waste. The volume of the ultimate high-level waste was indeed very small: the contribution of a family of four using electricity for 20 years is a glass cylinder the size of a cigarette lighter."


The French seem to be leading the world in managing nuclear power and its waste products. So how big, in terms of volume, is their waste storage problem?

Let's assume all of France's electricity is generated by French nuclear plants (it's not -- Wikipedia says the number is about 88%) and that they use all of their generated electricity. (Wikipedia says they export a lot of it.) The population of France is about 64,473,140. So that's about 16 million family-of-four equivalents. In 20 years, they'll need to store 16 million cigarette lighters. What is that, about 7 million cubic feet?

Assuming that's in the ballpark, and assuming you can store that waste without having to space it out to avoid assembling a critical mass, that'd be a cube about 19 feet on a side, every twenty years. Pretty small. The Bat Cave could probably handle 20 years of waste...

2008/10/21

Another success for cancer immunotherapy

For cancer patients, personalized treatment offers a new range of options -- and hope - Los Angeles Times:

"Those words could serve as the new mantra in medicine. After having his tumor removed and undergoing chemotherapy and radiation, he received a novel treatment that was designed using his own white blood cells and proteins taken from his tumor to prod his immune system into recognizing and attacking more cancer in his body."


Many credit Dr. William B. Coley for pioneering cancer immunotherapy, in the late 1800s and early 1900s. Coley focused on triggering bacterial infections in cancer patients, because his review of case histories showed that these infections often caused tumors to shrink. He surmised that the infections stimulated patients' immune systems to attack the tumors as well as the bacteria.

2008/10/16

CMake

Last spring I evaluated waf as an alternative to SCons (and its 3rd party Qt4.py plugin) for Qt4 projects. I've finally settled on CMake.

waf's wscript files could be beautifully concise. Alas, support for Qt4 applications was unstable, and the support for building OS X application bundles was both rudimentary and unstable. (By "unstable" I mean that the qt4 and osx tools would break periodically, and/or that the internal APIs would change so much between releases that my own customizations would break.)

The final straw was that I could not control the library order when linking static Qt4 libraries. That made it impossible for me to build Qt4 apps which used QtSvg.

I wish I had time to document these problems properly -- no doubt waf's maintainer(s) would prefer bug reports to detail-free claims that "it doesn't work."

In any case, CMake seems to be doing the job. It can perform out-of-line builds, supports defining and running unit tests, and doesn't get in the way of writing integration tests in Python, to drive e.g. C++ programs. It knows how to build Qt4 applications and lets me control the link order for static libraries. And it works well on OS X and Linux.

Go Vote Now

I'm Bob Schieffer of CBS News, and I will leave you tonight with what my mother always said: Go vote now. It will make you feel big and strong.
:)

The New York Times (registration required?) has video, a transcript, and some fact-checking on last night's debate.

2008/10/15

PolitiFact | Beating a retreat on a lavish retreat

PolitiFact | Beating a retreat on a lavish retreat:

Obama's comments suggest a misunderstanding of the details behind AIG’s collapse, or a deliberate effort to skip over the realities of AIG's corporate structure in order to make a good point. Also, Obama slams AIG for two junkets at a time when the company had only held one. AIG might have had a tin ear when it came to organizing corporate events. But Obama’s wrong to lay blame for the financial meltdown on a highly regulated, profitable part of the business that sells life insurance. We rule the claim Barely True."


Turns out the AIG junket involved a business unit which dealt in insurance, not the unit which lost all that money on mortgage-backed securities. And many of the attendees were independent AIG insurance agents, not employees of AIG. And of course the cost of the junket was several orders of magnitude smaller than the cost of the AIG bailout.

Even in the financial crisis, there are few simple truths.

2008/10/11

Lake Peak

Last month I got to spend time in the mountains above Santa Fe. The resulting video is up at Vimeo now.


Lake Peak from Mitch Chapman on Vimeo.

The compression is bad. Then again, Vimeo is free :) And they provide hyperlinks to the original uploaded video.

2008/10/07

We Are Too Many: 1/4 of World's Mammals Face Extinction

One Quarter of World's Mammals Face Extinction: Scientific American:

" Deforestation, along with hunting or gathering food are the prime causes of the rapid declines in land mammals, such as elephants in Asia; most endangered marine mammals, like the vaquita in Mexico's Gulf of California, are killed by fishing nets, ship strikes or pollution."
"Vast tracts of tropical rainforest have been replaced by palm oil plantations for food and biofuels, satellite imagery reveals."

2008/08/13

Put a feather in his cap...

Wikipedia: maccaroni

So that's what the lyrics are about.

2008/08/05

GPS cellphones to unleash gamers onto the streets - tech - 05 August 2008 - New Scientist Tech

GPS cellphones to unleash gamers onto the streets - tech - 05 August 2008 - New Scientist Tech:

"But being able to discover the physical location of other people has downsides. Researchers at Portsmouth University have had to abandon GPS games projects because they cannot get approval from the ethics committee.
'Already there are social networking applications for the GPS iPhone which let you see where other iPhone users are,' says Andy Bain, lecturer at Portsmouth University's School of Creative Technologies. 'If I were a thief I'd abuse that knowledge right away to get myself more iPhones.'
Commercial games developers are not subject to the same ethical scrutiny as academics, he adds. It could be left to their customers to work out how to avoid anti-social gamers."

I don't know anything about gaming or social activities — I'm an old-school geek. But... Given that phone GPS is supposed to be accurate to within a few meters only, it's easy to imagine "wave function" games which rely on GPS. Such games might show the locations of participants as spheres, to indicate the GPS error. It would fall to the players to collapse the wave functions (find the other players).

I could lose a lot of money creating dull GPS-based games. "Never mind whether it's alive or dead, where is Schrödinger's Cat?" "Bohrtherford — Find the electron." Etc.

Best to lie down until the urge goes away.
"But think about this. Supposing you were to introduce a psychic, someone with clairvoyant powers, into the experiment — someone who is able to divine what state of health the cat is in without opening the box. Someone who has, perhaps, a certain eerie sympathy with cats. What then? Might that furnish us with an additional insight into the problem of quantum physics?"
"Dirk, this is complete nonsense."

-- Dirk Gently's Holistic Detective Agency, Douglas Adams

2008/08/03

Compiling subversion 1.5.1 on OS X 10.5.4

I've just tried to compile the subversion 1.5.1 client from its two source tarballs (subversion-1.5.1-tar.bz2 and subversion-deps-1.5.1-tar.bz2). I took care to first hide the /usr/local libraries from my existing subversion installation. Even so, the compilation failed, complaining

/usr/lib/libexpat.a: No such file or directory


The workaround was to temporarily move the system's /usr/lib/libexpat* dynamic libraries, and then to rebuild.

Here's the build script which worked for me:
#!/bin/sh
set -e
VERSION=1.5.1
rm -rf subversion-${VERSION}
tar xjf subversion-${VERSION}.tar.bz2
tar xjf subversion-deps-${VERSION}.tar.bz2
cd subversion-${VERSION}
./autogen.sh
./configure --without-apxs --with-ssl
make
sudo make install
sudo make install-swig-py

2008/08/02

New TextMate bundles

These aren't really new. I just wasn't aware of them.

JavaScript Tools


The JavaScript Tools bundle helps you lint, format and compress your JavaScript code, and convert code to and from JavaScript bookmarklets.

My favorite feature: whenever you save a JavaScript file via Command-S, the bundle automatically runs it through jslint. If any errors or warnings are found, a tooltip appears which shows the number of warnings/errors.

If you run a full validation using Control-Shift-V, you'll get a popup window showing "compilation" results -- complete with syntax errors and clickable links to take you to the offending source code.

Installation


I installed under ~/Library/Application Support/. It may be better to use /Library/Application Support/.
$ cd ~/Library/Application Support/TextMate/Bundles
$ svn export http://bundles.bundleforge.com/trunk/bundles/JavaScript%20Tools.tmbundle/

BTW I'm not sure why export is preferred over checkout.

If TextMate is already running, you can load the bundle by selecting Bundles->Bundle Editor->Reload Bundles.

Sproutcore


I haven't done much with Sproutcore yet, but it does already have its own TextMate bundle which provides a few tab-completion snippets.

Installation

$ cd ~/Library/Application Support/TextMate/Bundles
$ curl --location --get http://github.com/sproutit/sproutcore-tmbundle/tarball/master -o sproutcore-tmbundle.tar
$ tar xf sproutcore-tmbundle.tar


The curl --location option is required, since github will issue a redirect.

The extracted tarfile will have a root directory name of the form sproutit-sproutcore-tmbundle-.*, so a directory rename is needed.
$ mv sproutit-sproutcore-tmbundle-blah-blah.../ Sproutcore.tmbundle



2008/07/29

Google Calendar supports CalDAV

Google Calendar has added support for CalDAV. For Mac weenies, this means you can share calendars across multiple Macs, adding and removing events via iCal. And you can do it without paying for MobileMe.

Wonderful stuff!

2008/07/24

Terminal.app hangs at startup

I just got bit by this bug, under OS X 10.5.4. The symptoms are that sudo hangs, and Terminal.app hangs when opening a new tab or when starting up. Console.app shows messages of the form

7/24/08 7:04:44 AM kernel devfs: ttys001: name slot allocation failed (Errno=17)


rprr posted a workaround in the above thread which worked for me. I don't know how to link to specific messages in the discussion thread (or whether that's even allowed under the terms of use, egad), so here's a recap:
1. Started Terminal. It hung up. Did Force Quit and Sent Crash report to Apple.

2. Since I had a working X11 application, I used it to open about 10 xterms using the Applications->Terminal Menu of X11.app

3. I started Terminal again. Now it works.

Anarchogeek: Beyond REST? Building Data Services with XMPP PubSub

Anarchogeek: Beyond REST? Building Data Services with XMPP PubSub

Addresses a few problems which I've never had to face. Still, lots of interesting ideas to chew on. Hints at techniques that could be applied even to low-volume web services which involve long-running server-side computations.

Many little parasites add up to one big biomass - earth - 24 July 2008 - New Scientist Environment

The main point of the article is that parasites are much more populous than previously believed. But this quote was the most interesting:

Many little parasites add up to one big biomass - earth - 24 July 2008 - New Scientist Environment:

"Dobson says he has work in press showing that parasites contain between 10 and 1000 times more pollutants than their hosts. He suggests parasites might play an important role in cleaning up the animals they inhabit."


So they castrate you, but they also keep you clean...

2008/04/22

Served up in a fine china Meatri Dish

Love the Steak and Save the Cow:

"PETA offers a $1 million prize to whoever can come up with tasty, edible, lab-grown meat, an advance they say would save billions of animals while still satisfying our carnivorous cravings."


Of course there's another solution, courtesy of the late, great Douglas Adams:
The animal staggered to its feet. It gave a mellow gurgle.
'A very wise choice, sir, if I may say so. Very good,' it
said, 'I'll just nip off and shoot myself.'
He turned and gave a friendly wink to Arthur.
'Don't worry, sir,' he said, 'I'll be very humane.'

2008/04/17

Why Lockheed Martin signed on w. the Spaceport

From KRQE in Albuquerque: Spaceport launch tests future spacecraft




"It looks a bit like the space shuttle and would fly to space and return the same way. But even the big version would not carry people, just satellites.

The goal is to get to orbit faster and cheaper thanks to an automated reusable spacecraft run by its own computers and just a handful of people for a launch crew."

New Scientist: Revealed: the Asian source of the annual flu epidemic

Revealed: the Asian source of the annual flu epidemic - health - 17 April 2008 - New Scientist:

"Better surveillance in east Asia should lead to better predictions of how flu is evolving, and what is likely to be needed in next year's flu vaccine, says Smith."

2008/04/08

Thank you, wsgi

Thanks to all of the developers behind wsgi.

When I first heard about it, wsgi struck me as an unnecessary complication. Then someone showed me how it could simplify testing of web applications. And now:

High-Scalability:

Google App Engine supports any framework written in pure Python that speaks CGI (and any WSGI-compliant framework using a CGI adaptor), including Django, CherryPy, Pylons, and web.py. You can bundle a framework of your choosing with your application code by copying its code into your application directory.

2008/04/04

Visual Web Developer "Failed to start monitoring changes"

I keep forgetting about this...

I'd like to do development on an ASP.NET web application which resides in a VMware Fusion shared folder. Unfortunately, as noted in the Microsoft Forums, Visual Web Developer 2005 Express Edition (at least) does not support hosting on a UNC share.

So, AFAICT, the only option is to do development in a local folder. To access that folder from the host operating system, it needs to be shared from the Windows VM.

VMware Fusion, OpenSUSE 10.3 x64, copy and paste

I recently installed a 64-bit OpenSUSE 10.3 virtual machine under VMware Fusion. Everything worked fine except cut&paste -- the vmware-user executable was not launching when X11 started.

ldd showed a dependency on libexpat.so.0, in addition to libexpat.so.1. I installed that using yast, rebooted, and -- huzzah -- cut&paste now works.

yast_install_libexpat.png

More details are available in the VMware Fusion discussions forum.

2008/03/26

Five Open Tools for 2D Structure Layout (aka Structure Diagram Generation)

Five Open Tools for 2D Structure Layout (aka Structure Diagram Generation)

Good summary of several alternatives. I've been using CDK of late, but am partial to tools written for CPython. I wonder if any of the alternatives make it as easy to extract coordinates as does CDK?

2008/03/21

TUAW Terminal Tip: Safari 3.1 brings true one-window mode

Terminal Tip: Safari 3.1 brings true one-window mode:

...true one-window mode is finally, finally, here for Safari. All you need to enter is the command below into Terminal, hit enter, and you're sorted.

defaults write com.apple.Safari TargetedClicksCreateTabs -bool true


Yay!

Functest

Writing Functests:

"This is where functest really shines. When you run functest against any directory or file the collector actually compiles a dependency chain which includes any valid python modules in all the parent directories..."


Hm. So functest would let me dispense with this nonsense boilerplate in my test modules?
import sys
import os
thisdir = os.path.abspath(os.path.dirname(__file__))
def relpath(p):
return os.path.abspath(os.path.join(thisdir, p))
sys.path.insert(relpath("../"))



I wonder if nose does/will provide similar facilities? It's pretty nice in other respects...

Twill, CherryPy 3 and testing with internal servers

Twill can test CherryPy web servers "in process", without having to run them as servers. I've used twill this way with CherryPy 2, but when I recently tried to do the same thing with a CherryPy 3 server everything broke.

I had based my code on an old CherryPy 2 tutorial by Titus Brown, and was trying to grep through the CherryPy 3 code tree to figure out how to patch it up. Bad idea :)

Yesterday Google finally turned up a solution, from a talk Titus gave at PyCon 2007.

The upshot: don't use cherrypy._cpwsgi.CPWSGIApp. In CherryPy 3, your application itself is already a WSGIApp. What's more, I think cherrypy._cpwsgi.CPWSGIApp may be broken. For sure, it and twill have incompatible ideas about the correct type of the 2nd constructor argument.

Anyway, thanks to Titus, here's an example of how to connect twill to a CherryPy 3 application for in-process testing:

import twill
import cherrypy
...
wsgi_app = cherrypy.tree.mount(myApp, "/", myConfig)
cherrypy.engine.start(blocking=False)
twill.add_wsgi_intercept('localhost', 8080, lambda: wsgi_app)


[Update 2008/03/24] Ditched the cherrypy.server.quickstart() invocation, per fumanchu's comment. Reported as Ticket #801.

2008/03/10

waf build errors

I'm evaluating waf to see if it's easier to use than SCons (especially for Qt projects). So far the results are encouraging. In particular, waf reports many kinds of problems using straightforward (color-coded!) error messages, rather than Python tracebacks.

target 'build_info' does not exist

Sometimes waf does spew an unintelligible Python traceback reminiscent of SCons. For me, these typically end with a KeyError:

File "/path/to/.waf-1.3.2-blah/wafadmin/Task.py", line 290, in must_run
prev_sig = tree.m_sig_cache[key][0]
KeyError: -214303645


This error always translates to "you are trying to build a file which is part of your source tree."

My SConscripts work in situ, creating object files etc. in the same directories where the source code resides. waf prefers to put build products in a separate build/ subdirectory. When waf is instructed to generate an output file in its build tree, and when that file already exists in the source tree, waf fails with the KeyError traceback.

I'd bet this problem is most common in software projects which started life using build systems like Make or SCons -- tools which default to building in situ.

For example, I'm trying to use waf in a subversion workspace where I've been doing SCons builds for years. To make matters worse, one of the build products is a header file, containing revision number and date for the current build. This looks like a source file, so it's likely that I never checked whether it was properly removed by scons -u -c.

In retrospect, I should have started with a clean check-out...

2008/03/07

Rogue Amoeba: Code Signing and You

Code Signing and You:

"Code signing itself is a neutral technology, but it gives incredible power to the system vendor, and that power is just waiting to be exercised and abused."


It's possible that Apple intends to close off the OS X platform. If that happens, I'll go back to Linux.

2008/03/06

DailyTech - Researcher: Basic Greenhouse Equations "Totally Wrong"

From DailyTech:

"NASA refused to release the results.  Miskolczi believes their motivation is simple.  'Money', he tells DailyTech.  Research that contradicts the view of an impending crisis jeopardizes funding, not only for his own atmosphere-monitoring project, but all climate-change research.  Currently, funding for climate research tops $5 billion per year.
"

"The equations also answer thorny problems raised by current theory, which doesn't explain why "runaway" greenhouse warming hasn't happened in the Earth's past. The new theory predicts that greenhouse gas increases should result in small, but very rapid temperature spikes, followed by much longer, slower periods of cooling -- exactly what the paleoclimatic record demonstrates."

"Miskowlczi has used his theory to model not only Earth, but the Martian atmosphere as well, showing what he claims is an extremely good fit with observational results."


Hey, at least we still have peak oil.

2008/03/03

Intermittent Pickle Problems in Jython

The previous post mentioned "integrating" Jython and CPython by transmitting a stream of pickles between the two. I encountered one intermittent problem with this approach, and I'm unsure of its cause. (Hm, and I should probably post this to a Jython mailing list...)

Problem


In Jython I'd pickled the str() of a java.io.StringWriter, into which I'd just written the SD representation of a CDK molecule. Jython could create the pickle alright. But when I tried to unpickle it in CPython, sometimes, for some molecules, I got a traceback:
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pickle.py", line 970, in load_string
raise ValueError, "insecure string pickle"
ValueError: insecure string pickle


The error occurred consistently in my application code, always on the same input structure. But I couldn't derive a simple test script to demonstrate the problem.

Investigation


Examination of the problematic pickle data showed that a Python unicode string literal marker had somehow been inserted, and the type code for the item was somehow S (for string) rather than V (for unicode):
...
sS'sdf'
p3
Su'ZINC00000181\n CDK...
^ What the... ?


Workaround


Google turned up a usable workaround: encode the offending string as utf-8 before trying to pickle it.


import codecs
enc = codecs.getencoder('utf8')
...
sdf = enc(sdf)
...


Ted Leung: The Sun is going to shine on Python

Congratulations to Ted Leung (and to Frank Wierzbicki):
The Sun is going to shine on Python.

Their work at Sun will extend well beyond Jython, but Ted's post reminded me of my recent experiences. Jython 2.2 sure made it pleasant and easy[1] to get what I needed out of CDK, and to integrate the results into a CPython app via pickle and subprocess.

I did miss some language features such as yield which have appeared in CPython since 2.2. Maybe at some point Ted and/or Frank will have time to re-sync Jython with CPython?

[1] I had one intermittent problem with this approach. See the next post.

2008/02/26

New Scientist: Fatal brain cancer tamed by gene therapy

Fatal brain cancer tamed by gene therapy - 25 February 2008 :

Previous attempts to treat glioblastomas with gene therapy failed because some tumour cells survived and regrew. The new treatment overcomes this problem by permanently priming the immune system to pick off any straggler tumour cells.

A harmless virus that only infects fast-dividing cancer cells is injected directly into the brain... One gene, HSV1-TK, kills the cancer cells by activating ganciclovir...


And here's the cool bit:
...a second gene, Flt3L... summons immune "dendritic" cells from the bloodstream into the brain.


(How does it do that?)

[The dendritic] cells engulf the debris and transport it back to lymph nodes, where they re-prime the immune system to attack any remaining tumour cells during and after treatment.


Lymph nodes seem like a gunnery school for white blood cells: you go there to learn how to distinguish friend from foe. (BTW fevers seem to help lymph nodes do their jobs.)

2008/02/25

Doc Searls: The FCC and the Giant Zero

The FCC and the Giant Zero:

"Message to Verizon and the rest: the Internet is not about ‘consumer choice’. We produce as well as consume. We need to be able to run our own servers. [emph. added] We need to be able to exercize supply as well as demand. We need symmetricality, not just neutrality."


Amen to that.

I live in Santa Fe. As far as I can tell, my choices are Earthlink (via Qwest DSL @ 1.5Mbps) and Comcast. If I want a static IP address, a useful step to server-hood, then my rates would go up by 30%. Bah.

Netgear WAN MTU Size

(Not sure why I haven't written this up yet. It sure was a problem for a long time...)

I used to work "offsite" -- outside the home -- several days a week. When offsite my laptop could perform subversion operations against a repository on my home network, with good performance. But when the notebook was "inside" the home network, those same operations would take forever.

Eventually I stumbled on the fix, clearly explained in the help sidebar of the WAN Setup page of my Netgear WGR614 router: change the MTU to 1492. (Shades of Christopher Columbus!)

Nobody reads documentation :\

The normal MTU (Maximum Transmit Unit) value for most Ethernet networks is 1500 Bytes, 1492 Bytes for PPPoE connections, or 1436 for PPTP connections.


2008/02/14

Site-specific browsers and web-app testing


 ?


Site-specific browsers should simplify testing of some types of web applications, e.g. those which support multiple registered users. On platforms such as Mac OS X, which typically run only one instance of each application, SSBs should allow you to launch multiple, distinct applications which point to the same website.

Is anyone doing this? Is it better (and does it always suffice) to simply run multiple copies of a twill script, and to dispense with browser-based tests?

I haven't tried Fluid yet, since my main work machine is still running Tiger.

Alas, I guess basic Prism apps won't do the job:

prism_one_copy.png


Technorati Tags:
, , ,


2008/02/13

DNA Articles du Jour

Next-generation pathogen sequencing

http://www.technologyreview.com/Biotech/20191/

454 Life Sciences have figured out how to isolate pathogen RNA from human tissue samples, and have used the process to identify previously-unknown pathogens as the likely cause of death for three transplant recipients.

In the 1980s, my brother's neighbor almost died from an illness whose cause was never determined. More recently, local doctors have been unable to figure out why a friend's daughter had a fever for three weeks. This process may make it possible to diagnose the causes of many more illnesses.

"...the sequence of the new virus was different enough that existing methods could not have detected [it]..."


"As many as 40 percent of cases of central nervous system disease cannot be traced back to a specific culprit. For respiratory illness, the figure is 30 to 60 percent."


"Usually, PCR requires some advance knowledge of the sequence in question because it relies on molecular primers that match the string of code to be amplified. But 454 sequencing avoids that problem by using a large number of random primers."



Combining DNA from >2 "parents"

http://www.dailytech.com/article.aspx?newsid=9835

I didn't know people could have problems with their mitochondrial DNA.

"...[the] research involved implanting the DNA from a [woman] with a mitochondrial disorder into the egg of a [woman] with healthy mitochondria. Thus the woman with the genetic disorder passed on the rest of her genetic legacy, while the other woman contributed only [healthy mitochondrial] DNA."


Ethical firestorm to follow...

2008/02/10

Installing PVM under MacPorts on Leopard

I've been having trouble getting PVM 3.4.5 to install under MacPorts on Leopard. The conf/DARWIN.def configuration file defines the FAKEXDRFLOAT preprocessor symbol; it may be needed for OS X 10.4, but it causes a compiler error w. GCC 4.0.1 under 10.5:

../../src/pmsg.c:785: error: static declaration of 'xdr_float' follows non-static declaration.


The workaround is simple: install the Darwin8 variant.

$ sudo port install pvm +darwin_8

2008/02/09

DailyTech - Solar Activity Diminishes; Researchers Predict Another Ice Age

DailyTech - Solar Activity Diminishes; Researchers Predict Another Ice Age:

Researcher Dr. Timothy Patterson, director of the Geoscience Center at Carleton University, shares the concern. Patterson is finding "excellent correlations" between solar fluctuations, a relationship that historically, he says doesn't exist between CO2 and past climate changes. [emphasis added] According to Patterson. we shouldn't be surprised by a solar link. "The sun [is] the ultimate source of energy on this planet," he says.


Oh no! Is it too late to start increasing our greenhouse gas emissions, to keep the planet from freezing over? ;)

Whatever is the truth about how we affect our environment, it's good to be reminded of our insignificance — and our uncertainty.

2008/01/30

Stephen Fry - Bloggery

No, no: Break a Leg.

Stephen Fry has broken his arm so badly it took ten screws to pin it in place. The x-rays look so bad they actually convey a sense of the pain he must be feeling.

Interesting to note that he suffered the break while filming a segment of "Last Chance to See" in Brazil. I didn't know there was such a series, but (from a selfish perspective) what serendipity: Douglas Adams was one of my favorite authors, and I'm a fan of Mr. Fry's work as well.

I have a little list of people I'd like to meet. No idea what I'd say to any of them, except perhaps, "Thank you." Stephen Fry is on that list. Douglas Adams was there, too, but I missed him by a year; like others he has slipped onto the list of missed opportunities.

Maybe I should just post a "get well soon" to Mr. Fry's blog :)

2008/01/26

Online NewsHour: Update | Obama Routs Clinton in South Carolina | January 26, 2008 | PBS

Online NewsHour: Update | Obama Routs Clinton in South Carolina | January 26, 2008 | PBS:

'We are up against the idea that it's acceptable to say anything and do anything to win an election,' Obama said.


That's almost word-for-word what the late Paul Tsongas said about Bill Clinton during the 1992 Democratic primaries. From the New York Times archives:
Paul E. Tsongas unleashed his harshest attack yet tonight against Bill Clinton, assailing his Democratic rival as a "pander bear" who "will say anything, do anything to get votes."


We'd have a different world if Tsongas had won. At the least he would have helped us face the fact that Social Security and Medicare are unsustainable. The Concord Coalition strives, still, to spread his message.

Back to the present, and Obama:
'We know that this is exactly what's wrong with our politics; this is why people don't believe what their leaders say anymore; this is why they tune out. And this election is our chance to give the American people a reason to believe again.'


2008/01/25

Likin' bzr

I've been using bzr for the past couple of months, and am liking it.

I'm not using it on any projects involving multiple people. All of my employer's code still lives in subversion repositories.

Rather, I'm using bzr for local, lightweight revision control. It sure is nice to be able to go into a directory tree where I'm whanging together a prototype, or where I'm working up some documentation; and to say

$ bzr init
$ bzr add .
$ bzr commit -m "New repository"'


And bingo, I can make changes and back out of them at will, with little fear of trashing anything. And of course, for technical writing it's nice to be able to refer to old revisions.

Lately I've started fiddling around w. bzr branch, building prototype web servers in one directory tree and occasionally pulling them out to a "deployment" branch. This feels a little more like working with subversion, but bzr lets me make local "checkpoint" commits, where some things are broken, without fear of breaking the build.

At this point my only problem with bzr is that I don't quite grok what's going on under the hood. Distinctions between branches and checkouts seem clear enough. But I don't understand why, when I commit from a "checkout" workspace, a subsequent bzr status in the source workspace will tell me that my workspace is out of date; whereas a similar sequence of actions from a "branch" workspace -- a commit followed by a push, followed by a status in the target workspace -- offers no warning that the code has been updated.

Given some time and experience these confusing behaviors should make more sense. Meanwhile, it sure is nice having cheap, local revision control. Kinda like XCode 3's Project Snapshots, but without the XCode :)




Technorati Tags:
, ,


2008/01/16

Mill at the Camp Bird Mine, Ouray County, Colorado (LOC)

Wow. Ken and Dave and Suzanne and I drove past this mine in August, 2006, in Suzanne's indomitable Bronco. The place looks a bit more run-down now.

This LOC collection is going to be full of gold nuggets...

2008/01/14

DailyTech - Cellulosic Ethanol Promises $1 per Gallon Fuel From Waste

DailyTech - Cellulosic Ethanol Promises $1 per Gallon Fuel From Waste

GM's (or rather, Coskata's) approach starts ... by putting the various organic waste materials, such as tires, crops, crop waste and yard waste into a grinder. The remaining powder is then exposed to plasma, which causes the organic powder to ferment, releasing carbon-chain gas. It rises into the air where natural anaerobic bacteria eats the gas molecules and excretes ethanol and water vapor. This mixture then rises, and travels through a series of tubes with a separating membrane. The yield is pure water and pure ethanol.

...an analysis of the process conducted at Argone National Laboratory reveals that for every unit of energy Coskata uses, it creates approximately 7.7 times as much energy, a ratio well above current tradition ethanol production.

Lutz ... also explained that the move will take GM and other auto makers "out of the firing line" of accusations that they contribute to everything from "out-of-control global warming, to funding terrorism."


Producing fuel from renewable resources may reduce net carbon emissions, and it's interesting to see technological breakthroughs emerge. But I wonder how well a change in fuel sources would compare with a change in lifestyle -- for example, one which encouraged the use of mass transit -- in reducing emissions. Have any relevant studies been published?

2008/01/10

Sir Edmund Hillary has died - Yahoo! News

From Yahoo! News:

WELLINGTON, New Zealand - Sir Edmund Hillary, the unassuming beekeeper who conquered Mount Everest to win renown as one of the 20th century's greatest adventurers, has died, New Zealand Prime Minister Helen Clark announced Friday. He was 88.


'Sir Ed ... lived a life of determination, humility, and generosity,' Clark said in a statemen"


...he was more proud of his decades-long campaign to set up schools and health clinics in Nepal, the homeland of Tenzing Norgay...

2008/01/07

Using supervisor on OS X

Last week's sojourn with Leopard gave me a chance to learn about some new ways of performing common system administration tasks. I've already written about using iCal in place of cron. I also had a chance to get acquainted with launchctl.

I have some custom web app servers which need to launch at system startup, and which need to be restarted if they fail. (I guess I could launch them from within Apache...)

The last time I needed to launch anything at system startup on OS X, /Library/StartupItems was in vogue. It's still usable, but now launchctl and /Library/LaunchDaemons et al are recommended in its place. As the launchd man page states:

In Darwin it is preferable to have your daemon launch via launchd instead of modifying rc or creating a SystemStarter Startup Item.


At some point my web apps may be deployed on Linux. So instead of going all the way with launchctl I decided to introduce supervisor into the mix: use launchctl to keep supervisor running, and use supervisor to keep the custom services running.

Of course this is a stupid thing to do. Both launchctl and supervisor are intended for the same types of problems. But supervisor will be available on Linux whereas, presumably, launchd will not. This is as good a place as any to learn how to use supervisor.

Besides, I have a long history of solving problems in ways which are almost, but not quite, entirely incorrect.

After much bumbling about, this became the plist script which would get supervisor up and running at system boot:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN
http://www.apple.com/DTDs/PropertyList-1.0.dtd >

<plist version='1.0'>
<dict>
<key>Label</key><string>com.agendaless.supervisor</string>
<key>ProgramArguments</key>
<array>
<string>
/Library/Frameworks/Python.framework/Versions/Current/bin/supervisord
</string>
</array>
<key>Debug</key><true/>
<key>RunAtLoad</key><true/>
<key>KeepAlive</key><true/>
</dict>
</plist>


This script is installed as /Library/LaunchDaemons/com.agendaless.supervisord.plist. As the launchctl.plist man page says, that's the place for "System wide daemons provided by the administrator."

Both the name of the plist file and the value of the Label are based on the domain of the copyright owner for supervisor: http://www.agendaless.com/

The ProgramArguments consist solely of the path to the supervisord executable.

RunAtLoad ensures that supervisor is started as soon as it is loaded.

Setting Debug to true increases the odds that, if some problem arises in running supervisor, the problem will be noted in the system log.

Finally, KeepAlive ensures that, if supervisor dies, it will be restarted. (KeepAlive is not documented in the OS X 10.4 man pages; it may make sense only for OS X 10.5. I need to re-read the blog where I saw it mentioned to better understand its intended use.)

I'm still such a novice with supervisor (not to mention launchctl) that I'm not sure supervisor meets the expectations of launchctl. But in any case, the above seems to work.




Technorati Tags:
,


2008/01/06

Intel iMac hard drive failure

Just after returning from Christmas vacation my iMac (Intel Core Duo 1.83GHz, 17") started showing spinning beachballs. And the system log started accumulating error messages similar to those described on this blog. The hard drive was dying.

Luckily I'd run a SuperDuper backup the night before starting vacation.

It was also lucky that I had an early-model Intel iMac. Supposedly newer models are much harder for amateurs to service.

Thank goodness for John Wood's iMac_Disassembly web page. If it weren't for him I'd either be running from an external hard drive right now or shipping the iMac off for a very expensive (not under AppleCare) repair.

Using the photos and instructions on the disassembly page I was able to swap out the failed 160GB Seagate Barracuda 7200.7 for a 320GB Western Digital WD3200AAJS, purchased from NewEgg. Required tools:

  • A #0 Phillips screwdriver for the memory slot cover
  • A T-8 Torx driver for the top case
  • A small Allen wrench (not sure about the size) for the screws securing the LCD panel to the back case
  • A sharp knife and a spot of rubber cement for moving the temperature sensor to the new drive
The whole job took about an hour and a half, not because it was difficult, but because I am a coward :)

There were two minor differences between my iMac and the one Mr. Woods took apart. Mine had two "hooks" at the top of the front plate, and I bent one of them slightly before discovering it was there. And in addition to the black tape overlying the sides and bottom of the LCD panel, I had perforated foil tape running along the top edge.

Everything's up and running again, and now I have lots of free disk space :) Time to do another backup. Of course in the meantime I've been doing development under Leopard on the MacBook; so it's tempting to follow that backup with an archive-and-install of 10.5 onto the iMac...

2008/01/03

Leopard, 'ls -l' and extended attributes

Under OS X v10.5 the permissions column from ls -l contains extra characters which I haven't seen before.

$ ls -l
total 16
-rwxr--r--@ 1 me me 165 Jan 2 06:38 run_webalizer
-rw-r--r--@ 1 me me 0 Jan 3 10:04 run_webalizer.scpt
The man pages didn't say anything about these @ characters. Google was no help since it ignores punctuation characters like "@".

Eventually I realized that, since I had done an "upgrade" installation of Leopard, my man pages might be out of date. Indeed they are: Apple's online man pages explain @ and much else that's new in the ls command:
If the file or directory has extended attributes, the permissions field printed by the -l option is followed by a '@' character. Otherwise, if the file or directory has extended security information, the permissions field printed by the -l option is followed by a '+' character.


And
The following options are available:
-@ Display extended attribute keys and sizes in long (-l) output.


Ah, Bach. Look at some of the interesting tidbits revealed by -@:
$ ls -l@
total 16
-rwxr--r--@ 1 me me 165 Jan 2 06:38 run_webalizer
com.macromates.caret 33
-rw-r--r--@ 1 me me 0 Jan 3 10:04 run_webalizer.scpt
com.apple.FinderInfo 32
com.apple.ResourceFork 754
So that's how TextMate knows where to put the cursor when I re-open a file.

Now I just need to figure out how to get my man pages up to date.

Replacing cron with iCal

cron is deprecated in OS X. iCal makes a straightforward, if tedious, replacement, despite its limited support for scripted alarms.

In iCal you can easily create a repeating event with an associated alarm that runs a script.

ical_repeating_event.png


Put all of your periodic system management events into a hidden "Automation" calendar (so they don't clutter up the calendar view) and you're all set.

automation_calendar.png


Of course, there's a problem. I prefer to write system management scripts using Python. iCal can run only AppleScripts.

It's easy to write an AppleScript "wrapper" which just launches a shell script, but the process involves lots of button-clicking:
  • Launch Script Editor
  • Enter do shell script "/path/to/shell/script"
  • Save the script
  • Quit Script Editor
Luckily, the osacompile command lets you do the same thing from the command line. Together with Python's pathname-manipulation facilities, osacompile makes it simple to create AppleScript wrappers for shell scripts.

Given the path to a shell script, the following Python program creates a corresponding AppleScript wrapper in the same directory:
#!/usr/bin/env python
import sys, os, subprocess, logging
def main():
for filename in sys.argv[1:]:
pathname = os.path.abspath(filename)
scriptname = os.path.splitext(pathname)[0] + ".scpt"
if os.path.exists(scriptname):
os.remove(scriptname)
status = subprocess.call([
"osacompile",
"-e", 'do shell script "%s"' % pathname,
"-o", scriptname])
if status:
logging.error("Got status %d creating %s" %
(status, scriptname))

if __name__ == "__main__":
main()