Programmer

JabRef and xmonad

I use JabRef for BibTeX reference management. It has a handy GUI and a nice web search feature so you don’t have to manually type in entries. But it apparently doesn’t like to work with tiling window managers like xmonad. If you start JabRef in xmonad, you just get a blank white/gray box with only a File > Close menu option and nothing else. This makes it completely unusable.

It took me a while to google up a solution since there were a few false starts with some sort of MToolkit vs XToolkit option in Java but it turns out you can just set the environmental variable _JAVA_AWT_WM_NONREPARENTING=1 and things will start working correctly.

So if jabref is in your path you could make an alias for jabref like:
alias jabref="_JAVA_AWT_WM_NONREPARENTING=1 jabref"
and then just type jabref and it should work normally.

LaTeX
Programmer

Comments (0)

Permalink

Handy Apply-based R Progress Bars

In a funny congruence with my post on R progress bars, Mark Heckmann just posted about some wrappers for the apply functions in R. He wrote up some functions that imitate sapply, lapply and apply but automatically add a progress bar so you can monitor the progress. They work very nice since you can just substitute his apply_pb‘s in place of R’s standard apply‘s. He says it’s a bit of a performance drag but after testing a bit it looks like they really shouldn’t add much overhead at all if there’s any major calculations inside the loop. Very handy.

Programmer
R

Comments (0)

Permalink

Progress Bars in R

Recently, I’ve had a lot of time consuming tasks running in R where it’s nice to know how the computer is doing. I usually just output the name of the current iteration or a dot or something but I finally decided I should figure out how to make a nice progress bar in R. It turns out it’s really simple since it’s already builtin with the txtProgressBar function. So you can do something like:

[R] numberSteps

That’s good enough for me but there’s also winProgressBar for a fancy Windows progress bar and tkProgressBar (in the tcltk package) if you really want to get fancy.

Programmer
R

Comments (2)

Permalink

Syntax highlighting in terminal

Syntax highlighted cat I was just quickly flipping through code on a terminal and got to thinking that it would be pretty handy to be able to syntax highlight when using head or grep without having to open an editor. Luckily, I remembered Pygmentize was pretty handy when syntax highlighting in LaTeX so I wondered if they had an equivalent output for terminal. It turns out they do (in standard or 256 color no less) so in a couple minutes I had a really short script for highlighting code at the terminal saved it to bin/ccat and was ready to go. Pygmentize really is impressive. Here’s the script if anyone else is looking to do the same: [bash] #!/bin/bash if [ ! -t 0 ];then file=/dev/stdin elif [ -f $1 ];then file=$1 else echo “Usage: $0 code.c” echo “or e.g. head code.c|$0” exit 1 fi pygmentize -f terminal -g $file [/bash] It just looks for stdin and if it doesn’t find it it looks for a file name or takes direct input. Obviously it requires Pygmentize (which is really easy to install if you already have Python).

Bash/UNIX
Programmer

Comments (7)

Permalink

Tab Indented Standard Input Redirect in Bash

I managed to forget how to redirect standard input (when you want to feed a bunch of lines to a program) in a bash script while still indenting and had to go digging around for it. So I figured I’d make a note here so I don’t forget again and for anyone else in the same boat. It’s just <<- instead of <<. For example if you want to keep indentation within a loop:

[bash] for i in 1 2 3 4;do catYou can use whatever you want to indicate the end of the input instead of EOF if it floats your boat (as long as you use the same thing both times) but unfortunately <<- doesn’t work with spaces for indentation (although I’m a tab man myself).

Bash/UNIX
Programmer

Comments (2)

Permalink