Don't write shell scripts

Command substitution errors are silently ignored whenever the substitution occurs in a command:

$ echo $(false); echo $? 0 $ variable=$(false); echo $? 1

Not when setting variables. Course not.

When I say don't write shell scripts, I'm talking mostly about sh and bash, but every shell I've used has fairly arcane rules that need to be followed. The convenience of the shell, its brevity, especially when creating pipelines, is manifested through these rules, but they're numerous and complex enough to regularly trip up and confuse even experienced folk.

After spending years writing shell script - including one >1000 line bash script that has been running in production for ~10 years - I now strongly think that shells, like bash, should only be used interactively, and not for any kind of automation, or even the very thinnest of glue.

The second finest shell script in the universe is a single line long:

exec $something_else

The finest... does not exist.

The Who: a beginner's guide

http://gu.com/p/39qd8

To me, a lifestyle business doesn’t equate to running a tiny business as an alternative to having a job. A lifestyle business doesn’t have to be small at all, either in revenue or employees. The main requirement of a lifestyle business is just that it allows the entrepreneur/owner to live how he or she wants to live now, while running the company.

There's some interesting stuff in the comments too.

Product or service?

I once tried to be an entrepreneur.

I moved to Luxembourg with my wife, set up a company, and then wondered what I was going to do. I couldn't decide if I should build a product of some sort - and then, what? - or if I should provide services. Predictably, I floundered for a few years.

I suspect I'd have made a better job of it had I been able to read What Should You Do With Your Crappy Little Services Business? on TechCrunch, and the comments on Hacker News. I see now that I have a strong bias against providing services, but that services - by which I mean things like bespoke development, system administration, and so forth - might actually be a better fit for my life, especially now I have kids.

On Launchpad we agonize about going read-only for 60-90 minutes a month to make database changes. Waitrose, however, have quite a different idea.

They've built a new website:

...you can continue to shop at Waitrose.com as normal.
However, in order to allow us to transfer your details over to the new website, you will be unable to make any changes to your Waitrose.com Account, including your billing details and delivery address, between the 28 February to the 11 March 2011.

I can think of reasons why they might plan a migration this way, but I can't think of any that actually justify it. They are mucking around with their customers - grocery shoppers - for 11 days. After which the customers will be left with a website which they can probably no longer navigate, and is likely to be full of bugs.

Script to control native Spotify on Linux

Almost the simplest possible Python script to control the native Spotify client on Linux:

#!/usr/bin/env python import dbus import sys if __name__ == '__main__': session = dbus.SessionBus.get_session() spotify = session.get_object( "org.mpris.MediaPlayer2.spotify", "/org/mpris/MediaPlayer2") for command in sys.argv[1:]: getattr(spotify, command)()

Use like:

$ spotify-control PlayPause $ spotify-control Next $ spotify-control Previous

I tried appending “/rss” to the URL of one of my tag archive pages, and somewhat to my surprise, it worked.

Per-tag RSS feeds for Tumblr by Paul Mison.

Tagging installed Python libraries

Generating TAGS for the project I'm working on with the addition of an installed library - Twisted for example - can be a pain:

$ python >>> import twisted >>> twisted.__file__ '/usr/lib/python2.6/dist-packages/twisted/__init__.pyc' >>> $ etags -R src /usr/lib/python2.6/dist-packages/twisted

I got bored of that.

Enter pyctags to take the pain away:

$ pyctags -e -R src py:twisted

It's a pretty simple script:

#!/usr/bin/env python from imp import find_module from os import execvp from os.path import dirname from sys import argv, stderr def expand(arg): if arg.startswith("py:"): module_name = arg[3:].replace(".", "/") try: return find_module(module_name)[1] except ImportError: stderr.write("Could not expand %r.\n" % module_name) return arg else: return arg if __name__ == '__main__': args = ["ctags"] args.extend(expand(arg) for arg in argv[1:]) execvp("ctags", args)

Free ticket folly

Norwich has been selected as a pilot for a nationwide scheme to get people to swap one in every 25 journeys from their car to the bus ... To help make the vision a reality, a million free bus trips are being given away nationally to get car drivers on board.

