Sunday, July 26, 2015

2015 Voting Guide for Seattle Techies

“How cool is it that in our brief lifetime we get to participate in Seattle's first council elections by district? This feels momentous!”

“Not as momentous as it would feel if we'd been born in time to be optimistic about space exploration or liberal Twitter...”

“Whatever, anyway, I'm so informed about local politics, I know who to vote for in every council position. They should let me vote for every position. Maybe I should take up residence in every district.”

“Even if that was how voting worked you still wouldn't get to vote for position ten.”

“Which one is that?”

“The sky.”

“The sky?”

“By the 1869 Charter Doc Maynard was recognized as sole owner of the sky. He subdivided and sold it to people he knew—”

“—let them in on the ground floor—”

“—yes, as it were, and its ownership has remained a fairly small, though gradually growing, group.”

“Your Boeingses, your Kenmore Airs—”

“—and, typically enough, Ma Bell. Its portion of the sky passed down to Century Link, whose only remaining profitable business is charging cellular providers for easements.”

“Well, that and tricking out-of-towners looking for football parking into entering their company garage, then fining them.”

“Sure. Anyway, until now most of the owners have been businesses, and businesses can't vote, but I figured out how to suspend a hammock from an array of drones, and I'm claiming residence in the sky for this election.”

“Who sold your ass sky? You've lived here like eight months.”

“I'm renting... well, technically it's sort of a squatters' rights situation...”

“How long does that take to kick in exactly?”

“...unh-unh...”

“Fine... so who are you voting for, then, for position ten?”

“Myself. I'm the only one that meets the residence requirement.”

“... What's even, like, your ZIP Code in the sky?”

“That would be nine-eight-one-go fuck yourself—”

“—hey, now—”

“—not you, personally. The postal service would like to establish a branch up—”

“—and I suppose you're still a two-oh-six, or did they stick the sky in four-two-five?”

“Six-five-oh. I got my phone in college.”

Sunday, July 19, 2015

Going Theory

Until today, my going theory was that my performance improvement in running this year was due to more consistent training and the sequence of a few years of minimal/"barefoot"-style running (which improved my turnover and body control) followed by going back to regular trainers and adding some new stretches (thanks, Tom Cotner!) that helped lengthen my stride. Turnover plus stride length equals speed; the body control helps keep me consistent and healthy. Also, though I mostly train in cushy trainers now, I'm continuing to forefoot-strike and use minimal shoes occasionally, so that I can race in minimal shoes (providing an advantage similar to racing flats) at any distance I want.

Then I read some articles citing studies claiming that typical doses of caffeine can improve performance by perhaps up to 3% in endurance athletes. This is my first season where I trained remotely well since becoming a coffee drinker. 3% more than covers my 5k improvement, and of course I'm racing in much lighter shoes than in the past. That really popped my balloon. I thought I was doing all this smart stuff to improve, outsmarting my younger, dumber self. Turns out it's just coffee and shoes.

Tuesday, July 14, 2015

, and the banker said, "Do you have savings anywhere else?" and I said, "Yeah, shoeboxes," and he said, "Shoeboxes?" and I said, "Under my bed, filled with solid gold bars, which is pretty space-efficient," and he paused, and I continued, "It's not like I was making much use of the space under my bed anyway. In the interest of diversification I bury some of the boxes secretly on other peoples' property; this adds some risk. But there's growth potential, too, because who knows, someone might put more gold in 'em!"

Wednesday, November 26, 2014

The Broken Promise on Mercer

Everyone hates the Mercer project. Activists campaigning for district-based city council elections attacked it as a symptom of the at-large council's downtown-centrism. Meanwhile, everyone hates an enormous parking-lot of a road, no matter how they're trying to travel along or across it. And it's an expensive parking-lot of a road -- no matter how much money we spend, “Mercer” will still be a code word for bad traffic, and we're spending a lot of money on it.

Complete streets rules, however, require that projects like this take into account bike and pedestrian access. Since bike and pedestrian routes across Aurora in the vicinity of Mercer and Broad were so horrible before the project started, almost anything would count as an improvement. So there's some promise at least. The removal of the worst parts of Broad Street and an Aurora underpass with sidewalks that are more than an afterthought will be great improvements when they're finished. And what's the plan for biking through east-west in the corridor? Instead of trying to build a cycletrack along the expanse of Mercer, plans called for a route mostly along Roy. OK, so it'll use a cycletrack along the expanse of Mercer for a couple blocks to get under Aurora, and east of there Roy will turn into Broad for a block and then Valley as it runs south of Lake Union Park, for reasons that I'd describe mostly as historical -- anyway, I'm going to call it the Roy route for the rest of this post.

The Roy route looked pretty good in the plans' overhead views. Not a centerpiece of our AAA (All Ages and Abilities) bike network, perhaps not always a ride full of delights, but a reasonably direct and safe way to get from A to B. In fact, by these standards, the lines drawn on the ground today are already pretty good. The temporary version of the Aurora underpass path is a little tight, and on the wrong side of Mercer for people riding through, but considering that it's an active construction zone, it's not so bad.

So what's the problem? Two things, and without fixing them the Roy route just won't live up to its potential to sew up the fragmented neighborhoods all the way from Fred Hutch to Lower Kinnear.

  • Signal timings. Too many of the signal cycles, particularly at 9th Ave N and Westlake, are way, way too long. Maybe, maybe, this can be justified during peak hours as a way to maximize vehicle throughput on Westlake. Personally I don't think any possible throughput that could be gained extending cycle lengths from kinda long to extremely long is worth delaying the bike route or pedestrian access to the park and bus stops... especially because the peak-hour queue for Mercer often extends past Valley. I think prioritizing pedestrian, bike, and transit access over vehicle throughput aligns with the city's stated policies. But even if SDOT disagrees about the relative value of peak-hour vehicle throughput, there is no possible justification for these cycle lengths off-peak, when there just isn't much traffic trying to use Westlake at all. If Seattle wants to develop a jaywalking culture, this is how it will develop a jaywalking culture.
  • Construction closures. There's a lot of construction coming to this corridor in the next generation or so, especially east of Aurora. If the Roy route is going to fulfill the promise of a pedestrian/bike route in the Mercer corridor, it must be continuously open, both ways, all the time. Currently construction on a building has closed the route eastbound for a single block between Westlake and 9th (it hasn't just closed the bike lane, it's actually closed the street to eastbound traffic generally). There's not really a great detour route, and the lousy one that exists (taking Dexter north to Aloha, crossing Westlake at the north crosswalk after a stupefying wait, and taking one of the various paths through the park) isn't indicated. The closure of sidewalks and crosswalks has had typical effects also, especially at intersections with long signal cycles and especially near bus stops. Making the Roy route one-way for a block is, for people biking, just like making Mercer one-way for a block would be for people driving, and the city needs to start thinking about it that way when it issues construction permits.

Sunday, October 19, 2014

Seattle BMP Implementation plan!

So, now, a clearer look at what the Bike Master Plan's lines on a map will actually mean for the next five years. Here are the big takeaways for me:
  • It's weak in West Seattle. This isn't all that surprising, as the BMP has always been weak in West Seattle, but this plan throws it in relief. The two greenway routes in the eastern residential neighborhoods are great, but there's little help in here for access to businesses in Alaska and Admiral Junctions, and little help for getting between the junctions (and adjacent hilltop neighborhoods) and low-lying destinations (primarily the bridge and Alki). These connections are menaced by a junction without a name, the junction of Fauntleroy, Admiral, and the high bridge, and that doesn't look to change.
  • It's not totally clear that a plan has cured SDOT of opportunistic bike planning. Opportunism is a problem when it becomes a game of, "We'll build bike access where there's room," rather than, "We'll build bike access where we need it." Nothing in this implementation plan looks like the great routes needed between the U District and three key destinations to the south: downtown, Capitol Hill, and the Central District. There's growth coming to Northgate and Alaska Junction and still these are places the bike network goes to die. And we've continued to allow retail, entertainment, and even residential incursion into industrial areas like SODO and Interbay while transportation planning remains exclusively freight-oriented.
  • Paging Mr. Newmark, we'll have some missed connections. Northeast Seattle is probably the worst. The recent NE 75th St bike lanes stopped just short of Roosevelt to the west and 39th to the east, and will stay that way. New lanes on 130th make it to the Interurban but stop at I-5, a few blocks short of both Roosevelt and lanes on 125th. The 68th St greenway will end into nothing at both ends, even though it's just a few blocks from other routes. Elsewhere, the plan for existing ROW on 6th and Airport to extend a good bike route south from the end of the SODO trail is fine, but what happens in the east-west jogs? In particular, the jog on Spokane from 6th to Airport? There isn't a lot of room among the highway ramps... and this is a route filling one of the biggest gaps in our cycling network, so it's one we really should get right.

    EDIT: There are a few things to be happy about regarding connections. The plan includes work on N 34th and Fremont Ave in Fremont, an opportunity to fix some of the awkward turning situations at 34th/Fremont and 34th/Stone, to patch a short gap in the Interurban Route, and to improve wayfinding between the Interurban Route and the Burke (or even to suggest alternate Interurban Route connections for people that find Fremont Ave too steep).

  • Neighborhood greenways will prove their worth in SE and Central Seattle. What's awesome about the plans to blanket these parts of town with greenways is how easily they connect together, at simple side-street intersections, while separated arterial routes require more complex connections.
  • Don't sleep on the suburbs. During BMP discussions some people expressed concerns about planned routes near the edges of the city, especially the southern edge near Boeing Field -- "Will these routes be useful if they drop off at the city limits?" Yesterday I saw some new bike lanes out the window of the train on the way home from mountain biking and went down to check 'em out this morning. Tukwila has recently built a half-decent bike route using East Marginal Way, parts of Boeing Access Road and its ramps, and Airport Way, and they're waiting for that connection from Seattle that, by this plan, won't be complete until after 2019. It turns out Tukwila's lanes really lose a lot of their usefulness because the connection north into Seattle is so bad. The ball is really in Seattle's court when it comes to connecting to several neighboring cities, especially to the south, where routes are affected by the SODO gap as well as gaps closer to the borders.

