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()