the corner office : tech blog

a tech blog, by Colin Pretorius

Lightweight Linux distros

With each successive release the Ubuntu server VMWare image I run when I'm in XP gets more and more bloated.

{2010.07.04 02:38}

Converting my CVS repo

I've been using git for a while now, and I'm sold. New pet projects are going into git but I still had a years-old CVS repo, containing dozens upon dozens upon dozens of projects. After a few abortive attempts I managed to get the lot converted. This is how I did it.

I settled on cvs2git which is part of the cvs2svn toolset. A simple apt-get install cvs2svn on Ubuntu. I worked through the instructions on this page, which I'd linked to before.

You really need to run the conversion per module, because if you point cvs2git at your top-level CVSROOT, it'll mix up all tags and commit logs. I created the script below to automate the whole thing. My bash scripting skills are anything but l33t, but it did the job.

The steps:

  1. Create and change into a working directory. The script will create a convert subdirectory, into which all the converted modules will go.

  2. Create a copy of cvs2git-example.options (which a simple locate should find - probably somwhere in /usr/share/doc/cvs2svn/examples) in the working directory. Rename to cvs2git.options (or edit the script appropriately).

  3. In cvs2git.options, find the line containing text

    r'test-data/main-cvsrepos'
    

    and replace with

    os.getenv('CONVERT_MODULE'),
    

    That line tells cvs2git which repo to convert. Using an environment variable allows the bash script to repeatedly export the module to convert.

  4. Dump this script into the working directory:

    #!/bin/bash 
    # script to convert CVS repo to lots of git modules
    
    CFG_FILE=/path/to/working/dir/cvs2git.options
    REPO=/path/to/my/cvsroot
    
    function generate_blob {
    	export CONVERT_MODULE=$REPO/$1
    	cvs2git --options=$CFG_FILE	
    }
    
    function git_from_blob {
    	if [ -d $1 ] 
    	then
    		rm -rf $1
    	fi
    	mkdir convert/$1
    	cd convert/$1
    	git init
    	cat ../../cvs2svn-tmp/git-blob.dat ../../cvs2svn-tmp/git-dump.dat | git fast-import
    	git checkout master
    	cd ../../
    	rm -rf cvs2svn-tmp
    }
    
    function convert {
    	if [ -d cvs2svn-tmp ] 
    	then
    		rm -rf cvs2svn-tmp
    	fi
    	if [ ! -d convert ]
    	then
    		mkdir convert
    	fi
    	generate_blob $1
    	git_from_blob $1
    }
    
    for FILE in `ls $REPO`; 
    do
    	convert $FILE
    done
    

  5. Run the script. The 'Already on master' warnings come from the git checkout master command, which is needed to actually check out code from the newly created git repos. It doesn't seem to have any adverse effects, and if the repo isn't going to be used in-place the git checkout could probably be removed.

All seems fine after the conversion, which is to say all tags and commit logs seem to be in place.

{2010.06.24 15:12}

YAML

StackOverflow: Which Java YAML library should I use?

{2010.06.23 15:46}

Slow Ubuntu server logins

Getting rid of all the login startup gumpf in recent versions of Ubuntu server: (see eg. Ubuntu forums Server 10.04: How to Eradicate the MOTD System?)

