RSS

Author Archives: Paul

Unknown's avatar

About Paul

I'm the geek.

So alike, yet so different

I’ve recently fallen into the world of Mac OS X. (Fallen, pushed; what is difference?)

I keep getting caught out by the little things that are just slightly different to what I’m used to in Linux.

Take the most recent example: the mail command. I had a little anacron script set up on my Ubuntu box that would generate a summary of a previously-unseen messages in a user’s Gmail spam folder, and send it to that user. (Mostly because Mrs E kept forgetting to check hers.)

While I was perusing the mail man page on Mac OS X, and reading up on various options on Google, I found that the Mac version had a useful -E switch that would allow it to quietly abort if there was no message body, saving me the hassle of having to find a recent port of moreutils so that I could use the ifne command.

The thing that got me stuck for ages was trying to find a replacement for the -a switch in the GNU/Linux version of mail, which allowed the insertion of arbitrary headers, and was useful for setting the sender to something appropriate.

Eventually, after much reading of man pages and search results, I realised that the answer had been staring me in the face for ages, I just wasn’t doing it correctly because the order of the parameters became more important:

echo Wibble | mail -s "Subject goes here" recipient-address@example.com -r "<mail-sender@example.com>" -F "Mail Sender"

That was harder than expected…

(Note to self: WordPress doesn’t tell you that it’s stripping out the content in angle brackets that you’ve just retyped three times…)

 
Leave a comment

Posted by on Tuesday 13 March 2012 in Geeky stuff

 

Tags: , , , ,

Make me one with everything?

I’m a little concerned about Canonical‘s decision to go for Unity over GNOME in Ubuntu 11.04; it seems like a very radical step to take, and could end up backfiring by putting off potential users for a long time.

On the other hand, if it works the way they’re hoping, it could be very successful and bring a whole new league of users to Ubuntu and, more importantly, to Linux. (As the joke says, “Change must come from within.”)

Personally, only one of my home PCs runs standard Ubuntu, and that’s running the LTS version, so I won’t see the change there until next year (by which time things might have changed). The laptops run Xubuntu, the HTPC¹ runs Mythbuntu (as of this week), and neither of those is going to start using Unity in a hurry. (Oh, and for the sake of completeness, there’s an increasingly-lonely Windows box, that gets used for my Nike+ uploads and a bit of development stuff.)

1. That reminds me, I must write something about the HTPC…

 
Leave a comment

Posted by on Thursday 21 April 2011 in Geeky stuff

 

A fine evening’s fettling

There are few things more relaxing than spending a couple of hours in your garage, doing a task that you know how to do, you’ve done before, and you have all the right tools for.

I had a new tyre put on the Falco‘s front wheel yesterday, and I needed to get it put back on so I could use the front paddock stand on the Elefant.

As the front brakes had to come off anyway in order to remove the front wheel, I thought it would be a good opportunity to give them a bit of a clean before it ends up being sat around for most of the winter. Pump the pistons out a little bit, give them a good spray with brake cleaner, a scrub with an old toothbrush, and a wipe with a rag. A little smear of rubber grease around the visible part of the pistons, then push them back in.

There was almost a comedy piston-falling-out moment, when I forget that one caliper had nothing stopping the pistons moving when I pushed the others back in, but fortunately I realised just in time to stop an egress of brake fluid… phew.

Refitting the wheel was a bit of a pain: the design of the front spindle means that it’s easy to end up with the left fork in the wrong place, if you don’t get the spindle positioned correctly. In fact, the first time I had a new front tyre on my first Falco (R.I.P.), the fitter cocked it up to such an extent that it was hard to push the bike around, because the caliper was fouling the disk so much.

Once I was happy with the position of the front wheel and spindle, the brake pads were given a fresh smear of copper grease, replaced, and everything tightened up in the correct order (or untightening, bouncing the forks, and retightening, as per the workshop manual, to make sure the forks are correctly aligned).

A couple of beers whilst doing it, some decent tunes on the stereo, and I was perfectly happy. If only it wasn’t so cold; the next little job (replacing the Elefant’s speedo drive and front wheel bearings) might need thermals, as well as my padded overalls.

 
Leave a comment

Posted by on Sunday 14 November 2010 in Uncategorized

 

