Sunday, 29 April 2007

Moving to Ubuntu

I recently installed Ubuntu 6.10 on my laptop (dual boot with Windows XP). I already had my hard disk partitioned in two, C: for Windows, and D: for data. So, I copied D: onto a USB drive and then installed Ubuntu onto what was the D: partition.

Everything went well, and Ubuntu was up and running without any trouble. One most excellent resource I came across was Automatix which not only allowed me to easily install essential software, but it also introduced me to new software which I now consider essential.


  1. while the wireless network card worked immediately after the install, it hasn't worked since the first time I used the hibernate feature.

  2. battery life 'seems' severely reduced

A month or two goes by and Ubuntu 7.04 is released, so I did and upgrade through the update manager. It only took 10mins for me to download the 1Gig of update (at over 1000kbps on my cable broadband connection), but it took about 50 minutes to install.

I was hoping this would fix the wireless connection and power consumption problems, but instead it broke the hibernate feature. So now I had no wireless and couldn't hibernate and a battery that only just lasted the train trip to and from work. I've just now fixed hibernation by following Robin Battey's comment on this blog (it's the 4th comment). However, after resuming my usb mouse doesn't work (this is plugged into a USB hub which in turn has several USB devices attached). I'll have to try this a few more times and see if it stays broken.

I've just now begun looking into the wireless issue. Looking in /var/log/dmesg I see:

[ 20.460000] NET: Registered protocol family 23
[ 20.700000] ipw2200: Radio Frequency Kill Switch is On:
[ 20.700000] Kill switch must be turned off for wireless
networking to work.
[ 20.700000] ipw2200: Detected geography ZZR (14 802.11bg
channels, 0 802.11a channels)

so at least I have a trail to follow now. More on this later, if I make any progress...

Update 1 : I haven't had much time for fault finding this, but I did notice Beagle updating its database - possible source of battery drain - lucky there is a 'Index data while on battery power' option which can be disabled. Maybe this will help. I'll probably just go for a clean reinstall and see what happens. Not something I'm looking forward to though...

Update 2 : Just thought I'd mention that I've also had problems with my USB mouse after resuming. I've got a USB hub with a few things plugged into it and maybe this is causing some grief. I'll have to stop using the hub and see if things improve.

Monday, 23 April 2007

Getting to know Groovy

I've recently become interested in Groovy because of its very cool language enhancements, and ease of use. One of the stated goals is to make 'writing concise meaningful maintainable code easier'. I first used it just to write some simple utility scripts, but it in the future I hope to write some full applications (swing and web based) using it to see just how productive it can be.

To get started, I bought the Groovy in Action book. This is very well written and was easy to work through, and covered so much information I think I'll be going back through it many times.

If you are interested in Groovy, then you should have a look at these resources:

Some more specific references that you'll need once you start playing with Groovy:

As I was working through the book, I wrote my own sample code to test out the new language features and to help get a grasp on the new syntax. In case you are interested, I've included this code below:

Sample Groovy script to demonstrate language features
// semi-colons optional
// asserts are enabled by default
println "\n\n### ASSERTS ### "
assert 1==1
def value = 2
try {
assert 1==value
assert false
} catch (AssertionError e) {
assert true
// gstrings
println "\n\n### GSTRINGS ### "
def firstName = "MC"
String lastName = "Hammer"
assert "Hello MC Hammer"=="Hello ${firstName} ${lastName}"
String multiline = """This
is a multiline gstring
${lastName} time!"""
assert "This\nis a multiline gstring\nHammer time!"==multiline
// everything is an object - no primitives
println "\n\n### OBJECTS ### "
def a = 10
def b = 20
assert a+b==30
// notice the language enhancements (java.lang.Number
assert b.minus(a)==10
assert 'java.lang.Integer'==a.getClass().getName()
// Ranges
println "\n\n### RANGES ### "
def myRange = 1..5
assert myRange.size()==5
assert myRange.contains(4)
// Lists
println "\n\n### Lists ### "
def myList = []
myList += '1'
assert myList == ['1']
myList += ['2','3']
assert ["1","2","3"] == myList
def otherList = ['2']
assert ["2"] == myList.grep(otherList)
// Closures
println "\n\n### CLOSURES ### "
// standard java (can't use standard for loop)
for(Iterator i = myList.iterator(); i.hasNext();) {
// standard java (using while loop)
String result1 = ''
Iterator i = myList.iterator();
while(i.hasNext()) {
assert '123'==result1
// groovy
String result2 = ''
myList.each { item -> result2+=item }
assert '123'==result2
String result3 = ''
myList.each { item -> result3 += item*2 }
assert '112233'==result3
class MethodClosureSample {
int limit
MethodClosureSample (int limit) {
this.limit = limit
boolean validate (String value) {
return value.length() <= limit
def MethodClosureSample first = new MethodClosureSample (6) //#1
def MethodClosureSample second = new MethodClosureSample (5) //#1
def Closure firstClosure = first.&validate //#2
def words = ['long string', 'medium', 'short', 'tiny']
// java.util.collection.find(Closure)
assert 'medium' == words.find (firstClosure) //#3
assert 'short' == words.find (second.&validate) //#4
// Looping
println "\n\n### LOOPING ### ";
def store = ""
for(x in [1,2,3]) {
assert store == "123"
for(x in 1..3) {
assert store == "123"
store = ""
(1..3).each { store+=it }
assert store == "123"
println "\n\n### CONSTRUCTORS AND PROPERTIES ### "
class MyClass1 {
String name
void setName(String n) {
name = n?.toUpperCase() // NPE safe
String toString() {
return "myclass1 -> name : ${name}"
def c1 = new MyClass1(name: 'MC Hammer')
assert "myclass1 -> name : MC HAMMER" == c1.toString()
assert == 'MC HAMMER'
assert c1.getName() == 'MC HAMMER' // auto created getter (and setter) only if they don't already exist
assert 'BUSTARHYMES' == c1.@name // direct access to field
// protection from Null Pointer Exception
assert null == c1?.name?.toLowerCase()

Saturday, 14 April 2007

USB Hard Drive enclosure

I've got a couple of PATA harddrives from old computers lying around and recently I needed some extra disk space to shift some things around and for backup. So I bought a USB Hard Drive enclosure (NexStar 3).

Since I have a windows laptop and a Linux desktop, I really wanted to be able to use it with both, so, what disk format to use?

From what I've read, Linux access to NTFS is getting better, but still not 100%. On the other hand, with this nifty little program Ext2 IFS For Windows windows can mount EXT2 volumes. So, I've formatted it as EXT3 (backwards compatible with EXT2) and have successfully used it on both platforms.

I had one little confusing incident, where windows refused to recognise the disk and wanted to format it รข€“ but reading the FAQ for Ext2 IFS the author documents how (when using a journalled filesystem such as EXT) if anything is in the journal then windows won't mount the volume since it is mounting as EXT2 (unjournalled). In any case, to get things working again I just reattached it to the linux machine and shutdown cleanly.

Alternatives to the USB enclosure could be a Network Storage device or a hard disk caddy for the desktop. I wonder if anyone makes a USB hard disk caddy?

Monday, 9 April 2007

Copying files between linux machines

Being a Windows user and new to Linux I automatically started looking around for a Linux equivalent of WinSCP. I've just recently installed Linux on my laptop, and when I wanted to browse the file system of my desktop, it suddenly occurred to me that I might be able to just browse it through Nautilus.

It turns out to be really simple in Gnome: just go to 'Places' in the menu bar and select 'Connect to server...'. From here you can pick from several different protocols (including FTP, SSH, Windows share).

I just needed to specify SSH, and supply the desktops details and then I could see the server in the Nautilus tree. Fantastic!

Details : Ubuntu 6.10 (Linux laptop1 2.6.17-11-generic #2 SMP Thu Feb 1 19:52:28 UTC 2007 i686 GNU/Linux)

SoundJuicer and MP3

By default, SoundJuicer doesn't give you an option to extract to MP3. You need to set up an MP3 profile to do this, as described here. Note though, when I tried it I had to restart SoundJuicer before Mp3 turned up in the Output Format list (under preferences).

Details : Ubuntu 6.10 (Linux laptop1 2.6.17-11-generic #2 SMP Thu Feb 1 19:52:28 UTC 2007 i686 GNU/Linux)