sudo apt-get purge landscape-common landscape-client
sudo chmod -x /etc/update-motd.d/*

You can probably delete 'em just as easily. Put something friendly in /etc/motd to compensate.

(As a reminder, the other slow login culprit can often be if the server can't resolve the client's hostname, usually fixed on local machines or VMs by adding an entry to /etc/hosts.)

{2010.05.30 02:08}

More git links

{2010.05.25 13:04}

git on windows

Not as simple as on Linux.

{2010.05.22 02:56}

The Dark Magic of Structured Finance

The Dark Magic of Structured Finance:

Suppose that we misspecified the underlying probability of mortgage default and we later discover the true probability is not .05 but .06. In terms of our original mortgages the true default rate is 20 percent higher than we thought--not good but not deadly either. However, with this small error, the probability of default in the 10 tranche jumps from p=.0282 to p=.0775, a 175% increase. Moreover, the probability of default of the CDO jumps from p=.0005 to p=.247, a 45,000% increase!

I still think that the popular idea that the people creating these things were too stupid to know that there would be these 'glitches' is unsatisfying.

{2010.05.14 16:27}

Java AMQP fun

I'm playing Eve Online again. There's a site called eve-metrics.com which has become a monster data hub. They spray their incoming data feeds via AMQP. Cool, thinks I, this'll be fun to play with and will make a change from JMS and the homegrown messaging systems I do battle with for a living.

There seem to be two main AMQP contenders in java. First up - RabbitMQ. Nifty, lots of people I know have said nice things about Rabbit. I copy and paste the maven snippet (no need to fire off IDE searches), I hack an example, I'm up and running after a few errors. Every time something bombs out I get a long cryptic error message from Rabbit. That's OK, it's got enough detail to make sense to me and be google-friendly. I'm up and running within minutes. The client's still bombing out with various network/frame size issues after a few messages, though. Perhaps it's a version thing? Maybe it's an issue with the AMQP broker? I'm a total n00b at this, so maybe I should try another implementation to see.

The alternative for Java is Apache QPID. Oh dear. It's an Apache project, but no public maven repository. Some outdated version in a repo, but not the latest. Gee, it's been a while since I had to manually hook jar files into an Eclipse project, but OK - I download the .tgz. and get it all linked up. This includes hooking in an slf4j binding, which needs manual linking because I'm no longer in maven country. This isn't fun.

Examples and tutorials? Lots of and lots of links on the site, but the Java stuff I want is just a link to example code in the svn repo. Which means I have to fire up an svn client and check out the code. Lots of code.

I dig around a bit. I try a topic listener. Self-contained, can't be too bad, can it? Sadly, not. I *think* I've got the connection details right, but every time I call con.connect() with what I think are a reasonable set of parameters, I get a ConnectionException. With absolutely no error message. Looking at the stack trace, it's an IllegalStateException in InputHandler.next(). Whatever that is.

Not cool. I could crack open the class and see what's actually happening to cause the IllegalStateException, except that I don't have the freakin' source code because this isn't a maven project and I'd have to go downloading sources and manually link them. No way, just no way.

At which point I decide that between an error with no error message and a lot of effort before I can try to make progress, I'm giving up on QPID.

It's not fair to knock open-source projects, it's not like I'm paying for any of this, and these people are sharing their code - good on them. But if you're going to share software, it's a shame if it's not doing simple things to make users' lives easier. In this day and age, and especially when there are other competitors, that means things like maven repos, like a wiki page saying 'do it like so', and spitting out sensible error messages. Especially if you enjoy the eminence of being an official Apache project.

If the code's bombing out on line 2, with no way to figure out how to resolve the problem, then you're losing potential contributors and users.

Update: and after a bit more playing and digging through the Javadocs, and convincing myself that everything worked fine by using a Python implementation, I worked through the problems I was having with the RabbitMQ test client, and now it's working like a charm. Happy, me.

{2010.04.16 16:05}

C4251

I'm playing with Visual Studio again.

Compiler warning C4251. Oh, the trouble a std::vector can cause in a dll.

{2010.04.03 14:07}

Firefox tab close buttons

I have Firefox set up at home to only have the close button at the end of the tab row, and not on each tab. I remember finding a setting for this years ago when the behaviour changed after an upgrade. I thought I'd blogged about it, but Google-says-nooo.

Anyhow, I use the close-on-every-tab default on my work Firefox and finally decided to make peace with close-on-every-tab at home as well. I searched for the setting and found an old article which reminds me that this is a feature change that happened between Firefox 1.x and 2.0. Firefox is already up to 3.6. Sheesh!

Anyhow, for posterity, the setting (in about:config) is browser.tabs.closeButtons and the options (nicked from the article) are:

  • 0 - Display a close button on the active tab only
  • 1 - Display a close button on each tab (default)
  • 2 - Don't display any close buttons
  • 3 - Display a single close button at the end of the tab bar (Firefox 1.x behavior)

{2010.04.03 08:28}

« Older | Newer »