Debian-based distributions have a really useful series of directories to run cron scripts from. Any executable you place in /etc/cron.hourly, /etc/cron.daily, /etc/cron.weekly or /etc/cron.monthly will get run with that frequency. I like these for two reasons: 1) it’s file-based, which I find a lot easier to manage and keep track of than each user’s crontabs and 2) this eliminates one possible source of bugs in my work – namely, the scheduling of my cron tasks.

However, there is a downside to /etc/cron.daily and friends. All scripts in there run as root. It’s generally bad practice to run anything as root that doesn’t have to run as root… and this is especially true if your script has scary lines like “rm -rf $SOME_VAR” in it. You’re asking for trouble.

Unfortunately, AFAIK there is no way to drop privilege within a script. However, this can be done by spanning a whole new child process. So, let’s add a short preamble to all the scripts we place in /etc/cron.daily and friends:

#!/bin/sh

USER='some-low-privilege-user'
if [ `whoami` != "$USER" ]; then
  sudo -u $USER "$0"
  exit
fi

... rest of the script ...

Now we have some extra assurance our cron job isn’t going to go haywire and screw the whole machine!

Only a short two years into its budding existence, blog.fogel.ca has been consumed by www.fogel.ca.

Don’t worry, not much is going to change. All blog.fogel.ca permalinks should still work – seamlessly and correctly redirecting to www.fogel.ca. You’ll still get the same ramblings about transit, travel and tech here that you used to get from blog.fogel.ca.

I also used the move as an opportunity to switch up my hosting from a shared Dreamhost machine to a full VPS with Linode. (BTW, Linode is the third VPS provider I’ve been with – and they’re the best I’ve found. Definitely recommended.) And I moved some of my image hosting to my Flickr account… which was working great until I discovered their active-image limit of 204 images. Doh! Wish I had known that 204 images ago.

I’m still using Wordpress, and I’m using the constructor theme, with some custom mods. Hope you like orange!

The answer is instead, to write a bunch of emails. Have you written yours? The SFBC makes it easy.

This actually reflects nicely on one of the things I like most about the internet. For a lot of stuff, it lowers the bar to participation – and civic/government stuff is a prime example. There are some ~350k people who ride Muni every day. But only a few dozen, (sometimes non-representative) riders actually go to the meetings and tell the people making the decisions (who too often don’t actually use the systems themselves) what they think is best. But in this brave new world, with the internet, some 650 people have written emails to the mayor already. (Yes, I just referenced a comment on a blog post as a source, sue me.) Now, 650 >> a few dozen. That’s awesome. Unfortunately, 350k >> 650, but let’s take another look at these numbers 10 years down the road.

If you use Muni, please consider taking a few minutes and dumping your thoughts about Muni’s situation on the mayor and the SFMTA board. Here’s the fruits of my evening Caltrain ride.

To: gavin.newsom@sfgov.org, sfmtabudget@sfmta.com
From: Mike Fogel
Subject: cuts to muni are not the answer

Dear Mayor Newsom:

Over New Years Eve, while walking home a young man assaulted me in attempt to get at my wallet. He didn’t get my wallet, but he did separate my right shoulder and send me to the ER with blood draining down my face.

The result was I found myself suddenly dependent on Muni for basic transportation. Previously, I rarely used Muni – only when biking or walking was not an option for some reason.

Muni ridership is often broken into two groups: ‘choice riders’ and ‘transit-dependent riders’. But the reality is this is a false dichotomy. At one point or another, we all find ourselves to be ‘transit-dependent’ riders.

It is said that a good estimate the health of a community is to look at how it treats those most in need. To remain healthy, our city needs Muni stronger and faster than ever – not weaker and more crowded. A strong Muni is an essential part of our city, without which we cannot grow.

I urge you to look to cutting other, non-essential luxury services our city provides for funding the current Muni shortfall.

Thank you for your time.

Michael Fogel

Stanford has a lot of their lectures online. To access them, you’ve got to have… access! That means you need to already have an SUNet ID with proper permissions. The standard way to get those permissions is to apply to Stanford, get accepted, and start paying Stanford lots of $$$.

