El gabinete de los viejitos

Cuando sea hora de votar, acuérdense de esto:

http://www.jornada.unam.mx/2012/02/28/politica/014n1pol?partner=rss

Josefina Vázquez Mota, afirmó que cuando ve a otro aspirante que nombra a su gabinete, pienso que suman como mil 500 años de edad, y que al observar cómo en otro partido se integra a su consejo político a ex gobernadores, algunos con historias terribles, pienso que suman como mil 500 años de prisión.

Acuérdense de estos comentarios a la hora de ir a votar, acuérdense de cómo desprecia a la gente simplemente por su edad, cómo para ella la experiencia no vale nada, y piensen si así descalifica y menosprecia a sus colegas políticos, ¿qué hará con los planes de apoyo a la tercera edad?.

Elecciones – Desconocidos vs. Superestrellas

¿Por quién prefieres votar? ¿Por Vázquez Mota y su equipo de “desconocidos” que van a seguir hundiendo al país tratándolo como si fuera una empresa?

¿O por este equipo de superestrellas de la ciencia, el arte, la política y la economía?

Y la neta, si no los conoces, ve investigando quienes son. La decisión es tuya.

http://www.jornada.unam.mx/2012/02/17/economia/008o1eco

Ubuntu and Juju with local providers

Want to play with Ubuntu’s awesome Juju but don’t want to get into the hassle of getting EC2 configured?

https://juju.ubuntu.com/

It’s actually pretty easy to set up a local provider to experiment with this.

You need to be running Ubuntu 12.04 (yes, it’s not released yet but you can use the beta version or daily  images). Oh, and you can install this on a virtual machine if you really don’t want Juju to mess with your actual system.

Make sure to have a valid SSH key, if you don’t have one, create it with

Then

Once the packages are installed, run

this adds you to the libvirtd group at runtime.

Then run juju bootstrap. Juju will complain about a config file or something. Ignore it! and then edit .juju/environments.yaml and replace everything on that file with this:

The admin-secret is a MD5 random key, you should probably generate your own with something like this:

Then finally it’s time to bootstrap things:

This will exit pretty quickly, but things are not ready yet. Note that it will take a few minutes to get packages and actually prepare the nodes.

Once your juju is bootstrapped you can follow the rest of the steps here:

https://juju.ubuntu.com/docs/user-tutorial.html#bootstrapping

Find and -exec and why doesn’t basename work in there?

Ever wonder why this doesn’t work to rename all your isos to .nrg?

The thing is, the backticks are a bash construct, and whatever you specify to -exec does *not* get shell-expanded. So it’s being passed verbatim, with the only substitution being the {} for the found filenames.

But this works! (though quoting may pose some challenges). This works because it *is* being processed through bash, so all the normal expansion and shell tricks will work.

Notifications – during and after launching

When I launch a long-running process I like to forget about it, but how do I know when it’s finished?

You can of course have it send an email after it finishes:

For this to work, it’s very useful to have ssmtp configured, so you have a sane, working local SMTP agent.

You can also send the notification only if the command succeeds:

OK, so you forgot to add the notification to your initial command line. You can use a loop to monitor a particular process and notify you when it’s done.

In this case I’ll be monitoring an instance of netcat. Determining the process name is up to you 🙂 The delimiters $ and ^ look for the executable names only.

The while loop will run while the process exists; once the process disappears the loop continues with the next instruction in the line, which is popping up an alert on the desktop and then sending an email. So if I’m not glued to the desktop, I’ll still get an email when this is done.

while pgrep $nc^; do sleep 5; done; alert; (echo “finished” |mail -s “finished” you @somewhere.com)

find’s printf action

If you use find, it outputs full paths, which may not always be desirable. Turns out find has a -printf action with which you can do  niceties such as outputting plain filenames (as if you’d used basename on them, but this means one less command on your pipeline):

The -printf command has a lot of formatting variables and possibilites! give it a try, look at the man page for more information.

ASCII video rendering

If you’re a CLI jockey you may enjoy looking at a nice ASCII rendering of your face via your webcam:

mplayer -vo caca tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0

Or to watch your favorite video in ASCII rendering:

