2017 Tour de Cure Donation Drive

It’s that time again, ladies and gentlemen: I am fundraising for the Tour de Cure, the annual bicycle race that benefits the American Diabetes Association. Since I have diabetes, I have absolutely no shame about guilting my friends and family into donating to the cause. So let’s dive right in, shall we?

What am I donating to?

The American Diabetes Association does a lot of things to improve the lives of people with diabetes. First and foremost, they fund research that aims to prevent and cure diabetes. This is hugely important. However, while a cure is being developed, they also fund programs for people with diabetes, like Camp Carolina Trails – the summer camp for children with diabetes at which I volunteer every summer. They are also involved in government, making sure that people with diabetes have a voice in Washington, which is especially important as the Senate considers the AHCA.

Why are you doing this?

I’ve done the Tour de Cure for the past two years. It’s nice to do something tangible to try and combat this disease that often leaves me feeling powerless and not in control. Plus, I know that there are a lot of other people, including the children I work with every year at camp, who will benefit from events like this. As an added bonus, my blood sugars are great when I’m exercising, and this is an excuse to do that.

So what do I get?

I’m glad you asked! You get to see pictures of me wearing ridiculous things while I’m riding in the Tour. Last year, I created a set of donation goals, and for each one, I would another absurd item to my costume. I’ll be doing that again this year. See below.

But I donated last year, and you didn’t even send me a “Thank You” e-mail! What gives?!

You’re right. I didn’t send out “Thank You” e-mails last year, and I feel bad about it. This year, I promise I will send them out. Unfortunately, despite my best efforts, I’m not perfect. And while that isn’t a good excuse for lack of manners, sadly, it’s the only one I have. If you choose not to donate to my race, I hope you’ll donate to someone else’s.

Alright, what can I do to humiliate you during the race?

Here are the goals:

  • $200 – This is just the starting bid. I need to raise $200 to enter the race. But, just for you, I’ll leave the streamers on my handlebars from last year’s race (see pictures below).
  • $400 – I will attach a red cape to my jersey, and ride with it on the entire race (unless it gets caught in my bike, falls off, or otherwise becomes a hazard…)
  • $600 – I will super-glue a cowboy hat to my helmet. Last year was alien-head deely-boppers, and I think it’s time to change it up.
  • $800 – Same as last year, if I reach $800, I will attach a milk crate to the front of my bicycle, put an ET plushie (which I still have from last year) in it, and ride the race like Elliott from E.T.
  • $1000 – I really wanted to make this my fundraising goal, but I think I’ve started too late. Nevertheless, if we reach $1000, I will take your most ridiculous suggestion and incorporate it into my outfit. Please add your suggestion to your donation e-mail, comment below, or send it to me in an e-mail. If the suggestions aren’t creative enough, I will come up with my own, and I promise that it will be suitably ridiculous.

Will we make $1000 this year? Will E.T. ride 25 miles around a bicycle course in Woodinville, Washington at a charity bike race? Will the alien-head deely-boppers come off my helmet, or are they permanently welded to it with hot-glue from last year? Donate to find out!

None of that is quite humiliating enough.

Don’t worry, it’ll be enough. Did I mention that I’m riding with a company team made up from people at work, none of whom I actually know? Yeah, it’ll be plenty humiliating.

How do I donate?

Please donate through my Tour de Cure Participant Page. Donations directly to the American Diabetes Association are awesome, and I encourage them, but they won’t benefit my ride directly. Any amount helps, and I will greatly appreciate it.

Where are the pictures from last year?

Well, I’m glad you asked…

With alien-head deely-boppers... because fundraising.

Alien-head deely-boppers. Yes, people did point, stare, and take pictures.

My bicycle, complete with streamers, and a jersey with retro-gaming buttons all over it.

My bicycle, complete with streamers, and a jersey with retro gaming buttons all over it.

My race jersey with retro gaming buttons all over it.

My race jersey with retro gaming buttons all over it.

Convince me further…

