Category Archives: linux

Redmine + Gitolite integration

I’m a big fan of both Redmine, the project management web application and Git, the distributed version control system.

Recently, I learned that it’s possible to integrate Git into Redmine so that git repositories for a project can be created via the Redmine web interface. This is done using plugins which connect Redmine with git hosting software: either gitosis or more recently, gitolite.

Unfortunately, this is a deeply-confusing process for novices like myself. There are multiple forks of the plugins, long threads in the Redmine forums that discuss various hacks/tweaks to make things work and no one authoritative source of documentation. After much experimentation, this is what worked for me. I can’t guarantee success for you.

Read the rest…

R 2.12 to 2.13 package upgrade

If you:

  • use Linux
  • have just upgraded your R installation from 2.12 to 2.13
  • installed some/all of your packages in your home area (e.g. ~/R/i486-pc-linux-gnu-library/2.12) and…
  • …are wondering why R can’t see them any more

just do this:

# at a shell prompt
cp -r ~/R/i486-pc-linux-gnu-library/2.12 ~/R/i486-pc-linux-gnu-library/2.13
# in R console
update.packages(checkBuilt=TRUE, ask=FALSE)
# back to the shell
rm -rf ~/R/i486-pc-linux-gnu-library/2.12

update: corrected a typo; of course you need “cp -r”

Dropbox tip continued: convert a file tree to HTML

A couple of posts ago, I outlined a small bash script to generate an index.html file, containing links to other files in a directory. This was for generating links to files in a Dropbox public directory.

I had completely forgotten about the very useful UNIX/Linux command named tree. If not installed, it should be in your distribution repository (e.g. sudo apt-get install tree for Ubuntu/Debian). Then simply:

cd Dropbox/Public/mydirectory
tree -H . > index.html
Next, navigate to index.html at the Dropbox website and you should see something like the tree on the right. It’s a little ugly and obviously, not as convenient as something like Github, but can be a good quick and dirty fix if you need to share a hierarchy of directories and files.

First cautious steps with CUDA

I recently obtained an account on our GPU cluster, so I thought I should get my head around some of the technology that drives GPU computing.
Put simply, GPUs can be used to perform calculations and since there are many processors on a GPU, this can lead to quite substantial speed increases as compared with CPUs. NVIDIA are leading the way and they provide libraries and software tools for people interested in this field.
Development is typically performed using C, C++ or Fortran. I’m not a compiled languages guy – I could just about manage a hello world in C – so I’m relying on tools built by other people, such as R gputools.
Step 1 is to download and install the required libraries, toolkit and possibly, drivers. I ran into a couple of minor problems on my machine, so I thought I’d document them here.
Read the rest…

MongoDB and Ubuntu 10.04

Fans of MongoDB and Ubuntu, rejoice. Installation just got easier, with the appearance of mongodb in the Ubuntu repositories.

However – the latest version in lucid is 1.2.2, whereas you want the very latest, 1.4.2. All the instructions are here. As usual, it’s just a case of adding a line to your sources list, importing a GPG key and then:

sudo apt-get update
sudo apt-get install mongodb-stable

