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."