I like to make this into a fun challenge, but this race is important to me, and to a lot of other people in my situation. Diabetes isn’t easy to live with, and it’s not going away any time soon. Last year, I meant to ride the 25 mile course for the first time. I trained a bit, and I thought I was ready. However, the night before the race, I experienced a perfect storm of a CGM (Continuous Glucose Monitor) sensor failure, a low blood sugar, and an extremely high blood sugar that lasted until just before the race. It was almost like diabetes knew what I was doing and was trying to stop me. That morning, I woke up at the right time, and considered not even going to the race. I felt awful. I was dehydrated and had ketones from the high blood sugar (high ketones make you nauseous; it’s not fun), I had barely slept because of the low blood sugar, and I didn’t feel like going one bit. But I drank a lot of water, drove out to the race, and although I elected to do the 10 mile race instead of the 25 mile, I completed it. I won.

Battles like this happen every day in the life of a diabetic. They’re not always quite that bad, but if you let it, diabetes will make you miserable. There are several cures for Type 1 Diabetes in the works right now, and some of them are very promising. They need funding. And, in the meantime, we need to make sure that people with diabetes have access to the community and care that they need.

So please, support my 2017 Tour de Cure ride.


Which Distro? An Introduction to Picking “a Linux”

Every few days, someone on the Linux users group on Facebook posts a question that goes something like this: “I’m new to Linux. Can you recommend a good distribution for blah?” Where blah is usually something like gaming, media, or learning Linux. Like many people who are new to Linux, when I was first exploring the Linux world, I tried out a lot of distros. Eventually, I came to the conclusion that it doesn’t matter which distro you choose. I’ll explain a bit more about what a distro is, what kinds there are, and why it does and doesn’t matter, below.

What is a Distribution?

It’s hidden right in the name, but it’s not immediately obvious: a distribution of Linux is the Linux kernel, packaged up and distributed in a usable form. Linux, by itself, is just a kernel: the part of an operating system that manages the hardware, and provides interfaces for the various pieces of software and hardware that make the computer usable. If you were to just boot the kernel all by itself, the machine would start and do nothing. It would spin the fans and hard disks faster or slower, handle new device connections, and maybe even accept user input, but the computer wouldn’t be usable, because the software that interacts with the user (you) is not part of the kernel – no text terminal, no on screen menus or mouse pointer, no nothing. Once the kernel is running, it spawns other programs that handle user interaction. This is a basic model of operating systems.

So, apart from some basic patches and alterations that the makers of Linux distros might make to their specific release of the kernel, the underlying kernel is basically the same from distro to distro. The difference is in the software they install around it, and that’s also one of the reasons Linux is more customizable than any other popular operating system today. For example, there are quite a few different graphical interfaces that support Linux: KDE*, Gnome, Unity, XFCE – these are all visually different interfaces that function differently. And that’s just a very, very small portion of the desktop environments available. So two different distros with the exact same kernel can look and behave very differently on the surface. This is, to a large extent, how various Linux distros differ: the packages included with the base system, and their initial configurations. Ubuntu and Kubuntu, for example, are two distinct distros, yet they are mostly the same except that Ubuntu ships with the Unity desktop environment, and Kubuntu ships with KDE. One could easily uninstall Unity from Ubuntu and install KDE.

Major Differences: Package Management

Arguably the most fundamental distinction between various distros is the way they facilitate software installation. On a base Linux system with no package manager, the way you install packages is by copying the executable binary and it’s shared objects to the proper locations. This isn’t the easiest or most convenient thing to do, as it doesn’t allow you to easily keep track of what software package is installed where, or what version it is. So most Linux distributions ship with a package manager like apt (Debian-based), yum (Red Hat), portage (Gentoo), or pacman (Arch). These package managers will not only install packages from a central repository – all of which has been checked so that it is compatible with all the other software in the repository – but they will install all the dependencies as well. Everyone who has ever tried to install a package from source on a freshly installed system will tell you that this is a great relief, and saves hours of hunting online for tarballs**.

Which package manager you choose is largely a matter of preference, and this is the basis on which I think you should make your decision. Debian-based distributions come with “apt”, which is – from my biased perspective – a reliable, relatively easy to use package manager. Distribution upgrades (i.e. major upgrades) can be done without nuking the system and starting over, it has support for multiple architectures on the same system (e.g. installing 32-bit packages on a 64-bit machine), and is pretty painless. Even the most frustrating problems can sometimes be solved by throwing around a bunch of apt commands semi-brainlessly.

