2005/12/30

China, the USA, competition for resources

China eyes increased energy cooperation with US - Yahoo! News

It's interesting to watch as China's per-capita energy demands begin to approach those of the US. Latest development: China's top economic planning body recommends increased cooperation with the US on energy issues.

I should go read the details before posting this :) but it's encouraging that the Chinese govt are trying to plan ahead rather than wait until we are in direct conflict.

China has a chance to play leapfrog in technology for energy production and conservation, and in transportation. That's where the real opportunity lies for the US: in sharing the costs, and results, of improving energy efficiency. Worst of all worlds would be for us to be stuck with our current energy infrastructure while other nations move ahead.

2005/12/20

Bush's Snoopgate - Newsweek National News - MSNBC.com

I agree.

If we could just trust this president, or any president, then we wouldn't need the Congress and the courts.

Our executive branch has long kept secrets from its citizens -- classified documents, "black" military programs. The risk to the country in permitting the government to operate in secret, without accounting for its actions, is much greater than the risks which those actions are supposed to mitigate. The risk is that, once the habit of government secrecy is established, the ability of the country to detect and act against dangerous concentrations of governmental power will be lost.

2005/12/19

Honda plans to mass-produce solar cells

According to the article production will start in 2007. Once it reaches full capacity Honda will be producing enough solar panels each year to power 8000 homes.

"Honda said its solar cells would be composed of non-silicon compound materials, consuming half as much energy and generating 50 percent less carbon dioxide during production when compared with conventional solar cells made from silicon."

How will their efficiency compare to those of other types of solar panels? Dunno.

They're targeting the Japanese domestic market first.

2005/12/16

Javascript Animation: Tutorial, Part 2 - Schillmania.com

Look here for some clues on how to do animation, in JavaScript, without expensive page reflows.

The tutorial also describes ways to animate more efficiently, using a single timer. This evokes the realtime "executives" I used to see when I worked with flight sims in the aerospace industry.

2005/12/15

The Straight Dope: Did John Wayne die of cancer caused by a radioactive movie set?

"Thirty years later, however, half the residents of St. George had contracted cancer, and veterans of the production began to realize they were in trouble. Actor Pedro Armendariz developed cancer of the kidney only four years after the movie was completed, and later shot himself when he learned his condition was terminal."

Mom has wondered from time to time whether or not Grandpa's leukemia had anything to do with his filming venues. She has mentioned a filming location, fallout, and the names of a few actors who died of cancer after working there. But I could never remember the place names. This link which my girlfriend provided seems to point to the right places.

Treehugger: Vulgarity and Nature: Chapter from Robert Grudin's Upcoming Book - American Vulgar

One of the things that drove me out of Ohio was the local attitude toward "growth" – it was considered good, progress, an improvement. All Icould see was the suburbs of Cincinnati and Dayton growing together along the I-75 corridor.

One of my friends and co-workers had this view of development. He was proud to live in one of the development communities that was spreading out over what had been farm land. (The community, whose name I have since forgotten, was featured a couple of years later in a National Geographic article about urban sprawl.)

Couldn't help thinking of my friend and his McMansion while reading this excerpt from Robert Grudin's "American Vulgar":


Growth is not just a cultural obsession. Growth has become a theoretical model for economists, executives and even civil servants. The idea is that economic entities[...] cannot remain robust unless they keep growing, and that this growth imperative has no chronological limit[...]The most colossal and preposterous of all vulgarities would be a civilization that, in the course of its busy, growing ways, paved over its environment and destroyed its only source of sustenance.

2005/12/13

LAMP vs. Java

This year I joined a team which is building web apps to teach cheminformatics. We do use a little Java because one of our vendors implemented its toolset in Java. (And those tools include 3D chemical structure depictors.)

We got started in the springtime, shortly before the appearance of TurboGears. But we're using a similar set of tools: PostgreSQL, Python, CherryPy and CherryTemplate, jsolait, and a fair bit of custom JavaScript. And HTML. And CSS 2.1. And R, at least for prototyping. And we're managing it all, to the extent that we're managing anything :), with subversion and Trac.

As the Businessweek article suggests, this set of tools works well. I don't see any reason to use any more Java than we absolutely must.

2005/12/12

Wired News: Cut Emissions and Pump More Oil

Some good news for oil, for a change?

Just how much CO2 is produced during oil refining, anyway? The article claims that pumping the gas back into oil fields in Western Canada alone could reduce "CO2 emissions to the tune of pulling more than 200 million cars off the road for a year".

The lifetime of the field where testing has occurred has been extended for another 20 years. The subsurface rock in that field is sedimentary; the article claims that, if the technique were tried in basalt fields, the re-injected gas would be converted to calcium carbonate in less than 18 months. From volcanic rock to chalk -- who knew.

2005/12/11

Sanyo Xacti VPC HD1EX | Digital Camera Review

Will Sanyo make HD video affordable?

Next in the Xacti VPC line: 1270x720x30fps, MPEG-4 format, 5MP digital imager, 10x optical zoom, recording to SD memory cards.

2005/12/10

New Mexico to be Virgin space hub | CNET News.com

Las Cruces will be moving up in the world.

2005/12/03

Weeping Eye

Flickr Photo

The Weeping Eye, a feature in Upper Antelope Canyon.


Okay, this is really just a test of Flock on Mac OS X. Flock integrates web browsing, blog editing and (Flickr) photo management/reference.


technorati tags: ,

2005/09/06

Digital Web Magazine - Writing Semantic Markup

This is a nice, concrete explanation of semantic markup and microformats.

2005/09/05

Summer Storm, Santa Fe Ski Basin


Summer Storm, Santa Fe Ski Basin
Originally uploaded by Chitch.
Just testing Flickr's blog-editing facilities.

DARPA Walrus

RED HERRING | The Pentagon's Flying Walrus

Also here.

"The usefulness of such a vessel for non-military purposes was evident as New Orleans sank into chaos after Hurricane Katrina left thousands of people stranded, thirsty, and hungry."

"...even a 1-foot-wide hole in the fabric of a 140-feet long airship would not bring the thing down in less than an hour."