Monday, April 7, 2014

A more interesting anti-Pono screed

Yeah, I'm talking about Pono, the silly $400 audiophile music player that makes the typical silly audiophile claims about why it's better. I could write a typical anti-audiophile screed and denounce their marketing copy as pseudoscience. I already did this on a G+ post and feel sort of silly about that, not because what I wrote wasn't true but because it wasn't very interesting. I have much more interesting things to say about the Pono than, Your claims are silly and you should feel silly!. Here they are:

  • Pono might actually sound better than your phone. But less due to the expensive hardware in the Pono than the expensive hardware in your phone. The worst audio fidelity problems encountered in the real world are much more prosaic than those Pono talks about in its ad copy. One of my old computers, the dearly departed talkingcookie, suffered from noisy interference in audio I/O during hard drive, mouse, and keyboard activity. This sort of thing is caused by simple board layout and shielding problems that could just as easily occur on a phone. If I had to guess, though, iPhones have probably never had this problem.
  • Pono is Prius-shaped. Some people have commented on Pono's weird triangle shape, speculating that it wouldn't fit well in your pocket. They weren't buying one anyway. Driving a Pontiac Aztek sets you apart as someone that bought an ugly car. Driving a Toyota Prius sets you apart as someone that bought a green car, at least to people soft-headed enough to think the environmental difference between a Prius and a typical car is anything but incremental --- fortunately for Toyota Americans are notoriously soft-headed about cars. To those that are soft-headed about audio fidelity the Pono's wacky shape sets them apart as discerning, and fortunately for Pono Americans are notoriously soft-headed about music.
  • Pono isn't straight-up elitism, but it's sideways elitism. Neil Young said something about wanting to take the experience of listening to music back to his beloved 1970s. In the 1970s the parts of the audio chain the Pono represents really made a difference. They were the quality and condition of the vinyl disc and of your turntable. Today the other parts of the audio chain vary as much as ever: the mixing and mastering of the music on one end, and on the other the amplifiers, speakers or headphones, and listening environments. But the fidelity of the record from the master copy to the DAC is solid for everyone. This must gall the elitist, who subconsciously sees ubiquitous access to high-fidelity audio as desacralizing it somehow. If there's a case to be made that recorded audio quality is worse today, it's about the loudness war, and how the listening environments of loud cars, buses, and trains have contributed to it. Of course the Pono doesn't try to elevate the living room as the preferred environment to entice tomorrow's engineers to master for nice, quiet spaces. It instead promises flat frequency response (hmmmmmm...) no matter what kind of lousy headphones you're using (their ad copy elsewhere dares to utter the word earbuds, so... hmmmmmmmmmmm...) by virtue of its... low output impedance? Well, I said I wasn't going to harp on the pseudoscience, so...

/micdrop

(EDIT: formatting derps)

Wednesday, January 1, 2014

Do you believe in conspiracies?

So there's a poll about conspiracy theories that is asked of Americans, by Public Policy Polling, with at least the veneer of procedural propriety. Among the questions: was the moon landing faked, is global warming a hoax, is Obama the damn Antichrist, and... “Do you believe the Bush administration intentionally misled the public about the possibility of weapons of mass destruction in Iraq to promote the Iraq War, or not?”

We-e-e-e-lllllllll... one of these things is not like the other, right?

How do I answer this question? Am I a lefty conspiracy nut or a sane moderate adult? Was I a lefty conspiracy nut in college (when this all went down, for me), and a sane moderate adult now that I'm almost 30 (WAT WAT WAT WAT WAT WAT WAT)? Was Bush involved in some sort of plot that led people off to die just to enrich its profiteering members pockets? Probably not. But I think something happened sort of like what happened with the (currently stuck) Deep Bore Tunnel in Seattle.

