Saturday, September 6, 2008

How to breathe life back into a 10 year old Compaq laptop using Xubuntu

Many years ago I lent an old slightly damaged laptop to a friend (the laptop locking mechanism was broken and the screen slightly damaged). Last year he bought a cheap but highly functional laptop after my loaner, now nearly ten years old, stopped working and eventually returned it to me for possible repair and use.

It is a Compaq E500 which has a rather stylish black and grey layout, good quality keyboard and a clear colour screen (in 1999 it was retailing for $1,970 and in 2008 they sell on eBay for under $100). The hard disk had fatally crashed and windows now failed to boot up only ever giving a blue screen of death. I'm unsure if the hard disk has a physical problem but after it laying around on my study floor for six months I thought it might be possible to replace Windows with a suitable free small version of Linux so the machine could become a handy wireless web laptop and guest machine. [E500 Spec: 14.1 in 1024x786 TFT display (1600x1200 external), 12GB hard disk, CDROM 24x, Video Out, Pentium III 650MHz, 192MB SDRAM.]

After failing to get the standard Ubuntu to install from a CD I had to hand (I gave up after letting the disk whizz around for over a half hour) I did a little research and opted for Xubuntu which is a cut down version for machines with more limited resources. I downloaded and created a CD from the ISO file on my trusty MacMini. The E500 install took over an hour but the main screen gave a countdown bar so you can see something is happening. I re-booted when it told me and it worked first time. It boots up more quickly than it used to under Windows and had even recognized my 2GB USB flash drive!

After a little play to ensure that it seemed responsive enough I dug out an old Belkin wireless card (802.11b) and was quite astonished when I plugged it in and the OS used it to find wireless connections without any further configuration. I had to tweak the wifi settings to connect to my secure network but had it working as a wireless laptop fairly painlessly.1

It's now a smart "netbook" (with a much better screen than the Acer Aspire One) for checking email while watching TV. The remaining issues are hardware specific2 and I'm not sure I'll get around to fixing them, e.g. recognizing the function key buttons for changing brightness and volume & the second touch pad key doesn't do anything. All in all I'm pretty delighted to turn a useless brick into a nicely functional spare laptop.
Footnotes

[1] The old Belkin wireless card is so out of date that it can't support an encrypted connection so security on this laptop is reliant on screening by MAC address. In the process of testing it out I found wicd is a neat free Linux graphical tool for sniffing out and managing your wireless connection. I have just bought a cheap 802.11g card off eBay to solve the security problem.

