Offline radio, a wobbly analogy

It’s 1981.

You want to listen to music while you’re at home. So you go out and buy a cheap radio with a power cord. You take it home, plug it in, and listen to some music.

But what if there’s a power cut, or if you want to listen to music while you’re away from home? You go out and buy a new radio, this one with a battery compartment. You can plug it in when you’re at home, and use batteries when there is no other power available.

But what if there’s no radio signal, or there’s interference, or none of the radio stations are playing music you want to listen to? So you go out and buy a new radio, this one with a battery compartment and a cassette recorder, so you can record your favourite music when it is available, and listen to it on those occasions when you happen to be in the middle of the Sahara with no power and no signal.

Note that the device you have ended up with is more complex, bigger, heavier, and more expensive than the one you started with. Is this a trade-off you’re happy with?

It’s 2011

You want to take your web site offline? Yes you can. But understand that you’re going to end up with something more complex (harder to design, build, and test) and more expensive than a web site that assumes and relies on a network connection. Do you need that? Are your users constantly complaining that they can’t use your site when they’re in on their yacht in the middle of the Atlantic with no 3G? Is this a trade-off you’re happy with?

Footnotes

  • The analogy is wobbly because you don’t actually need a power supply at all to make a radio receiver. The power is there for amplification.

  • This stuff won’t stay hard and expensive forever. The libraries for building (and browsers for consuming) sites that work offline will get better.

  • No points for being the first to say, “Daddy, what’s a cassette recorder?”

Whom will our leaders defend?

John P. Hussman poses the question, “An Imminent Downturn: Whom Will Our Leaders Defend?(via John Mauldin’s Thoughts from the Frontline newsletter)

The global economy is at a crossroad that demands a decision – whom will our leaders defend? One choice is to defend bondholders – existing owners of mismanaged banks, unserviceable peripheral European debt, and lenders who misallocated capital by reaching for yield and fees by making mortgage loans to anyone with a pulse. Defending bondholders will require forced austerity in government spending of already depressed economies, continued monetary distortions, and the use of public funds to recapitalize poor stewards of capital. It will do nothing for job creation, foreclosure reduction, or economic recovery.

The alternative is to defend the public by focusing on the reduction of unserviceable debt burdens by restructuring mortgages and peripheral sovereign debt, recognizing that most financial institutions have more than enough shareholder capital and debt to their own bondholders to absorb losses without hurting customers or counterparties – but also recognizing that properly restructuring debt will wipe out many existing holders of mismanaged financials and will require a transfer of ownership and recapitalization by better stewards. That alternative also requires fiscal policy that couples the willingness to accept larger deficits in the near term with significant changes in the trajectory of long-term spending.

Basically: to whom are the politicians most beholden? To their corporate backers, who give them the money to get elected, or to the voters who actually do the electing? In Western Europe, things haven’t got bad enough yet to tip the balance towards the latter, but we’re heading that way at a steady pace. The financial sector has to be shackled.

Charlie Stross uses the turbulence of the forthcoming decade as part of the background for one of his characters in Rule 34. The following paragraphs brilliantly capture the potential for some ultimate good coming out of this cascade of crises:

Dorothy’s job is an odd one: catching corporate corruption before it metastasizes and infects society at large. After Enron collapsed–while you were still in secondary school–the Americans passed the Sarbanes-Oxley Act, accounting regulations for catching corporate malfeasance. But all they were looking for was accounting irregularities: symptoms of maladministration. The unspoken ideology of capitalism didn’t admit, back then, of any corporate duty beyond making a return on investment for the shareholders while obeying the law.

Then the terrible teens hit, with a global recession followed by a stuttering shock wave of corporate scandals as rock-ribbed enterprises were exposed as hollow husks run by conscience-free predators who were even less community-minded and altruistic than gangsters. The ravenous supermarket chains had gutted the entire logistics and retail sector, replacing high-street banks and post offices as well as food stores and gas stations, recklessly destroying community infrastructure; manufacturers had outsources production to the cheapest overseas bidders, hollowing out the middle-class incomes on which consumer capitalism depended: The prison-industrial complex, higher education, and private medical sectors were intent on milking a public purse that no longer had a solid tax base with which to pay. Maximizing short-term profit worked brilliantly for sociopathic executives looking to climb the promotion ladder–but as a long-term strategy for stability, a spiralling Gini coefficient left a lot to be desired.

The European Parliament responded by focussing on corporate governance. If corporations wanted to be legal citizens, the politicians riding the backlash declared, they could damn well shoulder the responsibilities of good citizenship as well as the benefits. Social as well as financial audits were the order of the day. Directives outlining standards for corporate citizenship were drafted, and a lucrative niche for a new generation of management consultants emerged–those who could look at an organization and sound a warning if its structure rewarded pathological behaviour. And as for the newly nationalized supermarket monopolies, a flourishing future as government-owned logistics hubs beckoned. After all, with no post offices, high street banks, or independent general stores, who else could do the job?

Obscure Rails 3.1 asset pipeline feature messes with my head

For some time, I have been in the habit of appending a datestamp to my image assets whenever I update them. This is a low-tech, reliable cache-buster. For example, if I add a new icon to the sprite image “app-icons-20110901.png” (last edited 1 September 2011), I would change the name to “app-icons-20110909.png“, and change the matching CSS from

.test {
    background-image:url(/images/sprites/app-icons-20110901.png);
}

to

.test {
    background-image:url(/images/sprites/app-icons-20110909.png);
}