Tunnel supporters (oh, geez, here Al goes on another tunnel rant) decided they wanted a deep-bore tunnel built before they set out to make a case for it. They knew the existing viaduct wasn't seismically sound and needed to be replaced. They knew it couldn't be rebuilt in similar form because it wouldn't meet building codes or highway design standards. These are near-indisputable facts, and no amount of future-nostalgia for the viaduct will make them go away. They believed they needed a full limited-access freeway in that corridor; that's an opinion I disagree with (at the very least, I think it's a bad assumption to go in with), and I think it's really the crux of the matter. All the rest of the questions flow forth from there. They believed a surface-level freeway or a cut-and-cover tunnel would be too temporarily disruptive to public waterfront access and existing businesses; these are widely popular opinions and I agree with both. At that point, the only option is to build a tunnel, and the task ahead is to sell it.

The way they sold the tunnel is through studies. Good leaders involved in a sound decision making process would have started the study by determining goals and needs. This process would have identified many important needs that really will be met well by the planned work in the Highway 99 corridor: providing vehicular access to the Port of Seattle and industrial district from the city at large, reconnecting the local street network across the highway between Lower Queen Anne and rapidly-growing South Lake Union (the tunnel wasn't necessary for this, but it's kinda part of the plan), providing a legible route for Highway 99. It also would have identified needs our plan doesn't readily meet: ensuring fast, reliable, and direct mass transit access between downtown Seattle and southern and western corners of the city, maintaining the pedestrian network of Pioneer Square, managing surface traffic in downtown and SODO, providing a bypass of downtown Seattle congestion for long-haul traffic in the corridor that actually carries such traffic (I-5, the reasons for which could fill a whole blog post), addressing all our environmental goals, and being fiscally responsible. Phew, that's a lot of stuff the tunnel sucks at — and I only really disagree with supporters on one thing!

But the studies weren't designed to find how to meet our needs, they were designed to sell a freeway. The metric placed above all others was vehicular travel time between Green Lake and the Port of Seattle, a race designed to be won by a freeway tunnel with few exits between these points and none between Mercer and Yesler. The necessity of a pure limited-access freeway seemed self-evident without examination to most people, and was never effectively challenged. Studies and arguments showing that a non-freeway alternative met our full slate of needs better than the tunnel, for less money, were dismissed without official acknowledgement, in ways that stifled discussion. Cascadia prides itself on open government, but what we saw was a farce of that: advisory votes on confusing measures without any real discussion of what we needed and why. I don't think that's a nefarious conspiracy, but it's bad leadership and bad decision making that ultimately misled all of us, public and leaders alike.

Similarly, the Bush administration determined it wanted to invade Iraq before building a justification based on WMD. It had a number of reasons it wanted to go, but the WMD case was considered likely to gain support in the media, so the administration assembled what evidence it could find (including the erratic and evasive behavior of Hussein's regime when pressed) and presented it widely. It wasn't a back-room conspiracy; it was put together by people whose various earnest reasons for wanting to replace Saddam Hussein were no secret. The public case was disingenuous and held together by wishful thinking. I'd say wishful thinking for a war is pretty perverse on the face of it, but if you believed in the rest of the case for invasion (as many Americans did and continue to do) you'd continue to support it (as many Americans did and continue to do).

So when the WMD evidence turned out flimsy this didn't change the opinion of many on the war (though the experience of being a country at war did, which could fill another blog post... by someone else). In Seattle, when new traffic and tolling revenue projections showed the tunnel in a worse light, this didn't change a lot of people's views on it. WMDs were never really the leaders' reason for war, why should they determine the people's acceptance of it? Because the media ran with that narrative and wanted to hold the administration's feet to the fire? Even that didn't matter much; people that opposed the war all along simply had a loud new ally, and people that supported it got to exercise their well-earned skepticism at the media. In this age of polarization few were left in the middle aside from that very media, trying desperately to hold together a common narrative, being duped badly, acting as stupid as it looked (that could fill another blog post).

Back on topic... I don't think that's a nefarious conspiracy, but it's bad leadership and bad decision making that ultimately misled all of us, public and leaders alike. Do I believe the Bush administration intentionally misled us? To Public Policy Polling, as I read the question, you can put me in with those that believe in the New World Order and Reptilians: a true conspiracy believer. And not as crazy as all that, either.

Wednesday, August 22, 2012

LaTroy Hawkins and the 2004 Cubs

I was reading a bit about the Cubs today, and the subject of the 2004 Cubs came up. And, unsurprisingly, LaTroy Hawkins was prominently featured as one of the reasons that team did not make the playoffs, even though it was in many ways better than the 2003 Cubs, who did. When this happens I usually like to make a little comment that Hawkins wasn't actually as bad that year as many perceived, and that he never really deserved much of the criticism he received from fans and the media that year. But blog comment space doesn't allow for a full analysis of Hawkins' 2004 season, and the reasons that different stats paint a very different picture of the sort of season he had. This format does, so here goes.

The popular narrative is that LaTroy Hawkins was a talented pitcher that couldn't perform under pressure and was thus uniquely poorly suited to be a closer. Indeed, in 2004 as he closed for the Cubs, his ERA was stellar at 2.63 and his strikeout and walk rates excellent but he blew 9 saves.

Aggregate stats like ERA and strikeout rate have the weakness that they don't use the individual game as a unit. A closer's save record, like a starter's W-L record, hold the individual game up and attribute its result to a pitcher. That's why they resonate in ways that aggregate rate stats don't. Unfortunately they can also be pretty inaccurate measures of a pitcher's impact on the games he pitched in. And sometimes, as in Hawkins' case, they're even misleading indicators of what happened while he was pitching.

Measuring a single player's actual impact on a game is impossible, but measuring what happened while he was pitching is done regularly with WPA. Hawkins' WPA didn't shine as brightly as his rate numbers, but it was pretty good, around 1.2. It's better than any other Cub reliever that year, and in line with what many other good relievers did. You'd expect a reliever that blew so many saves to have a bad WPA. His decent WPA suggests that his blown saves were not as bad as those of many others. Indeed, my recollection is that several times he blew saves in games the Cubs won; he held the tie and often was credited with the win himself. Even if he performed poorly he left with the game still in reach. WPA will rightly say this sort of blown save is better than the stereotypical reliever meltdown, where the closer gives up the tying and winning runs.

So what do the game logs say? Let's look at the 9 blown saves of LaTroy Hawkins in 2004.

  1. April 28: Hawkins entered the game with one out in the 8th and a one-run lead. He gave up a home run to tie the game and finished the inning with the game tied. The Cubs happened to score one in the 9th and win (this does not bear on Hawkins' WPA, nor on any rational analysis of his performance, though he was credited with a win). Although it occurred before Hawkins was installed as the closer, this fits the pattern of a blown save that was, while not good, about as good as a blown save can be.
  2. May 28: In the second game of a double-header Hawkins entered in the bottom of the 9th with a two-run lead and gave up a two-run homer to tie the game. He finished out the 9th and was replaced for the 10th by Francis Beltran, who threw one pitch that was hit out for a home run and a Cubs loss. Again, Hawkins allowed the tying run but not the winning run to score, though this time he blew a larger lead.
  3. June 13: In the bottom of the 11th Hawkins entered with a one-run lead. He allowed three singles (one which he fielded; it is possible though not certain that he fielded poorly -- either way, WPA counts it the same as any other single) and the tying run, finished the 11th, pitched a 1-2-3 12th, and exited with the game tied. The Cubs went on to win. The pattern holds.
  4. July 4: A one-run lead going into the top of the 9th, a solo home run, a blown save, a tie-game departure, a Cub run (on an RBI walk by Todd Walker), and a win. The pattern is four-for-four.
  5. August 21: Another one-run lead in the bottom of the 9th. Hawkins recorded only one out before allowing two runs and picking up the loss. A throwing error on Aramis Ramirez contributed; still, the pattern is finally broken.
  6. August 25: Exactly like July 4, except in the details. Hawkins gave up the tying run on a double to a guy named Magruder, and the Cubs won it on a solo shot from Corey Patterson. Pattern is 5-for-6.
  7. September 21: Another for the pattern (6 out of 7), and another blown save-win for Hawkins. This time it was the bottom of the 9th, and Patterson (another Cub that had a pretty solid season that many remember as disappointing) scored the winning run on a wild pitch, setting up a save for Ryan Dempster.
  8. September 25: Hawkins entered with two on and one out in the bottom of the 9th and gave up a 3-run jack to tie it up. That's -0.4 on the WPA scale, which is exactly halfway between 0.1 (what he'd have got for the save) and -0.9 (what he'd have got had he given up another donger instead of finishing the inning). That's the very mathematical signature of the pattern. 7 out of 8. Oh, yeah, the Cubs lost in extras, holding onto a slim half-game wild-card lead.
  9. September 29: I'll have the regular. The real orthodox regular. In a one-run save opportunity in the top of the 9th Hawkins gave up one run. The Cubs went on to lose in extras and fell a half-game back in the wild-card race.

So the final score: in nine blown saves LaTroy Hawkins finished out the inning with the game tied eight times, giving the opponents the lead only once. On top of that he picked up losses after entering tie games three times. This does not amount to a great season, and the stretch run was particularly mediocre, but it does amount to a better season than the blown-save count and popular narrative would lead you to believe. And that bit about a decent-but-not-great season with a mediocre stretch run? That describes the 2004 Cubs to a T, the whole team. Singling out any one player is silly.

Saturday, January 7, 2012

Jane Jacobs on the *oof*

I'm reading Jane Jacobs again, this time The Economy of Cities, which Jess gave me as a Christmas gift. And, oof! When I read The Death and Life of Great American Cities I did it on the L (as documented on this blog in the past), and now I'm doing it on the 5, with its lovely payment scheme where, as long as downtown Seattle's Ride-Free Area is in effect, you pay as you exit on buses leaving downtown. Some Seattle Transit Blog commenters call this scheme PAYPTTF, or “Pay As You Push To The Front”, and on a full bus that's about how it works out.

So in between giving and receiving body blows trying to deal with the flow of people through this bus I'm reading her account of how cities and urban work are the real sources of development and prosperity; not rural work, and not the earth, as many people have thought. And how the “impracticality” of big cities is one of the driving forces of progress. If only Seattle, not that big a city, could get over itself and make it practical to get people on and off of buses quickly. Nürnberg and Erlangen do it with no fancy smart cards or anything (my guess is at least some other cities in the German-speaking world are similar)! And their bus drivers give change!

Jacobs is largely thought of as a hero on the left, but her ideas often have something in common with Libertarianism; see this article from the Mises Institute. In The Economy of Cities she shows these stripes very strongly. She celebrates how the public good is served when people have the freedom to go off and develop their own work for their own profit. Certainly Jacobs' thought is wide-ranging. Her comments on development economics make perfect sense to someone that's read Amartya Sen; her comments here and on environmental regulations often point to the futility of common types of government action, as in Death and Life her most common targets for criticism were centrally-planned government redevelopment projects.

From where we stand today, her thoughts on environmental topics are interesting. She stressed the importance of recycling, and mining waste for usable products. Among other authors I've read, some of Paul Hawken's ideas come to mind. And, indeed, cities facing expensive waste disposal problems have made some strides in this way. She stressed the importance of chemical scrubbing of smokestack emissions, producing useful, profitable by-products. Unfortunately some of the worst chemicals we emit don't have a profitable economic use. So we're now stuck in the undesirable position where the combined actions of people working for their own good don't serve our overall good — the position where we really do need some kind of regulation.

In this sense, I might say Jacobs ended up being too optimistic on the ability of cities to solve their own environmental problems. But maybe she was actually right-on with her frequent pessimism that our cities, and our economy, is stagnating and failing to come up with practical solutions to its problems.

Friday, December 9, 2011

Stories I don't know (yet): the history of Phinney Way and the future of Green Lake Way

A few months ago there was a fire at the corner of 46th and Phinney Way. Jess told me she saw the fire on the way home from work, and this confused me. We live near Fremont Avenue, Jess works east of where we live, and Phinney (the street) is west of where we live. Unless she stayed on the bus too long, she shouldn't have passed the fire on her way home. It turns out that Phinney Avenue is west of us, and Phinney Way is basically an onramp to Aurora, just east of where we live. Seattle is full of wacky street naming quirks, but why would we have ever named this onramp Phinney Way when there's a street with nearly the same name a few blocks away, the onramp isn't in Phinney, and in fact takes you directly away from Phinney?

More recently I was thinking about intersections near where I live that hinder pedestrian mobility. Two that came to mind were confusing multi-way intersections. First, the 5-way intersection of N 50th Street, Green Lake Way, and Stone Way; second, the 7-way (!) mess involving two separate N 46th Streets, Green Lake Way, and Whitman Avenue. In fact, these intersections aren't much fun to cross by bike, bus, or car either. What do they have in common? Green Lake Way, which is itself a nearly-uncrossable pedestrian barrier all the way from 46th to 50th. How could one street cause this many problems?

And what do these two odd streets have in common? For one thing, geographical proximity. Here's a nice Google Earth cap:

Here's another thing these streets have in common: they didn't exist 100 years ago. Here's a clipping from the 1912 Baist map of Seattle:

In Chicago, I'm told, the diagonal streets that muck up the otherwise orderly street grid were there first, at least on the north side (I could be wrong about this, but I don't feel like researching it right now). The 1912 Baist map shows that in Seattle the grid streets came first. Roads taking curvy, relatively level paths around the hills like Fauntleroy Way and Sand Point Way didn't exist yet (though railroads took these sorts of paths did); neither did most of the current crossings of the Ship Canal; neither did roads like Bridge Way, Fremont Way, nor our culprits: Green Lake Way and Phinney Way. This last set of roads had not been built because their main purpose is to quickly funnel automobile traffic to and from Highway 99, which wouldn't exist in its current form for another 20 years (per Wikipedia: Ford started mass-producing cars in 1914; the Aurora Bridge was opened in 1932, and the highway through Woodland Park was built somewhere around that time; the Alaskan Way Viaduct and Battery Street Tunnel were built in the 50s).

So the mess created by Green Lake Way comes into focus. At some point during the upswing of the automotive era the through-travel needs of motorists ran roughshod over the local-travel needs of pedestrians. Wide, fast roads were built along reasonably level paths cut through the existing urban fabric to connect drivers to what was then the major highway of the west coast. Bridge Way from Wallingford; Fremont Way from Fremont Avenue in Fremont (grumble); Green Lake Way from Green Lake (in this case the name worked out, as Green Lake Boulevard at the time didn't exist south of Woodland Park). And Phinney Way. Start at Aurora and continue its path. There must have been a plan at some point to build another diagonal road continuing along its path to Phinney Avenue, like a mirror image of Green Lake Way. But for some reason it was never completed, and Phinney Way is left as a weird stub with a weird name.

I'm sort of interested in when exactly these roads were all built, and why Phinney Way was never completed. It seems likely to me that these events predated the “freeway revolt” movement, so did some kind of proto-freeway revolt take hold (a proto-revolt for a proto-freeway), stopping the road? Or was it a more mundane reason? One reason I'm interested is that I believe we need to start reversing some of the legacies of the automotive era in our cities. One that I'd love to see go is Green Lake Way. I'm not a natural activist or leader, but I can envision a more cohesive and walkable neighborhood with more pedestrian-friendly intersections. There are plenty of other ways to get to Highway 99, and Highway 99 is no longer as important for north-south travel in the region now that I-5 exists. I don't know if anyone else is interested in this, but I'm sure interested in the history, and what we might be able to do in the future to re-shape our city.

Saturday, August 27, 2011

The Death of Vehicular Cycling!?!

Apparently vehicular cycling has “been complete[ly] pummeled” or is a secret sect that's been discredited entirely. Funny, I hadn't noticed. In my daily riding, the advice of John Foerster remains as relevant as ever. But I guess some vehicular cycling advocates have really been, politically and socially, left behind by the times.

It's really a shame to see this. But it sounds like there's such a gulf between the core concepts of vehicular cycling and the social and political position of its advocates. I hope that, after the rhetoric has cooled off a bit, that we can employ the best ideas of vehicular cyclists and their adversaries within the community.

The concepts: vehicular cycling came to the US in a time when bicyclists largely rode on the wrong side of the road or on sidewalks, ducked in and out of car-park areas and inconsistent shoulders, and in many places would have been arrested for taking a lane on an arterial road. Bike trails and bike lanes were designed with little noticeable regard for their users; seemingly more to keep cyclists out of the way of motorists than to provide safe and useful places to ride.

In this atmosphere, the vehicular cyclists told us to ride on the correct side of the road, to ride a straight line, and to take a lane if it wasn't wide enough to share with a car. The core concept was that the safest and most effective way to ride was to be visible and predictable. This was good advice, it still is good advice, and it has largely been adopted. I rarely see the sorts of behavior that apparently predominated in the Bad Old Days.

Reasoning from the principles of visibility and predictability, they decried the state of bike paths and bike lanes. Bike lanes forced cyclists to do things that no driver would do, and because cyclists were rare on the road, this made their actions unusual, unpredictable to drivers. Like riding in the shoulder, riding in a bike lane could make cyclists invisible to drivers. Bike paths were often installed in disused rail rights-of-way; a train has, to understate wildly, quite different needs from a bicycle. Along these trails visibility at intersections was poor; trains had the right to stop traffic, and used flashing lights, gates, bells, and driver education campaigns to do it. Bikes get none of these advantages. The only way to safely ride a bike trail along an old railroad was to come to a stop at every intersection, even at unimportant side streets. Many of the trails were given superfluous curves, as if the landscape design was more important than cyclists' transportation needs. These criticisms of bike lane and bike trail projects remain true in many cases; there are lots of old trails and plenty of new ones being built to bad standards. In some cases, however, trail designers have started to take visibility, predictability, and real transportation needs into account when designing trails. At any rate, visibility and predictability remain a valuable rubric for evaluating infrastructure, whether you're planning a bike path of planning a route to work.

The politics: vehicular cyclists have taken lots of political stands against more “mainstream” cycling groups, policies, and ideas. Foerster attacks some policies as being improperly influenced by motives other than cyclist safety. For example, he cites the influence of bike manufacturers on safety standards that require only cheap reflectors, rather than expensive lights, for night riding (for my part, I'd love a bike with a built-in headlight). Or the influence of motorist groups on bike safety laws that run against his principles for biking. At the same time, vehicular cyclists have criticized the anti-car, pro-urbanist, environmentalist slant of many cycling groups. For the most part, vehicular cyclists in name want to keep a very narrow focus on cycling issues.

Given the wide range of issues that directly affect how cyclists get around today, keeping a narrow focus may have merit. If a cycling group takes political positions on the Deep Bore Tunnel and road tolls, how can it have time for the important stuff that affects day-to-day cycling, like good visibility at trail intersections? It seems to ignore a few things, however. Environmental, anti-car, and urbanist concerns may convince lots of people to try cycling — paying attention to these issues probably unites the biking community more than it divides it, and helps it make alliances with other sorts of groups (transit advocates, environmentalists, urbanists). Urban densities, good air quality, and slow driving speeds can really open up utility cycling to the masses. And cyclist safety, on a per-cyclist basis, seems to improve as cyclists increase in numbers. Furthermore, the specific political positions taken, such as the absolute opposition to separated bike facilities, have not been helpful. In European cities (and American college campuses!) pedestrianized cycle tracks have helped people feel safe, if at much slower speeds, and got a lot more people biking. Bike movements on cycle tracks are visible and predictable, just not fast, yet vehiculars still oppose them. That vocal vehicular cyclists have taken these positions may have more to do with their social attitudes than their principles.

The social attitudes: One thing that always stands out to me when I read vehicular cyclists is that they sound old. Their “opponents” in the cycling community tend to sound closer to my generation. The vehiculars stress personal responsibility, and the rewards of learning difficult skills. Their opponents stress the social benefits of increased cycling and insist that the government support them because they're doing so much good.

There are some conflicts that are probably specific to this particular generational divide. The older generation has settled into a suburban lifestyle, having chosen suburban homes in a time when inner-city life in America was at its nadir, while my generation is doing its best to gentrify the hell out of post-industrial inner cities. Indeed, most vehicular cyclists I read are from the suburbs or exurbs, biking in very tough traffic conditions indeed, and their opponents do tend to live in the city. In dense cities a slow or pedestrianized bike culture works because distances are shorter, high speeds are often impractical anyway, and the needed coverage area is not so great. Cycle tracks let everyone bike (as long as they live in the city). In vast American suburbs and exurbs there's no hope of good, useful, separated bike infrastructure going everywhere a cyclist might want to go. A vehicular cycling strategy, and respect for this from drivers and law enforcement, lets everyone bike (as long as they're strong enough to make the distance).

Then there are the timeless generational conflicts. The older generation (along with those that harbor socially conservative attitudes) stresses hard work and self-reliance, is skeptical of social engineering and great change, and tends to focus on the benefits of the status quo (which, after all, it built) as opposed its downsides. The younger generation tends to feel more righteous and entitled, and encourages the world to change in its image. It decries the injustices of the status quo, which it only inherits. The status quo, relevant to this conflict, is car dependence. Vehicular cyclists frequently defend cars and their drivers, and usually don't criticize cultural car dependence or vehicle emissions. Their “opponents” often engage in absolutist criticisms against drivers and self-righteously rant against car dependence and the lack of government support for their better lifestyle. Both groups will often sound completely irrelevant to eachother. Vehiculars aren't going to go to the city to ride on some slow cycle track, wait at stoplights, and dodge pedestrians and smoking hipsters. And the emerging mainstream of urban cyclists isn't going to take a lane in front of a truck doing 45 MPH.

The personal conclusion: I have to straddle these camps. Fremont, where I now live, is semi-urban; north of the ship canal but south of Green Lake, full of single-family homes, converted duplexes, and modest apartment buildings. Canyon Park, where I work, is pure exurbia. I love cycling, I'm reasonably fit, and I care about my technique in every regard (whether that's knowing how to take a lane, how to fix a flat and adjust my dérailleurs, or how to quickly get on and off of a bus bike rack) but not enough to log over 40 miles per day to get to work, so I take the bus part of the way. I ride according to the advice of John Foerster when I'm on the roads (I find I get into the most trouble when I lapse), and I believe most cyclists would do well to read Effective Cycling and practice their skills, but I also believe we'll get a lot more people riding, and reap real social benefits, if we don't make expertise a prerequisite. I like to go fast, because it's more fun and takes less time than riding slow, but if they build a good cycle track on Broadway I won't complain about having to ride slow on it.

Wednesday, February 17, 2010

distcc, the Macintosh, the Linux box

Today I decided to get distcc working between Jess' computer and mine. There went my day...

I think my situation is fairly common. I have a Linux box that's pretty fast and Jess has a Mac laptop that's not quite as fast. I sometimes have to build Audacity on Jess' computer, and it would be nice if my computer could help with the compiling. Unfortunately this is not as easy as it should be. Here are some of the problems:

1. Apple's version of distcc isn't compatible with the normal version (Apple added some stuff to the protocol). It also has client-side restrictions on the names of compilers you can use, which are configurable, but require the compiler to be in the same location on the client and server. So you should build a normal version of distcc from the source package to install at /usr/local.

2. distcc 3.1 won't build if you just ./configure && make && make install because of a tricky 3-way incompatibility involving GCC, Python, and universal binaries.

3. Xcode likes to invoke gcc with the -x option to specify language. distcc refuses to distribute tasks using -x (Apple's version accepts it, but since it uses a different protocol we can't use it).

And how I did this.

First you need to get a couple of cross-compiling tools build on the Linux side. The good news is that you don't have to have everything for distcc, just as, gcc, and g++. For as you have to find an odcctools package somewhere. There's one here that should work. Then you need Apple's GCC package, matching the one on your Mac. Use gcc --version to get the release and build numbers and find the package on Apple's site.

To build GCC and as instructions #0-4 on this page should work (adjusting for correct target, version numbers, and sources — opendarwin.org no longer exists). It lists cc1plusobj at one point instead of cc1objplus — other than that, fine. Jess has an Intel Mac with MacOS 10.5.8 and XCode 3.1.4, for which the target is i686-apple-darwin9, GCC version number 4.0.1, and GCC build number 5493. So I had with binary names like i686-apple-darwin9-gcc-4.0.1; there is a compiler with the same name on the Mac in the PATH (this must be the case for distcc to work). Heed the directions! You will probably get compile errors, and they won't matter.

Next you need to build a normal version of distcc 3.1 for Mac. To get around the universal binary weirdness you need a non-universal install of Python. Grab a Python 2.6.x source package and the standard ./configure --prefix=$HOME/foo && make && make install cycle will give you a non-universal. $HOME/foo/python2.6. So you can cd back to the distcc source and do PYTHON=$HOME/foo/python2.6 ./configure --prefix=/usr/local && make && make install. It should build and install correctly. Once that's done you don't need that extra Python binary, so you can nuke $HOME/foo.

OK. Now time to make some little connections. First, on the Linux side, you need distcc to be able to find these new compilers. On Deb/Ubuntu you can set the search path by setting PATH in /etc/default/distcc. You should also set up which network interfaces to listen on in that file.

On the Mac side, as our reference notes in step #5, it's nice to have little shell scripts to run distcc. He puts them in /usr/local/bin, you can put them anywhere... the important thing is that his scripts don't work for me; I need $@ instead of @!. Maybe he has csh and I have bash or something. Anyway, for the g++, if your /bin/sh works like mine, you'll want:
#!/bin/sh
/usr/local/bin/distcc <your $TARGET>-g++-<your GCC version> -msse2 "$@"

Then, to account for XCode's use of gcc -x c++ instead of g++, you'll need to get a little fancy in the gcc script (this obviously won't cover all cases but it's been good enough for me so far):

#!/bin/sh
if [ "$1" = "-x" ] && [ "$2" = "c++" ]
then
shift 2
/usr/local/bin/g++ "$@" # this should point to your g++ script, wherever it is
exit
fi

/usr/local/bin/distcc <your $TARGET>-gcc-<your GCC version> -msse2 "$@"

Now you're almost ready. On the Mac, put localhost your_server in ~/.distcc/hosts (reverse the order if you want to go to the server first) and give it a test run (run your gcc script on something simple). tail -f /var/log/distccd.log on the Linux box to make sure the jobs are making it over. For distcc to distribute you need to use the -c flag (i.e. /usr/local/bin/gcc -c hello.c); otherwise, because there's a linking step included in the compile, it must be done locally. You can do /usr/local/bin/gcc -c hello.c && gcc -o hello hello.o && ./hello for a nice test.

Then in your XCode projects you can set the CC variable to the location of your gcc script, and CXX to the location of your g++ script. There might be a better way to do this, I'm far from an XCode expert. Since this bypasses XCode's normal way of working with distcc, it won't know to add extra parallel build steps. Fix this with: defaults write com.apple.Xcode PBXNumberOfParallelBuildSubtasks 6. Or whatever number works best for you there.

I'm pretty sure this is everything essential I did (I went down lots of dead-ends, including trying to use Apple's distcc). And now distcc works!

To be honest, some of the ways Apple modifies Free tools rub me the wrong way. I appreciate that it's a lot easier to interoperate with their tools than, say, Microsoft's, but Microsoft actually wrote their own compilers; they can do it however they want. Apple used GCC and distcc in such a way that interop takes way more work than it ought to. I guess that's why the Linux box is mine, and the Mac is not.

Wednesday, January 27, 2010

Resizing QEMU images with Win7 installed under Linux

Here's another Windows 7 post. I started with a 16GB virtual image for Windows and almost immediately ran out of space. It turns out that it's not that hard to resize your partition; I found a very helpful forum post on the subject written a few years ago, and a couple things have changed for Windows 7, so I'll post an updated method here.

First, I'm working from the poster's second set of instructions. He claims they're more dangerous, but they're really not. You never have to work on your only copy of your data; in fact, by the end you'll have three working copies of the drive. It's probably a good idea not to delete the extras until then, but if you are crunched for disk space that's fine. Make sure you have the following commands available: qemu-img, ntfsresize, hexedit. They all should be available in packages supplied by your distro. I'm starting from an image called win7.img, using an intermediate raw image called win7.raw, and ending with an image called win7.qcow2. Obviously, you should use whatever names you're comfortable with.

Before you start, be sure you shut down Windows normally last time you used it. Otherwise ntfsresize will refuse to touch the data.

First, your disk image is probably in qcow2 format. You need to convert it to "raw" format, which is just a flat readout of the data. Check the format:

$ qemu-img info win7.img

If necessary, convert to raw; this will take several minutes (where I have qcow2 you should put the format of your image):

$ qemu-img convert -f qcow2 win7.img -O raw win7.raw

Now expand the raw image by writing to a large offset in the file. This should run very quickly on most Linux filesystems, and not consume much extra space. The bs parameter specifies the "block size" for writes (in bytes) and the seek parameter the number of blocks to skip. So I will write 83886080 × 512 = 42949672960 bytes (40 GiB) in.

$ dd if=/dev/zero of=winb.raw bs=512 count=0 seek=83886080
0+0 records in
0+0 records out
0 bytes (0 B) copied, 1.2997e-05 s, 0.0 kB/s


Become root and use Linux's loopback device to operate on the raw image as if it were a real hard drive.

$ sudo su
(enter password)
# losetup /dev/loop0 win7.raw


Now you'll want to check out the fake disk geometry and edit the partition table using fdisk. You'll want to switch fdisk to display in units of sectors, print the partition table, delete the main partition, and remake a larger one in its place. Your input is in bold.

# fdisk /dev/loop0

The number of cylinders for this disk is set to 5221.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): u
Changing display/entry units to sectors

