Extracting select pages from a PDF

Ever needed to make a new PDF containing a subset of the pages of an existing PDF?

The pdfnup tool is nominally for printing PDFs n-up (n logical pages to a sheet), but it can be told to cut and paste pages into a new PDF, like so:

pdfnup original.pdf --nup 1x1 --pages 1,3,5,7,21-25 --outfile subset.pdf

On Ubuntu, you can install pdfnup with a simple sudo aptitude install pdfjam.

Further reading: pdfjam

Update: pdftk also seems like an intriguing option, especially for more complex operations.

Toto, I've a feeling we're not in 32-bit land anymore

I got a new computer and have had some time to put it through its paces. It's a Dell Studio XPS, with a Core i7 920, 6GB of RAM, and a 24" display. All things considered it was a pretty good deal (ordered in January, $1060 shipped). I later upgraded to 2TB of disk.

This thing is blazing. And building with make -j8 makes me happy inside.

As far as I can tell, everything in it works out of the box with all free software on Ubuntu GNU/Linux Jaunty Jackalope (9.04) x86_64. (Even the ATI Mobility Radeon HD 3450.)

The display, a Dell S2409W, is nothing to sneeze at, either.

There is space inside the case to mount an extra hard drive. It goes in vertically, which is nice because you don't have to wrestle with all the cables and wedge it past the RAM to get it in. However, there is only space for one additional hard drive.

Power consumption is much better than my old desktop. The machine idles at 97W. This goes up to maybe 170W at high load.

My only complaint is the noise. The fans go on like a leafblower when you're pegging the CPU, but I don't really care about that part. The problem for me is more the baseline noise. The computer isn't loud, per se... but it isn't quiet either. It's in my room and I put on earplugs when I go to sleep. Take that with a grain of salt, though, because I'm a person who has trouble falling asleep in the presence of a wall clock.

Chrome

I haven't used Google Chrome much, but it's been interesting following Chrome/Chromium development on the blogs. The things that make it to the blogs are neither too vague so as to be uninteresting nor too detailed so as to seem unimportant or trivial.

The Chrome folks have a lot of cool ideas (especially about UI), and it's neat seeing fresh ideas in the web browser arena. One of my favorite little gems so far:

In most tab strips, when you close a tab the other tabs expand to fit the space that has just been made available. The upshot of this is that the close boxes of the remaining tabs all move around slightly, which makes it harder to quickly close tabs by clicking in the same spot. [...]

For Chrome, we came up with something a little different. Realizing that maintaining a fixed width for tabs when closing them would keep close buttons aligned under the mouse pointer, we designed a system whereby the tab strip will re-layout when you close a tab to fill the gap left, but not resize the remaining tabs, until you move your mouse away from the tab strip [...].

(Ben Goodger, "Tabbed Browsing in Google Chrome")

That is clever. An engineer did the right thing there.

In addition, it's interesting to be able to read about the software development methodology employed by Google, which one usually doesn't hear too much about. For example, the way they use usage data to identify newly coined words that should be added to the spellcheck dictionaries or the way they systematically regression-test the renderer on the million most popular web sites. Most free software projects don't have these resources, and most proprietary shops don't publicize these kinds of details.

Update, 30 Mar 2009: I tried some Chromium builds on GNU/Linux and they are blazing. Wow.

Configuring Radeon R600/R700 devices on Ubuntu Jaunty

Update, 18 Mar 2009: Ubuntu Jaunty Jackalope 9.04 and later now support R600/R700 hardware out of the box. Make sure you update to at least xserver-xorg-video-radeon 1:6.12.1-0ubuntu1, libdrm2 2.4.5-0ubuntu2, and linux-image-generic 2.6.28.11.11. If you have done so, you can stop reading this page now.

Update, 5 Mar 2009: fixed the instructions for the DRM modules. You need to build from the origin/r6xx-r7xx-support branch.

I got a new computer with an ATI Radeon 3450 graphics card (R600 series). Here are the steps I took to configure it on Ubuntu Jaunty Jackalope 9.04 using free software (open source) drivers. The instructions below might also be useful for other Radeon hardware, in particular, R700-series cards.

Happily, Ubuntu 9.04 does drive the 3450 out-of-the-box (it boots into X and is usable, using the free radeon driver). Its performance was, however, kind of poor on my machine. I noticed "wiping" and flickering when scrolling (e.g. in firefox or gnome-terminal) or moving windows around.

Building the development versions of the radeonhd and drm drivers fixed these issues and significantly improved desktop performance. Everything is quite slick-looking now, even while driving a 1900x1080 display. Kudos to the driver developers, and to AMD/ATI for cooperating with driver development. Ubuntu does package radeonhd, so sooner or later, after this code gets released, an out-of-the-box installation will provide this level of performance as well.

For historical reasons there are two free drivers for ATI Radeon devices: radeon and radeonhd. They have approximate feature-parity these days. I used radeonhd because I found instructions for it first. :) Instructions are adapted from these sources: radeonhd r600-r700 instructions, Ubuntu community documentation for RadeonHD. (For your reference, the Radeon feature matrix describes what features are supported on what models.)

Download the build prerequisites:

$ sudo aptitude install git-core build-essential
$ sudo aptitude build-dep xserver-xorg-video-radeonhd

Clone the repos for radeonhd and drm:

$ git clone git://anongit.freedesktop.org/git/xorg/driver/xf86-video-radeonhd
$ git clone git://anongit.freedesktop.org/mesa/drm

Build and install radeonhd:

$ cd xf86-video-radeonhd
$ ./autogen.sh --prefix=/usr
$ make
$ sudo make install
$ cd ..

Build and install the drm modules:

$ cd drm/linux-core
$ git checkout origin/r6xx-r7xx-support
$ make radeon.o drm.o
$ sudo cp radeon.ko /lib/modules/`uname -r`/kernel/drivers/gpu/drm/radeon/
$ sudo cp drm.ko /lib/modules/`uname -r`/kernel/drivers/gpu/drm/

Now we'll configure X to use the new drivers. If you don't have an xorg.conf file with stuff in it, auto-generate one:

# X -configure
# mv /root/xorg.conf.new /etc/X11/xorg.conf

Change the Device section. I modified the Driver line and added the following options:

Section "Device"
    Driver "radeonhd"
    Option "AccelMethod" "exa"
    Option "DRI" "on"
    Option "VideoOverlay" "off"
    Option "OpenGLOverlay" "on"
    Option "TexturedVideo" "off"
    [...]
EndSection

Verify that the DRI module is loaded and that non-root applications can access it:

Section "Module"
    Load  "dri"
    [...]
EndSection

Section "DRI"
    Mode 0666
EndSection

Then reboot your computer. That should do it.

2008 in Review

I know, it's a month and a half into 2009, but... well, better late than never.

The following is a list of the most popular posts on this blog and on my web site in 2008. Numbers 1, 3, and 5 hit Reddit. People mostly found the other articles by searching.

  1. Top Ten Essential Emacs Tips.
  2. Scrolling with the Thinkpad's TrackPoint in Ubuntu 8.10 Intrepid. Who knew a little X.org tweak could cause so much trouble?
  3. A million lines of Lisp. Apparently, people will read anything about Lisp.
  4. Emacs in Ubuntu Hardy now has anti-aliased fonts. And it is beautiful.
  5. Stupid screen tricks. GNU Screen has changed the way I work and the way I interact with computers.
  6. Instructions for setting up Emacs on a variety of platforms.
  7. Towards using the FreeRunner as my primary phone. Which, I am happy to say, I have been now for months.
  8. Writing a raytracer from scratch. Why, you ask? Why the hell not? It was a lot of fun and I learned a thing or two about software and math.

(Google Analytics helped me make this list. Interesting tidbit: among the browsers that people typically use to read this blog, Firefox has a commanding lead with 75%. The runner-up is Safari with 7%, followed by IE with 5%.)

Highlights of the past year:

  • I wrote a thesis and got some papers published. In the course of my work, I also learned a few things about software development and tools, which I'll share shortly.
  • I traveled to New York, Las Vegas, Germany, and Switzerland (with passage through Spain, Liechtenstein, Austria, and the UK). All of these were a lot of fun.
  • I got a new phone (some would say, a mobile computer with a phone in it), one capable of running only free software. It's glorious.

2008 was a great year. Except for the collapse of the global economy, but remember, now is the time to buy. Here's to 2009!

The Ubuntu netboot/network installers

The Ubuntu netboot (network) installers are fantastic, and for how good they are, they are hardly ever publicized.

The idea of just downloading your OS whenever and wherever you need to install it is kind of astounding. It makes the Windows/Mac experience of having to dig up some DVD and type in a 25-digit number seem positively archaic. It's the difference between walking across the street to buy bottled water, and turning on the tap and just having water appear. It completely changes the economics of the game when you no longer have to think of your operating system as a scarce resource.

As I understand it, there are three ways to do a netboot install. I've previously written about installing Ubuntu by booting from files downloaded to your hard disk. It's also easy to do a netboot install from either a CD or a USB key, and the procedures are very similar.

All three methods are nice because they have small initial downloads, about 10 MB; they then download the rest of your OS (and only the latest version of each package) at install time. It's a waste of time to download a ~700MB CD image if you're going to upgrade half of your packages right after installation. (Software is usually out of date by the time you install it! Especially during the development period for each release.) The installer is small enough that you can even burn it to one of those business card CDs.

The netboot installers are also versatile. They will install, at your request, any (or all!) of the following: Ubuntu desktop, Ubuntu server, Kubuntu desktop, Xubuntu desktop, Edubuntu desktop, and many more. They also support installing to encrypted LVM for full-disk encryption. (The netboot installers are based on the ncurses Debian installer.)

The hard disk method has the advantage that, of course, you don't need to use any external media. However, in my experience, the CD and USB key installers are a little less flaky. Unlike a hard disk installation, they also work even if you don't have Grub already installed.

For either the CD or USB key methods, you can find the appropriate files here:

http://archive.ubuntu.com/ubuntu/dists/jaunty/main/installer-i386/current/images/netboot/

(This is for Jaunty/i386. If you want a different release or have a different architecture, like amd64, adjust the URL accordingly.)

For CD installation: download mini.iso and burn it to your CD.

For USB media installation: download boot.img.gz and follow the instructions here. It will boil down to doing something like this:

# zcat boot.img.gz > /dev/sdX1
# aptitude install mbr
# install-mbr /dev/sdX

Then boot from your new media into the installer.

"Being Productive With Emacs" Redux

This past IAP I taught a short class on Emacs ("Being Productive With Emacs") at MIT. It was similar in content to the class that I taught in 2007, although I pared down the material a bit.

I've posted the slides online. You may use the slides under the terms of the GFDLv1.3+ or the GPLv3+.

(I made the slides using S5, which is pretty sweet. It lets you make moderately professional looking DHTML slides in a text editor without much pain.)