By changing the name of the file, I can guarantee that as soon as a browser gets the new CSS, there is no risk of it re-using an old version of the sprite file from cache. This works great on static sites that are updated rarely, and on sites where you haven’t gone to the trouble of implementing a more sophisticated system of (image) asset fingerprinting.

Rails 3.1 comes with fingerprinting baked in as part the new asset pipeline. Unfortunately, the asset pipelining breaks in the presence of my manual fingerprinting efforts. Rails refuses to serve up an image asset whose file name ends in a dash followed by more than 6 digits:

  • /app/assets/images/app-icons-2011.png is fine
  • /app/assets/images/app-icons-201109.png is fine
  • /app/assets/images/app-icons-2011090.png doesn’t work
  • /app/assets/images/app-icons-20110909.png doesn’t work

The error reported is a straightforward Routing Error:

No route matches [GET] "/assets/app-icons-20110909.png"

So code like this in a stylesheet will not work:

/* application.css.erb */
.test {
    background-image:url(<%= asset_path 'sprites/app-icons-20110909.png' %>);
}

(Also, running bundle exec rake assets:precompile will not generate a matching MD5 fingerprinted image under /public for the affected file.)

I haven’t gone into the source code to find out exactly where this happening (I think this all goes on under the hood in Sprockets rather than in Rails itself) but as the old joke goes, the solution is pretty simple:

Doctor, doctor! It hurts when I do this!

Well, stop doing that, then.

If you’re doing Rails 3.1, just let it take care of the fingerprinting, and everything will be fine.

Further reading:

The Non-Scenic Route

Brilliant article by John Lanchester in the London Review of Books: “The Non-Scenic Route to the Place We’re Going Anyway

Quarterly GDP data don’t, on the whole, tend to make the person studying them laugh out loud. The most recent set, however, are an exception, despite the fact that the general picture is of unrelieved and spreading economic gloom. Instead of the surge of rebounding growth which historically accompanies successful exit from a recession, we have the UK’s disappointing 0.2 per cent growth, the US’s anaemic 0.3 per cent and the glum eurozone average figure of 0.2 per cent. That number includes the surprising and alarming German 0.1 per cent, the desperately poor French 0 per cent and then, wait for it, the agreeably frisky Belgian 0.7 per cent. Why is that, if you’ve been following the story, laugh-aloud funny? Because Belgium doesn’t have a government. Thanks to political stalemate in Brussels, it hasn’t had one for 15 months. No government means none of the stuff all the other governments are doing: no cuts and no ‘austerity’ packages. In the absence of anyone with a mandate to slash and burn, Belgian public sector spending is puttering along much as it always was; hence the continuing growth of their economy. It turns out that from the economic point of view, in the current crisis, no government is better than any government – any existing government.

Some summer reading

  • Charles Stross – Rule 34 A sharp and funny thriller set in 2020s Edinburgh, full of observations on the impact information technology might have on policing, politics, and our personal lives. Like many of Charlie’s books, I found the ending a bit too vague. He seems to like leaving you with questions and opportunities for you to use your imagination to fill in the details. Apart from that, brilliant.
  • James Gleick – The Information A history of how we deal with, well, information: language, writing, communication. Gleick spins a thread of discoveries, inventions, and insights from pre-literacy right up to present information age. It’s the earlier chapters I found most compelling, though. The book is subtitled, “A History, a Theory, a Flood,” and once Gleick gets through Shannon and into the era of the Flood, many of the anecdotes and details feel incomplete, or drift off into unsatisying speculation. Gleick is at his best as a chronicler, but the story of the information Flood has only just begun, so it’s hard to paint a complete picture. The Information actually complements Rule 34 very nicely: together they vividly cover both the past and the future of the subject.
  • Kate Griffin – A Madness of Angels Urban Fantasy didn’t used to be my cup of tea, but I’m discovering more and more hardboiled Urban Fantasy books that sit with me rather well. I’m not sure if this strictly qualifies as hardboiled, but despite a certain tendency towards overly descriptions it doesn’t have any of the goth-ish faux-noir sensibilities that I (perhaps unfairly) associate with the genre. Tough, well-drawn characters and a present-day London that is both gritty and filled with thinly disguised wonder are going to have me coming back for more.
  • Harry Connolly – Game Of Cages No doubt whatsoever about the hardboiled nature of this one. I read the first book in this series, Child Of Fire a couple of months ago after having read Harry’s guest posts on Charlie Stross’s blog. Harry’s Twenty Palaces books tackle Lovecraftian horror with a very head-first American hardboiled flavour in the same way that Charlie’s Laundry books cover it with a uniquely British twist. His new book, Circle of Enemies is just out, and will be on my next Amazon order.

  • Derek Landy – Skulduggery Pleasant 3: The Faceless Ones Alex got the first book in the Skulduggery Pleasant series for Christmas, and declared it “awesome”. He persuaded me to read it, and damn it, he’s right. It’s funny, and full of fast-paced action and snappy dialogue. So now I’m following behind Alex as he works his way through the whole series. (I wish he’d hurry up on book 4; I’m eager to find out what happens next!)
  • Lev Grossman – The Magicians Very mixed reviews on Amazon for this one, and I can see how it might not suit everyone, but I loved it. It builds up a complex set of relationships very quickly, but it doesn’t linger lovingly on them, or tease out every nuance, because it moves through the plot at a blistering pace. It appears blatantly derivative of Narnia, Harry Potter, and The Secret History, but it blends these old and new archetypes with an insouciance I found entertaining. In fact, the multiplicity of influences is exactly what keeps it interesting: just when you think you know what the next chapter will bring, it actually turns in a different direction.