"...there is plenty of demand in the private sector for a bigger cargo carrier. The largest fuel-guzzling Boeing 747 cargo plane can only carry 400 tons.

There has to be demand for an airship that could haul 500 tons directly from a Chinese factory to a Wal-Mart parking lot somewhere in the United States."

2005/08/22

A Wave of Marine Extinctions?

Scientists Fear Oceans on the Cusp Of a Wave of Marine Extinctions

Combined with the environmental costs of raising cattle, this kinda argues for a vegan diet...

"In the past 300 years, researchers have documented the global extinction of just 21 marine species -- and 16 of those extinctions [have] occurred since 1972."

"The large-scale industrialization of the fishing industry after World War II, coupled with a global boom in ocean-front development and a rise in global temperatures, is causing fish populations to plummet."

"Large-scale fishing accounts for more than half of the documented fish extinctions in recent years... ocean fish catches tripled between 1950 and 1992."

Not only the intended catch species are threatened: "...accidental bycatch alone accounted for an 89 percent decline in hammerhead sharks in the Northeast Atlantic."

"...conservationists said NOAA officials are reluctant to classify fish as endangered because it conflicts with their agency's mission of promoting commercial fishing."


How do they produce these numbers? Accounting for catch sizes seems straightforward -- just look at the books for the fisheries. But how does one figure out the total decline in hammerhead shark populations, let alone the fractional causes for that decline?

Still, the article provides plenty of food for thought.

2005/08/18

Java Jar file manifests, and Class-Path

I've been having trouble building jar files. I'm using Apache ant on Mac OS X. I have been unable to create valid Class-Path values when using ant to generate my MANIFEST.MF files.

The solution: compose my MANIFEST.MF file manually (based on the broken MANIFEST.MF created by ant). It turns out that Class-Path can be specified as a series of space-separated paths extending across multiple lines, with leading indentation. F'rinstance:


Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.4
Created-By: 1.4.2-50 ("Apple Computer, Inc.")
Main-Class: JChemLoader
Class-Path: /usr/local/jchem/lib/batik-core.jar
/usr/local/jchem/lib/chart.jar /usr/local/jchem/lib/dom4j.jar
/usr/local/jchem/lib/jchem.jar
/usr/local/lib/java/postgresql.jdbc.jar


As long as no single Class-Path entry is more than 70-71 characters in length, this should work.

The problem with ant-generated Class-Path values was that the values, when written out, were being split at arbitrary points. (The value I was supplying to ant was a colon-separated sequence of pathnames. Maybe that was part of my problem?) ant was trying to satisfy the rules for jar file formatting, as specified by Sun:


Line length:

No line may be longer than 72 bytes (not characters), in its UTF8-encoded form. If a value would make the initial line longer than this, it should be continued on extra lines (each starting with a single SPACE).


Perhaps it's just my lack of familiarity, but I find Java, jar files, and CLASSPATH to be a vile combination. Python (PYTHONPATH) handles things much more cleanly. Even gcc and make handle library locations in a much more pleasant way.

2005/08/17

Green Car Congress: Solar-Power-Augmented Prius Takes the Grid Out of Plug-in

Green Car Congress: Solar-Power-Augmented Prius Takes the Grid Out of Plug-in

No greenhouse costs beyond those needed to make the PV array; ditto other environmental costs (e.g. poison leaching).

I wonder how much weight these things add? I wonder if they do anything at all to reduce the heating of the car interior? My Subaru is like an oven in the northern NM sun, just from heat radiating into the interior from the roof.

2005/08/06

Passing arguments to Mac applications

I'm building a suite of cooperating, cross-platform GUI applications. They're written in C++, using Qt. I'd like to be able to pass command-line arguments from one app to another, but on OS X I've had trouble doing so.