Command (m for help): p

Disk /dev/loop0: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders, total 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0x23830da9


      Device Boot      Start         End      Blocks   Id  System
/dev/loop0p1 * 2048 206847 102400 7 HPFS/NTFS
Partition 1 does not end on cylinder boundary.
/dev/loop0p2 206848 31455231 15624192 7 HPFS/NTFS

Windows 7 has created two NTFS partitions on my disk. The second one is the one we're interested in. Also note the disk geometry: 255 heads. If it doesn't say 255 heads, and your disk is large, it should say 255 heads. Obviously the disk geometry is completely made up, and I'm not really sure why Linux's loopback device should be expected to fake the same geometry as Qemu... comments on the forum suggest this value should always be 255. Anyway, on to editing the partition table entry. The number you use for the first sector must be the same as in the original partition table; for me that's 206848.

Command (m for help): d
Partition number (1-4): 2

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First sector (63-83886079, default 63): 206848
Last sector, +sectors or +size{K,M,G} (206848-83886079, default 83886079):
Using default value 83886079

Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 7
Changed system type of partition 2 to 7 (HPFS/NTFS)

Command (m for help): p

Disk /dev/loop0: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders, total 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0x23830da9


      Device Boot      Start         End      Blocks   Id  System
/dev/loop0p1 * 2048 206847 102400 7 HPFS/NTFS
Partition 1 does not end on cylinder boundary.
/dev/loop0p2 206848 83886079 41839616 7 HPFS/NTFS

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 22: Invalid argument.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.