Stanford doesn’t want these lectures to get out on the open internet. So they do a few things to try to ensure that doesn’t happen. First, part of Stanford’s terms of use is that you will not redistribute their lectures. Note that the concepts and code I’m showing you here in this post could be used to help you illegally redistribute their lectures. I do not condone any such illegal use. By using the the concepts and code in this post in any way whatsoever (including just reading this post), you agree to follow Stanford’s terms of use.. If you don’t agree to these terms, please leave now.

In addition to their terms of use, Stanford places a more practical barrier in the way of illegal redistribution of their lectures – they only distribute their lectures as streaming WMV and Sliverlight. Now this sucks for me, the legal end-user, for a number of reasons. Most importantly, this means I need a high-bandwidth connection to watch my lectures. I can’t watch them offline.

Enter MEncoder and Greasemonkey.

MEncoder is a tool to save streaming video to disk. Greasemonkey is a Firefox browser extension that allows you to run custom javascript for any particular page displayed in the browser.

To save a lecture to disk for offline viewing, the basic command you want to run is:

mencoder mms://the-streaming-video.wmv -ovc copy -oac copy -O filename_out.avi

Now the ‘path-to-streaming-video.wmv’ you need to use will be unique for your authenticated SUNet session with Stanford’s servers. You can manually find this unique path by navigating with your browser to the lecture you’re interested in, viewing the source of the page, and manually scanning for the path. Or you can install the following small and simple Greasemonkey script.

// ==UserScript==
// @name          Stanford Video MMS Path Retriever
// @copyright     2010, Mike Fogel, http://fogel.ca
// @license       This SW may not be used to violate Stanford's terms of use.
// @namespace     http://fogel.ca/greasemonkey
// @description   Adds a header containing mms path to Stanford player page.
// @include       https://myvideosu.stanford.edu/player/slplayer.aspx*
// ==/UserScript==

function get_mms_path() {
  var o = document.getElementById('WMPlayer');
  return 'mms' +  o.data.substring('http'.length);
}

function add_header(message) {
var elem = document.createElement('div');
  elem.id = 'GM_mms_path';
  elem.style.color = 'green';
  elem.innerHTML = '<h2>'+message+'</h2>';
  document.body.insertBefore(elem, document.body.firstChild);
  return elem;
}

function set_selection(hdr) {
  var range = document.createRange();
  range.selectNodeContents(hdr.firstChild);
  selection = window.getSelection();
  selection.removeAllRanges();
  selection.addRange(range);
}

function main() {
  var mms = get_mms_path();
  var hdr = add_header(mms);
  set_selection(hdr);
}

main();

The Greasemonkey script scrapes the page, finds the ‘path-to-streaming-video.wmv’, adds it in large, bright green text to the top of the page, and selects it so you can just hit ‘cntrl-c’ to copy it to your clipboard. Then over in a terminal, you can paste that path into your MEncoder command. Running the command will take a long time – in fact, as long as the lecture is. This is because MEncoder simulates a regular streaming video player to the Stanford servers. MEncoder will convert and save the streaming video according the the suffix of the output filename you specify (eg. ‘.avi’ in my above example).

I don’t have to do this every morning (thank god) but I have been doing it about once a week lately. The transit route described here is kinda the ’standard’ route – you can get creative with all the different transit agencies in between Sacramento and Palo Alto, but as far as I am able to find, no ‘creative’ route is able to beat out the ’standard’ route. Note that I’m purposefully excluding a ‘bike + transit’ option for the purposes of this DeathMatch.

All times AM, all money in USD (duh).

The Route, via Transit

  • Walk, house -> bus stop: 3 min
  • SacRT, bus: 6:35 -> 6:50, $2.50
  • Amtrak, capitol corridor, Sacramento -> Richmond: 7:00 -> 8:25, $13.60 (10-ride pass)
  • Bart, Richmond -> Mlibrae: 8:42 -> 9:51, $5.31
  • Caltrain, Milbrae -> Palo Alto: 9:55 -> 10:25, $4.25
  • Stanford Shuttle: 10:30 -> 10:40, free
  • Walk, shuttle stop -> class: 3min

