Why I Ubuntu

I thought I’d share my source of motivation for working on Ubuntu in the hopes that it might inspire others too! (Note that this is my personal opinion; I don’t speak for Canonical in this blog.)

I believe that the world is moving in the direction of widespread technical savvy and ubiquitous technical companions (think smartphones or tablets).

I want such technology to be a force of empowerment, and thereby a force of good for humanity. To me, empowering means cheap, trustable, adaptable, and easy to use.

Open source software trivially fulfills the first three, in ways that proprietary software cannot. And Ubuntu is doing it’s best to fulfill the last.

Cheap

Yes, technically Open Source doesn’t have to be free. But in practice, it is. Proprietary software can be too, usually through ads. But Open Source always is and, more importantly, always will be.

Trustable

With Open Source, it’s easy to have complete confidence even without being an engineer. As a consumer, Open Source means it won’t spy on me and will do only what it says on the tin.

Adaptable

Proprietary software can be adaptable, no question. Not all adaptations require source access, though it does help.

But importantly, Open Source reduces the opportunity cost for creating or even using software. You can stand on the shoulders of giants. Anyone can provide support or contract work.

There is no barrier to entry to modify Open Source software. And most such software is designed specifically to interoperate with other software, so it’s easier to mix and match.

By way of example, think of a fictional school system in India that wants to create a customized version of Ubuntu. Very trivial to do, and they don’t need to seek anyone’s permission.

Ease of Use

This last point has generally eluded the open source community. But it’s the most important in my mind. What good is the most capable technology in the world, if it never improves lives because it is so hard to use?

My goal is empowering, in a utilitarian sense, as many users as possible. I rarely write code for me alone.

This, more than the rest, is why I support Ubuntu. Ubuntu specifically focuses on users and expanding Open Source beyond the chasm. And more than that, Ubuntu has the best chance of all the current efforts to cross the chasm.

Conclusion

When I think of empowering, I don’t tend to dwell on the modern first world. They don’t especially need empowerment. I’m thinking of the less-franchised or even our own sci-fi future, when our relationship with technology becomes even more important. Do you think Geordi would run code on the Enterprise for which he doesn’t have source access?

Also note that this is not a moral argument; I don’t especially consider Open Source a moral directive for these purposes. Users won’t flock to us because Ubuntu is open source, but rather because Ubuntu delights them.

I understand why people work on splinter efforts or other projects, but for me, I think the work that Canonical does with pre-installs, enterprise support, for-purchase apps, Ubuntu One, and user testing is an invaluable addition to the main Ubuntu project. These are how we reach new users.

OnlyShowIn Unity

tl;dr; version: Add Unity to your OnlyShowIn keys.

This is just a PSA that I’ve been doing work in Ubuntu to support Unity’s addition to the set of registered XDG environments.

Which means that in your desktop file, you can now say OnlyShowIn=Unity; to have an application only show up or only autostart in Unity instead of KDE, GNOME, etc. (Or alternatively, use NotShowIn=Unity;)

By and large, Unity uses the same apps and services that GNOME does. So if you currently have an application that does OnlyShowIn=GNOME;, there’s a very good chance it should now be OnlyShowIn=GNOME;Unity;. You might also want to re-evaluate whether you even need OnlyShowIn.

I’ve filed a bunch of bugs against various GNOME apps and patched them in Ubuntu. But I’ve only focused on apps that Ubuntu installs by default.

Playing Well: Golden Rule

This is part of a series on how to play games well: Stoicly and enjoyably. Not to triumph, but to have fun.

This one is simple. Merely putting yourself in the other players’ shoes is the key to winning or losing well. Sounds obvious, but it’s easy to forget in the heat of the moment.

This is a very subjective rule and audience-dependent, but it’s flexibility is a feature. I’ll just give some examples of things that I find can often be off-putting and worth avoiding.

  • Taking overt pleasure in the conquest instead of the play.
  • Conversely, being angry, depressed, or obsessed about the fact that you’re losing.
  • Blaming luck.
  • Noting the cleverness of your own moves.
  • Suggesting that if a certain thing had happened differently, you would have totally won (obviously all players can construct fictional pasts where they won, but it’s not terribly interesting or helpful).
  • Similarly, the “I would have won in X more turns” argument.
  • Taking too long.

Now, these can all be done in good ways. It’s just that they can easily be unwanted.

Just think about the ideal behavior of someone you’ve just beaten. Now do that when you are beaten. Same for the ideal behavior of someone who’s just beaten you.

One interesting corollary here is that when you are doing well, it’s encouraged to note the bad luck of your losing opponent. Or if you’re doing poorly, how awesome a certain move of theirs was. It gives people the chance to talk about it without having brought it up (assuming you actually do want to talk about it :) ).