I know what the bus is like, thanks, and a free bus journey is not going to change my mind. It's going to help out people who were going to take the bus anyway.

Just one double-decker bus can take 75 cars off the road.

Yes, if it's full, if you're under 5'6" tall or willing to have both legs or your head amputated, if you want to sit next to a soap dodger or on the previous soap dodger's seat crud, if you want to catch or spread the latest flu virus, if you want to arrive an hour later or leave an hour earlier than your friends, and you really like to ignore your comfortable, convenient, self-controlled seat/radio/ventilation/heating/aircon equipped, already budgeted car sitting at home.

The millions spent on this campaign might be better spent, say, hiring some people who hate buses to design a bus service they would use.

Giving away free tickets is throwing the money into the wind.

My issues with PayPal

What don't you like about PayPal?

There are several factors, most stemming from their ubiquity/monopoly in the web payment area that forces me to use them:

  • Site full of stupid usability issues; I don't want to trust my money/details to something so broken,
  • Every time I log in there's another hurdle to jump before I can get my money, move some money, etc.
  • Closed world, no competition within the PayPal world; take it or be outside of it,
  • Many stories about PayPal withholding money; banks can be abusive too, but I can take my business elsewhere.

That's about all I can think of for now, or other reasons are variations on the above. My displeasure earlier today was triggered by the first of those points.

Avatar
Reblogged schwuk
A collection of free, printable quick references for a variety of languages and web technologies—PHP, CSS, Subversion, Ruby on Rails, Microformats, etc.

I've already used these cheat sheets today, and I like the way he asked for donations ("I'm saving donations towards a a new Cobham mesh chair! £98.41 (of £126.99) to go!", and a little progress bar) so I donated. Thank you Dave Child.

However, not every cloud has a silver lining: donations via PayPal. Do I need to say any more, or is PayPal's reputation as a corpulent scum-drenched bastion of incompetence widely known?

I hope I never have to ask them for a job.

Arse mouth

My wife starts off any discussion of our new overlords government by referring to David Cameron as "arse mouth". She doesn't like the way his mouth looks. This has proved to not be a good way to start a reasonable and balanced discussion of policy.

Landscape

Today I start a 6 month long rotation onto Landscape. Weirdly, I'm not nervous, just keen to be productive as soon as possible, to learn as much as I can, and to have fun all the while :)

"What the fuck you lookin' at?"

Reply to "Downstream bug reports – fail!"

Johannes Schmid wrote a short piece about Ubuntu and bug reports on Launchpad and I wrote a reply. Unfortunately a server error on blogs.gnome.org prevents me from commenting directly on his post, so I'll do it here:

This is something we're working on; it's in the interests of Ubuntu to get bugs reported upstream.
Launchpad already has a decent level of integration with the GNOME bug tracker. Launchpad can actually integrate with Bugzilla and Trac after some initial setup, syncing comments bidirectionally and linking the upstream bug to the bug in Launchpad. Launchpad can also help people file the bug upstream by jumping to a pre-filled form on the upstream bug tracker. We want to add to all this - for example, to be able to file the bug automatically upstream - but recently we've been concentrating on stabilising the existing features.
Many people work hard to get bugs forwarded to upstream bug trackers. There is an upstream bug report on Launchpad which is used to keep track of how well we're doing at getting bugs forwarded upstream.
To help getting bugs upstream, projects on Launchpad can set their bug tracker: look for "Configure bug tracker" on the project home page. It's not yet easy to add a new external bug tracker, so this part can be a bit fiddly. It is being worked on, and we're happy to help: drop into #launchpad on freenode, or ask on Launchpad.
Projects can also declare how they're packaged in Ubuntu on their project page: see the bottom left of the page for "Packages in Ubuntu". This makes it even easier to send package bugs upstream to the correct place.
As you can see, Launchpad does a lot to help get bugs upstream. It's not always as obvious or as easy as you might hope for, but it is being worked on, and has already improved a lot.

Brackish was good way back when, but I've ignored Kittie since then... until now. The latest album rocks pretty damn hard.

Free Thrash!

Lost World Order - a thrash band I've never heard of before today - have released their album Marauders for free download. It's pretty good.