Mac GUI applications typically are launched via NSWorkspace (or, for non-Cocoa apps like the ones I'm building, via the underlying CoreFoundation functions). They're launched with no argv entries. Arguments typically consist only of pathnames to open or print, etc. Accessing them is no picnic.

The simplest solution I've found uses environment variables to pass the arguments around. It works on Unixes including OS X. It should work on Windows.

One gotcha is that you have to explicitly retrieve the environment arguments when your GUI app starts up, instead of having them initialized for you by the C/C++ runtime.

Another gotcha is namespace collisions. The names of the environment variables conveying the arguments must be chosen carefully to prevent them being used/modified by unrelated applications. Maybe some sort of Java-like "com.dmoonc.my_app_suite..." convention would be appropriate.

Anyway, this is probably good enough for now:

envargs.h


#ifndef ENVARGS_H
#define ENVARGS_H

#include <string>
#include <vector>

typedef std::vector< std::string > ArgList;

// Retrieve and clear the environment arguments
// passed to this process.
// Should be done as soon as possible
// after application launch.
void getEnvArgs(ArgList& args);
ArgList envArgs();

// Set environment arguments for passing
// to a process about to be launched.
void setEnvArgs(ArgList& newArgs);

#endif // ENVARGS_H


envargs.cpp


#include "envargs.h"
#include <iostream>
#include <sstream>
#include <stdlib.h>

using namespace std;

static const string C_NumArgsName("_appsuite_numargs");
static const string C_ArgPrefix("_appsuite_arg_");

void getEnvArgs(ArgList& args)
{
args.clear();

char *numArgsCStr = getenv(C_NumArgsName.c_str());
if (numArgsCStr)
{
istringstream ins(numArgsCStr);
int numArgs;
if (ins >> numArgs)
{
for (int i = 0; i < numArgs; ++i)
{
ostringstream argname;
argname << C_ArgPrefix << i;

const char *argnameCStr = argname.str().c_str();
char *argCStr = getenv(argnameCStr);
if (argCStr)
{
string arg(argCStr);
args.push_back(arg);
}
else
{
args.push_back("");
}
}
}
}
}

ArgList envArgs()
{
ArgList result;
getEnvArgs(result);
return result;
}

static bool cppsetenv(string name, string value)
{
bool result = true;
ostringstream spec;
spec << name << "=" << value;

result = (0 == putenv((char *)(spec.str().c_str())));
if (!result)
{
cerr << "Could not set environment variable:" << spec << endl;
// TO DO: Ditch the bool return value and throw an exception
}
return result;
}

static bool cppsetenv(string name, unsigned int ivalue)
{
ostringstream svalue;
svalue << ivalue;
return cppsetenv(name, svalue.str());
}

void setEnvArgs(ArgList& newArgs)
{
if (cppsetenv(C_NumArgsName, newArgs.size()))
{
for (unsigned int i = 0; i < newArgs.size(); ++i)
{
ostringstream name;
name << C_ArgPrefix << i;
cppsetenv(name.str(), newArgs[i]);
}
}
}

2005/08/03

RSS News Readers: Extrapolation

This claim is false:

"When people get an RSS feed, they need not go through standard Web site navigation patterns that we are accustomed to tracking. They look at just what they want, when they want."

The same claim could be made for the early web. The problem is not looking at what you want. The problem is finding what you want to look at.

What (I Hope) Is Next For RSS News Readers


RSS news readers help you find and read content which is of interest to you. They face challenges.

RSS Advertisements


News readers will become less useful if they cannot help you filter out RSS advertisements.

Redundant Articles


I already wish news readers could perform higher-order aggregation. My subscriptions reflect my interests, so they have significant content overlap. Just this morning, for example, I must have seen about ten different news items all providing roughly the same information about Mighty Mouse.

I wish my news reader could at least identify and group together "duplicate" articles such as these, so I could deal with them all at once. Click on one to read it, mark the others en masse as having been read, move on.

I wish I could use my system's standard search tools (Spotlight for me, who knows what for Longhorn^WVista users) to search through old feed articles.

Not to be a shill for Brent Simmons, but the full version of NetNewsWire seems to have begun to address these wishes.

It's nice that my most original ideas have already been had by others.

Soldier's Grove: Energy efficient public policy

WorldChanging: Another World Is Here: Disaster Recovery Done Right

"
Rather than rush to get buildings up and running as quickly as possible, the villagers took their time...

The village passed ordinances stipulating that new buildings be built to specific thermal performance standards and obtain at least 50 percent of their heating needs with solar systems...
"

2005/08/02

Eco-friendly foam increases shuttle foam shedding

Shuttle Foam Loss Linked to EPA Regs

'"NASA chose to stick with non-Freon-based foam insulation on the booster rockets, despite evidence that this type of foam causes up to 11 times as much damage to thermal tiles as the older, Freon-based foam," warned space expert Robert Garmong just nine months ago."'

2005/08/01

Successor to the Shuttle?

SafeSimpleSoon.Com

Seems pretty retro: a crew capsule sitting atop a booster, designed for automatic stability during re-entry and equipped with an escape rocket during departure. But it's supposed to be all new...

[update 2005/08/18]

Wired has a related article this morning, describing the progress of tSpace in their development of a new Crew Transfer Vehicle. They've used $6 million in NASA funding and have actually developed working hardware.

My favorite bit concerns new NASA administrator Michael Griffin, who according to the article said he "would buy rides for NASA astronauts on privately owned spaceships."

Inside Kyoto

Wired News: U.S. Spearheads New Climate Pact

"However, Kyoto excludes developing nations such as China and India, home to a third of humanity, from a first period of targets to 2012. Both have ratified Kyoto and promised to take part in talks to widen the pact beyond 2012."

2005/07/28

Behind Kyoto

New Scientist Breaking News - US-led emissions pact seen as Kyoto rival

"The world’s four largest coal-consuming countries have announced a pact to share technology for limiting emissions of greenhouse gases."

"The new pact ... allows the countries to set their own goals for emissions of greenhouse gases, with no enforcement measures."

According to the article, Australia pulled out of Kyoto even though the protocol would have allowed Australia increase its emissions by 8% between 1990 and 2010.

"[The signatory nations'] companies will now hope for increased access to Asian markets for their technologies."

"There is speculation that the new group will seek to reach a formal agreement with the signatories to the Kyoto Protocol. Such an agreement might allow companies from the new group who sell clean technologies to developing countries to gain carbon permits that could be traded with companies operating under the Kyoto Protocol."

2005/07/27

Beyond Kyoto

U.S. to announce 'Beyond Kyoto' greenhouse pact - Yahoo! News

"...the United States and Australia have never ratified the [Kyoto] protocol because it excluded major developing nations such China and India."

"Australian Environment Minister Ian Campbell said on Wednesday that the five countries had been quietly working on the pact for months.

'It's quite clear the Kyoto protocol won't get the world to where it wants to go ... We have got to find something that works better[...],' Campbell told reporters on Wednesday."

"...analysts say the protocol is of limited use because many signatories are already above their emission targets."

Nations as a whole may be exceeding their targets, but – just as there are pockets of low entropy in the universe – some places are producing lower emissions than others:

"Greenhouse gas emissions last year in Multnomah County, which includes Portland, dropped below the level of 1990, and per capita emissions were down 13 percent.

The city has also built 750 miles of bicycle paths, and the number of people commuting by foot or on bicycle has increased 10 percent."

2005/07/03

Sweden, Subobia, Kuwait: Civic Lessons

Treehugger: Biogas-Powered Train in Sweden

I worked in Linköping in the early 1990s. This small city in southeastern Sweden was remarkably different from my home of the time, Huber Heights, Ohio.


Miljö Vänlighet

Many of my coworkers in Linköping rode bicycles to work, even in the wintertime. They'd emerge from their offices in the afternoon darkness to stretch dry, warm cloth covers over the frozen bicycle seats. Then they'd strap their briefcases onto the cargo racks and disappear into the streets of hard-packed snow, trench coats tucked tight around them.

Those who didn't ride bicycles complained about their government's inconsistent social engineering efforts. "They have raised the price of bensin to encourage the use of public transportation. And now they have raised the price of public transportation."

We consultants, of course, had a rental Saab 900. In the summertime we might walk to work along the local canal, but in the winter we'd hustle a block to the parking lot, pile into the Saab, and enjoy the electrically heated seats during our ten-minute commute.


Outer Subobia

Back in the States my neighborhood was designed for cars, clotted with automobiles. It could take 20 minutes to get to the supermarket 2 miles away. Walking or bicycling anywhere seemed foolishly dangerous. Biking to work was out of the question. Far better to join the rush of semis and GM boatmobiles on the local highways.


Warped

Popular Science and the 1973 energy crisis had made a strong impression on me. So I had been delighted when my parents bought a 1976 Honda Civic, touted for its efficient CVCC engine (two combustion chambers per cylinder!) and top-notch engineering.

A few months later, after several blown head gaskets, a heat-warped aluminum head and a complete engine overhaul, my parents sensibly traded the Honda for a 1978 Ford Granada.

Unlike my parents I hadn't much regard for reality. And I had only contempt for the Granada, its hideous 3-box design and its crappy fuel economy. The car was disgusting then, and for the nearly fifteen years afterwards in which it ran without failure.

The CRX

Our family's experience with Honda automobiles had been bad. But I continued to admire Honda's efforts to produce fuel-efficient designs.

In 1983 rumors started circulating about a two-seat Honda design which would deliver 50 mpg on the highway and reach speeds of over 90 mph. The rumors proved true when the CRX HF appeared on the market. If I ever managed to buy a brand-new car, this would be the model.

In 1990 I got my chance. Lots of overtime and per diem from the Swedish contract had filled the bank account. In July I pulled out the yellow pages and called the local Honda dealerships.

It didn't take long to find a dealer with a CRX HF in stock. Within a few days the deal was done, and I started getting to know my new car.

Unlike the first Honda our family had owned this one lived up to its promise -- and then some: The EPA said the HF would get 52 mpg on the highway. It sometimes topped 60 mpg. It accelerated as well as my previous car, and had much better handling.

The CRX was all I'd hoped for. It fed my appreciation for design optimization. And, against the backdrop of continued visits to Sweden, it amplified my growing environmentalist-consumer smugness.

Kuwait

About a week after I bought the CRX, Saddam Hussein invaded Kuwait. Driving to work, I saw no signs of awareness. Hadn't anyone heard President Bush's warnings about the implications of the invasion for the U.S. oil supply? Vans and trucks and semis rammed the air aside, 10-15 mph above the speed limit, carrying only their drivers, blithely ignoring the cubic increase in power required to reach higher speeds.

You can imagine how smug I felt as they barreled past me :)