Now re-connect the partition table and check that it worked.

# losetup -d /dev/loop0
# losetup /dev/loop0 win7.raw
# fdisk -ul /dev/loop0

Disk /dev/loop0: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders, total 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0x23830da9


      Device Boot      Start         End      Blocks   Id  System
/dev/loop0p1 * 2048 206847 102400 7 HPFS/NTFS
Partition 1 does not end on cylinder boundary.
/dev/loop0p2 206848 83886079 41839616 7 HPFS/NTFS

# losetup -d /dev/loop0

Now, especially if you're resizing from a much smaller drive, we should check that each of the NTFS partitions has the correct number of heads stored in it (the forum post has an explanation of why this is important; to make a long story short, Windows won't start if it's wrong). To find the address of each partition, take its start value from fdisk and multiply by the sector size of 512 bytes. Then convert to hex.

# bc
2048*512
1048576
(this is the start of the first partition in bytes
206848*512
105906176
(this is the start of the second partition in bytes)
quit
# printf "%x %x\n" 1048576 105906176
100000 6500000
(these are the hexadecimal addresses)

Open win7.raw in hexedit; hit return to enter an address, enter the first address, hit return again. Now you're at the start of the first NTFS partition. At an offset 0x1A bytes from that is the head count. Navigate to that byte (if the original address was 0x100000 you'll be at 0x10001A). Make sure it's FF (the hex value of 255). If not, type over that byte with FF. Then do the exact same thing for the second address. Hit ctrl-x to exit, confirming changes if necessary.