Red-Hat/Fedora-like distributions (like RHEL, Fedora, OpenSuSE, CentOS, and Oracle Linux) use “yum”, which installs rpm files. The last time I used yum was years ago, so my opinion isn’t worth much in this regard. I’ve heard that you have to nuke a Fedora system in order to do a distribution upgrade – that is, you have to do major upgrades by wiping the system and starting over – but I don’t know if that’s the case anymore. If you’re a beginner, I’d recommend using one of the other options, but this is my wholly biased opinion; take it with a grain of salt (and maybe a trial of Fedora on a VM).

Gentoo (and probably some other distros based on Gentoo) use “portage”. Portage is pretty freaking cool, in that it compiles every single package from scratch. It’s a somewhat agonizing experience (although not as much so on today’s faster machines), especially if you want to install a huge software package like KDE. But the benefit of doing things this way is that every binary on your system is optimized specifically for the box sitting in front of you (or under your desk, or wherever it is you have the thing). It’s more useful if you actually know what you’re doing, and can manipulate the various compiler flags effectively, but I’m sure there’s some speed-up even if you don’t entirely know what’s going on under the hood. Gentoo is my favorite distro for learning the ins and outs of Linux, and if you’re a first-timer and really want to dive into Linux and get a good head start, I can’t recommend enough that you take the time to do a full, manual, Gentoo install. Just… uh… don’t be discouraged if you fail the first time. Or the second. You’ll learn a TON, trust me.

My experience with other package managers like pacman is minimal. I used Arch for a while, and it’s a very nice distro. It’s something of the best of both worlds between Gentoo and more user-friendly distros like Debian.

Smaller Distros

The Internet is replete with smaller distros with funny names, and there are too many to mention. Most of them are offshoots of one of the main distributions I’ve described above, with various configuration changes. There are some medium size distributions as well (Linux Mint, Puppy Linux, etc) which tend to do a pretty decent job, and are sometimes designed for very specific situations Puppy Linux and Damn Small Linux, for example, are designed to be very small and light weight, and are especially useful for booting from a CD or USB key to do system repairs. Linux Mint, in particular, is a refreshing spin on Ubuntu. I tend not to trust the really small distros though (the ones you’ve never heard of with websites straight out of the 90’s), because I’m dubious as to whether they’ll continue to be supported in the future, and whether they’ve been tested thoroughly. There are probably good ones out there, I just don’t shop around too much anymore.


In many ways, it all comes down to choices, and the number of them you want to make. If what you want is a plug-and-play operating system that isn’t Windows or Mac OS X, go with Ubuntu, Linux Mint, Fedora, or a similar distro that has a one-and-done type install: you pop the disk in the drive, set up your language, time zone, and login credentials, and away you go. These distros have default packages that support most of your day-to-day needs, and it’s fairly easy to install components that aren’t pre-installed. They work on most of the common hardware out of the box, and they have a lot of online support options.

If, on the other hand, you want to make the choices yourself, choose a distro like Gentoo, Arch, or Debian. Gentoo and Arch, in particular, don’t even choose a default desktop environment for you, so you can choose any configuration you want right from the beginning without having to undo someone else’s work. One time, I installed Gentoo only to realize that I had disabled the kernel configuration for my hard drive controller, so the system couldn’t boot: that’s how much control you have. Debian has some base packages that install a very minimal system, as well as some options that will install a lot of common packages for you. It’s more immediately usable than the other two, but allows you to install a minimal system if you want.

At the far end of the spectrum of choices is LFS: Linux From Scratch. You compile the kernel from scratch, and gradually start loading things on the disk until you have a working operating system. I’ve never done this, but it’s always been in the back of my mind. You can find resources for doing that here: http://www.linuxfromscratch.org/


One last thing I want to mention is stability. Stability is probably the other most important dimension of a distro, and I would be remiss if I didn’t talk about it just a bit. If you’re cycling through different distros exploring the Linux world, you might not care too much about stability. Honestly, if you play around with things enough, you’re going to wreck your distro no matter how stable it is. But if you’re looking installing Linux on a machine you care about, stability is very important.