2005/06/18

Managing Finder Workflows

With the new Automator in Mac OS X 10.4 it's easy to add contextual menu items to the Finder. Just edit your workflow in Automator, Select "File->Save As Plug-in...", enter a name for the plug-in, and specify that the plug-in is for Finder. (Apple has posted some examples of how to create plug-ins.)

It's easy to add a workflow menu item. How do you remove one?

Intuition says that your personal workflows might be represented as files somewhere in your home directory. Finder's new Smart Folders should tell whether that's really the case.

Create a dummy workflow named "DeleteMe" and save it as a Finder Plug-in. Then switch to the finder and select "File->New Smart Folder". In the little brushed-metal "toolbar" which appears, select the "Home" folder. In the criteria list add the following criteria:

"Kind", "Any", "+"
"Last Modified", "Today"

Somewhere in the list of search results a Folder named "Finder" should appear. Hitting the info icon on that item doesn't tell much, but the "More Info..." button reveals that it's located in /Users/YourUsername/Library/Workflows/Applications/Finder. And lo, opening the folder shows an Automator Workflow named "DeleteMe".

Drag the workflow to the trash, right click anywhere in a Finder window, and select the "Automator" cascading menu item. The "DeleteMe" menu item should be gone.

The Short Form

Workflow menu items live in your ~/Library/Workflows/Applications/ folders. They can be removed from your context menus by dragging them to the trash.

There's probably a better way to discover all of this...

2005/06/16

Birds and wind farms

New Scientist News - Wind turbines a breeze for migrating birds

Migratory birds learn to avoid wind farms, at least in Denmark. But resident birds may not fare so well. For example, the wind farm in the Altamont pass in California has killed a lot of raptors.

The subsections in the reports on the Wind Power and Bird Studies page suggest there may be other environmental factors, e.g. grassland vs. desert vs. prey populations.

2005/06/12

Godfather of the Hybrid

According to TreeHugger, Victor Wouk has passed on.

I wasn't familiar with the name. Caltech, where he attended graduate school, provides more details. This year they hosted the inaugural Victor Wouk Lecture.

A Rich Life


The American Institute of Physics gives some idea of all the things Wouk accomplished.

He picked Caltech, in part, because they had open book exams. During WWII he worked on the separation of uranium isotopes. For the founder of Motorola, Russell Feldman, in the early 1960s he worked on designing a practical electric car. He eventually concluded that a hybrid vehicle would be more practical.