GtkGrid is Great

One under-the-radar change in GTK+ 3.0 was the addition of GtkGrid, which can replace GtkBox and GtkTable. There are two major reasons it is great:

  1. Better support for the new height-for-width layout engine. I’ve had several layout and spacing issues with labels and GtkTable in 3.0, but converting to GtkGrid fixed them. So if you’re having odd spacing issues, try a Grid.
  2. GtkGrid finally adds the feature that rows or columns with hidden contents also automatically hide their spacing. So if you’re making use of dynamic layouts that add and hide rows, you don’t have to jump through hoops to making your spacing perfect.

Using Ubuntu One’s Cloud API

I recently finished up a branch adding support to the backup program duplicity for Ubuntu One. I thought I’d write up how I did it, because some things weren’t obvious.

My needs were simple: Python versions of get, put, delete, and list operations.

Code snippets under GPL-2+ license. These don’t have any error handling, but that’s simple enough to add. Note that for the list and put snippets you will need to either use trunk or a release greater than 0.2.0 of the ubuntuone-couch Python module.

If parts of the snippets are confusing, it may help to consult the official documentation.

Log In

First, you have to log the user into Ubuntu One. There’s a utility class in ubuntuone.platform.credentials to help with this. It’s designed to be asynchronous, but for our simple purposes, we’ll fake synchronicity with a main loop.

_login_success = False
def login(self):
    from gobject import MainLoop
    from dbus.mainloop.glib import DBusGMainLoop
    from ubuntuone.platform.credentials import CredentialsManagementTool

    global _login_success
    _login_success = False

    DBusGMainLoop(set_as_default=True)
    loop = MainLoop()

    def quit(result):
            global _login_success
	    loop.quit()
	    if result:
		    _login_success = True

    cd = CredentialsManagementTool()
    d = cd.login()
    d.addCallbacks(quit)
    loop.run()
    return _login_success

Create Volume

Another piece of set up before we can get to the good stuff is to create a volume if needed. A volume is just a directory in Ubuntu One that can be synchronized (but isn’t by default). It’s OK to attempt to create a volume multiple times, but Ubuntu One will report back an error if you try to create a nested volume.

Note the auth.request call. This adds the required OAuth header to our request so that we can successfully authorize with the server. This is why we must be logged in first, to have access to the credentials that auth.request uses.

def create_volume(path):
    import ubuntuone.couch.auth as auth
    import urllib
    base = "https://one.ubuntu.com/api/file_storage/v1/volumes/~/"
    return auth.request(base + urllib.quote(path), http_method="PUT")

Delete

Alright, we can get down to brass tacks now that we are logged in and have a volume in which to work. Let’s start simple with a file delete request.

def delete(path):
    import ubuntuone.couch.auth as auth
    import urllib
    base = "https://one.ubuntu.com/api/file_storage/v1/~/"
    return auth.request(base + urllib.quote(path), http_method="DELETE")

That was easy!

List

Listing involves requesting the metadata for the parent directory / volume and explicitly asking for information about its children.

def list(path):
    import json
    import ubuntuone.couch.auth as auth
    import urllib
    base = "https://one.ubuntu.com/api/file_storage/v1/~/"
    url = base + urllib.quote(path) + "?include_children=true"
    answer = auth.request(url)
    filelist = []
    node = json.loads(answer[1])
    if node.get('has_children') == True:
        for child in node.get('children'):
            child_path = urllib.unquote(child.get('path')).lstrip('/')
            filelist += [child_path]
    return filelist

Get

This is a little tricky. You have to first ask for metadata about the file to get the actual content path. Then you have to hit files.one.ubuntu.com to get the data itself.

Note we don’t quote the twiddle in the content_path field. It needs to be unquoted.

def get(remote, local):
    import json
    import ubuntuone.couch.auth as auth
    import urllib
    base = "https://one.ubuntu.com/api/file_storage/v1/~/"
    answer = auth.request(base + urllib.quote(remote))
    node = json.loads(answer[1])
    base = "https://files.one.ubuntu.com"
    url = base + urllib.quote(node.get('content_path'), safe="~")
    answer = auth.request(url)
    f = open(local, 'wb')
    f.write(answer[1])

Put

Last, but not least, putting a file on the server. Note that you must specify a content type and length.

def put(local, remote):
    import json
    import ubuntuone.couch.auth as auth
    import mimetypes
    import urllib
    base = "https://one.ubuntu.com/api/file_storage/v1/~/"
    answer = auth.request(base + urllib.quote(remote),
                          http_method="PUT",
                          request_body='{"kind":"file"}')
    node = json.loads(answer[1])
    data = bytearray(open(local, 'rb').read())
    size = len(data)
    content_type = mimetypes.guess_type(local)[0]
    content_type = content_type or 'application/octet-stream'
    headers = {"Content-Length": str(size),
	       "Content-Type": content_type}
    base = "https://files.one.ubuntu.com"
    url = base + urllib.quote(node.get('content_path'), safe="~")
    return auth.request(url, http_method="PUT",
                        headers=headers, request_body=data)

