My Favourite Utilities

Spinrite is a disk maintenance and repair utility. Originally created to deal with spinning disks in mind, it has also been discovered to work on SSDs.

Remote Utilities is a remote access/maintenance utility.

A Bit of Plumbing

So the bathroom tap was dripping. In fact it was more like a little stream.

I am not a plumber.

I checked online for some help changing a washer, but couldn’t find my tap. This what it looks like.

The main problem was getting the top off. With most taps, there is a little plastic cap or lid that should be prised off, revealing a screw which holds the top on. Not in this case.

The top part lifts off. This sounds easy, but I had to use a plumbing tool that apply some leverage. Let me just repeat that: The top lifts off and there is no screw to undo.

Here is a picture of the tool I used.

The rest is easier. Undo the base to reveal the washer. I needed a 3/8 inch washer. There is general information about changing a dripping tap. See, for example, this video http://www.youtube.com/watch?v=SR6vnfNLr-8.

Google Drive serves up Web Pages

I was listening to the This Week in Google podcast the other day. They talked about the possibility of serving up a static website from a Google Drive folder.

So I looked up the LifeHacker article but I needed a look at the Google Apps Developer Blog for the details. I got confused and started thinking I would need to use an API to set up the website from a folder.

But looking at the URLs, I guessed that when you share the folder with the web pages and make it public, the hash value taken from the shared url for the folder can be used to create a web url.

More Details

So some detail. First create a folder in your Google Drive that will hold your html files, images javascript etc. Make sure you create an index.html which is the entry point.

Share the folder, using the “Public on the web” option. The link share looks something like this:

https://drive.google.com/folderview?id=0B0dQc5h3FWiTcVo3bjlqSGdEeVk&usp=sharing

Looking back the Google Developer Blog, when I changed the URL to the format

https://googledrive.com/host/0B0dQc5h3FWiTcVo3bjlqSGdEeVk

I got a website :).

Backing up those gmail messages in All Mail

I recently read an article on wired.com that mentions in passing backing up all of that information you have lurking in the cloud, like emails.

It got me thinking about a perl script I had for grabbing IMAP data. The basic idea is that the module allows for fetch, delete, copy on IMAP-based email. This allows you, for instance, to grab all of the emails lurking in Gmail’s “All Mail” folder. You know – the place where emails go when you say “archive this one, I don’t want to see it no more.” With the advent of the “Priority Inbox”, using the archive feature, especially with keyboard shortcuts, makes reducing the size of your inbox a much more realizable task.

Anyway, perl has this module, Net::IMAP::Simple::SSL that lets you access IMAP from perl. Here is a simple script to show how it can do it’s thing. Script comes with no warranty, etc.

Don’t forget to put your username and password into the script at the top. See $username and $password.


#!/usr/bin/perl
#
# example-imap-ssl.pl
#
# Get mail from google via imap, and dump it to console.
#

use strict;
use Net::IMAP::Simple::SSL;
use Getopt::Long;

my $host = "imap.googlemail.com";
my $username = '<insert your google username>';
my $password = '<insert your google password>';

my $boxes = 0;
my $brief = 0;
my $dump = 0;
my $help = 0;
my $verbose = 0;
my $mailbox = "%";
my $remove = 0;
my $regexp = "";

#----------------------------------------
# process any command line arguments
my $result = GetOptions('help|?+'  => $help,
			'brief|b+' => $brief,
			"dump+"         => $dump,
			'dump-folders+' => $boxes,
			"host|h=s"      => $host,
			'mailbox|m=s'   => $mailbox,
			"password|p=s"  => $password,
			"regexp=s" => $regexp,
			"user|u=s" => $username,
			"verbose|v+" => $verbose
    );


print "IMAPS client: $username@$hostn" if ($verbose || !$dump);

if ($help) {
		print "
  --brief, -b              synopsis of every message (to,from,subject)
  --dump                   dump the mailbox selected
  --dump-folders           dump all folders contained in selected mailbox
  --host, -h         set the imap server contacted to be 
  --mailbox, -m     	   set the set of folder(s) to consider
  --password, -p     the password to use
  --regexp        display messages matching regex 
  --user, -u         the username to use

";
		exit 0;
}


