Widget_logo
Welcome!
Cheap USB Webcam for Mac OS X

This is something I've been meaning to post about for a little while now. A couple of weeks back, whilst looking for a USB headset (the Mac Mini doesn't support unpowered microphones in its mic jack) I came across the Logitech QuickCam E2500.

Out of the box, this little webcam's mic works on Mac's (albeit with slight interruptions of huge static,at which point you need to restart the connection) but the webcam won't. In order to get the webcam working, you need to download the bleeding edge copy (version 2009-02-06) of Macam. This can be obtained from the Sourceforge download page. When I tried the current version 0.9.2 (the current version) it didn't work, but YMMV.

Once you've got that installed, you'll be able to use the webcam on your Mac. That is, with the notable exception of in iChat, for which you will need iChatUSBCam (which is shareware and thus I haven't tested it). Works okay with Skype, though...

Tweet, tweet

I really need to get my Twitter feed integrated over here, don't I?

REXML: Why Attribute Queries Won't Work

After using REXML as the XML parser for my dissertation for a while now I suddenly came up against a big problem with it. Basically, I was trying to bring back elements of a large XML document based on its attributes. the XPATH do this is something like the following, where "song" is the element and "genre_id" is the attribute:

//song[@genre_id=30]

That should return all elements named "song" with an attribute named "genre_id" that equals 30. Except it didn't.

Now, being as REXML is the default XML parser included in the Ruby library I figured it would be well tested and this must be a bug in my code. I spent about 3 hours working out that, in actual fact, the problem lies with REXML.

The long and short of it is this: querying using attributes when you use the default namespace tag in your XML document is broken. It will always return nil. 

Luckily enough for me (and anyone here looking for a solution to the problem) Sam Ruby has solved the problem with a monkey patch. Monkey patches in Ruby are dynamically loaded patch that extends or modifies code in Ruby without altering the source code. Put the following in a ruby (.rb) file, anywhere you like:

require 'rexml/document'
doc = REXML::Document.new '<doc xmlns="ns"><item name="foo"/></doc>'
if not doc.root.elements["item[@name='foo']"]
class REXML::Element
def attribute( name, namespace=nil )
prefix = nil
prefix = namespaces.index(namespace) if namespace
prefix = nil if prefix == 'xmlns'
attributes.get_attribute( "#{prefix ? prefix + ':' : ''}#{name}" )
end
end
end

Then issue the following in a terminal:

export RUBYOPT='-rubygems -r/home/rubys/bin/monkey_patches'

That should solve the problem.

NC4000 Battery

Currently my laptop won't run on its battery. Or rather, it'll only run for 5 minutes without any mains. That's pretty poor and shows my battery is dead (it is over a year old, which is roughly the right lifespan).

Today I bought a new battery. It cost roughly £34 but I was pretty amazed at the distribution of costs for my little laptop battery. Mine was the cheapest I found for my HP NC4000 but others were around £60 in total. Just goes to show you; when buying laptop batteries it pays to shop around.

Skype Says: "Unable to mount database"

I'm not sure but I think this one may be specific to the Mac. Still, thought it was worth mentioning.

Recently I bought a Skype kit and decided to have another go at it, having use and left it before. I opened up Skype, tried to login and recieved the error: "Unable to mount database". A quick Google yielded some results; this posting on the Skype forum was the best. Basically, the guy tells you to:

  1. Go into <Your home directory>/Library/Application Support/Skype/ in Finder
  2. Delete the folder named after your Skype username.
  3. Close Skype 
  4. Open Skype
  5. Log in as normal
That should solve the problem; at least it did for me. Some of the other information I came across pointed to some kind of corruption of a profile file in that directory that then caused Skype to throw a wobbly for that particular user. Looks like pretty poor programming on behalf of Skype, though. Us Mac users aren't usd to uninformative errors...