vlc –vout caca some-file.avi

 

 

Random picking without repetition

So the problem was to draw people at random from a list. The list is contained in a leads.txt text file, one per line.

This nifty one-liner will output a randomly-picked person from that file every time it’s invoked. it’ll then remove the name from the file so it doesn’t get repeated again.

It can be shortened by changing shuf |head 1 to shuf -h 1.

If you’d rather avoid deleting already-chosen entries from the file, this version just comments the names it picks:

Building Debian/Ubuntu packages with sbuild

Many of the on-line instructions and tutorials are quite complicated. Why? It was easy for me:

To build a virtual machine:

this will create a schroot in /var/lib/schroots/precise-i386. Note how it appends the architecture to the schroot name. Also note that the first time you run mk-sbuild, it’ll show you a configuration file and configure your environment. I didn’t change anything in the config file, I used it “as it was”. When it prompts you to log out, do it, otherwise things won’t work.

OK now you want to build a package using your chroot with sbuild:

This will build the package on precise for ALL available architectures. Note that -d is just “precise”; the -A flag will tell sbuild to build architecture: any packages for all available architectures (so if you have amd64 and i386 chroots, it’ll do the right thing and build two packages).

If you want to build arch-specific packages:

This will magically build for the given architecture (i386). Note that arch: any packages will also be built.

You can also specify the arch as a parameter (but then you have to leave it out of the -d name):

This will not work:

Using diff on the output of two commands – named pipe and bash magic

Ever wanted to diff the output of two commands? Usually it’s done by first piping each command to a temporary file and then diffing them.

The following syntax creates a named pipe for the command and uses the pipe’s name instead of a filename. Bash takes care of everything automagically so all you have to do is:

That’s a dumb example, but how about this?

The commands can be as complicated as you need them to be!

Countdown bash function

To be put in your .bashrc. Combines a waiting period with a (simple) progress report.

The perfect keyboard layout?

I remember an easier time when all keyboards had the same layout (C-64, anyone?) and if you wanted to type special characters you had to resort to arcane command sequences, if they were at all possible.

My, how times have changed.

My first PC compatible had a spanish keyboard, and you could very simplistically tell the OS (MS-DOS) about your keyboard layout. For a while this worked pretty well. Then someone decided that Latin America was so different from Spain, that we needed our very own keyboard layout; this layout just moves stuff around needlessly, destroying many years of experience for those of us who were accustomed to the spanish keyboard. I understand removing the ç as it’s not used in Latin America, but why move all the rest of the stuff around?

Latin American Keyboard

So basically I got used to the spanish keyboard which has worked well in all kinds of OSes, from MS-DOS to Windows, OS/2 and yes, Linux.
While the Latin American layout was such a pariah that, at some point, it got overwritten by the Latvian keyboard (la), so when doing a system upgrade, all of a sudden your keyboard was in latvian, and you had to select “latam” for Latin America.

French Canadian Keyboard

Eventually I happened to get a laptop with a Canadian French keyboard. Luckily, this is not the dreaded french AZERTY keyboard, but basically an english keyboard layout with most symbol keys mapped very strangely. So if you want to type the basic alphabet you’re OK, like you’d be with an english keyboard, but things start getting weird when you need to create special characters or compose accents, cedillas and stuff like that. This was so different from any other layout I’ve used, that I was basically freaking out. I could just ignore the red characters on my keyboard, and/or use it as just an english keyboard, but I routinely need to compose text in spanish and in french, so how would I go about doing this?

And no, the ages-old trick of memorizing ASCII codes for special characters doesn’t cut it: for one, it’s unreliable on Linux (especially on graphical mode), and for another, it’s just primitive! I used to chuckle at all the people I’ve seen through the years who had a nice “cheat sheet” glued to their desktop with ASCII codes for frequently-used accented characters, as opposed to taking 15 minutes to correctly configure their keyboards to do this natively.

So anyway, what I came across while checking out the available keyboard maps under Linux and trying to figure out how to type stuff on the Canadian keyboard, was this wonder of wonders, the US International with AltGr Dead Keys layout.