my $imap;
if ($verbose > 1) {
    print "Connect to $hostn";
    $imap = Net::IMAP::Simple::SSL->new($host, Debug=>1, use_ssl=>1);
}
else {
    $imap = Net::IMAP::Simple::SSL->new($host, use_ssl=>1);
}

$imap->login($username, $password);

if ($boxes) {
    print "Enumerating folders for '$mailbox':n";
    my @folders = $imap->mailboxes($mailbox);
    for my $f (@folders) {
        print "  '$f'";
    }
    print "ne='", $imap->errstr(), "'n";
    $imap->quit();
    exit(0);
}


if ($dump) {
    my @folders = $imap->mailboxes($mailbox);

    for my $f (@folders) {
	my $msg_count = $imap->select($f);
	for (my $i=0; $i < $msg_count; $i++) {
	    my $msg = $imap->get($i);

	    if (!defined($msg)) {
		print " undefn";
	    }
	    else {
		for my $m (@{$msg}) {
		    print "$m";
		}
	    }
	} #for (my $i...
    } #for @folders
}
else {
    my @folders = $imap->mailboxes($mailbox);
    for my $f (@folders) {

	my $spam = 0;
	my $type = " ";
	my $msg_count = $imap->select($f);

	if ($f =~ /.*spam.*/i) {
	    $type = "S";
	    $spam = 1;
	}
	printf "%4i messages in $f ($type)n", $msg_count;

	for (my $i=0; $i < $msg_count; $i++) {

	    my $matched = 0;

	    if ($verbose > 1 || $brief || length($regexp)) {
		#print "$i $type" if ($verbose > 1);

		my $msg = $imap->get($i);

		if (!defined($msg)) {
		    print " undefn";
		}
		else {
		    if ($brief) {
			my ($sub, $from, $to, $date) = "";
			for my $m (@{$msg}) {
			    $sub = $m if ($m =~ /^Subject/);
			    $from = $m if ($m =~ /^From/);
			    $to = $m if ($m =~ /^To/);
			    $date = $m if ($m =~ /^Date/);
			}
			print "$from $to $date [$sub] n";
		    }
		    elsif (length($regexp)) {
			#print "regexp: searchn" if ($verbose);
			for my $m (@{$msg}) {
			    if ($m =~ /$regexp/) {

				$matched = 1;

				if ($verbose > 0) {
				    for my $n (@{$msg}) {
					print $n;
				    }
				}
				else {
				    print $m;
				}
			    }
			}
		    }
		    elsif ($verbose > 1) {
			for my $m (@{$msg}) {
			    print "$m";
			}
		    }
		}
	    }
	}
    }
}

$imap->quit();


The new thing I struggled with was the name of the folder where archived emails live. It is

[Google Mail]/All Mail

But spaces are bad in all kinds of place names, and here is another. There is a wildcard character available ‘%’ and replacing spaces with ‘%’ works fine. So with the name

[Google%Mail]/All%Mail

all of your mail can be downloaded in one go. When researching this, I also found references to [Gmail] as a the IMAP folder name. YMMV. List the IMAP folders if you get stuck.

In the same way, sent emails can be downloaded from “[Google Mail]/Sent Items”.

Note that the format of the downloaded emails isn’t pretty. There is just one great file with all of them concatenated together. But this is a quick and simple backup. And grep is your friend, too.

I use the perl above like this:

./example-imap-ssl.pl --user me --password my_passwd -m '[Google%Mail]/All%Mail' --dump > 2011-01-31.all-mail.backup
bzip2 2011-01-31.all-mail.backup

Further information
Turning on imap in gmail.
Turning on ssl in gmail (if you haven’t done this, you really should).

Aspire One Live Update Problems, and Messaging

I recently looked at the Aspire One netbook for a friend who couldn’t get the Messaging working – MSN really. I clicked on the icon, some waiting then… nothing. This started a can of worms.

When I started the Live Update feature, the downloads of various patches proceeded normally, until the last update. Then I got some “Server Error”, and the update stopped.

Turns out, Control-F2 lets you run any command, and the any command I ran was xterm.