[2] The hardware side remains a puzzle. The E500's BIOS is dated 1999 and there's a new BIOS that helps to solve the problem of buttons being available to non-Windows OS's (see discussion). Having reformatted the disk I can't install the new BIOS to flash (using a .exe file that HP have available) or (for some reason I can't fathom) run DOS from a floppy even with it set as the first boot device.

Postscript

I have tried booting from CD using the latest Puppy Linux (Dingo). It runs well, possibly faster than Xubuntu but I haven't managed to map the keyboard touchpad correctly yet. If I get this working I'll give it good trial as Xubuntu tends to take a couple of seconds to change screen tabs when running Opera, while I haven't noticed any real performance problems with Puppy Linux so far. When you think about it, it's pretty impressive to be able to run the latest version of the Opera browser on such an old machine.

Saturday, August 9, 2008

How to add 8GB of memory to Sony Ericsson K750i

My previous memory stick in my mobile phone was a 4GB MS Pro Duo card. This is the maximum the phone is supposed to be able to cope with. I took a slight risk and paid £23 for an 8GB MS2 card (with Pro Duo adapter) with the intent of extending my mobile's life as a thrifty guy's iPod.

Initially there seemed to be a problem reliably writing files but after re-formatting and using a card reader (rather than the phone cable) to update files, it seems to do the job. I formatted using DOS with the command FORMAT E: /FS:FAT32 /A:4096, check this discussion as to why I chose these options. The phone status only reports a 4GB card but it actually does cope with 8GB.

I'm amazed to fit such a large card on a three year old mobile phone. This is enough space to take a large MP3 music collection (about 50 CD's worth of music, including 15 hours of Wagner's Ring of the Nibelung), 40 podcast subscriptions, a couple of free audio books, various maps supporting my GPS bluetooth gadget, document backups and 2.5GB spare for future growth.

For document backups I use TrueCrypt to keep an encrypted 400MB disk image which can be mounted on my Mac or a PC that includes all my scanned documents over the last two years (I use a Fujitsu ScanSnap scanner to keep PDF versions of bank statements, tax bills etc.) as well as other key reference documents. This may seem an odd thing to keep on the phone but if I was on holiday and my laptop got stolen I could still print out identity documents if someone lent me a PC. By using encryption if the phone was stolen at least I wouldn't worry about my ID being compromised.

My old 4GB memory card? This is now in my pocket camera (Sony T100) giving enough space for 3 hours of 640x480 video or 1,600 photos at 2592x1944 (5MB) resolution.

Thursday, August 7, 2008

How to write a spreadsheet formula for ISBN-10 to ISBN-13 and ASIN

I wanted to convert 10 digit ISBNs to the new 13 digit format and vice versa for my "checking second-hand book prices given an ISBN" spreadsheet. It turns out that (for the moment) any ISBN-13 starting with 978 can be converted to an ISBN-10 and this will be the same as the ASIN used by Amazon, so this can be used to look up their data. The problem is that the last digit of the ISBN may change due to it being calculated using a different ISBN standard, so to convert from one to the other your spreadsheet needs to do the checksum calculation.

The following formulae are based on a 13 or 10 digit ISBN in cell A3 and cell A6 reserved for a check digit calculation. These should be in one line in a spreadsheet cell, the layout here is to help readability.

Formula to create ISBN-13 from ISBN-10
=if(
len(A3)<11,
concatenate(
"978",
mid(A3,1,9),
mod(
mid(A3,1,1)*3+
mid(A3,2,1)+
mid(A3,3,1)*3+
mid(A3,4,1)+
mid(A3,5,1)*3+
mid(A3,6,1)+
mid(A3,7,1)*3+
mid(A3,8,1)+
mid(A3,9,1)*3,
10
)
),
A3
)

Formula to create ISBN-10 from ISBN-13 (starting with 978)
=if(
len(A3)>10,
concatenate(
mid(A3,4,9),
if(A6=10,"X",A6)
),
A3
)

To calculate the check digit (A6)
=if(
len(A3)>10,
mod(
mid(A3,4,1)+
mid(A3,5,1)*2+
mid(A3,6,1)*3+
mid(A3,7,1)*4+
mid(A3,8,1)*5+
mid(A3,9,1)*6+
mid(A3,10,1)*7+
mid(A3,11,1)*8+
mid(A3,12,1)*9,
11
),
""
)

Tuesday, May 27, 2008

Track Flickr group membership history using iMacro


User Guide
This script keeps a running log (every time you execute it), by updating a discussion message and/or saving a snapshot of group memberships. For the running log you have to create a message in each Flickr group you are an administrator for (or specifically declare), called "Member count". This log keeps a historical record of "date, membership total, total number of items". Before adding a new log entry it checks if the last entry (and the one before that) was less than a fortnight ago and updates it semi-intelligently.
Why?
I created this script as there is no easy alternative for keeping a history of membership for restricted groups in Flickr.
NotesI'm an administrator for 9 Flickr groups and maintain membership logs in 4 other groups. Watching the macro chug along updating the logs is quite satisfying. It takes 10 seconds per group (loading 3 to 4 web pages each time and added waiting time, to avoid possible page freezes, composes most of that time) but this can increase up to three-fold depending on Flickr traffic. For a macro that I only need to run once every one or two weeks that doesn't seem too shabby.

[Source code now maintained at Sourceforge.net]

iMacro setupiMacro installs itself with some example JavaScript files (.js) which are visible in the folders that iMacro shows you in Firefox.

If you find the location of these folders on your hard disk (on the Mac these are under /<your_username>/iMacros/Macros/) and then save the script in this location with a ".js" extension you should be able to see the file when you refresh the iMacro folder list in Firefox.

You should then be able to play the script from within iMacro (you have to already be logged in to your Flickr account and have created "Member count" discussion topics for groups you want to log). In the first instance I suggest you try the test test version which will run fully and show you the intended changes in the detailed change log but will not actually commit them.

See wiki.imacros.net for further help.

Monday, May 26, 2008

Flickr iMacro script to invite all your Flickr friends to a group

There was no automatic way to invite all your friends to join a group so I knocked up this quick script to take you from any group main page to the invite page, extract your list of friends (and no other contacts) and then send off the invite. The invite only goes to friends not yet in the group and not previously invited so you will not be bugging them with unwanted spam.

Note that more than 500 friends may result in time-out errors waiting for Flickr to respond. In this situation you may be better off inviting a few hundred at a time by recording an iMacro selecting the first checkbox on the invite page, then generalize it by removing the ATTR=NAME: and copy that line 200 times but change POS=1 to POS=R1 so that the next checkbox relative to the cursor position is ticked each time. When you've trimmed to a more manageable number then this script can apply again.

[JavaScript source code START]
/*
Description:
JavaScript for iMacro to create a block invite for all your
friends (but not family or other contacts) to join a Flickr group.
For more information see http://useroffline.blogspot.com

Assumptions:
- You have iMacro installed.
- You have your group's main page currently displayed.

Why:
There is no block invite facility built into Flickr.
*/

// Get friends list
var friendArr=new Array();
iimPlay("CODE:\
TAG POS=1 TYPE=A ATTR=TXT:Invite\n\
TAG POS=1 TYPE=A ATTR=TXT:Choose<SP>from<SP>your<SP>contacts?\n\
TAG POS=5 TYPE=TR EXTRACT=HTM\
");
// Tidy up extracted data
friendArr=iimGetLastExtract(1).split("name=\"");
friendArr.splice(0,1);
for(i in friendArr){
friendArr[i]=friendArr[i].split("\"")[0];
friendArr[i]="TAG POS=1 TYPE=INPUT:CHECKBOX ATTR=NAME:"+friendArr[i]+" CONTENT=YES";
}
iimPlay("CODE:"+
"' Total no. of friends = "+friendArr.length+"\n"+
friendArr.join("\n"));
// Send the message
iimPlay("CODE:\
TAG POS=1 TYPE=INPUT:SUBMIT ATTR=NAME:Submit&&VALUE:PREVIEW*\n\
TAG POS=1 TYPE=INPUT:SUBMIT ATTR=NAME:done_send&&VALUE:SEND*\
");

[JavaScript source code END]

Thursday, May 22, 2008

Re-list books on Amazon using iMacro

User GuideThis script imports my Google spreadsheet of books and then pastes them to sell on Amazon books. It takes about 20 seconds to list each book but you only process those in your spreadsheet marked to be re-listed.
Example Google Spreadsheet.
Why?Unless you pay £28.75 per month to Amazon Books to become a professional seller, you don't get the facility to import from a spreadsheet. This iMacro code does exactly that, for free, though it is of course intended for smallish quantities (in practice I'm normally adding less than 6 books at a time and have less than 20 books up for sale).
Having recently realized that the handful of books I was trying to sell had not only all expired but had also permanently gone from my closed listings so I had to put them in from scratch, I had the incentive to spend a few hours playing with JavaScript and iMacro to find a decent work around.
Known Bugs
When I have more than 20 books the last ones on the list are ignored as already listed, probably due to export limitations with iMacro. My work around is to list new books at the top of the spreadsheet and it will work fine. You could also cut and paste previously listed books into a second page of the spreadsheet and keep the front page for new books to be listed.

