I'm quite optimistic about the future, but I seem to be posting anti-predictions instead of predictions. Perhaps I'll post positive predictions someday, but today I have some more negative ones:

Labels: ,

Long ago (1997), Internet Explorer 4 gave us user style sheets, in the accessibility options. You could point the browser at your CSS file, and it would merge the user styles with the author styles. As with many features in IE4, other browsers adopted this feature too (Mozilla in 2002, Opera in 2003, I think).

User styles are quite neat. However, having to edit a file somewhere and then reload the browser is sort of a pain. The Stylish addon for Firefox makes user styles much easier:

  1. You can edit the styles per site instead of globally.
  2. You can organize your CSS into named sections.
  3. You can share these sections with others.
  4. You can browse userstyles.org to find CSS shared by others.
  5. You can install user styles from others with just a few clicks.

I just keep forgetting to write my own styles. Tonight I got fed up with MyWay's 700-pixel fixed width TV listings:

I used Firebug to look at the structure of the site, and after navigating nested tables with no class or id names to hang my CSS onto, I decided to use CSS attribute selectors to address the two tables that I wanted:

@-moz-document domain("tv.myway.com") {
  table[width="700"] {
    width: 100% ! important;

  table[bgcolor="888888"] {
    background-color: #fff ! important;
    padding: 2px;

  table[bgcolor="888888"] td {
    border: 1px solid #bbb;
    font-family: tahoma ! important;
    font-size: small ! important;
    -moz-box-shadow: 1px 1px 2px #bbb;

  table[bgcolor="888888"] td a {
    font-weight: bold;
    color: #000 ! important;
    text-decoration: none ! important;

Here's the result:

Try out user styles. If you don't know CSS, you can explore userstyles.org; if you do, you can also try writing your own.

Labels: ,

[Warning: my thoughts on this topic are still not entirely clear. I sat on this post for a week but I couldn't find better words, so I decided to post anyway.]

When I think about being “green”, I think of three things:

  1. Clean: solar, wind, wave energy instead of coal, oil, and sometimes nuclear. Part of this is to reduce pollution, but lately it's about reducing CO2 released into the atmosphere.
  2. Sustainability: renewable energy, better agricultural practices, and sometimes population reduction/stability. This is to avoid depleting resources.
  3. Conservation (mostly of energy): less driving, less air travel, less lighting, less water, less energy. This is to reduce the impact of our activities on the planet.

I think all of these could use refinement.

I'm a big fan of Clean. Pollution in general is getting too little attention these days, and CO2 gets too much. CO2 is not a poison; it's a good gas to have. Our problem is that we're way out of balance. We're producing far more than we use, so it's building up in the atmosphere. We need to get back into balance, but that doesn't mean zero. Pollution on the other hand we should be at zero. But it doesn't need to be zero production; it's okay to produce if you can clean it up. For example, algae, fungi, and bacteria can be used to clean up some types of pollution, and titanium dioxide can do wonders. Here again balance is the key. Produce as much as is used, and we're good. That's different from saying produce zero.

I'm a fan of Sustainability but I think it's secondary to, and a consequence of, balance. I think depleting non-renewable resources is fine, as long as we do it knowing we're using it up, and we start coming up with a sustainable solution. We might decide to use oil, but deciding not to use it because we're going to use it up is not a compelling reason. Not having any oil and not using any oil are essentially the same. I think for now we should continue using oil, especially for waxes, lubricants, and biodegradable plastics.

I'm less of a fan of energy Conservation, in part because I think it addresses the wrong issue. (Raw material conservation is a separate issue.) The problem isn't turning the lights on. The problem is the impact that causes, because the electricity is generated in ways that pollute or produce CO2. Do you turn off your solar-powered yard lights when you don't need them? Doesn't it sound silly? Turning off your incandescent bulb powered by a wind farm seems almost as silly. Solar, wind, and wave energy are abundant—in fact, literally tons of photons fall on the Earth every hour. And if we don't use that energy, it's lost. If we had abundant clean, cheap energy, would we still feel bad about using incandescent lights? I think we would, because we're trained to, but we shouldn't. There are still good reasons to use less energy, but they're about cost rather than environment.

Historically, asking people to switch to a worse lifestyle at lower cost (public transit in suburbs, abstaining from sex, eating boring food, not going on vacations, using unpleasant lighting, etc.) doesn't seem to be as effective as asking people to switch to a better lifestyle at higher cost. The EV1 and original Insight were “sacrifice” cars. You had to give something up (range, comfort, size), but you could feel good about sacrificing for the sake of the environment. The Prius is quite different. It is comfortable, is roomy, has nice features, and has good range. You're not sacrificing lifestyle when going from a $16k car to a $20k Prius, but it does cost more. And the Prius is far more successful than the EV1 or original Insight. We should focus on abdundant clean, somewhat sustainable energy. I think we'll improve the environment much quicker by giving people lots of clean energy than to tell them to sacrifice. In addition, lots of other problems, like cleaning water and reducing pollution, become much easier to solve when we have lots of energy.

Labels: ,

I try to keep my Firefox cookie file clean. I used to run a script on cookies.txt to remove most cookies and keep only the ones for sites I visit often and trust. This was simple when the cookie file format was plain text. However, Firefox has been moving files to the sqlite format, and my script no longer works.

Sqlite seems to be pretty nice. The first thing I needed to do was figure out what format cookies.sqlite used. I ran select * from sqlite_master using the command line interface and it told me there was a table named moz_cookies with (id INTEGER PRIMARY KEY, name TEXT, value TEXT, host TEXT, path TEXT,expiry INTEGER, lastAccessed INTEGER, isSecure INTEGER, isHttpOnly INTEGER) as columns. Pretty straightforward. I used this information, plus the Python sqlite3 module (standard with Python 2.5) to write a script to clean up my Firefox cookies:

# Change this to where your cookies file is
COOKIE_FILE = ('/Users/amitp/Library/Application Support'
HOSTS = [  # keep only cookies from these hosts
    # … other hosts omitted in this example code

# Connect and then issue commands
# through the “cursor” object
import sqlite3
connection = sqlite3.connect(COOKIE_FILE)
cursor = connection.cursor()

# Remove Google Analytics cookies from all sites
cursor.execute('DELETE FROM moz_cookies WHERE name IN'
          ' ("__utma", "__utmb", "__utmc", "__utmz")')

# Remove any cookies from non-approved hosts
   'DELETE FROM moz_cookies WHERE host NOT IN (%s)'
    % (','.join(len(HOSTS) * ['?'])),

# Commit changes to disk,
# locking the file during the process

# Print the cookies we have left
print 'After:'
rows = list(cursor.execute(
          'SELECT host, name FROM moz_cookies'))
for row in rows:
    print '%30s : %s' % row

The script opens the cookies.sqlite file (unlike cookies.txt, it appears to be safe to open and edit this file while Firefox is running!), removes most cookies, commits the changes, and prints out the remaining cookies.

Lots of the Firefox profile information has been moved into the sqlite format (instead of the mess we had before), so I should explore some of the other files to see what might be fun to play with.