2011-02-10

Separate input per window in Irssi

In Irssi, "the client of the future", the input box behaves differently by default from the input box in other clients, for example XChat. In XChat, each window or tab has it's own input buffer, so you can draft a statement in one window while still conversing separately in other windows. In Irssi, the default behavior is to for there to be only one input buffer, which persists as you change windows.

To get a separate input buffer for each window (while still pooling the input history), see this script.

2011-01-28

Color control with matplotlib

Sometimes it's important to control the color of lines drawn with matplotlib. Two examples I encountered today were drawing a number of horizontal or vertical lines on the same axes and drawing more lines than the number of unique colors in the default color ring. Here's how you can use a colormap to get the desired number of colors:

import matplotlib.pyplot as plt
cmap = plt.get_cmap ('gist_rainbow')
num_colors = 10
for i in xrange (num_colors):
    plt.axhline (i, color = cmap (1.0 * i / num_colors))

2010-11-01

to title case, at the shell

This filter turns the input into "Title Case".

cat [whatever] \
| sed 's/.*/\L&/; s/[a-z]*/\u&/g'

Courtesy of this post.

2010-08-26

Python string concatenation

Looks like the fastest way to assemble your strings, in general, is by generating lists and then calling '{separator}'.join ({string list}), according to Oliver Crow.

2010-05-12

Boost, Autoconf configure error

After upgrading tu Ubuntu 10.04, I started having a problem using an Autoconf-generated configure script to detect the Boost libraries. Ultimately, the problem turned out to be that the libraries just were not installed anymore! Here's what the configure output looked like:

checking for boostlib >= 1.38.0... yes
checking whether the Boost::Filesystem library is available... yes
configure: error: Could not link against  !
Note the two spaces before the "!". That's where the library name should be, if it were even found. So apparently I had the headers left over somehow, but the library had been uninstalled. Something to keep in mind if you see such an error...

2010-04-19

Extract a single file from a tarball

If you've got a tarball with a particular file that you want to extract to standard output, use a command like the following:

tar zxf0 {the tarball} {path to desired file within tarball}