Working with Org-mode: Committing Changes Everywhere

I'm a huge fan of Org-mode, and I keep all of my org-mode files in git repositories which are under myrepos control.

However, because I often make lots of changes to my agenda and notes, I hate having to manually visit each individual project and make changes to it. [And it's also annoying when I forget to commit a specific change and then have to try to get my laptop and desktop back into sync.]

Luckily, myrepos can easily run a command in parallel in all of the repositories! The following "update_org_files" command will update all of my org-file containing repositories in parallel:

#!/bin/bash

ORG_GREP='-e .org$ -e .org_archive$ -e .org_done$'

if [ "x$1" == "xdoit" ]; then
    if git status --porcelain -z | grep -z '^ M' | grep -zq $ORG_GREP; then
        git status --porcelain -z | grep -z '^ M' | grep -z $ORG_GREP | \
            sed -z 's/^ M//g' | \
            xargs -0 git commit -m'update org files'
        git push;
    fi; 
else
    emacsclient -n -e '(org-save-all-org-buffers)' >/dev/null 2>&1
    mr -d ~ -j5 run update_org_files doit;
fi;

An updated version of this lives in my git repository

Plotting Embedded Bitmap in Vector Plot in R

Recently, one of my collaborators complained that one of my plots took forever to render on his machine. The particular plot in question had a few thousand points, many of which were overlapping. Ideally, R would be able to simplify the vector image which was drawn to avoid drawing points which were occluded by other points, but this is difficult to do properly, and R currently doesn't do it.

However, R is able to plot to a bitmap, and bitmap images have the nice property of automatically handling this for you. Furthermore, raster images have recently been made far less clunky in R, so it's pretty easy to shove an arbitrary bitmap image anywhere. With dev.capture in Cairo coupled with grid.raster in grid, we have everything we need to solve this problem:

require(grid)
require(Cairo)

start.rasterplot <- function(width=NULL,height=NULL) {
    x.y.ratio <- convertX(unit(1,"npc"),"mm",valueOnly=TRUE)/
        convertY(unit(1,"npc"),"mm",valueOnly=TRUE)
    width.points <- as.numeric(convertX(unit(1,"npc"),"points"))
    dpi <- as.numeric(convertX(unit(1,"inch"),"point"))
    if (is.null(width) && is.null(height)) {
        width <- 1024
    }
    if (is.null(width)) {
        width <- height*x.y.ratio
    }
    if (is.null(height)) {
        height <- width/x.y.ratio
    }
    Cairo(width=width,height=height,dpi=1024/width.points*dpi,file="/dev/null")
}

stop.rasterplot <- function(plot=TRUE) {
    raster.image <- dev.capture(native=TRUE)
    dev.off()
    if (plot) {
        grid.raster(raster.image,width=unit(1,"npc"),height=unit(1,"npc"))
        return(invisible())
    } else {
        return(raster.image)
    }
}

Now we can do the following:

pdf(file="raster.pdf")
start.rasterplot()
print(xyplot(y~x,
      data=data.frame(y=rnorm(1E8),x=rnorm(1E8))))
stop.rasterplot()
dev.off()

and our PDF will contain a raster image, and will load in seconds instead of taking forever to plot the file.

Debian Booth at Scale 12x

I spent the weekend at SCALE 12x running the Debian booth. SCALE is one of the best conferences that I get to attend every year; it has a great mix of commercial exhibitors and community groups, and routinely gets great speakers. As I've done for quite some time, I organized a Debian booth there, and talked to lots of people about Debian.

If you're in the Southern California area, or have a chance to give a talk for SCALE 13x, you should do so! Thanks again to Matt Kraai and Paul Hardy for helping out in the Debian booth all weekend!