Direct Monetary Cost

2.50 + 13.60 + 5.31 + 4.25 = $25.66

Time Analysis

Percent Efficiency Assumptions
  • Transfers/walking: %0, including 2 min window on each side cause it takes a while to get situated on bus/train
  • Bus/shuttle: %30
  • Bart: %50
  • Caltrain: %70
  • Amtrak: %90
Effective 100% Efficiency Time

(sacrt) + (amtrak) + (bart) + (caltrain) + (stanford shuttle) =
(15 – 2*2) * 0.3 + (85 – 2*2) * 0.9 + (69 – 2*2) * 0.5 + (30 – 2*2) * 0.7 + (10 – 2*2) * 0.3 =
11 * 0.3 + 81 * 0.9 + 65 * 0.5 + 26 * 0.7 + 6 * 0.3 =
128.7 min ~= 2 hrs 9 min

Wasted Time

Total Travel Time – 100% effective efficiency time =
(4 hrs 13 min) – (2 hrs 9 min) = 2 hrs 4 min

The Route, Driving

  • Walk to car, 3 min
  • Drive @ rush hour, Sacramento -> Stanford: 2 hrs 50 mins, 124 miles (src: google maps)
  • Park car and walk to class: 15 min, $11

Direct Monetary Cost

Assumptions
  • 30 mph
  • $3.00 per gallon for gas
  • bridge toll: $4.00
  • ignoring all other car costs – they’re not ‘direct’ (ie. you don’t pay them right then)
Calculation

124 / 30 * 3.00 + 11.00 + 4.00 = $27.40

Wasted Time

3 min + (2 hrs 50 min) + 15 min = 3 hrs 8 min

Conclusions

Taking the trip via transit rather than driving saves $1.74 (oh boy!) and 1 hour, 4 minutes of time. If we were to add in the full costs of owning an automobile (AAA estimate: ~52.2 cents/mile) then the monetary cost for driving rises to $79.73, thus implying a monetary savings of $54.07 for taking the trip via transit, rather than driving. Bam! Headshot.

Commute Mode DeathMatch Leaderboard

  • Transit: 1 (headshot)
  • Driving: 0

Coming soon: ‘biking + transit’ jumps into the rumble!

Over the past six weeks SF has been doing some trial improvements to Market Street. These are simple livability improvements – mainly restricting private vehicle traffic and adding some paint here and there. They’re collecting data and feedback about these improvements with an eye to revamping the whole street come 2013.

Feedback? You want feedback! OK!

To: marketstreet@sfgov.org
From: Michael J. Fogel <mike … at … fogel.ca>

Subject: Market Street improvements feedback

Good morning MarketStreet@sfgov.org

A few thoughts about the Market Street trial improvements from the perspective of an SF user (walk, Muni, bike, taxi, and occasionally – private vehicle driver):

  1. I think the changes to restrict private vehicles on Market Street have been a step in the right direction. The blocks with reduced traffic are now more pleasant to be on – which will in turn attract more people to these blocks, which will in turn make the street more pleasant – a virtuous cycle.
  2. The trial improvements have been limited in their impact because the choosen blocks are not high-profile, high pedestrian traffic blocks. Restricting private vehicle traffic between, say 6th and 3rd, would do a significantly better job in making the advantages of these improvements clear to more people.
  3. Restricting private vehicles, while not hindering taxis, delivery vehicles, and Muni was an excellent choice. While these professional drivers are often more aggressive, they drive more predictably and are generally much safer than private drivers. They also are now able to provide essential services to Market Street with greater efficiency – a benefit to all users of the street.

Because of Market Street’s high profile, a successful Market Street improvement program has potential to motivate further livability-oriented changes around our region. I encourage you to build and expand upon the trial improvements completed thus far, pushing them to the busiest areas of the street where they will be seen and felt by the most people.

Thanks for your time,

Michael Fogel

These are the first SFgo signs going up in a residential neighborhood in SF. SFgo is intended to bring ‘smart’ driving to SF by providing real-time information to drivers on key traffic corridors, enabling them to make better route-planning decisions.