Basically, it takes the right Alt key (labeled AltGr on my keyboard, a monstrosity I was already used to from the LatinAmerican and spanish keyboards) and uses it to “compose” or “deadkey” stuff (dead keys are like accents, for instance, where you press the accent key and then the next letter you type will be accented). In combination with ~, “, ‘ and , this enables me to type nearly all accented characters with relative ease.

Also, I can use AltGr+vowel to type acute-accented vowels (áéíóú), and AltGr+n for ñ.

Grave accents (è) and tilded letters (ã) can be composed by AltGr+accent (use for grave, ~ for tilde), and then the letter you want to type.

What I like about Linux’s keyboard selection thingy is that you can see an actual layout map. Thus, even if my keyboard doesn’t have the characters stenciled in, I can take a quick peek and see where stuff I need might be.

Thus I can do things like use ç or €, all with a minimum of fuss. Also more complicated stuff like ï œ ø is still just one AltGr+key away. All this while preserving a layout that’s very familiar to everyone (english), and where most strange characters using while programming {}][\|~ are also much easier to use than on the spanish keyboard I was used to (it needs AltGr for all sorts of braces and piping, which makes it very painful on my hands).

The actual US International with AltGr deadkeys layout as shown by the Gnome keyboard selection applet.

So there you have it, if you see yourself wrestling with choosing a good physical keyboard layout *and* making it work on your OS, stop pulling your hair out, get an english-layout keyboard and use US International with AltGr Dead Keys!

Can Ubuntu succeed? comparing to iOS and Android

Last week during Ubuntu Developer Summit, head honcho Mark Shuttleworth said something to the effect of “iOS and Android have managed to succeed despite Microsoft’s monopoly,  and we haven’t” (see the keynote here). As a few days passed I thought about it a bit and here’s what resulted.

I think it’s not quite as clear-cut as “they have done it and we haven’t”. Microsoft’s monopoly is on the desktop, and it is there that Ubuntu is going directly against Microsoft and perhaps, yes, failing to capture a percentually significant chunk of the market. And I won’t go into the whole “Linux is better than Windows” debate.

Rather, let me point out a key fact about Android’s and iOS’s success: they both did so in a market where Microsoft wasn’t a dominant player. Before Apple unleashed the iPhone on the world, the smartphone market was very fragmented, with Microsoft a relevant player (Windows Mobile), but nowhere near the dominance it has in the desktop. Nokia (Symbian) and RIM (Blackberry OS) were two big players, but they have both been relegated, one to irrelevance (Nokia – plus the deal with Microsoft), the other (RIM) to a frankly defensive posture where they lack a strategy and are scrambling just to stop the exodus of users.

Now, even while Apple and Google are the two strongest players in the smartphone market, things are pretty much in a state of flux, and no platform can claim the stranglehold that Microsoft has on the desktop. So those companies are forced to innovate and stay on their toes. But the fact is that, even with a product that is clearly superior to previous offerings, any one of these companies would have had a hell of a time dethroning a hugely dominant player from the field.

Ubuntu’s challenge is greater as it’s going head-on on Microsoft’s cash cow, and there’s no real competition for the desktop. The only other mainstream operating system with any success is Mac OS X. Apple is content with whatever niche they’ve carved for themselves, and it’s clear to anyone that the strides they’ve made in the past decade are more due to the halo effect of the iPod and iPhone than because of OS X’s (admittedly great) merits. So yes, they have a superior product, but that still hasn’t propelled them beyond a 10% market share.  While I’m at it, let me comment: it’s easy to forget that the first versions of OSX were kludgy, slow and difficult to use, and had a myriad usability problems. It was the iPod and then the iPhone that propelled Apple from a fringe player into the powerhouse they are today. In the end, Apple realizes that promoting Mac OS X is not worth a big effort, and that the momentum from the iPod and iPhone are enough to keep OS X alive.

So what does Ubuntu need to succeed on the desktop? I have no insight in this topic, but let’s just realize that it’s not as clear-cut as looking at, and imitating, Android’s and Apple’s successes, because as I’ve said, their playing field was a vastly different one. Would a “halo-effect device” help Ubuntu the way the iPhone helped Mac sales? maybe. Maybe all Ubuntu needs is endurance, as even hugely dominant players (Ford, IBM, WordPerfect, Netscape) can be surpassed under the right circumstances.

Ubuntu and Community Testing

During Ubuntu Developer Summit (UDS), held last week (May 9-13) in Budapest, Hungary, a very interesting program was discussed. It’s the Ubuntu Friendly program. The end product of Ubuntu Friendly should be a way for people to find out whether a particular computer system can run Ubuntu properly (it’s friendly!). This has many possible uses, not the least of which is to enable people to choose a system on which Ubuntu has a good chance of working without much tinkering by the end-user. This is important in a world where most people compare a preinstalled Windows system (which has had most of the dirty driver installation/enablement work done by the manufacturer) with a from-scratch Ubuntu installation, where Ubuntu is expected to pick up all the hardware and work adequately with it.

Due to this last scenario/requirement, in my opinion, installing Ubuntu is already a much cleaner/friendlier experience than installing Windows; on my laptop, a Samsung QX410, Ubuntu has a few glitches which require manual configuration (touchpad, hotkeys), but the system is immediately usable out of the box. The same can’t be said of Windows, where a plethora of device drivers are required for even the most basic devices to even work. However, since the system is purchased with this work already done, to the user’s minds, the Ubuntu experience is not as polished as the Windows one.

I digress. So the Ubuntu Friendly program seeks to award Ubuntu Friendly status to those laptops the community finds work well with Ubuntu. This in a way replaces the Ubuntu Ready program, where manufacturers were responsible for running the tests on their systems. It also complements the existing Ubuntu Certified program, where hardware is tested in-house by Canonical, under more stringent standards, and an official Canonical-sanctioned certificate is issued to machines that are deemed certified, as in, work with Ubuntu out of the box.

Needless to say, there’s a lot of interest from the community in this Friendly program; it’s a win-win situation where the community can contribute valuable testing and results, and the world becomes a better place through what will be a large list of systems that the community has identified as being “Friendly” to Ubuntu.

During UDS, the sessions where this program was discussed had great success; attendance was good, and I was glad to see people from outside the Hardware Certification team in Canonical participate. Yes, there was a lot of interest and participation from community members too. There were a lot of valid concerns and good ideas being talked about, and even though an extra session was scheduled for this program, they all ran out of time with people still wanting to participate.

All in all it’s a very interesting program, one that hopefully will take form quite soon. If you’re interested in seeing what this is all about, here’s the blueprint with a more formal description of what is being planned.

The myth of better device support on Windows

It’s long been argued that peripheral support in Linux is far inferior to that under Windows, and that this has been a factor for Windows’ dominance in the desktop. More and more, the myth that Windows has any kind of technical superiority leaves place to the fact that marketing, and being bundled with nearly every PC sold worldwide, are Windows’ only keys to its widespread adoption. And here’s a story to prove that point.

I bought a printer (HP Photosmart C4780). It’s one of those cheap, $50 numbers that eat through ink like crazy. So I come home, wondering if I’ll have to install 500 MB of crap as included in the bundled CD to get the printer to work with my Mac at home.

As is usually the case with the Mac, I just plugged it in and it worked, both the printer and the scanner, without a hitch or problem.

I then proceeded to do the same on a freshly installed Ubuntu 10.10 laptop. Same story, the printer just worked, and Ubuntu even recognized it when being plugged in, no need to install drivers or anything.

Now, on Windows the printer wouldn’t have worked at all without installing a boatload of crap, HP is notoriously bloaty when it comes to their bundled software.

The usual wisdom is that hardware manufacturers care more about Windows, and ship all their hardware with drivers and stuff to make it work. It would seem, then, that the burden is on Apple and Linux distributions to provide drivers and support to most hardware. It would seem like a daunting task. But they do it, and the end result is that Mac OS and most Linux distros include drivers for everything, right out of the box. This puts them a step ahead of Windows, when it comes to ease of use, at the cost of maybe a slight bloat. Still, my Ubuntu installation is much leaner than the 16-GB behemoth that is Windows 7.

So there you have it, the myth of better hardware support on Windows, finally debunked.

Now, if I could only get the braindead wireless support on the HP printer to work…