Configuration lives in /etc/mongodb.conf, databases live in /var/lib/mongodb, logging goes to /var/log/mongodb/*.log.

What I learned this week about: productivity, MongoDB and nginx

Productivity
It was an excellent week. It was also a week in which I payed much less attention than usual to Twitter and FriendFeed. Something to think about…

MongoDB
I’m now using MongoDB so frequently that I’d like the database server to start up on boot and stay running. There are 2 init scripts for Debian/Ubuntu in this Google Groups thread. I followed the instructions in the second post, with minor modifications to the script:

# I like to keep mongodb in /opt
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/mongodb/bin
DAEMON=/opt/mongodb/bin/mongod
# you don't need 'run' in these options
DAEMON_OPTS='--dbpath /data/db'
# I prefer lower-case name for the PID file
NAME=mongodb
# I think /data/db should be owned by the mongodb user
sudo chown -R mongodb /data/db
# don't forget to make script executable and update-rc.d
sudo /usr/sbin/update-rc.d mongodb defaults

nginx (and Rails and mod_rails)
This week, I deployed my first working Rails application to a remote server. It’s nothing fancy – just a database front-end that some colleagues need to access. I went from no knowledge to deployment in half a day, thanks largely to this article, describing how to make nginx work with Phusion Passenger.

Along the way, I encountered a common problem: how do you serve multiple applications, each living in a subdirectory?

# You have:
/var/www/rails/myapp1
/var/www/rails/myapp2
# You want these URLs to work:

http://my.server.name:8080/app1


http://my.server.name:8080/app2

Here’s how to do that:

# Make sure the Rails public/ directories are owned by the web server user:
sudo chown -R www-data.www-data /var/www/myapp1/public /var/www/myapp2/public
# Make symbolic links from public/ to the location which will be the web server document root
sudo ln -s /var/www/myapp1/public /var/www/rails/app1
sudo ln -s /var/www/myapp2/public /var/www/rails/app2
# These are the key lines in the server section of nginx.conf:
server {
        listen       8080;
        server_name  my.server.name;
        root /var/www/rails;
        passenger_enabled on;
        passenger_base_uri /app1;
        passenger_base_uri /app2;
}

That’s me for the week.

Brief notes on Ubuntu 9.04 (jaunty) -> 9.10 (karmic)

Recording my Ubuntu upgrade experience has become something of a tradition, so here goes.

  • Machine 1 (laptop, LG T1 Express Duo). Largely trouble-free. On-board soundcard not seen on reboot. Fixed (temporarily, lost on reboot) using “sudo alsa force-reload”.
  • Machine 2 (various generic hardware, cobbled together over many years). Upgrade smooth until final restart, when machine froze. Rebooted to a blank screen. Fixed by swapping out ATI video card for old NVidia FX5200. Discovered that rsyslog is running riot due to a hot CPU and is trying to fill up /var/log.
  • Machine 3 (Dell Optiplex GX550). Install froze at “stopping winbind server”. Rebooted with rescue CD, mounted and chroot-ed into Linux partition, tried “dpkg –force-all –configure -a”, but to no avail. Reinstalled in same partition, all is working well.

All in all, not very impressed. Canonical, could do better.

Fix Kile for Ubuntu 9.04

Ubuntu/jaunty rocks, on the whole. However, to prove that newer does not always equal better, they threw in a couple of shockers. The first is the upgrade from the excellent Amarok 1.4 to the completely-broken 2.0. Head here to repair the damage.

Kile is by far my favourite LaTeX editor and suffered, though not as badly, in the upgrade from 2.0 to 2.1. Reports of various problems litter the web; in my case I see broken toolbar buttons that do nothing when clicked. This fix is much simpler. Just “sudo apt-get remove kile”, scroll to the bottom of the intrepid package page, choose your architecture, download the deb file and “sudo dpkg -i kile_2.0.1-1ubuntu1_i386.deb”. I had no dependency problems and it works just fine.

Finally – open up Synaptic, find kile and from the Package menu item select “lock package”, to prevent future upgrades.

Update: a few days after writing this, an apt-get dist-upgrade upgraded my Kile to 2.1 (despite the “lock package”). However, the broken buttons issue is now fixed for me. Go figure…

Easy visualisation of database schemas using SQLFairy

BioSQL schema

BioSQL schema


Here’s a common problem solved: how to generate a pretty picture of your database schema. A Google search throws up all manner of home-brewed solutions using graphviz, perl scripts and so on. Or you can make life easier and simply install SQLFairy.

Under Ubuntu: as simple as “sudo apt-get install sqlfairy”.

Next, dump your database tables, e.g. for MySQL:

mysqldump -u username -p -d mydatabase > mydatabase.sql

Finally, for a PNG image of your schema:

sqlt-graph -f MySQL -o mydatabase.png -t png mydatabase.sql

Too easy. Example shown is the BioSQL schema.

update: if your schema lacks explicit foreign keys, try the –natural-join options (man sqlt-graph, man sqlt-diagram)

Text to fasta and other delights of the shell

One thing I’ve learned in my current job is that some familiarity with Linux tools for processing text files: awk, sed, grep, head/tail, cut/paste and so on, often provides a speedier solution than writing a script in (insert scripting language of choice here). I know this stuff is trivial to shell gurus, but I still get a little buzz out of it. A couple of real-life examples.
Read the rest…