Thursday, March 4, 2010

Fonts in rumai (wmii)

How do you know what fonts you can use in rumai or wmii?
xlsfonts will list all the fonts in the format that wmii expects:

xlsfonts > available_fonts.txt

You can use the '*' symbol to generalize. Here are some that work ok. Some are quite ugly, others OK:

-*-fixed-medium-r-*-*-18-*-*-*-*-*-*-*
-*-fixed-bold-r-*-*-12-*-*-*-*-*-*-*
-*-fixed-medium-r-*-*-12-*-*-*-*-*-*-*
lucidasans-bold-12
-adobe-helvetica-medium-r-*-*-12
-adobe-helvetica-bold-r-*-*-12
-adobe-palatino-bold-r-*-*-14
-*-lucida-bold-r-*-*-12
-*-dejavu sans mono-medium-r-*-*-14
-*-dejavu sans mono-medium-r-*-*-14

Tuesday, March 2, 2010

wmii (rumai) with gnome in Ubuntu 9.10 & 10.04

NOTE: modified from here

This is a step by step to install rumai as the windows manager in gnome.

  1. install necessary packages
  2. 
    sudo apt-get install dwm-tools # for menus
    sudo apt-get install libixp libx11-dev  # for the install itself (necessary??)
    On Lucid Lynx I needed to install these two packages also:
    sudo apt-get install 9base libxft2-dev   # plan 9 file system (need on 10.04)
  3. Install a good build
  4. The Ubuntu wmii packages (karmic? and jaunty?) and even the current repo can be buggy. Download a solid build (hg2474) here or here. Unpack it, go into the src directory and sudo make install.
  5. modify some gnome settings
  6. 
    gconftool-2 -s /apps/nautilus/preferences/show_desktop --type bool false
    gconftool-2 -s /desktop/gnome/background/draw_background --type bool false
    ## Tell gnome to use wmii as the window manager
    gconftool-2 -s /desktop/gnome/session/required_components/windowmanager wmii --type string
  7. have wmii fire up at login
  8. System -> Preferences -> Startup Applications Add an entry for /usr/bin/wmii
  9. get rumai
  10. make sure you have ruby and rubygems. Works great with ruby 1.9. (I'm using 1.9.1)
    gem install rumai
    Also make sure your rubygems are executable by adding something like this to your .bashrc:
    export PATH="$PATH:$HOME/.gem/ruby/`ruby -e 'print RUBY_VERSION'`/bin"
  11. grab a rumai config wmiirc
  12. To make it easy for beginners, my master branch work's out of the box:
    git clone git://github.com/jtprince/wmiirc.git ~/.wmii
    For more advanced possibilities, you'll want to start with sunaku's and then branch, etc.:
    git clone git://github.com/sunaku/wmiirc.git ~/.wmii
    Now make a soft link to the file this wmii will be looking in:
    ln -s ~/.wmii ~/.wmii-hg
    Now logout and back in and it should work. This is pretty stable and works pretty well. If wmii crashes, restart in a terminal or from the panel (add a "run application") with the command "wmii" or "killall wmii && wmii".

Friday, January 8, 2010

multifactorial plotting in R: lattice

I've mentioned before in personal communications that if you have lots of factors in a data set you can just flatten out the data set and then use openoffice data pilot to pivot around different factors (also can be done in ruby with Ruport and 'pivot'). This is a good method.

There is a much better method I recently came across: "trellis plots". The package in R is called lattice.

This is clearly the way to quickly and neatly plot multifactorial data in lots of meaningful ways.

Some resources:
In R (as sudo if you want system wide installation):
install.packages("lattice", dependencies=TRUE)  # I don't think there are any dependencies
library("lattice")

Monday, January 4, 2010

pymix compilation errors on Ubuntu

pymix was a little tricky to compile. Here's what I did to get it working.

I downloaded and installed numpy [but that is probably not necessary].

Then I finally had to go into pymix's setup.py and change the location for where it was looking for arrayobject.h:
From:
numpypath = prefix + '/lib/python' +pyvs + '/site-packages/numpy/core/include/numpy' # path to arrayobject.h
To:
numpypath = '/usr/share/pyshared/numpy/core/include/numpy' # path to arrayobject.h

At this point, 'python setup.py build' worked, but the install failed with this error:

byte-compiling /usr/local/lib/python2.6/dist-packages/AminoAcidPropertyPrior.py to AminoAcidPropertyPrior.pyc
SyntaxError: ('invalid syntax', ('/usr/local/lib/python2.6/dist-packages/AminoAcidPropertyPrior.py', 170, 14, ' as = alpha.pop(0)\n'))

turns out that 'as' is a reserved keyword in python 2.6, so you need to go in to that file and change it to something else, like: nada = alpha.pop(0)

Tuesday, December 15, 2009

Bayesian Optimal Discovery Procedure (BODP) R code

The r code given as an additional file to the paper Bayesian optimal discovery procedure for simultaneous significance testing requires your data to be in matrix form. I spent a day trying to troubleshoot the code when all you need to do is the following:

Open R
Copy and paste the R code from Cao et al.
x<-read.table("x.txt") #your control state
y<-read.table("y.txt") #your test state
x<-as.matrix(x)
y<-as.matrix(y)
BODP(x,y,1000,10) #feel free to change 1000 and 10 to whatever you'd like

Sunday, November 29, 2009

A thread I started a while ago suggests a solution to getting hibernation and suspend working properly with nvidia cards on Inspiron 5160 in Ubuntu. At least as of Karmic Koala (9.10), the solution one-line easier:

In the device section of /etc/X11/xorg.conf add the line:
Option "NvAGP" "1"

To /etc/modprobe.d/blacklist.conf add the following:
blacklist intel_agp

then reboot

slow browsing in firefox in Ubuntu 9.10 Karmic Koala

type in about:config into the browser bar

change the value of the key "network.dns.disableIPv6" from 'false' to 'true'

drastically increased browsing speed for me.

Saturday, November 14, 2009

a little Perl spice for ruby

An insightful blog post got me envying some of the brevity of Perl, so I implemented a couple useful idioms from Test::More in Ruby (which is pretty trivial since it allows opening up a class).

We'd like to have a really terse vocabulary when describing the most common test cases:

## equality
num = 8
num.should.equal 8 # bacon
num.must_equal 8 # minitest::spec
num.should == 8 # rspec
num.is 8 # clearly superior, similar to Test::More "is a, b"

## true/false
(num == 8).should.be.true # bacon
(num == 8).ok # superior, like Test::more "ok (something)"


So, for Bacon at least, this is all that needs to be done (put in your spec_helper.rb file)

class Object
def is(arg)
should.equal(arg)
end
def ok
should.equal true
end
end


The argument against this would go, "well, it's better to be more verbose and understood". The counter-argument something like, "this still makes sense and is way easier to write, so I can write more spec's which == better code".

Monday, October 12, 2009

wxruby: wxWidgets for ruby on Ubuntu

A nice link on how to get the basic wxruby (wxWidgets for ruby) going on Ubuntu/debian.

Some examples in the examples folder require some more libraries. For instance, the opengl example requires libopengl-ruby (and maybe freeglut3 libglut [??]) and one of the drawing examples requires librmagick-ruby.

So this should be enough to get you going with most of the examples:
sudo apt-get install libwxbase2.8-{0,dev} libwxgtk2.8-{0,dev} librmagick-ruby libopengl-ruby
sudo gem install wxruby

Saturday, October 10, 2009

how to safely delete things in Ubuntu/Linux

I accidentally performed a `rm -rf` on a very big and important directory. I was able to recover close to half of the files using extundelete, but it still left me with a sour taste in my mouth. Now that there is a solid freedesktop specification for how to Trash things, it seems high time to remedy this situation.

In my ~/.bashrc file:
if [ ! `which gvfs-trash 2>/dev/null` ]
then
alias dl='mv -t ~/.Trash/' # for older systems
else
alias dl='gvfs-trash'
fi
So, now we can simply dl files and they go to a safe place. Still, I find myself using rm, so this little alias will help cure my addiction, by reminding me that I should be using dl instead of rm. I can still use the rm command by putting it in single quotes (that's how to get past any alias) as in: 'rm' -rf some_directory.
alias rm="echo \"use dl or 'rm'\""

Wednesday, October 7, 2009

How to share a VirtualBox virtual machine with multiple users on Linux/Ubuntu

Have you ever wanted to share your virtual machine with other users? Doing so will save a lot of space (since you only need one virtual machine) and keep you more in line with the EULA of the distribution you are running virtual (assuming that's Windows or Mac).

There are many tutorials online (for example) that will help you to install VirtualBox on your linux machine. A couple things to note:
  1. You probably want to use the package from the VirtualBox download site (and not the open source one that you can get with apt-get) since it has many of the features that are important for a good virtual machine (like USB support and OpenGL acceleration etc).

  2. Make sure a vboxusers group was created and that everyone who would want to use the virtual machine is part of that group.
Prerequisite: right now the only way I can get this to work is if everyone wanting to share the virtual machine has sudo privileges. I'd be interested if anyone can suggest a way to do this without them. OK, we're ready to start:
  1. Make a shared directory for your virtual machines:
    sudo mkdir /var/local/VirtualBox
  2. Create a soft link from the home directory of each user sharing:
    ln -s /var/local/VirtualBox $HOME/.VirtualBox
  3. Now create a custom application launcher for your panel:
    sh -c "gksudo 'chown -R $USER:$USER /var/local/VirtualBox'; VirtualBox"
    (that command [or similar] could be wrapped up in a .bashrc function, a script placed in your $HOME/bin directory or whatever).
Also, remember when you buy your next computer to think about getting one with virtualization capabilities (for instance, an intel chart of core 2 duo desktop processors which support virtualization)

Sunday, September 20, 2009

Make coloring pages from any picture for free

Download and install GIMP.
windows download or ubuntu (sudo apt-get install gimp).

In GIMP,

Filters -> Artistic -> Photocopy

A dialog box will allow you to adjust the sharpness and amount of black and white you want to see with a preview.

That's it!