Using gnome-keybinding-properties

ubuntu netbook logoLast week I reinstalled my aspireone, which I’ve had for quite a while but which is really excellent for events. I put the latest Ubuntu Netbook Remix onto it and it installed like a dream, with peripherals and powersaving all working correctly. It says something about the positive experiences I’ve had with *buntu installs lately that I even did this over the wifi!

The weird thing was that I don’t really use Gnome on other machines as I prefer KDE, and I hadn’t seen the Unity desktop before (as I understand it, this is a lightweight gnome replacement – it still looks and smells like gnome to me), so there were a few things that were “missing” as far as I was concerned. Easily the most annoying is the Alt+F2 shortcut, I don’t really care what GUI I’m using, I mostly just run things from that! I also realised that I now had workspaces, but that there was no keyboard shortcut to switch between them (I don’t use a mouse, so it’s keyboard or nothing for me).

Enter a wonderful utility called gnome-keybinding-properties.
Continue reading

Navigating Bash History with Ctrl+R

I spend a lot of time at command line, and bash records the history of all the commands I’ve typed and puts it in .bash_history (there’s a limit on how many it stores but for me it goes back a few days). I find it really useful to look back at the history to use the same commands again or edit them slightly. You can press the up arrow to go through your history but it can take a really long time to find what you’re looking for. So instead, try Ctrl + r.

To do this: first press Ctrl + r, then start typing the command or any part of the command that you are looking for. You’ll see an autocomplete of a past command at your prompt. If you keep typing, you’ll get more specific options appear. You can also press Ctrl + r again as many times as you want to, this goes back in your history to the previous matching command each time.

Once you see a command you like, you can either run it by pressing return, or start editing it by pressing arrows or other movement keys. I find this a really useful trick for going back to a command I know I used recently, but which I can’t remember or don’t want to look up again. I hope this is a useful trick for you too!

Launching Links in Opera from Command Line

I’m an Opera user but I use a number of applications from the command line, and often I want to launch links from those applications into my web browser. I’ve just switched over to reading my feeds using canto (web applications are becoming decreasingly accessible these days, although I’m saving that rant for another day) which is a console-based application. This, like many other applications, allows you to specify a URL handler to use when you want to visit links.

To launch a link into a new tab in an existing Opera window, I simply used this:
opera --remote 'openURL(<url>, new-page)'

Where the <url> is the address to access; the same trick works in other programs too. For example I use irssi for IRC, with the openURL plugin, and this can do the same trick. To launch the link I simply set the http handler like this:
/set openurl_app_http opera --remote 'openURL($1, new-page)'

Since I have to look these settings up every time I want them, I thought I’d blog them for next time – and of course for anyone else who finds this useful between now and then!

Missing pcre.h when installing pecl_oauth

I was playing with pecl_oauth last week (more about that in a later post) and when I tried to install from PECL, it grabbed the files, ran the configure step but stopped with an error status during make. This is bad news for those of us who are ubuntu users rather than compile-happy linux users! Closer inspection showed this line around the point things started to go wrong:

Error: /usr/include/php5/ext/pcre/php_pcre.h:29:18: error: pcre.h: No such file or directory

I didn’t have the header files for pcre installed – in ubuntu the headers are in the -dev packages so I just installed what I needed:

sudo aptitude install libpcre3-dev

Re-attempting the pecl install, everything worked as expected. This is on Ubuntu 10.04 Lucid Lynx, and from reading around you’d want to install the same package in response to this error message, regardless of what you were doing to cause it. Hope this helps someone.

Printable PDF Handouts from OpenOffice Impress

Last week I was preparing a training course for a client, and I wanted to print the slides nicely for the attendees to refer to and make notes on etc. The slides were done, I’d talked to my friendly printers (Mailboxes etc in Leeds) and all I needed to do was generate the handouts. Which was fine until I googled for help with doing that from OpenOffice, only to find that although it has this awesome “Export to PDF” functionality for documents, slides, etc, it wasn’t going to do it for handouts.

I’m an ubuntu user, and it turns out that there’s a clever package called cups-pdf which installs a pretend printer, and anything you could print, you can turn into a PDF. Brilliant. I installed it with aptitude and instantly I had a printer named “PDF” which printed to a /home/lorna/PDF directory.

Did I mention I love ubuntu?

I also wanted to add a cover page to my document, before I sent the whole thing to the printers in a PDF file for them to print and bind. For this I simply created an OpenOffice document and used the usual export to PDF. By the magic of twitter, I got some great advice from EmmaJane and installed the package PDFShuffler which enabled me to combine the two documents and save the result as a PDF.

DSCF2526.JPG

By the magic of open source, I have beautiful handouts :) Printing in Linux really has come a long way, I can’t thank the developers and maintainers of all those libraries enough – all I did was install two packages!

One-Step Symlink Switch

This is a trick I use when deploying websites so I thought I’d post it here for posterity. Actually, technically I stole it from someone else but for now let’s pretend it’s mine (thanks @__kb!)

When I deploy an application, which is almost invariably a PHP application, I like to put a whole new version of the code alongside the existing one that is in use, and when everything is in place, simply switch between the two. As an added bonus, if the sky falls in when the new version goes live, the previous version is uploaded and ready to be put back into service. In order to be able to do this, I have my document root pointing at a symlink, let’s say it is called “current”. (disclaimer: I have no knowledge of non-linux operating systems, this post is linux-specific)

When it is time to deploy, I place the new code onto the server, and create two new symlinks, one called “previous” which points to the same location as the “current” symlink does (bear with me) and one called “next” which points to the location of the new code. To deploy, all I need is this:

mv -fT next current