Because the distro packagers are usually on the same team (or are the same people) as the people who maintain their distro’s package repositories, their attitudes and values contribute to how stable the resulting collection of packages will be. Debian, for example, is know for being fairly conservative and FLOSS (Free Libre Open Source Software) fanatical, which makes for a very stable, very reliable system, and makes it a bit harder to install proprietary software (not much harder, though.) Ubuntu, on the other hand, is less gun-shy, and uses more up to date packages at the expense of a slightly increased probability that their packages will have unresolved bugs. It’s worth doing some research to find out the attitude of a perspective distribution’s repository maintainers before making your final choice.

Stability is the main reason I forsook Ubuntu years ago, and now only use Debian. Ubuntu is the only operating system I have ever installed (aside from Windows) which has crashed during or right after installation***. It’s a great distro that is paving the way for lots of innovation and publicity in the Linux and Open-Source world, and it has become a stepping stone (at the very least) for new users, but I don’t like the way they do choose their packages, and the default packages that are installed. And, if I’m honest, even though it’s a small and easily fixable issue, Unity absolutely drives me up the wall.


Hopefully this will help you choose the distro that’s right for you. You should play around with a few of them and read up on them (Wikipedia is a great place to do this) before picking the one you intend to use for ever and ever… and always know that you can change your mind at any time. As you learn to use Linux, you’ll likely realize that you wish you had done certain things differently during your installation, so you’ll likely be itching to re-install after a while anyway.

If you’re curious, as you might already have guessed, I install Debian on everything I get my hands on: my desktop, my parents computers, Raspberry Pis – hell, I’d install it on my toaster if I could. After administrating around 20 Debian machines during my two years as a SysAdmin, I’ve come to appreciate its elegant simplicity and robustness, and I wouldn’t replace it with Ubuntu if you paid me. But that’s just my opinion; I encourage you to draw your own.

*It has been pointed out – and rightly so – that the K Desktop Environment (formerly referred to as simply “KDE”) is now properly called “KDE SC”, for “KDE Software Compilation”. For simplicity, however, and since it is still referred to in the Debian repository and popularly as KDE, I’ve left the incorrect acronym as is.

**A member of the Linux Facebook group pointed out that newcomers to Linux might not know what a “tarball” is. Tarball is slang for an archive compressed using the unix tar utility, usually with the extensions .tar, .tar.gz, or .tar.bz2. Source code for many open source packages come packaged in a tar archive.

***It’s true, I’ve had many a Gentoo installation crash on me on or before startup, but that was always because I had done something stupid, and was entirely my fault. The same opportunity doesn’t really exist in Ubuntu; I’ve had installations crash once, and succeed after installing again with the same options for no discernible reason.

Equus: Not Exactly About Horses

When you were a child, you had all sorts of misconceptions about how the world worked. For example, when I was very young, I was convinced that we lived on the inside of the world; that we were surrounded by a crust of blue stuff that was the sky. It’s inevitable that we misunderstand some things about the world as children. After all, much of what children learn they learn from inference (this object fell, I infer that all objects will fall when dropped; A space shuttle launched into outer space, so we must not be surrounded by a crust of blue stuff.) Have you ever wondered which of those misconceptions you still have? Is it possible that one or two or those misconceptions have survived unchallenged in the back of your mind all these years? In a way, that’s a small part of what the play Equus is about.

One of the things I love about theatre as a medium is that they never portray just one main idea (not in good plays, anyway.) You always leave a really great play with plenty of things to think about, and ideas from a really powerful play will stick with you for weeks afterward. When I went to see Equus at the Segal Centre, I didn’t know what to expect. I didn’t know the play, though I could gather from the name that it had something to do with horses. I haven’t stopped thinking about the play since I left the theatre. Equus is one of those plays that sits in the back of your mind, aging, growing, and unfolding as it gathers context from your own life experiences.

To say that Equus is a play “about” any one particular thing would be an injustice. Yes, it has a well established theme. Yes, the plot is linear and easy to follow. But to say that Equus is about coming of age, or about the effect of parents on their children, or the role of psychology in modern society would rob the play of the thousands of smaller themes and questions that the play raises. But to give you a brief idea of what the play is “about,” Equus is about a boy who forms a unique relationship with horses. And when that relationship is superseded by other elements of his life as he grows older, he reacts violently. Some people sum up the play by saying “it’s about a boy who falls in love with a horse.” It’s really not about a boy who falls in love with a horse. In fact, it’s about a boy who deifies a horse and falls in love with a girl. To say much more than that would ruin the play, so you’ll have to see it for yourself, and I highly recommend that you do.