Sunday, May 18, 2008

How to add a book title from an ISBN or ASIN in a Google spreadsheet

Having recently created an iMacro to import books from Google spreadsheet to Amazon, I realized that the formula I was re-using to automatically put in the book title was quite a neat feature of Google docs that most people are probably unaware of.

I use the importXML function. This finds data based on an HTML tag in any webpage and you can create that source webpage name as a formula. This gives a really neat way of cribbing data about a book straight from it's Amazon webpage to be used on your own spreadsheet (also known as website scraping).

Here's my example formula (assuming the ISBN or ASIN is at cell A1), read this as one line:
=importXML( concatenate( "http://www.amazon.co.uk/exec/obidos/ASIN/", A1), "//span[@id='btAsinTitle']")

By looking at the webpage source code for any Amazon book you can find HTML tags around all of the product data. In this case the HTML tag <span> with the ID attribute set to "btAsinTitle" surrounds the book title. If you wanted to grab data on the number of pages, publisher or even lowest second hand price, this is all possible in a similar manner.

I have also created neat formulas to grab best match full film title and release date from IMDB.com as a search sheet to support my DVD index so I can quickly cut & paste details based on typing in key words from the film title.

The only limitation is there is a maximum of 50 such formulas in any spreadsheet. However if you are building a catalogue or sales list, it is a fairly simple matter to cut & paste the values over the formulas for books or DVDs already indexed so only new entries use the formula.