Now you can use ntfsresize to actually resize the Windows partition. You have to connect the loopback device to the start of the partition you're resizing this time; this is the decimal version of the second offset you found in the last step. Before doing anything with ntfsresize we check that everything is OK using the -n flag.

# losetup -o105906176 /dev/loop0 win7.raw
# ntfsresize -n /dev/loop0
ntfsresize v2.0.0 (libntfs 10:0:0)
Device name : /dev/loop0
NTFS volume version: 3.1
Cluster size : 4096 bytes
Current volume size: 15999169024 bytes (16000 MB)
Current device size: 42843766784 bytes (42844 MB)
New volume size : 42843763200 bytes (42844 MB)
Checking filesystem consistency ...
100.00 percent completed
Accounting clusters ...
Space in use : 15875 MB (99.2%)
Collecting resizing constraints ...
Schedule chkdsk for NTFS consistency check at Windows boot time ...
Resetting $LogFile ... (this might take a while)
Updating $BadClust file ...
Updating $Bitmap file ...
Updating Boot record ...
The read-only test run ended successfully.


If your output is something like that you're ready to go. The default action is to expand the partition to its largest size, so you only need to run:

# ntfsresize /dev/loop0
Device name : /dev/loop0
NTFS volume version: 3.1
Cluster size : 4096 bytes
Current volume size: 15999169024 bytes (16000 MB)
Current device size: 42843766784 bytes (42844 MB)
New volume size : 42843763200 bytes (42844 MB)
Checking filesystem consistency ...
100.00 percent completed
Accounting clusters ...
Space in use : 15875 MB (99.2%)
Collecting resizing constraints ...
WARNING: Every sanity check passed and only the dangerous operations left.
Make sure that important data has been backed up! Power outage or computer
crash may result major data loss!
Are you sure you want to proceed (y/[n])? y
Schedule chkdsk for NTFS consistency check at Windows boot time ...
Resetting $LogFile ... (this might take a while)
Updating $BadClust file ...
Updating $Bitmap file ...
Updating Boot record ...
Syncing device ...
Successfully resized NTFS on device '/dev/loop0'.


Hopefully your result is something like the above. Now you can disconnect the loopback device and end the sudo session.

# losetup -d /dev/loop0
# exit


You should try out the new image by starting Qemu/KVM the way you usually would, except substituting the name of the new image for that of the old one. Windows will check the disk (because ntfsresize told it to), and everything should come out OK. If not, you still have the original disk image. If everything works you can delete your original image and go on -- if everything is broken you should delete the raw image, figure out what went wrong, and start over.

Now you probably don't want to keep the image around as a raw; qcow2 takes up less space on the host system and has a lot of nice features. You can easily convert it to qcow2 like this:

$ qemu-img convert -f raw win7.raw -O qcow2 win7.qcow2

Make sure the new qcow2 image works. If so, delete the raw image and you're done.

Thanks to poster IntuitiveNipple on the QEMU forum for writing a nice explanation of the bit-hacking necessary on NTFS, and the overall procedure for resizing images with Windows installed.

EDIT: I edited this post to fix table formatting in fdisk output.

Monday, January 18, 2010

The Windows 7 Chronicles: GNU Patch, mt.exe, and the horror of UAC

Real quick one here. patch is a nice little command-line utility. GNU provides a fine version, and there's a Windows build available through the GnuWin32 project. When you try to run it on Windows 7 you get UAC prompts. Why? It turns out that Windows guesses, based on the name of the program, that it's going to patch application files, and goes ahead and requests elevated permissions for it that it doesn't really need. This was discovered a long time ago and a bug was filed against GnuWin, because it's clearly their responsibility to code around Microsoft's incredibly stupid heuristics*.

*in·cred·i·bly stu·pid heu·ris·tics, n: Heuristics that happen to be wrong in my case.

The bug report lists a manifest that you can embed into patch.exe to fix the problem. It looks like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

Embedding it took me a while, but it's ultimately not that hard. First copy the manifest into a file somewhere. You have to use a tool called mt.exe, which is part of the Windows SDK. It's probably not in your path, but it's in the path of a Visual Studio Command Prompt. So open up one of those with admin permissions (under Win7: Start->All Programs->Microsoft Visual C++ 200x->Visual Studio Tools; right-click on Visual Studio 200x Command Prompt, select Run as administrator...). Then cd '\Program Files (x86)\GnuWin32\bin' (or wherever you've installed it) and mt -manifest yourfile -outputresource:patch.exe;1. Why ;1 at the end? Because Microsoft says so.

Wednesday, January 6, 2010

QEMU/KVM, Windows 7, blurry text

My mom got me a copy of Windows 7 for Christmas so I could run it in virtualization under Linux for development purposes (Audacity, mostly). That's been somewhat successful. I'm using KVM/QEMU and none of the audio devices that QEMU emulates have 64-bit Win7 drivers. Maybe I'll look at writing an emulation layer for a more modern sound card (it might be slightly easier to write a new 64-bit Windows driver for one of the cards QEMU already emulates, but it might be easier to get an addition to QEMU distributed widely). Anyway. I'm mostly writing this because I just solved a smaller, odder problem: the text in Windows just looked horrible! I generally prefer my text on Kubuntu to text on Windows*, but I didn't remember it being bad on Windows.

* I think people come to prefer the fonts and rendering style of the systems they use every day. I mostly use Kubuntu, and I find text easier to read there than anywhere else. It could just be that I like the font shapes better. FreeType (X11) and ClearType (Windows) look pretty similar given the same fonts, although there are some things FreeType can't do with hinting information because of patents. I find Mac OS X's font rendering ugly and hard to read, but that's probably just because it's more different and I'm not used to it.