In 1970 the Clean Air Act was passed, following studies which showed the negative effects of smog. Wouk got a federal grant to build a hybrid electric vehicle. He built a Buick Skylark which got 30 mpg and could hit 85 mph. (But it didn't run on water. [1])

The EPA's Eric Stork opposed the hybrid approach. (I wonder why?) Only one car was built by Wouk and his company, Petro-Electric Motors.

Scientific American, Oct. 1997, pg. 71 makes reference to the Skylark.

The rest of his family has done alright, as well. His brother is author Herman Wouk.

[1] From the first season of "That 70's Show".
Hyde: "I heard about a car that runs on water, man."
Fez: "You mean a boat?"

2005/06/11

Dr. Sarah's Sum of Two Cubes Activity Sheet

Dr. Sarah's Sum of Two Cubes Activity Sheet

Obscure mathematics references may explain the demise of Futurama.

Installing PyOpenGL on Mac OS X 10.4.1

Update 2007/02/26



Mike Fletcher has been working on PyOpenGL 3, which uses ctypes instead of swig. As a result, installation and updating are a lot easier. See the SourceForge project page for more info, but here's a quick summary:

$ sudo easy_install PyOpenGL
Password:
Searching for PyOpenGL
Reading http://cheeseshop.python.org/pypi/PyOpenGL/
Reading http://pyopengl.sourceforge.net/ctypes/
Reading http://sourceforge.net/project/showfiles.php?group_id=5988
Reading http://cheeseshop.python.org/pypi/PyOpenGL/3.0.0a5
Best match: PyOpenGL 3.0.0a6
Downloading http://downloads.sourceforge.net/pyopengl/PyOpenGL-3.0.0a6.zip?modtime=1171556482&big_mirror=0
Processing PyOpenGL-3.0.0a6.zip
Running PyOpenGL-3.0.0a6/setup.py -q bdist_egg --dist-dir /tmp/easy_install-9bs-Ie/PyOpenGL-3.0.0a6/egg-dist-tmp-1Y8vWy
Adding PyOpenGL 3.0.0a6 to easy-install.pth file

Installed /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/PyOpenGL-3.0.0a6-py2.5.egg
Processing dependencies for PyOpenGL


You can also install and run the demos:
$ sudo easy_install PyOpenGL-Demo


Once they're installed, how do you get at them?

$ cd /Library/Frameworks/Python.framework/Versions/Current/lib/python2.5/site-packages/PyOpenGL_Demo-3.0.0a6-py2.5.egg/PyOpenGL-Demo/
$ cd redbook
$ python movelight.py


Each demo pops up in its own lovely, top-level window.

Original Post



After upgrading to Mac OS X 10.4.1 I decided to install Python 2.4.1. Python made a framework install with no problem. But I ran into a small problem trying to install PyOpenGL-2.0.1.09.


I kept getting compile errors complaining about an incomplete definition for st_atimespec, et al. (Here comes another batch of extremely long lines...)





In file included from /Library/Frameworks/Python.framework/Versions/2.4/include/python2.4/pyport.h:155,
from /Library/Frameworks/Python.framework/Versions/2.4/include/python2.4/Python.h:55,
from src/config.h:1,
from _configtest.c:6:
/System/Library/Frameworks/Kernel.framework/Headers/sys/stat.h:225: error: field 'st_atimespec' has incomplete type
/System/Library/Frameworks/Kernel.framework/Headers/sys/stat.h:226: error: field 'st_mtimespec' has incomplete type
/System/Library/Frameworks/Kernel.framework/Headers/sys/stat.h:227: error: field 'st_ctimespec' has incomplete type





What was odd was that the build process was trying to include sys/stat.h from .../Kernel.framework/Headers, instead of from /usr/include.


I modified config/darwin.cfg and removed /System/Library/Frameworks/Kernel.framework/Headers from the list of include directories, and thereafter PyOpenGL built and installed without error.


The examples ran, too :)


Here's the context diff for config/darwin.cfg. Apologies, again, for the long lines -- I've tried to escape them using trailing backslashes.





*** darwin.cfg.orig Sat Jun 11 12:09:35 2005
--- darwin.cfg.new Sat Jun 11 12:19:42 2005
***************
*** 11,17 ****
[General]
build_togl=0
gl_platform=CGL
! include_dirs=/System/Library/Frameworks/OpenGL.framework/Headers:/System/Library/Frameworks/GLUT.framework/Headers:/System/Library/Frameworks/Kernel.framework/Headers
# Bob's OSX patch, comments out the library directories, adds -framework:GLUT
# for the *general* build parameters? Is that actually needed?
; Should make a 'frameworks= ' option!
--- 11,17 ----
[General]
build_togl=0
gl_platform=CGL
! include_dirs=/System/Library/Frameworks/OpenGL.framework/Headers:/System/Library/Frameworks/GLUT.framework/Headers
# Bob's OSX patch, comments out the library directories, adds -framework:GLUT
# for the *general* build parameters? Is that actually needed?
; Should make a 'frameworks= ' option!



2005/06/10

Trac, clearsilver and Python 2.4.1

Trac is an excellent web-based issue tracking system. It depends on clearsilver.

Clearsilver 0.9.14 doesn't like to configure with Python 2.4, due to changes in the internals of Python's site module.

The fix is easy enough, but for some reason it's hard to find via Google. (You can find it by searching for Python 2.4 within clearsilver's Yahoo Groups discussion forum.) Here's a context diff for clearsilver's configure script, showing the fix that worked for me. Apologies for the long lines...


*** configure Tue May 24 16:28:58 2005
--- configure.orig Tue May 24 16:24:45 2005
***************
*** 3084,3091 ****
PYTHON=$python_bin
PYTHON_INC="-I$python_inc"
PYTHON_LIB=$python_lib
! PYTHON_SITE=`$python_bin -c "import sys, os; print os.path.join(sys.prefix, 'lib', 'python%s' % sys.version[:3], 'site-packages')"`
! # PYTHON_SITE=`$python_bin -c "import site; print site.sitedirs[0]"`
BUILD_WRAPPERS="$BUILD_WRAPPERS python"
fi
fi
--- 3084,3090 ----
PYTHON=$python_bin
PYTHON_INC="-I$python_inc"
PYTHON_LIB=$python_lib
! PYTHON_SITE=`$python_bin -c "import site; print site.sitedirs[0]"`
BUILD_WRAPPERS="$BUILD_WRAPPERS python"
fi
fi


Here is the relevant discussion thread.

2005/06/09

Wired News: Tiger Tweaks Could Kill Folders

Wired News: Tiger Tweaks Could Kill Folders

A mantra from the late '90s: It's better to search than to browse.

"...he used Spotlight to find all the bulky QuickTime movie files scattered across many different folders. Then he created a Smart Folder for them so he'd always be able to quickly see which little-used files he could delete."

2005/06/07

WebObjects 5.3 is bundled with XCode

WebObjects 5.3 Release Notes

See previous post -- too much to learn.

Among others, Aaron Hillegass has praised WebObjects. He has held it up as a standard against which to measure recent changes to Cocoa (and its Controller layer), and has sometimes found the latter lacking.

Haven't yet had a chance to do much with CoreData and the modeling tools in XCode 2.0. Now XCode 2.1 may help me understand what the fuss was all about.