I think it’s safe to say that we can all relate to Alex – the aforementioned boy – in some way. We’ve all had our dreams and misconceptions thrown to the ground and smashed by the cold, stone floor that is reality, and we all know what that pain feels like. There’s something in Equus for all of us, and I think the Segal Centre’s production very successfully turns the play over and pours all the meaning out.

The Segal Centre’s production of Equus runs until October 2nd. For more information, check out their website.

Why People Kill Fish, and How To Avoid It

My fish tank, newly cleaned. Notice the thin haze of algae/minerals/salts/bacteria on the glass; It was left there on PURPOSE.

This is not a post about sushi. This is not a post about environmentalism. This is a post about how to keep a fish tank. Most people kill fish within a month of getting them. You’ve probably done it: you buy a fish (a Betta/Fighting fish or a Goldfish in a little bowl,) you give it a few little aquarium rocks, and maybe a fake plant and a little ceramic statue of a diver. You lovingly clean it every week, and cautiously feed it every day until, about a month later… it dies. But you took care of it! You did everything right! No. No, you didn’t. You did everything wrong. Here’s how you take care of fish.

There are three basic rules for taking care of fish.

  1. Clean the tank whenever you remember to.
  2. Feed the fish whenever you remember, but make sure it’s at least twice a week, unless you’re on vacation. Then it’s ok to leave them a week or so.
  3. Never never NEVER put PLAIN TAP WATER in your fish tank or bowl!

Let’s start with the last and work backward. This is how most people kill their fish: they clean the bowl about once a week, and they put fresh, clean, chlorinated tap water in the fish bowl. People who do this usually end up killing their fish within a week or so. When you buy your fish, forgo the luxury of the little ceramic diver and buy a bottle of tap water conditioner. Chlorine kills fish. Tap water conditioner removes the chlorine from your tap water.

Number 2: Don’t overfeed your fish. Some people might disagree with me on this one, but in the wild, no animal eats as often as we do. I feed my fish anywhere from one to four times a week, and I’ve had this tank for over a year with no food-related casualties. (I have had two natural deaths and one or two territorial disputes that ended badly.) I don’t know that a little overfeeding will hurt your fish, but it certainly won’t help.

Last, but not least, don’t clean your tank all the time. Fish live in filth. In the streams or tropics from which your fish came, their relatives float happily in their own pooh from birth to death. Your job is to simulate the cleaning properties of the plants and constantly flowing water that they don’t get in your tank. Beta fish, on the other hand, naturally live in mucky, still water, and hardly need to have their bowls cleaned at all.

When you clean your tank, use an aquarium vacuum (a tube with a bigger tube attached) to suck out about half the water in the tank. Sift through the rocks and try to get some of the turd and decaying food out from between the pebbles. When the tank water is down to about half, you’re done. Don’t refill the tank and start over; you just want to get rid of some of the muck, not all of it. Also, don’t throw the water out! Put it on your plants; they’ll love you for it. Then refill the tank with treated tap water, distilled water (if you want to waste money,) or Reverse Osmosis (RO) water (if you really want to waste money.) Distilled and RO water are only a waste of money in a fresh water tank. If you have a salt water tank, use them.

When you first get your tank, you should put in whatever water treatment/starter fluids the person at the pet/aquarium store tells you to put in. This will build up the bacteria that the tank needs to properly deal with the fish guano that develops in the tank. Pebbles and other “complex” surfaces are also important, because that’s where the bacteria live and om nom nom on crud.

Regularly testing a well established tank is a waste of time, in my opinion. Test pH, ammonia, and nitrates if you get a sudden die off or if your fish start looking sick, but nature does a fantastic job of regulating all these things all by itself… if you don’t clean your tank too often, that is. If it makes you feel better to keep an eye on things, test as often as you like.

Expect any given fish to live for several years (at least two,) and if they die before that, then something is probably wrong.

Hopefully this will serve as a loose guide to help you keep your fish alive longer, or encourage you to start a fish tank if you don’t already have one. Fish tanks have been a fixture of the Davoust household since I can remember, and I encourage you, if you’ve ever thought about getting a fish, to go out and get a small starter tank (a Betta in a bowl will do as well.) Feel free to leave questions in the comments if you have them, post a link to pictures of your own tank, or to tell me I’m wrong and extol the virtues of rigorous, monthly cleaning and daily feeding.