So these days QEMU's virtual VGA window can be resized. When you do this it just scales everything in the window. Unfortunately this makes anti-aliased, sub-pixel rendered text (ClearType) and deliberately sharp graphics (Diesel Sweeties) look really bad. KDE lets you set a window to an exact numerical size, which should fix the problem, but it doesn't; the size includes window decorations. Lame.

So I found a little program called xdotool that, among many other things, lets you resize windows from the command line by client size. Rad. It's in the Ubuntu repos, even. But setting the client size to exactly Windows' resolution didn't help.

So I took some screenshots, blew 'em up in the GIMP, and found that the window size was one pixel too large in each dimension. With my Windows resolution set to 1152x864 I actually need the QEMU window's client size to be 1151x863. I'm not sure if this is a weird problem with Windows, QEMU, or X11... but it's weird. And now that it's fixed, everything looks OK in virtualized Windows.

Sunday, December 20, 2009

Denver Airport Concourse Comparo!

Yesterday while waiting for a connecting flight in Denver Airport with Jess I realized that I've spent an unreasonably large portion of my life waiting for connecting flights in Denver Airport. When Jess suggested that we find food my first thought was, "There's no good vegetarian food in this concourse. Let's go to the United concourse." And thus the Denver Airport Concourse Comparo was born.

Concourse A

  • Airlines: Frontier (17 gates plus several more in the small-plane area operated by Lynx), Continental (3), JetBlue (2), AeroMexico/Air Canada/Lufthansa (sharing 2 gates), British Airways, Mexicana, Midwest, AirTran, Alaska, Frontier JetExpress, Great Lakes (several in the small-plane area)
  • Food (constraints: cheap-ish, fast, vegetarian): The only place to get quick vegetarian food in the A Concourse is Panda Express, and there your choice is basically lo mein and... more lo mein. Oh, yeah, there's some place called Lefty's with some vegetarian stuff, but they're on my blacklist from a previous trip for only serving breakfast food at 8 AM. THIS IS AN AIRPORT, PEOPLE! TIME HAS NO MEANING HERE! That's what pushed me to the Panda Express... I'm sure breakfast exists in China, and maybe even breakfast food, but in America Panda Express will sell you mushy lo mein all day. Um, where was I? Concourse A has Hope's Cookies, which are OK. No trendy coffee joints, but apparently there's a Quiznos with espresso and a full bar.
  • Centerpiece Art (There is lots of public art in Denver Airport, and much of it is in the terminal, which is outside the scope of this comparo; I'm limiting myself to the centerpieces around the tram stations and vertically above): On one side twisted train tracks through a desert; on the other a semi-flattened globe anchored by structures evoking satellite dishes or grandstands. There's some kind of museum exhibit on the mezzanine level, but it's not memorable.

Comments: Frontier is a pretty good airline but its concourse is the worst in the airport.

Concourse B

  • Airline: United (16 bazillion gates), United Express (7 bazillion gates in each small-plane area).
  • Food: There's a pretty good quick Mexican place on the second level. Lots of variety. There's a TCBY. Annoying hipsters and chipper businessdroids rejoice: B Concourse has a Coffee Beanery, a Seattle's Best, two Starbuckses, and a Caribou Coffee. There's something called Pour la France. I didn't know la France was a liquid.
  • Centerpiece Art: There is a sculpture of an astronaut down in the tram station. The motorized walkway continues through the center area, leaving room only for some random neon squiggles and some arches, like something out of that crazy walkway in O'Hare from the United concourse to baggage claim.

Comments: B is the biggest and busiest concourse. This last time there was an enormous Crocs stand on the upper level. It's the most mall-like of the concourses (but not even approaching DFW). The art is not so hot, the crowds are crowdy, this concourse ranks in the middle.

Concourse C

Concourse C is the concourse you're not supposed to know about. It's really a top-C-cret military base. Say it out loud: top-C-cret. And they thought they could get away with it. If you want to figure this stuff out you have to think like they think. See the patterns.

  • Airlines: I guess the army or whoever it was (CIA? WTO? Illuminati?) put up fake airlines and stuff there: 12 gates for "Southwest" and another 5 for "Northwest" and "Delta". Like I believe that -- worst fake airline names ever, amirite? It's rounded out by "US Airways" and "American", which are almost as obvious. We didn't see no planes take off, that's for sure. Oh, and they put the whole concourse in a TIME VORTEX.
  • Food: There's a TCBY in there. Not as big as the one in B. And some place that claims to have tamales, we haven't tried them.
  • TIME VORTEX: When you enter the TIME VORTEX you see spinning pinwheels. When you leave the TIME VORTEX you see flashing lights and a swinging sickle. A++++++ very good TIME VORTEX. Would TIME VORTEX again.
  • Centerpiece Art: It's this awesome decayed garden. Only the truly enlightened can see it, which is how it got so decayed: most people can't even see C Concourse at all, let alone the garden, so nobody can maintain it. Hell, I have it on good word the President's secret puppet master himself can only see the garden through a shard of a mirror once belonging to his puppetmaster. I am on to something for sure!

Comments: Jess and I just took the tram here to see what it was and it opened our eyes. They paged Jess over the intercom, so she picked up an information phone and dialed the number for "paging". Except that's for when you want to page someone else, so she hung up and dialed information. They said the page was actually for a "Jessica Mylan", not her. We got the message loud and clear: we know you're here and we're watching. So we went to a gate for a "Southwest" flight to San Francisco and sat and waited. We started talking one of the people at the gate. An agent or a dummy? We introduced ourselves as Jessica Mylan and Billy Philbert. He said, "Didn't they just page you, over the intercom?" The agent at the gate called for boarding. Nobody lined up. We got the hell out of Concourse C.

Saturday, October 31, 2009

mingw32, wine, library paths

Here is yet another thing I'm posting here just because Google searches turn up this blog sometimes and it might help someone save some time. Audience is people building Windows binaries on Linux with the mingw32 cross compiler and testing them in Wine. I do this sometimes for work on the Audacity project, which with a few minor modifications builds nicely with mingw32 -- it doesn't work exactly like a VS compile, but it lets me test wxMSW behavior, which is sometimes useful.

So you're running Linux, you've set up a mingw32 cross compiler (on Ubuntu just get all the mingw32 packages), and built some libraries with it. And you've built programs that use those libraries. But all the libraries are installed in places like /usr/i586-mingw32msvc/lib and /usr/local/i586-mingw32/lib. As far as I can tell, as of Wine 1.0, to get Wine programs to see libraries in those locations is to add them to PATH in a registry key. Typically Wine is configured so that your Unix root shows up at drive Z. So run regedit and go to HKLM/System/CurrentControlSet/Control/Session Manager/Environment and add to PATH, for example, ;Z:\usr\i586-mingw32msvc\lib;Z:\usr\local\i586-mingw32\lib (your paths may vary).

You'll also need to install the mingw32 runtime DLL to your Wine, which is usually something like gunzip -c /usr/share/doc/mingw32-runtime/mingwm10.dll.gz > ~/.wine/drive_c/windows/system32/mingw10.dll.

If you don't like having Z: point at root (for some people it's good for Wine to be highly integrated -- others would rather have it as far from their normal system as possible) you can point drives specifically at your library paths using winecfg, or other similar tricks. Symlinks from within ~/.wine/drive_c might be another appealing option.

Wednesday, October 1, 2008

Gentoo libselinux coreutils silliness

This blog entry probably isn't interesting to anyone. I'm writing it because Blogger blogs often turn up in Google results and it might be useful to a random searcher. Point: if you have libselinux on your system and want to get rid of it because it doesn't belong in your profile and is masked and frequently causes lots of obnoxious warnings, you probably shouldn't just emerge -C libselinux. You also probably shouldn't just do a emerge --depclean libselinux or even emerge -C libselinux && revdep-rebuild --library=libselinux.so.1. They might not work.

Not only will they not work, the emerge -C libselinux might not even finish correctly. The problem is that coreutils will build against libselinux even if you USE=-selinux. One of the autoconfiggey scripts does it. There's a bug in Gentoo bugzilla but no official action has been taken yet. If you happen to have updated coreutils since libselinux turned up, after you delete /lib/libselinux.so.1, lots of stuff doesn't work. /bin/ls, for example. And plenty of other programs you take for granted, and that emerge needs to finish unmerging libselinux. This was my experience and that of others. Learn from it.

The first thing you need to do is get a coreutils that doesn't need libselinux. First just make sure you need to do this at all: ldd /bin/mv | grep selinux. If no results you're OK. emerge -C libselinux && revdep-rebuild --library=libselinux.so.1 is all you need. Otherwise a new build of coreutils is in order. The person that filed the Gentoo bug kindly provided a couple patches that do the trick perfectly. It took a bit of messing around to figure out exactly where to put 'em, though.