Googling a bit reveals the fact that the Live Update program is called “onlineupdate”, and running it in xterm reveals all kinds of diagnostic details, including the urls of the patches. These are shell scripts; and have .sh at the end.

This is interesting because one of the patches is for Live Update itself.

I typed in the url of the Live Update fix in firefox, which helpfully has onlineupdate as the default handler for the patch files. It downloaded the patch and did the update.

I believe but have not yet verified that the patches were downloaded OK, and manually passing them to Live Update will install them.

Anyway, once the Live update fix was installed (plus a reboot), Live Update now installs updates like it should.

Live Update should be visited several times, because it seems that there are patches that do not appear until others have been installed first. I finally saw a fix for amsn (that supports MSN instant messaging). I had to manually select this patch in Live Update. After it installed (and another reboot) – Messaging started up fine.

Darned plugins – How to run a separate copy of Firefox

I recently created a wordpress website, www.leylandlandscapes.co.uk, and I tried free hosting.

This was the first free host trying to find a free host, and it is fraught with obstacles. The third one I tried, host-ed, was the first that actually worked. Of course I wanted everything, but the resources provided were suitable: a MySql database, PHP, a decent amount of web space. I can now understand why free hosting isn’t as free as you think.

Where are my pictures?
My biggest problem was that the pictures were missing.

My first measure of how good an online service is, is the response when you ask them a question. Do they answer? When do they answer? Does it help? They did, and it did.

The problem turned out to be my slightly paranoid firefox plugins. I have Adblock, and Noscript. Plus the Dansguardian content filtering at home. I needed a simple way to run firefox briefly without the plugins. My answer, being a linux user, was create another user, and run firefox under that account.

These are my steps for running a pristine firefox
I have seen other ways of running firefox with new profiles. But this seems cleaner to me, keeping everything separated as a new user. YMMV.

  • Create a new user (try using useradd), say chewy. root user needs to do this.
  • run the command

    xhost +local:

    This will allow any local user to use your X display.

  • Log in as new user. E.g.

    login chewy

  • Make sure firefox knows where the X display is, and run firefox.

    export DISPLAY=:0.0
    firefox

Updating Ipod Touch to v3.0 under linux

While I would love to tell you that this is possible without using a virtual machine, as far as I know at the time of writing, it isn’t.

However, I use VirtualBox to run XP Home, and I have successfully updated my ipod touch running iTunes from within the virtual machine.

There were 2 problems I encountered, when updating a 2nd generation Touch, and an iPhone:

  • USB problems with Touch – it seems to hang and never come back. My problem is that when the Touch is in recovery mode, the USB identity of the Touch changes, so you will need to enable the Touch in recovery mode. So dont run the VirtualBox in full screen mode, then you can use the USB icon on the status bar at the bottom to enable the Touch.
  • iPhone gives error 23 – despite the Touch having no network problems at all, the iPhone had problems that were more difficult to solve. It wouldn’t download the firmware. It was eventualy tracked down to something on my own network. When the update used a tethered mobile for internet access, the download happened OK, so I am guessing VirtualBox is capable of updating iPhones too.

Linux bluetooth audio: using alsa and a2dp

I got a pair of bluetooth headphones for Christmas, and they have made listening to music so much easier. The model is Zoom 4380. I used them with my phone, and the absence of wires from the phone (and the little drop-down speaker stalk) makes calling cool too.

The only problem I have atm is resuming music from the headphones, once it has stopped.

Anyway, the purpose of this thing here is using these headphones with Gentoo. In the end, the setup seemed easy. The journey wasn’t…
Read more Linux bluetooth audio: using alsa and a2dp

c902 and linux

A little while ago, I received a shiny new c902, and looked forward to loading it with mp3s…

I plugged it in, selected anything, but no joy. Hunting for a while led me to libmtp. I tried ubuntu Intrepid Ibex, and managed to download photos, but still no music.

Let me cut to the chase – I found that libmtp 0.3.5 and gphotofs do the business. I can see the phone storage, and the memory card. Normal operations work fine; I have filed up my memory card now.

Find gphotofs here: http://sourceforge.net/projects/gphoto/files/.

Mackeral sky

Unusual for me, but I quite liked this cloud effect.

Older posts