O you are Auth-ful…

… or, how Twitter’s changes broke my nice little perl script.

The script for queuing tweets still works, but they all disappear into the void rather than getting tweeted, now that Twitter only allows external applications to connect using OAuth.

I’ve found this handy little article here that seems to suggest that it’s easy enough to do using existing modules from CPAN.

Now all I need is a set of round tuits, and we should be back in business again. I’ve got some ideas for other stuff to tweet, once I get it all working again…

 
Leave a comment

Posted by on Monday 13 September 2010 in Geeky stuff

 

Tags: , , ,

Cycling Bling

Chain Bracelet

I had an urge to make a very metal bracelet out of a used bicycle chain.

Initially I’d dismissed the idea, thinking that keeping a chain tool in my bedside cabinet, for whenever I wanted to put it on or take it off, might be a bit inconvenient. But then I remembered that KMC chains, my usual choice of flexible power transfer system purveyor, come with a reusable link, and the problem was solved.

Possibly not suitable for the office, but I think it’s a must for the next Motörhead gig. \m/

 
Leave a comment

Posted by on Thursday 22 July 2010 in Uncategorized

 

Blogging by email

I wanted to see what happened if I submitted a blog entry with pictures by email.

Is it clever enough to do something sensible with the attachments? It’d be nice if it at least did a basic layout, which could then be edited later.

Let’s see what happens, shall we?

The picture? That’s a couple of Hungarian chilli plants (I’m not sure of the exact variety), which are sitting on my desk at work, waiting for me to figure out how to carry them home in a tank bag without trashing them. Answers on the back of a postcard, please.

 
Leave a comment

Posted by on Thursday 22 July 2010 in Uncategorized

 

Worn-out Worm

After behaving itself impeccably the weekend before last, on my trip to the NABD Rally and other places, my Elefant disgraced itself last week by deciding that it no longer wanted to let me know how fast I was going.

Initial suspect was the speedo cable, since that’s normally the cause of this kind of problem.  I phoned up Venhill shortly after I got to work, but (fortunately, as it turned out) they denied knowing the details of this cable, despite me having ordered one previously, so I’d have to send my old one in so I could make a copy.

I never got round to checking the cable until the weekend, when the front wheel was off anyway to get new tyres put on (as well as chain and sprockets, and fitting the Öhlins-spring equipped shock that I’d had lying around for ages) . The cable’s fine: spinning it by hand makes the speedo needle flick. Next thing to check was the speedo drive, which turned out to be very stiff. A bit of cleaning revealed that a stone had got caught and jammed the mechanism.

Problem solved… but when I rode away from getting the work done, I did so at an indicated 0 mph. Bugger.

Further investigation this evening reveals that the metal drive ring in the wheel has worn down the tangs on the plastic ring in the speedo gearbox. I’ve bodged it for now, but who knows how long it’ll last… looks like I’ll have to get a new one, but where from?

 
Leave a comment

Posted by on Monday 17 May 2010 in Motorbikes

 

Tags: ,

Ventura Rack and the Fast Fasteners

I’ve got to say something about the quality of service from Inox Fasteners

I’m trying to fit a set of second-hand Ventura L-brackets to my Aprilia Falco. Ventura were good enough to supply a set of fitting instructions, but I’ve got a feeling that they’re for a later revision of the L-brackets than the ones that I’ve got.

The instructions say that the centre bracket, which fits under the pillion seat between the grab handles, has threaded bosses to accept the original grab handle bolts… the one I’ve got doesn’t. I’m guessing that there should be some longer bolts for the grab handles, to go through the un-threaded bosses, with a nut on the end.

So, late last night (actually, early this morning), I placed an order via Inox’s website for some suitable bolts, expecting to get a confirmation and payment request before lunchtime today. Sometime after lunch, I realised that I hadn’t heard anything, so I sent an email expressing my concern, with the hope that I could get the parts tomorrow.

I was slightly horrified at myself when I got a response apologising for the delay due to a family bereavement… and then a further message saying that the bolts had been put in the post without waiting for payment! The normal payment confirmation email didn’t turn up until this evening, and I’m fully confident that I’ll get the bolts tomorrow and the Ventura rack will be nice and secure, well before the weekend.