Bacon Beans: A Manly Bowl of Beans for the Testosterone-Laden of Both Sexes

Now that's a delicious sight if ever I saw one. Just look at that beautiful bacon. Hungry yet? I am.

Are you tired of boring bean dishes? Do you wish you could make beans exciting? Well you can’t. But you can try by mixing them with BACON. You know how there’s always a bit of fat left over after cooking bacon? It just sits in the pan, and it always bothers me. It’s a waste of food, and worse: a waste of bacon. Today I decided that enough was enough: it was time to use that bacon fat. It was time to cook beans with it.


To make Manly Bacon Beans, you need beans (preferably re hydrated,) and no less than four strips of bacon. Use as much bacon as you like as long as you use at least four strips of it. Bacon is delicious. Don’t deprive yourself. You’ll also need some salt. Did I say this would be healthy? No. I said it would be delicious.

  1. Cook the bacon. It should be a bit chewy, not crispy: crispy bacon is an abomination. Once the bacon is cooking steadily, turn the heat down to medium. The secret to perfectly cooked bacon is taking it off the pan right before you think it’s ready. It will continue to cook a little after you take it off, and if you take it off even a 30 seconds too late, it’ll be crispy or worse: burnt.
  2. Once the bacon is out of the pan, immediately add the beans. Use as many beans as you like. This isn’t a science. You can add salt now or you can add salt later, but the beans are going to be boring if you don’t add salt eventually.
  3. Sauté the beans in the bacon fat on medium heat for a while. Try to brown them on the sides by spreading them out on the pan and letting them sit for a few minutes, and then stirring them around. This will make them a bit crunchy and wonderful. Feel free to eat a piece of bacon while you’re waiting.
  4. Put them in the container of your choice, tear the bacon into chunks with your bare hands, toss it in the beans, and enjoy.

While these bacon beans are delicious, they’re a little dry, which takes away from the flavor a bit. You might want to add some olive oil.

A side note about the title: If you’ve read my blog for a while, you probably know that I’m a feminist (if this surprises you, then you’ve been misinformed: Wikipedia Feminism.) So how can I justify calling these beans manly? It’s another discussion for another time, but 1) manly, in a feminist context, can simply refer to something that embodies traits characteristic of men. This doesn’t imply any inequality between men and women, or that being manly is better than being womanly, it just acknowledges that there are differences between men and women. These differences are fascinating and wonderful; they shouldn’t be swept under the rug because some misguided people decided to abuse them. 2) There is nothing “manly” about these beans, that’s just the voice with which I decided to write this post.

As far as the “testosterone-laden of both sexes” bit, we all – man or woman – have testosterone and estrogen in our bodies (excluding certain medical conditions.)

Feeding the Birds

Look at that face. He's saying, "I'm hungry! And all because you giant apes with your superiority complex cut down all my ancestor's trees!"

It Westmount, the city/borough of Montreal in which I live,  it is illegal to feed birds. I’ve heard from several people that it is, in fact, illegal to feed birds in most of Montreal. The argument is usually that birds will become dependent on humans as a food source, and that they won’t be able to find food in their natural habitat. I usually have trouble coming up with a counter argument to these points, but I’ve been thinking about it lately, and here’s my argument: look around you.

Do you see any “natural habitat” for birds anywhere? No. You don’t, because you’re sitting in or near a large human-nest that we call a “building,” most likely located in a city full of these buildings. We destroyed those bird’s natural habitat and built ourselves a habitat instead. How’s that for interfering with their natural feeding habits?

Second, what do you see outside your human-nest/building? Unless you live in a God-forsaken concrete hell, you probably see plants, planted by humans. Who planted them? Well I don’t know who exactly, but you’d better find them and arrest them! They’re feeding the birds! Even now, their evil act of legal defiance is being carried out as birds peck at the seeds of those plants, trying desperately to survive in this concrete and metal landscape we’ve built up around them.

Finally, take a look inside a Walmart, Home Depot, Airport, or any other large structure. On any given day, one of those structures may contain quite a few birds. Know why they’re there? They want to eat all the crap that we leave behind. And they apparently live quite well. Looks like you’d better pull out the handcuffs again, because Walwart’s feeding the birds too.