The f forces mv to overwrite the target if needs be, and the T directs mv to consider the second argument as a normal file, rather than as a directory to copy in to. The neat thing about doing it this way is that it happens in a single move, no weird results for people who manage to hit your site while you are typing the new symlink command or during the code updating. It is also just as simple to roll back from this, since you have a symlink pointing to the previously used code version.

I thought I’d share this snippet as it is a handy inclusion in deployment scripts/strategies. What are your tips for managing code deployment?

A “new” Netbook for Conferences

A couple of years ago, I attended ZendCon for the first time. At that time, the only laptop I had was a work machine weighing 5kg, and I was staying in a different hotel from the main conference – so I hastily bought pretty much the first non-ee netbook on the market (which was released about a week before my trip) and took that with me to the event. There were lots of limitations of it but I didn’t have a whole lot of choice … since then I’ve improved it significantly!

More than 512 MB RAM

I’ve now had the machine more than 18 months and I’ve been using it for events and keeping it by the bed pretty much ever since. However this year I’m speaking at TEK-X in Chicago and found myself wondering if I should get a new little machine to take with me. A few months back I upgraded the RAM in the machine (it had 512 MB originally!), and I came to the conclusion that actually, I didn’t need to splash out for a new netbook since with a bit more memory, its pretty usable.

Bigger Battery Life

Instead of replacing the machine, I bought the extended battery for the aspireone, taking me from about 2 hours to about 6 (I think, haven’t tried this battery life in anger yet). Its chunky, but not offensive:

DSCF1476

It is quite a bit heavier than the old one – my original post about getting the aspireone weighed it with its original battery at 971g and with the extended battery, its 1274g, which is still only half the weight of my current work laptop.

DSCF1480

Kubuntu Netbook Edition

Reading back to that original post about the netbook it was pretty obvious that I was hating that operating system. A couple of years ago, the support for aspireone in Ubuntu Netbook Remix became usable, and I installed that. Its been fabulous and I had no intention to do anything more than upgrade … until someone at OggCamp showed me they had the Kubuntu Netbook edition on their netbook.

DSCF1486

It is shiny and blue, and since I use KDE on my laptop I couldn’t resist and I upgraded it with a week to go before I take it as my only machine as a speaker at a conference!

In Summary

I haven’t spent a lot of money on the upgrades, the battery was about 50 GBP and the RAM came out of something else. I did have a large capacity SD card in the expansion slot since I only have 8GB hard drive. Then there was a problem with the machine suspending with the expansion slot in use and at around the same time I got a camera that takes SD … so I put my big card into there instead :) I don’t keep data on the netbook so its not an issue for me. I’ll be flying to Chicago for Tek in a few days, and presenting off my netbook as usual. For a budget machine with a little bit of love and attention added in, “Merry” (short for Merope) the netbook has been quite a fabulous investment!

svn+ssh with specific identity file

Here is a quick howto on using a config file to associate an SSH connection with a particular identity file. When I ssh directly from the command line, I can specify the port, identity file to use, and a whole raft of other options. However these options aren’t available when checking out from subversion using svn+ssh, and I needed to specify a particular private key to use. These instructions are for my kubuntu 9.10 installation but should work on every flavour of *nix as far as I know.

I was trying to check out using something like this:

svn co svn+ssh://[email protected]/desired/path

To do this, I created this file: ~/.ssh/config and in it I put the following:

host lornajane
HostName svn.example.com
IdentifyFile /path/to/private_key

Now I update my checkout syntax to make use of my alias rather than specifying the host directly, like this:

svn co svn+ssh://lorna@lornajane/desired/path

SSH realises that it should pull the host information from your local config file, and uses your HostName, IdentityFile and any other settings you specify (there are many options, see this reference for more information. For example I often use this for port numbers if I’m tunnelling my SSH between places, the possibilities are endless.

Hope this helps, if you’ve got anything to add then I’d be delighted to see a comment from you.

Open Office Presenter Console

I’ve been having issues with the presenter console on both my ubuntu machines since upgrading to Karmic (9.10). One is a Thinkpad T400 running kubuntu and the other is an aspireone netbook running ubuntu netbook remix. Neither wanted had a working installation after upgrade and I couldn’t get the plugin installed using the open office plugin manager.

I discovered that this plugin is now available through apitude – simply install the package openoffice.org-presenter-console and it should all work splendidly! I use the presenter console when I am speaking (which is quite often) to show the time and the upcoming slide, its a great tool.

Word Count

There’s a little command line utility on *nix which I use a lot – it’s wc or “word count”. This is especially useful to because I live in a world where everything is plain text right up until I have to send it to someone else (and sometimes not even then). Despite its name, word count can count more than just words – it can do characters, words, lines and can tell you the length of the longest line while its at it.

Counting Lines

The biggest problem with counting lines is remembering the name of the utility, since its called “word count” and not “line count”. I tend to use this for doing things like piping grep to wc and counting the lines to give me an idea of how many occurrences of something there are. I also use it to count errors in weblogs or really anything else that I could do with summarising. The syntax is something like:

grep -R TODO * | wc -l

Using a count like this is especially good for things like auditing code, where I need to know how prevalent something is – or refactoring, where I’m looking for how many of a particular pattern are outstanding. Counting lines is also very compatible with my habit of making lists in text files.

Counting Words

This is the feature that the utility was originally designed for, and as you can imagine, its pretty good at that. As with most things, this blog post started life as a text file and when I got to this point I saved it and ran:

wc -w wc_article.txt

It outputs the number of words (272) and the name of the file, which is useful if you’re giving it a pattern to match.

Word Count

Its a really convenient and versatile little program; I use it often and I hope others will find it useful too.