So, for all your stainless steel fasteners requisites: Inox Fasteners.

 
Leave a comment

Posted by on Tuesday 13 April 2010 in Motorbikes

 

Tags: , , ,

Wot no widget?

Curses. I wanted to put my Nike+ widget on my blog to show off my lowly running achievements, but wordpress.com doesn’t allow Flash (amongst other things).

Mind, the Nike+ website seems to be so flaky that it probably wouldn’t work half the time. Or maybe it just doesn’t like Google Chrome, or trying to run the Flash components on Linux. It’s so broken at the moment that I can’t even get to my profile page to find the correct URL to add in here somewhere. Pffft.

Edit: I’m pretty sure the problem with the Nike+ website is a combination of issues with Google Chrome (it often doesn’t render at all correctly the first time it’s loaded, whatever the operating system), exacerbated by problem with Flash on Linux. Something to investigate when I get a chance, although there are plenty of people on the Nike+ forums complaining about problems with Chrome.

 
Leave a comment

Posted by on Monday 1 March 2010 in Geeky stuff

 

Tags: , ,

Knit your own Tweets

The Perl scripts that I was fiddling about with seem to be working the way I wanted them to (even if what’s calling them isn’t always), so here they are for anybody else who wants to use them.

queue_tweet.pl


#!/usr/bin/perl

use DateTime;
use Sys::Hostname;

my $time = DateTime->now()->strftime("%F %T");
my $tweet = "$time\n";
my $hostname = hostname;

$tweet .= "$hostname\n";

while(defined($line=<STDIN>)){
    $tweet .= $line;
}

$tweet .= "%%\n";

#print $tweet

$tweetqueuefile="/var/local/tweetqueue";

open(QUEUE,">>$tweetqueuefile") || die("Cannot open tweet queue");
print QUEUE $tweet;
close(QUEUE);

send_tweet.pl


#!/usr/bin/perl

use File::Copy;
use Net::Netrc;
use LWP::UserAgent;

$tweetqueuefile="/var/local/tweetqueue";

open(QUEUE,"$tweetqueuefile") || die("Cannot open tweet queue");

# Read lines of first tweet

my $tweet;

while(defined($line=<QUEUE>)){
    if($line eq "%%\n"){
        # Exit loop
        last;
    }
    $tweet .= $line;
}

if($tweet != ""){
#	print "Sending tweet:\n$tweet";
    $machine="twitter.com";
    $netrc = Net::Netrc->lookup($machine);
    my $ua = LWP::UserAgent->new;
    my $req = HTTP::Request->new(POST => 'https://twitter.com/statuses/update.xml');
    $req->authorization_basic($netrc->login, $netrc->password);
    $req->content('status='.$tweet);
    my $result = $ua->request($req)->as_string;
#	print $result;
}

$tempfile="/tmp/tweettmp";

open(TEMP,">$tempfile") || die("Cannot open temporary file");

while(defined($line=<QUEUE>)){
    print TEMP $line;
}

close(TEMP);
close(QUEUE);

copy("$tempfile", "$tweetqueuefile") || die("Cannot overwrite tweet queue");

(As I’ve mentioned before, it’s a long time since I’ve written any Perl, so I’ve probably made any number of schoolboy errors. Still, they seem to do the trick.)

queue_tweet.pl reads from stdin to queue a tweet, and send_tweet.pl reads and sends the first tweet from the queue each time it’s called. You’ll need your credentials for twitter.com in your .netrc file.

For example, I’ve got the following entries in my crontab:

# Send any pending tweets
*/5 * * * * /usr/local/bin/send_tweet.pl

# Log disk temperatures
30 */4 * * * /usr/sbin/hddtemp /dev/sda /dev/sdb | /usr/local/bin/queue_tweet.pl

# Motherboard temperatures
35 */4 * * * /usr/bin/sensors | /bin/grep Temp | /usr/bin/cut -c 1-21 | /usr/local/bin/queue_tweet.pl

Let me know if you use them for anything more interesting than tweeting your system temperatures, or if you’ve got any (constructive) criticisms of my Perl code…

 
1 Comment

Posted by on Tuesday 16 February 2010 in Geeky stuff

 

Tags: , ,