My point isn’t, “Everyone is feeding the birds and they just don’t know it.” My point is that we’ve already destroyed much of these animal’s natural habitat, which has a much bigger impact than people feeding them bird seed. The damage is already done: birds in the city are already dependent on humans for their survival, because our plants, trash, and bird seed are the only things they have left to eat in what use to be their home. We’ve destroyed their homes, and now it’s our responsibility to try to provide what we’ve taken from them.

And finally, it’s not like we’re going anywhere, are we? Chances are that if there were a huge catastrophe that prevented all humans from ever feeding birds again, there wouldn’t be any birds left to be fed, or humans to want to feed them. And I know that’s not the reason that making birds dependent on us is a bad thing, but as I posited in the last paragraph, they already are.

Note: This is an issue I feel strongly about. If you like my ideas, please share this post and/or leave me a comment. If you don’t like this post, or you disagree with me, please leave a comment telling me why. I don’t bite, I promise.

Enough Sed

My goals were modest, or so I thought. Fiddle with my wmii configuration, add a battery charge percentage indicator to the status bar, run through lesswatts.org and make some readjustments to save some power, and that should about do it. Six hours of the day were blocked off for pure and simple “me time.” The cast of the musical I directed several months ago were coming to pick up the T-Shirts I had printed for them, and I gave them six hours to do so. It turns out that over two days I got only managed to do two of the things I had intended to.

The first thing to tackle was wireless. I had decided to switch to wicd instead of network-manager. Most people seemed to make the transition smoothly but, of course, not me. Something happened. Or didn’t happen. And whatever it was prevented wicd from connecting to or scanning for wireless networks unless network-manager had been run and had connected to a network. It seemed to have a mind of its own. So what do I do when a Linux distribution seems to have a mind of its own, the forums don’t give me an adequate (or any) response, I’ve crapped up the partition with unused packages (mostly KDE 4 related,) and a few hours of fiddling leads me no where but in circles? Reinstall the entire distribution, of course. Besides, my 10.04 install was just a dist-upgrade from 9.10, so the configuration files seemed to be a mess. Reinstalling fixed the problem entirely.

Next up, after the fresh install, was to tackle this stupid tap-to-click thing. Why on Earth anyone would want their trackpad to click randomly while they try to navigate their Desktop is beyond me, but it drives me absolutely insane. Why it’s enabled by DEFAULT is a complete mystery as well. Gsynaptics is great, but I don’t want to fiddle with trackpad settings, I want to scratch a spell into the back of my computer so it never does it again. But I settled for just changing the configuration files. In older Ubuntu versions you had to fuss with HAL, which is a bit of a pain, and has never worked for me. In Ubuntu 10.04, you use udev rules. It seems more straight forward, but I have a better way. In /etc/X11/xorg.conf.d you will find some configuration files. One of them will say something like 10-synaptics.conf. Edit that, and at the bottom of the top section add

Option “MaxTapTime” “0”

Log out, log back in, and the damnable tapping behavior will disappear.

Next, I wanted to be able to see what my remaining battery life was. Now I’m almost 100% sure that my solution is not the most efficient one, since it takes approximately 2 seconds for my code to check. But I wanted to learn about pipes and sed, and I wanted to do all this in bash with one line of code (hence the rather punny title of this blog post.) First I’ll show you the code, then I’ll explain it.

echo `grep ‘remaining capacity’ /proc/acpi/battery/BAT0/state | sed ‘s/[^0-9]//g’`/`grep ‘last full capacity’ /proc/acpi/battery/BAT0/info | sed ‘s/[^0-9]//g’` | bc -l | cut -c 1-3 | sed ‘s/^\.//;s/\./0/g;s/$/\%/’

It took me several hours to build that one command. I started hardly knowing anything about regular expressions. I’ve typed that line so many times that I can remember it by heart – I just typed it from memory. The echo and grep stuff is pretty simple: anything in `these quotes` get’s evaluated, and the returned value replaces the quotes. The first grep looks for the remaining capacity in the battery section of proc’s acpi diectory, and the second one looks for the last full capacity. The tricky parts are the sed commands. Each grep command is piped into a sed command, which removes all non-numeric characters. [0-9] matches all numeric characters.  Putting a carrot: ^ in front of the 0 inside the brackets matches everything but numeric characters. ‘s/regex/replace/’ will look for ‘regex’ at the beginning of a line, and replace it with ‘replace’ if it finds it. To make sed do that for every character, you add a ‘g’ at the end like so: ‘s/regex/replace/g’ So to look for every non-numeric character and replace it with nothing (i.e. delete it,) you do:

sed ‘s/[^0-9]//g’

If you just ran the echo stuff, you would get something like “40437/50800” depending on your remaining battery capacity (proc gives measurements in mWh.) This is piped to bc -l, which divides the two, and gives .79600393700787401574. You could leave it like that, but it’s not very pretty, and I still hadn’t learned all I wanted to about sed. So this result is piped to cut, which will trim the output into .79. For some bizarre reason cut starts with 1 and not 0, so the command is cut -c 1-3, which cuts everything but the first character to the third.

Now we want to do two things: we want to get rid of the decimal point, and put a parenthesis. But wait! That works if the battery isn’t fully charged, but what if the value is 100%? In reality, I never asked this question. It occurred to me right as I was just trying something to get my wireless working. I did whatever I was trying, saw it fail, and as I looked down at my status bar, I saw this: .0% Two failures in under a second. Pretty impressive. Originally I was getting rid of the decimal point by cutting characters 2 to 3, but when bc -l returned 1.0, the command cut off the 1 and added a %. FAIL. This is a problem for sed to handle. What we want to do is remove a decimal if it occurs in the first position, but convert any other decimal points to a zero. Then we add the percent. The sed expression goes like this:

sed ‘s/^\.//;s/\./0/g;s/$/\%/’

Wow, that’s a lot of gibberish. Let’s break it down.




In the first one, the ^ character tells sed that what we’re looking for comes at the beginning of the line. The backslash escapes the period. Huh? In the language of regular expressions, a period means “any character.” So we have to tell sed that we actually mean “period.” To do this, we do something called escaping, which means that we put a backslash to tell sed that the next character is to be read as is, and not interpreted to mean something else. The backslash is pretty much the universal escape character. sed will replace anything that matches what the expression in between the first and second slashes with whatever is in the second and third slashes, and since there’s nothing between the second and third slashes, the period will be deleted. Any leading decimal points are now gone.

The second expression is more or less the same, but it doesn’t have the ^, and it has a g. So this expression looks through the entire line for a period, and replaces it with 0 (because there’s a 0 between the second and third parenthesis. Not bad. But I think I can make this a little more efficient by making the expression more complex so that sed doesn’t have to search the entire line each time:


Uh… huh? When you put escaped brackets around something \( \), it tells sed to remember what that matches the pattern between those brackets. To use whatever it finds, you just type \1. The pattern is looking for one numeric character, so let’s say that sed gets 4.0 as input. This will recognize and store the 4, and then it will find the period, which is part of the regular expression, but not part of the pattern to be remembered. It will then replace what it found: 4. with the expression between the next two slashes, which is \10. That means that it will replace using the number it remembered, and add a 0, which will give us 400. But I just used 4 to prevent confusion with \1, in reality we’ll never have 400% battery charge, so we’ll find 1.0 and get 100.

Finally, the last expression simply replaces the end of the line, which contains nothing, because it’s the end of the line, with a % sign. The $ character means that the pattern should occur at the end of the line, and since the pattern is nothing, the expression refers to the nothing at the end of the line, essentially.

I have learned two very valuable lessons from all this. First, I’ve gained a lot of experience with sed. Second, I’ve learned something that I’ve long suspected: you don’t learn computer science by copying solutions you find on the internet, or by asking for help all the time, or by fixing a problem in a complicated manner because the elegant solution takes too much effort to understand. You learn computer science by finding the most elegant solution to a problem even if it takes you a few hours and a few dozen tries. You learn computer science by saying, “I wonder what would happen in I did this,” and then trying things out for a while. You have to take your time, and keep trying until you’re confident that you’ve solved the problem in the most efficient, effective manner. This is what it’s about.

Note: Yes, yes, it’s Thursday, and I was supposed to post this yesterday; I’m out of my rhythm and all that. So I’m planning to write a make-up post this weekend. Deal? Ok.