Tuesday 17 February 2009

Review - sansa clip ogg/mp3 player

With Linux cranks and the bad apples podcasts going to ogg only, I decided to invest in a new player.

The sansa clip seemed to fit the bill perfectly, for the following reasons.
  • mounts as a drive, easy drag and drop of files

  • plays ogg

  • built in fm radio

  • small

  • cheap

  • sexy

but it turns out that this is the best damn player I've ever owned... and here's why.
  • It can delete tracks. Very useful. I need to do this, otherwise I forget what I've listened to.

  • it can play tracks at an increased speed

That last feature sounds like a gimmick (or a discourtesy to the podcaster) however, I am enjoying it.
This morning, for example - it compressed lottalinuxlinks 106 down to MY commuting time, not Daves. Lynn didn't sound so sexy.. but kajarii did ;)

Battery Life could maybe be better... I have been spoilt by Sony players, having said that, battery life is perhaps the only thing to recommend Sony players.

Monday 16 February 2009

dell mini ram trouble

Odd problem with my dell mini on Saturday. I needed to get a few packages up to ubuntu intrepid versions, and found that wasn't a trivial affair given the "lpia" archictecture that the pre-installed 'dellbuntu' insists upon.

I was installing dependencies, but they were still appearing to be missing. Very odd, so I decide to install the vanilla 32 bit Ubuntu8.10.

I partition the drive (ext2 with no swap) and stick in an 8.10 usb startup disk. Start the install and BOOM!! major problems at 27%. I get warnings that "source and destination files don't match".... "you probably have a dirty CD, or a damaged hard-drive".

Bummer - it has to be the hard-drive right? We all know these solid state drives are friable?

A quick google suggests several folks have had trouble with the dell mini drives, so I was 100% certain that was the problem.
Anyway... long story short, it turns out it wasn't that at all.

My RAM was hosed. memtest86 on the startup disk (which I tried on a whim whilst googling for SSD device checking software) found 40,000 errors at a very specific range of addresses.

So I popped in a different ram block, and voila! All is well. Ubuntu 8.10 was running flawlessly 20 minutes later.

On the off chance any ubuntu devs reading this.. it might be worth adding a line to the error dialog stating that the memory could be an issue as well as the more likely CD or hardrive cause.

Even more importantly, THANKYOU for having that memtest86 on the install media by default.. you saved me from ringing dell support (a fate worse than death methinks?)

Wednesday 4 February 2009

Using binary data in python

For those who don't know, I am writing a python gui-frontend to an existing mysql database.

The original program that wrote out the data was written by an old-school C guy. Some of the data has been put into the tables in a "blob" format. Example
mysql> describe esttable;
| Field | Type | Null | Key | Default | Extra |
| serialno | int(11) | NO | PRI | 0 | |
| data | blob | YES | | NULL | |

so when I read this table with the MySQLdb module (a third party module for python) I get a string like this.
import MySQLdb
Cursor.execute('select data from esttable where serialno=31599')

You will note that this is packed with characters which need to be handled with care (understatement!)

So how to make sense of it?
One way is to use python's build in Struct module, which allows conversion between python and C types of variable.

after a bit of decoding.... I noticed the above is in chunks of 8 bytes, with /x00 at every 2,6,7 position. I also realise (by experiment) that the data contains 2 distinct unsigned doubles so the following code works for me.
import struct
def blobToList(blob):
for i in range(0,len(blob),8):
pythonlist.append("%s %s $%d.%02d"%(number,item,cost/100,cost%100))
return pythonlist
if __name__=="__main__":
testdata ='\x01\x00o\x00\n\x0f\x00\x00\x04\x00\xc9\x00\x00\x00\x00\x00'
print blobToList(testdata)

which gives me the following output
['1 111 $38.50', '4 201 $0.00', '1 1001 $28.50', '2 1415 $80.00']

and that makes more sense to me (just).