Fun times.

Webkit is wide-open

Surfin' Safari

My list of things to learn was big enough before reading this...

2005/05/15

Family Ties

This morning I was minding my own business, googling for my grandparents' cookbook, when I was reminded of a web of family ties.

My dad used to play in a country band in Columbus, Ohio. His musical talent was part of the reason he met and married my mom, whose parents were Smiley and Dallas Burnette.



My brother and I grew up in New Albany, Ohio. In the summers we used to spend a lot of time at Uncle Hank and Aunt Donna's house, which was next to their pizza place.

Uncle Hank and his brothers had once played as Hank Newman and The Georgia Crackers. His musical talent played a part in his meeting and marrying Donna, who was born Donna Albanese.

The Georgia Crackers
The Georgia Crackers -- The Newman brothers are the three in back. Left to right: Uncle Slim, Bob, Uncle Hank.


The Georgia Crackers had long since disbanded by the time I showed up. The only time I remember hearing them play was one night at Veteran's Memorial Hall, when I was maybe five years old. The high points of the evening for me were getting to stay up really late, seeing Uncle Hank and his brothers on stage (I'd never met Bob before, but it was funny when he picked up that huge bass violin and "threatened" to leave the stage), and Tex Ritter and his amazing blue cowboy outfit, studded with rhinestones. I never got to say a word to Mr. Ritter but remember staring, mesmerized, at the back of his jacket as he sat at the bar in Uncle Hank's den after the show.

[So much for memory. Dad says it was Uncle Slim who was fiddling with the bass.]

The Newmans had met Grandpa in the late forties, on the set of one of the Durango Kid movies. I guess they'd long been established in Columbus by that time.

Mom met Dad in Columbus, while she was driving Grandpa around the country on one of his road tours.

The mesh ties together. That's how my brother and I came to spend our summers with Uncle Hank and Aunt Donna.

Century of Country

Other references to the Georgia crackers are here and here.

2005/05/12

Google's Singularity machine

Epeus' epigone - Kevin Marks weblog, on Google's Singularity Machine


Map/Reduce

"Map/Reduce" evokes and . (Danny Hillis wrote about the CM architecture in the late 1980s.) Would there were time enough in the day to get hands-on with parallel and distributed algorithms.

Ceviche

What is ?

Sadly, this reminds me of my neighbor across the hall at Los Piñones apartments. He was not much older than me, in his early 40s I think. He was fond of seafood. In late summer of 2003, when my job and the health of my parents both took bad turns, he began to lose his life.

Suddenly taken ill, my neighbor was hospitalized with what was, for the first month, an unknown but deadly serious infection. The hospital staff in Albuquerque did what they could. Finally one doctor, after a flash of insight, walked in and bluntly asked whether my neighbor had recently eaten seafood.

From that point it was clear how to treat him, but it was too late. The infection had done too much damage. I can't remember all of the complications he suffered; I believe pneumonia and kidney failure were among them. Just before Thanksgiving, he died.

The restaurant was not shut down. As far as I know, they didn't even remove uncooked seafood from their menu, or add any cautions to it. Granted that would have been bad for business. And life is full of risk anyway. But some indication of regret would have been nice.

2005/05/11

2005/05/04

Wired News: Ethanol Grows as Gas Alternative

This article --

Wired News: Ethanol Grows as Gas Alternative

-- raises a few questions. It describes a process by which ethanol can be converted to hydrogen; and, separately, the current use of ethanol as a gasoline additive.

The most obvious question: what, if any, relationship exists between the conversion processes described in the article, and this research by Penn State researchers?

Is the hydrogen conversion technology being considered for use in cars, e.g. in fuel-cell vehicles? Or is it only for use in hydrogen "refineries"?

How does the carbon-dioxide by-product of the process affect the total environmental cost of hydrogen as a fuel?

Ethanol is made from grain crops, and the existence of the "corn belt" in which those crops is grown depends on certain climate conditions. Ongoing changes in global climate mean that the corn belt may move or disappear altogether.

It's easy to imagine a world in which we've become dependent on grain crops for both fuel and food (directly and indirectly, through consumption of meat and poultry). And it's slightly amusing to imagine a world in which, due to climate change, the "corn belt" has moved to Canada.

Much less amusing is a world in which that belt has disappeared.

Not to dismiss ethanol/hydrogen for the sake of an unlikely eventuality, but how likely is it that a drastic change in the grain supply will happen?

How likely is it to happen within the next 100 years? After all, you don't need to solve your problems once, for all. You need to solve them just long enough to buy time to find a better solution.

How long is long enough? Gasoline-powered vehicles have solved so many problems of transportation that we now have trouble replacing the extensive infrastructure which has grown up around them.

Ethanol/hydrogen is interesting as a possible fuel source. It's maybe more interesting for the questions it raises about climate and politics.

2005/04/29

Photoshop CS2 HDR

Photoshop CS2 HDR

A couple of years ago I saw an article on how to use Photoshop and exposure bracketing to create composite images that had good detail in both highlights and shadows. The article explained that digital had a smaller dynamic range than film, and that even film didn't have the range to cover some landscape scenes.

By the time I was done reading I had the impression that the author, Michael Reichmann, would be pleased if he didn't have to compress the dynamic range, but instead had a way to combine two images of 8-bit depth into a single image having, say, a 12-bit range.

Sure enough, the new Photoshop release can do it. And the same author has posted an article on how to use it:

http://www.luminous-landscape.com/tutorials/hdr.shtml

Naturally, now the problem is that neither computer monitors nor printers can handle 32-bit image data. And at the end of this article Mr. Reichmann suggests that camera manufacturers need to begin producing cameras that provide better control over exposure increments when producing bracketed shots.

But why stop there? Why not let the camera do its own sampling of light levels across the scene and then automatically produce bracketed shots which cover the scene's entire dynamic range?

Even better, why not perform the bracketing and merge in-camera, producing a final, high-dynamic range image with no effort on the part of the lazy photographer? (Me.) I can think of only three reasons: processing power, battery power and memory :)