Odds and Ends

Hope that was helpful!

You should be able to figure out how to do other things you’ll need from these snippets and the official documentation. Note that as of this writing, parts of that documentation are out of date. For the moment, trust my snippets over the documentation! I’m told the documentation is being updated.

Note that in terms of HTTP error codes, Ubuntu One seems to return 500 for out-of-space. And if you request a malformed path (like, with two slashes in it), it likes to give back an error code with a login page as an HTML payload.

Playing Well: No Stress Losing

This is part of a series on how to play games well: Stoicly and enjoyably. Not to triumph, but to have fun.

How to deal with failure? Everyone loses, but not always well.

One easy strategy is to realize that the past has already happened. It can’t be changed; period. Nor can the present really. You can control what will happen a nanosecond from now, but not what is happening this moment.

The past of a minute ago is as much a part of the historical record and unchangeable as “before you were born.” And no one sits around worrying about stuff that happened then. You just accept it as your time-inheritance.

So what’s the point in worrying about something you have no control over? Use the past to inform your future behavior, but don’t cry over spilt milk.

Don’t sit there depressed about what you’ve gotten yourself into. Just concentrate on how you’re going to dig yourself out or how you’ll do things differently next time.

In the same spirit, if someone just screwed you over, don’t stress about it to the point of ruling out cooperation in the future. Not that you should forget what happened, but dwelling on it will cause you to miss opportunities for collaboration.

One useful exercise is to imagine that you just walked into the room and took over a spot for someone that left. Then ask yourself, “Now what?” Because that’s what you do every second: take over from a younger, handsomer you.

Ideally this way of thinking about the past will make you happier. You can live in the moment and not stress about the foolish mistakes of you-from-two-minutes-ago. Though hopefully you can learn from them.

Déjà Dup in Ubuntu 11.10

So the result of the UDS session on including Déjà Dup in Ubuntu 11.10 was positive. Assuming no disasters, it will be on the CD!

I’d like to thank Canonical for sponsoring development by providing me work time to develop features and squash bugs!

I want to try to reduce the Ubuntu bug flood by really nailing things down this cycle. So I’d request that Ubuntu users try it and report bugs before the flood gates open. Especially test restoring too, as any bugs with restores are generally critical issues.

Yay for Open Source!

So I’ve avoided talking about the latest kerfuffle in Ubuntuland because I might be biased, working as I do for Canonical. But here’s a bit of musing inspired by it.

Progress

I’d like to focus a bit on how awesome the world is. Open source software is becoming a common and accepted tool. A person anywhere in the world can download and install for free a distribution like Ubuntu or Fedora and have a first class experience. It will come packed with powerful software like Firefox and LibreOffice.

You can provision a virtual server from someone like Amazon, fill it with services like a web server, a code repository, you name it. You can go from idea to website in seconds flat.

Need to look something up? Just ask Wikipedia, the rapidly enlarging sum of human knowledge. Want to buy a phone? Pick up a Linux-based Android smartphone.

If you step back a bit, that is amazing. Open source is empowering the world, literally making it a better place. The best (and defining) part is that each advancement can build upon the previous ones.

Design

But the best technical design with the most features isn’t going to change the world — or even just be as helpful as it can be — unless it’s easy and fun to use. That’s why I love that design-driven development is gaining more cachet in open source. I’m glad to see the efforts by Ubuntu’s Ayatana team and GNOME’s design team to cross the chasm and reach new users.

Motivation

Anyway, this is all part of why I work in the open source sphere. Not just to scratch my own itches, but because I believe I can use my skills to leave a lasting mark and to empower others. I’m incredibly blessed to be able to work in such communities and with such companies.

I just find it hard to get worked up over whether buttons are on the left or the right, whether the user can minimize a window, or whether GNOME and Canonical are getting along 70% or 90%.

Not that such discussions aren’t worth having, but it’s easy to get caught up in navel-gazing. We’re all on the same team. We’re trying to change the world, and it’s worth remembering every now and then that we are succeeding!

Howliday 2010

I’ve been meaning to post about this year’s Howliday, lest its new tradition get lost in the haze of memory.

Seeing as all participants were people that happened to have beards, it was discovered that long have poor folk — who could not afford more convincing disguises — adopted beards at this time of year to fool the banshees.

Ladyfolk generally just tried their best.

One can conveniently piggyback on top of Movember to guarantee an optimal face bush for Howliday.