The way I did it was to create a partial portage overlay. It has just one package in it. Hey, might as well learn this stuff. Create the directory /usr/local/portage/sys-apps/coreutils and copy the ebuild from the main portage tree into it. Also copy over the files directory and its contents from the the main portage tree. Apply the ebuild patch to the ebuild, and download the other patch into the files directory. Then run ebuild $fn manifest, where $fn is the name of the ebuild. This builds the manifest file so portage doesn't suspect your ebuilds of mischief. Now set up PORTDIR_OVERLAY in your /etc/make.conf to include your overlay directory (/usr/local/portage). At this point you should just be able to emerge coreutils and you'll get a version with no libselinux dependency. Now you can safely unmerge libselinux, run revdep-rebuild, and drink some delicous beer. I recommend a porter for this occasion, for obvious reasons. Then you can get rid of the overlay, because you shouldn't need it anymore.

If you don't want to mess with overlays you can always just download the straight source of coreutils, patch it up similarly to how Andreas did, and install that; you can just overwrite it with officially sanctioned coreutils whenever you get around to it, or not. However you do it, check your resulting binaries to be sure they don't need libselinux.so.1 before unmerging it. Also make sure the binaries get installed to /bin and not /usr/local/bin so portage, etc. will find them. You knew that.

Wednesday, January 16, 2008

Enoch Root and Edward Abbey on the El

In Cryptonomicon Enoch Root devises an encryption scheme that he initially calls "Pontifex" and describes with the following perl script:

#!/usr/bin/perl -s
$f=$d?-1:1;$D=pack('C*',33..86);$p=shift;
$p=~y/a-z/A-Z/;$U='$D=~s/(.*)U$/U$1/;
$D=~s/[A-Z]/$k=ord($&)-64,&e/eg;$k=0;
while(<>){y/a-z/A-Z/;y/A-Z//dc;$o.=$_}$o.='X'
while length ($o)%5&&!$d;
$o=~s/X*$// if $d;$o=~s/.{5}/$& /g;
print"$o/n";sub v{$v=ord(substr($D,$_[0]))-32;
$v>53?53:$v}
sub w{$D=~s/(.{$_[0]})(.*)(.)/$2$1$3/}
sub e{eval"$U$V$V";$D=~s/(.*)([UV].*[UV])(.*)/$3$2$1/;
&w(&v(53));$k?(&w($k)):($c=&v(&v(0)),$c>53?&e:$c)}


(The program is somewhat obfuscated; to really understand it I had to type it out in a more readable form. Also, in reality the algorithm was designed by Bruce Schneier and the Perl script written by Ian Goldberg. Here is Bruce's description of the system)

It's later revealed that the same instructions, written in natural language instead of Perl, can be followed by a person with a deck of cards to generate a "keystream" of random-looking numbers. Two people that start with their decks in the same order can generate this same random sequence. The sender writes out his message, writes a number from the keystream under each letter, then circularly-shifts each letter forward in the alphabet by that number. The receiver receives a message that looks random to anyone else, circularly-shifts each letter backward by the same number the first person used, and the result is the original message. The whole system relies on a shared secret: the two people communicating know how to arrange the deck into its initial position, but nobody else does. In this sense it's similar to a one-time pad, where the communicators generate long sequences of random numbers while physically in contact and agree on which to use for which messages before they start communicating this way. The advantage is that in this case the shared secret, instead of pages full of numbers that can be physically confiscated by eavesdroppers, could be something memorizable, like (as Bruce Schneier suggests in an appendix to the novel) a simple system for generating a deck ordering based on Bridge scenarios published in some newspaper on the day the message was written. As with a one-time pad, there are two major ways that an eavesdropper could break it. First, by discovering the shared secret. Second, by discovering a bias, that is, by mathematically analyzing the keystream-generating algorithm and finding patterns in it. Finding a bias would cut down the number of likely keystreams, perhaps enough that they can all be checked by brute force. Such a bias has been found in Solitaire, as mentioned in Bruce Schneier's page, linked above.

So.

Today after work I got on a Brown-Line train at the Merchandise Mart stop to ride all the way out to Francisco to go to my gym. Doors open on the right at Merchandise Mart, so I entered the crowded train from the right and had to stop and stand in the doorway, looking towards the left of the train. Seated to the right of the doors on the opposite side were a woman reading a book (not very interesting to watch) and a man repeatedly shuffling and fanning a deck of cards (somewhat more interesting). This guy must not have had much to do, or was practicing to escape the Chicago winters to become a card dealer in Vegas. Or maybe he was an Enoch Root, well-practiced at his card transformations, memorizing or analyzing the keystream generated from his deck transformations. It wasn't all that interesting, though, so I started reading.

Maybe at the Sedgwick stop the woman next to him got up, and I was the closest person to the seat she left, so I sat down. The man continued to shuffle his cards, sometimes accidentally jabbing me with an elbow, occasionally sneaking a glance at my book. I don't read secretly, so he may have caught a bit of Edward Abbey's description of his lazy trip down the Colorado River just before the building of the dam to form Lake Powell. At Belmont he stood up and flicked a card from his deck perfectly into the middle of the seat. The two of hearts. He walked out of the train. Transfer to Red- and Purple-Line trains at Belmont? Unlikely. Transferring at Belmont is for fools and amateurs. A man of his caliber would have obviously known to transfer at Fullerton.

So anyway a woman walked on the train, looked at the card on the seat. She recognized immediately that the first number of the keystream was 28! She probably looked at me funny, like I'd put the card there for some reason, but I don't really know because I had my face buried in Desert Solitaire trying to contain my laughter. Joy, mirth and laughter are not allowed on CTA vehicles. Do not make eye contact with other customers. If you see something, say something! Play safe; ski only in clockwise direction. Let's all have fun together. Especially with doomsday looming. She pocketed the card, sat down and started reading.

Monday, December 3, 2007

More Urban Jungle Shit

My Dear Readership, this might be a little rudimentary. I apologize. I do not apologize for, nay, do not even acknowledge whatever factual errors you may think you've found. "But pineapples don't grow on trees, Al!" Poppycock! My daydreams err not, and I err not in reporting them!

Al let out a little laughing yelp as he released himself from the tree. He swung his legs a bit, as if running in the air, then deftly braced himself for the landing. Hit the ground rolling into a somersault and then to his feet, presenting in his outstretched arms a pineapple. He paused to stare out at the sky, across the endless ocean. Just for a second now, the sky would be there the next day, too. He twisted the leaves off, discarded them, and drew a long, curved knife from a sheath at his hip.

Al peeked into the kitchenshit drawer. No, not in there. Surveyed the pile of dishes next to the sink that he'd been reusing for the past few weeks. Nope. He went over to the dark red drainboard (one of the better purchasing decisions he'd made in recent years), lifted up a skillet and a baking pan, and again came up empty. Ha, he was in an apartment in Chicago in December. Now the light from the setting sun was going to cast a shadow of his body, chiseled from years of swimming in the ocean and swinging up and down from trees, long across the beach. The traitorous yellow star had dipped below the sprawl on the western horizon more than an hour before he'd left work. The dishwasher. Top shelf. Eureka, choppin' knife! He sliced through the pineapple longitudinally, placed each half down flush against the dark red cutting board, then cut each half longitudinally also. He wondered if the dishwasher was clean.

Al continued making his lengthwise cuts until he bored of it, and then began cutting the rind off of each slice, and dividing each into slightly-larger-than-bite-size pieces. Al always chopped things a little coarser than most people did. He attributed this to laziness and low standards. The pineapple pieces piled high on a blue plate behind the cutting board. Al stopped to think in the middle of the process. He first thought that it was a lot of pineapple. Next that he could all of it easily. But that it wouldn't be proper. And then that he could probably satisfy his immediate desire for pineapple with just the flesh clinging to the rinds. But that wouldn't be proper either.

No. Al was alone in his apartment. There was no circle of knitters meeting in the church basement implementing social control by gossiping about the eating methods of young men. There was good fruit on those rinds! He grabbed one of the rinds and stuck it in his mouth, scraping his teeth down the flesh side, squeezing the nectar down his throat. Juice dripped down his chin, onto the cutting board, over the rinds and yet-uncut slivers. He sucked the rind dry. He picked up another rind and did the same. The nectar burned in the splits of his wind-dried lips. It danced sweetly across his tongue, and he looked up again at the sun as it melted into the ocean, then looked back at the rest of the people on the beach. A few rolled their eyes at him as they swallowed their last morsels, and one of those grabbed him by the arm and mock-dragged him behind the rest of the group headed back towards the village. He did get one last look at the sun before it sank into the ocean.

Al hoped Dan would get home soon and help him eat some of this pineapple. There was no Saran Wrap in the place and he couldn't find half his Tupperware lids.