2005/04/20

Wired News: People Are Human-Bacteria Hybrid

Wired News: People Are Human-Bacteria Hybrid

we are best viewed as walking "superorganisms," highly complex conglomerations of human cells, bacteria, fungi and viruses...we are somewhat outnumbered by the [microbes].


Nicholson's colleague, professor Ian Wilson from Astra Zeneca, believes the "human super-organism" concept "could have a huge impact on how we develop drugs, as individuals can have very different responses to drug metabolism and toxicity."


the human genome does not carry enough information on its own to determine key elements of our own biology.


2005/04/03

TortoiseSVN

Some of my co-workers dislike using the command-line to access Subversion repositories. For those running Windows, TortoiseSVN is looking good.

Once it's installed, subversion operations become available from the context menu of Windows Explorer. Checkouts, commits, configuration of TortoiseSVN, it's all right there.

When you're browsing a local checkout of an SVN repository, document icons are decorated with green checkmarks, red exclamation marks, etc. to show whether they are in sync with the repository, whether you have made local modifications, etc.

So far the only problem I've had with TortoiseSVN has been in figuring out how to do a checkout from a read-write repository. There may be better ways of solving the problem, but here's what has worked for me.

First, use svn+ssh to access the repository. In the URL, specify your username on the subversion host. And of course this means you need to use the absolute path to the repository in the URL:

svn+ssh://my_username@my_svn_server/abs_path_to_repository/my_project/trunk

Next, modify the TortoiseSVN settings to enable ssh tunneling. I'm not sure this is really necessary. But I did make the change, via the "Edit" button next to the "Subversion configuration file" label. Once notepad popped up with the contents of the config file, I uncommented the lines for ssh tunneling:

[tunnels]
ssh = $SVN_SSH ssh

2005/04/02

svn+ssh: Using Subversion with SSH

I've been trying to learn how to enable secure shell (SSH) access to Subversion, on both the client and server sides. It's kind of a pain.

The whole point of using SSH is to avoid sending your source code in the clear, so maybe the pain is worth it. Or maybe this is such a common-sense usage of Subversion that somebody (like, say, me) should put some effort into making it easier to do. But I digress.

To connect to an svnserve daemon via SSH you use this repository syntax:

$ svn co svn+ssh://.../

This requires some careful preparation. First, you need to have the following lines uncommented in your client-side ~/.subversion/config:
[tunnels]
ssh = $SVN_SSH ssh

Then, on the client, your URL must include the absolute path to the repository, followed by the path of the project you want to check out from the repository.

For example, suppose you ordinarily use this command to check out a project:
$ svn co svn://svn_server/project/trunk local_name

In order to perform the same checkout using an svn+ssh URL, you'd have to use this command:
$ svn co svn+ssh://svn_server/abs_path_to_repository/project/trunk local_name

You also need an account on the SVN server, with the same username as your account on the client machine. Or you need to specify the username when performing your svn checkout, like so:
$ svn co --username bubba ...

Or you need an entry like this in your ~/.ssh/config, to tell ssh as whom it should connect to the server:
Host svnserver
Hostname svnserver.blah.com
User bubba

On the server, you need to ensure that svnserve is in the path of the user account under which you run svnserve.

You also need to ensure that the account under which you run svnserve, as well as your user account on the server and any other userr accounts which need access to the repository, are all members of the same group. (subversion would be a good name for the group.)

You also need to make sure that your umask is set to 002 (group write-able). Otherwise other users of the remote repository might find themselves suddenly unable to change some file that you've added.

Got all of that? Good! Of course, I probably forgot a few steps...

2005/03/30

PHPmac - Additional Useful Apache2 Config Settings

I'd like to be able to replace Apache 1.3 on my iMac with Apache 2. I've installed the DarwinPorts port for apache2, but starting and stopping the server requires a trip to the command line. Is there any way to use System Preferences to control Apache 2?

Thanks to Google and the folks at phpmac for showing that the answer is "yes":

PHPmac - Additional Useful Apache2 Config Settings

2005/03/17

More Problems With Coal

Yesterday a study was publicized which claimed a correlation between mercury emissions from coal-fired powerplants and the incidence of autism.

On Tuesday the EPA issued a new "Clean Air Mercury" rule.

You would think this rule, which requires a 22% cut in mercury emissions by 2010, would gain some credit for the Bush administration, which has often been accused of weakening environmental regulations to the short-term benefit of industry. But it's not so simple. According to a Knight Ridder news article:

The Bush administration... [hailed] the reductions as the deepest cuts technologically possible... But nearly a dozen power plants nationwide have [cut] cutting mercury emissions by as much as 94 percent -- in test projects paid for by the same Bush administration.


Not long before the Three Mile Island incident, the Union of Concerned Scientists published a paper comparing total expected deaths from radiation, for
two types of powerplants: coal and nuclear. They concluded that nuclear power was safer. (!) If you consider other factors such as environmental damage caused by sulfur emissions (acid rain) and now mercury, the only advantages to burning coal are that: we have a lot of it; it's mined in areas which would otherwise be economically impoverished (e.g. West Virginia).

I think the paper was:
Union of Concerned Scientists. The Risks of Nuclear Power Reactors (Cambridge, MA: 1977).

2005/03/14

DarwinPorts and Subversion on Mac OS X

This is a recap of instructions posted by Bill Bumgarner (here and here) and James Duncan Davidson (here), on installing Subversion and Apache2 via DarwinPorts on Mac OS X 10.3.

Install DarwinPorts

Get DarwinPorts from CVS and build and install it. Assuming default installation locations are okay, this script should work:


#!/bin/sh

cvs -d :pserver:anonymous@anoncvs.opendarwin.org:/Volumes/src/cvs/od login
cvs -d :pserver:anonymous@anoncvs.opendarwin.org:/Volumes/src/cvs/od co -P darwinports
cd darwinports/base
./configure
make
sudo make install

Now you need to add the DarwinPorts binaries directory to your PATH. Depending on whether you prefer sh-like shells such as bash or csh-like shells, one of the following should work:

export PATH=$PATH:/opt/local/bin
set path=($path /opt/local/bin)

Install subversion and apache2

Next, using James's instructions as a guide, configure and install subversion and apache2. To do so, run the following script using sudo:

#!/bin/sh
port install apache2
port install subversion +mod_dav_svn +python
port install DarwinPortsStartup
Note a small problem here: This script installs subversion Python bindings, but only for a non-framework installation of Python. If you need bindings for a framework installation of Python, you're on your own.

Create The Repository

Bill created his subversion repository in /svn. I wanted mine in /usr/local/svn-repository, for no good reason.
$ sudo mkdir /usr/local/svn-repository
$ sudo svnadmin create --fs-type fsfs /usr/local/svn-repository/master
$ sudo chown -R www /usr/local/svn-repository
Patch httpd.conf

Bill has provided a patch for httpd.conf. It assumes that your subversion repository resides in /svn. If it resides elsewhere you'll need to change the patch file before applying it.

For example, since I put my subversion repository in /usr/local/svn-repository I had to change every reference to the /svn filesystem location in the patch file to point to /usr/local/svn-repository.)

You can copy the patch file to /opt/local/apache2/conf, and then apply it from there. Patch will ask you if it should assume this is a reverse patch (-R). Say 'y':

$ sudo cp my-httpd-conf-svn.patch /opt/local/apache2/conf/
$ cd /opt/local/apache2/conf/
$ sudo cp httpd-std.conf httpd.conf
$ sudo patch httpd.conf my-httpd-conf-svn.patch
patching file httpd.conf
Reversed (or previously applied) patch detected! Assume -R? [n]
y
Add Repository Users
$ cd /usr/local/svn-repository/
$ sudo -u www htpasswd -c master-auth mitch
New password:
Re-type new password:
Adding password for user mitch
Test The Apache2 Configuration
$ /opt/local/apache2/bin/apachectl configtest
Syntax OK

Start Apache2


It should start up, listening on port 8000.
$ sudo /opt/local/apache2/bin/apachectl restart
httpd not running, trying to start
At last you should be able to view the topmost directory of the (empty) subversion repository in your web browser, by loading http://localhost:8000/svn/

2005/02/02

Rendering GL content to grids and printers

I'd like to render 3D graphics into the cells of a wxGrid, and am considering using an offscreen wxGLCanvas to prepare the contents of each cell as requested. This seems like a common approach; for example, NSTableViews in Cocoa use a single NSCell to paint the contents of each column.

How to render the contents of the wxGLCanvas into each grid cell? The easiest way seems to be to set the size of the canvas to match the size of the current cell, render the scene, copy the content into a wxBitmap, and draw the Bitmap into the cell rect.

Others have shown how to copy wxGLCanvas content into a wxBitmap, e.g. in order to print the contents of a canvas. But the sample code I've found has omitted a key step: a call to glPixelStorei to ensure proper packing of the data provided by glReadPixels.

Anyway, here's what works for me. This code assumes the GLCanvas size has been set and the scene already rendered:


def _getBitmap(self):
c = self.canvas
x, y, w, h = glGetIntegerv(GL_VIEWPORT)

glPixelStorei(GL_PACK_ALIGNMENT, 1)
pixels = glReadPixels(x, y, w, h, GL_RGB, GL_UNSIGNED_BYTE)
img = wx.EmptyImage(w, h)
img.SetData(pixels)
img = img.Mirror(False)
self.bm = wx.BitmapFromImage(img)


2005/01/21

Temporarily disabling callbacks in wxPython

A data model can have many views. When a user changes one of the views, that change needs to be reflected in other views. If you use wxPython widgets to implement your views, this can set off an update storm. Here's how to avoid it.

It's frustrating that a programmatic change to a wxPython widget causes callbacks associated with the widget to fire. For example, if you've bound wx.EVT_TEXT in a wxTextCtrl then any subsequent call to SetValue can trigger the bound callback.

In contrast other toolkits (e.g. Apple's Cocoa) recognize that, when you change a widget programmatically, you're usually trying to treat it as just a passive MVC view. You just want to reconfigure your widget, not to generate any callback events. Events are for user input.

wxPython widget classes are derived from wxEvtHandler, and there lies the solution to the problem. If you want to update a widget without triggering its callbacks, first call its SetEvtHandlerEnabled method with an argument of False. Make your update, then call SetEvtHandlerEnabled with an argument of True.

It's a lot of extra typing, but it works. I just wish it hadn't taken me so long to notice wxEvtHandler. I could have avoided a lot of grumbling.

But that sure is a lot of extra typing...

Here's a wrapper function which lets you disable callbacks for the duration of a single method invocation, without suffering the typical verbosity of wxPython:

def withoutCBs(method):

def wrapper(*args, **kw):
widget = method.im_self

oldSetting = widget.GetEvtHandlerEnabled()
widget.SetEvtHandlerEnabled(False)
try:
return method(*args, **kw)
finally:
widget.SetEvtHandlerEnabled(oldSetting)
return wrapper
This wrapper makes it easy to perform a single, callback-free widget update:
    def _uiQuietBtnClicked(self, evt):

withoutCBs(self.field.SetValue)("Quiet")
Of course this is only good for invoking a single method defined directly on the target widget. What if you've composed a complicated method in a controller class, and you need to disable callbacks for the duration of that method? A simple refactoring lets you state explicitly which widget you want to stifle:
def withoutCBs(method, widget=None):

"""Prepare to call method with widget's callbacks
disabled.

If widget is None it is assumed to be the widget
bound to method.
"""
def wrapper(*args, **kw):
w = widget or method.im_self

oldSetting = w.GetEvtHandlerEnabled()
w.SetEvtHandlerEnabled(False)
try:
return method(*args, **kw)
finally:
w.SetEvtHandlerEnabled(oldSetting)
return wrapper
With this modification you can silence a widget for the duration of any operation, regardless of where it's defined:
    def _uiQuietBtnClicked(self, evt):

withoutCBs(self._performComplexOperation,
widget=self.field)()

def _performComplexOperation(self):
...