SFGo fell

SFGo oak

(Image credit: BIKE NOPA)

The first image is on Fell street, the second is on Oak. Both are right near their intersection with Divisadero.

So some big signs on some big streets. What’s the big deal?

To: Ross Mirkarimi <Ross.Mirkarimi@sfgov.org>
From: Michael J. Fogel <mike … at … fogel.ca>

Subject: SFgo signs are a step backward

Hi Mr. Mirkarimi,

I currently live at Hayes and Filmore, in your district. Over the past five years, I’ve lived at three different locations in SF, all in your district (Lower Haight, NoPa, and now Alamo Square). We’re lucky to live in the neighborhood we do.

I want you to know that I feel strongly the new SFgo signs are a step in the wrong direction. Rather than make our neighborhoods more people-scaled and people-friendly, these signs will push drivers (you and I included) further toward a freeway driving mentality while speeding along Oak and Fell. These streets are bad enough already. We should be taking steps to calm them, not speed them up.

Specifically:

- the SFgo sign on Oak should be removed completely. It serves no valid purpose.
- the SFgo sign on Fell should be moved to the freeway off-ramp down to Octavia. The sign should be placed well in advance of the Market street crossing.

In addition:

- the lights on Fell and Oak should be timed at 25mph, not 30. It requires aggressive driving to even keep up with the timing of the lights over the Alamo Square Hill.
- on Oak, from Baker to Scott one lane of traffic or parking should be removed immediately to provide a bike lane on the right hand side.
- A full study of these streets should be undertaken to identify effective longer-term steps we can take toward making these streets an asset to our neighborhood, rather than the barrier they currently are.

I’m not a member of any of the neighborhood groups. I don’t have time to go and speak out at the community meetings. I’m not the type that’s complaining about every little last thing that’s wrong with the neighborhood. But I feel strongly the new SFgo signs area a blatant, highly visible step in the wrong direction. I urge you to do what you can to remove the new SFgo signs from the neighborhood.

Thanks for your time,

Michael Fogel

There’s some good fantasy transit maps out there. Maps of what an effective transit system might look like in our region. Maps of what it would it might take to make build a system that works better than me in my private car.

But, what about the tourists? Will someone please think of the tourists? How are they going to get from Powell, to Civic Center, to Alamo Square, then out to the Museums?

Have no fear, the H is here!


View The H in a larger map

Muni’s next historic streetcar line, right after the E and the extension of the F over across Fort Mason.

Stanford has a few warnings posted in some of their garages:

garage toxic warning

Nice of them to advertise that the parking garage isn’t a healthy place to hang out, at least not according to your lungs and your junk. But really, a few things.

  • If a parking garage deserves an air quality warning, how about a congested freeway on a hot, still day?
  • The garage is not the source of that bad health stuff. Specifically, it’s the incomplete combustion of gasoline in the 100’s of internal combustion machines sitting around in the garage. Maybe we should put the warnings directly on the source of the problem?
  • If we should be concerned about the health effects on our lungs from our cars, what about the bigger effects – like cars being the leading cause of death for Americans 35 years old and younger? Or being a vital component of our awesome 73% overweight/obese rate? Or pushing our communities and ourselves farther and farther apart – to distance scales that work well for a two-ton block of steel, but not so great for a 150 lb chunk of human?

It’s easy to see and point at air quality numbers. They can be measured empirically, their effects can be studied in laboratories, and it’s easy to say “this is bad. See proof by X.” But more often than not cause-and-effect relationships don’t end with a nice, clean number at the end. As such, it’s harder to talk about these relationships, it’s harder to reason about them. The unfortunate wrench is that sometimes, these ‘unclean’ relationships are actually the most important ones of all. Which probably explains why you never hear of a mathematician being elected to public office.

Something’s officially happening. Learn more about what’s coming from the Project for Public Spaces, who was hired by the San Jose/Guerrero neighborhood group to flush out the design. Kudos to those neighbors for pushing this through the last few years… your work is much appreciated.

Guerrero and San Jose Plaza construction