Category Archives: General

The category for everything else

More Spreadsheet Tomfoolery

I’m still messing around with my bookkeeping. Here is another nifty formula for OpenOffice Calc. I have a list of revenue and the dates that revenue was received like so:

Date Amount
10 Jul 2009 $1,080.00
18 Jul 2009 $144.45
30 Jul 2009 $2,248.40
2 Aug 2009 $1,000.00
5 Aug 2009 $522.30

I want to create a month-by-month summary of these figures. Here is the (rather complex) formula to make that happen:

=SUMPRODUCT(A1:A5>=DATEVALUE("01 Jul 2009");A1:A5<DATEVALUE("01 Aug 2009");B1:B5)

That formula will give the total of all amounts for July. By repeating this for each month, you can get monthly summaries for the whole year.

Metamorphosis

A picture of a butterfly
I realise I’ve been a bit dark lately with my blog with very minimal posting over the last few months. A lot of things have been changing around here. My wife and I have swapped roles. That’s right, I’m the housewife now and she has a full-time job.

I’m still doing some contract work here and there but am spending most of my time looking after the kids and doing housework. To be perfectly honest, I’m enjoying it. Its really nice to take a break from full-time work, the first time I have not been working flat-out in about twelve years.

So where to from here? While kids and housework keep me reasonably busy, I’m not the kind of guy who can just sit around. So I’m planning to create some products for sale. I’ve set up a new site called siliconsparrow.com where I will base my professional operations. I am excited about the possibilities.

Unfortunately it means this blog will become a bit neglected. I’ll only be posting personal and hobby stuff here, and perhaps more housewife-related stuff like recipies!

TV addiction

One of the little rules in our house is that kids are not allowed to watch TV before school in the morning.

But these two are so addicted to the glow of a screen, they watch my screen saver and pretend it is a movie!

Sometimes they are quite amusing to watch, they come up with things like “Oooh, watch out little blob, that big blob is going to get you” or “That’s two cows dancing!”.

My screen saver is Electric Sheep by the way.

Toshiba vs Dell – Cashback deals and Customer Service

I’ve never done a good ‘ol consumer rant on this site so here we go. I’ll put my grumpy old man hat on…

A couple of months ago, it so happened that I bought a Toshiba laptop and a Dell screen in the same week. Both products offered a $100 cash-back deal. What happened next showed very dramatically the difference in attitude towards customers of these two companies.

How the Toshiba cash-back works

The cash-back cannot be claimed in the store, you need to go to Toshiba’s web site and fill in a form.

But there is no form on Toshiba’s web site. So I phoned Toshiba and after the usual phone menu maze and having to hold for quarter of an hour, the Toshiba representative told me I need to go to a different web site.

Next were several screens of web forms to fill in including all my personal details, the model number and serial number of the laptop, when I bought it, where I bought it, the address of the shop, the ABN number of the owner of the shop and more and more and more. So then could I submit my claim ? No. They require you to print out the forms and then photocopy the purchase receipt and write a note, put it in a paper envelope and go to the post office and post it!!  This all took me about two hours.

So Toshiba eliminate people who are not web-savvy, do not have a printer and a photocopier, cannot be bothered spending an hour filling out forms or cannot be bothered going to the post office.

I received my cash-back about 6 weeks later in the form of a postal money order. I had to physically go to the bank and deposit it over the counter so you can add an extra hour to the total time spent by me to claim this money.

You can also add to that, another half an hour I spent writing a letter of complaint about all this to Toshiba. Did I receive so much as an acknowledgement that they received my letter ?  Nope.

From a business point of view I can understand why they do all this. They figure if they make claiming the cash back difficult they can save money because I bet that less than 30% of customers actually go through all that bother. If they sell 1000 laptops, they’ve just saved $70,000.

Of course, this comes at the expense of aggrivating their own customers who like me, will probably never buy another Toshiba product again. Can you put a dollar value on that kind of customer resentment ?

How the Dell cash-back works

Dell credited my VISA card with $100 the next day. No forms to fill in, I didn’t have to do anything. Dell want to keep their customers.

Summary

I know who I will choose next time I buy a laptop.

Company Time I spent applying for the cashback Time before I received the cashback
Toshiba 3 hours 6 weeks
Dell 0 1 day

UPDATE: This Dilbert cartoon says it all…

Simple Slide Show is now open source

I’ve taken that old Simple Slide Show program I wrote years ago and given it a bit of a brush-up. I also changed the licensing so it is open source.

As a bonus, I have added a new feature to allow you to customise the colour and font used in the image captions.

You could use the source code from this to make your own more fully-featured slide show application, or just use it as example code for writing whatever. I hope you find it useful.

CLICK HERE to go to the download page. It’s free!

Linux is amazingly useful

It’s incredible the things you can do in Linux. Here’s two amazing things I’ve done today:

Amazing thing #1

I had a corrupted disk and I wanted to run some recovery tools on it but to be safe, I wanted work with a copy of the corrupted disk. So I created a raw copy of the entire disk and piped it to a different machine which had enough storage:

cat /dev/hda1 | netcat -q 1 192.168.0.15 9998

That created a file of 1128GB in size – probably the single biggest file I’ve ever created. It took more than 12 hours to copy to the other machine!

Then I created a loopback device so the system could pretend the file was a real disk:

losetup /dev/loop0 /home/adam/recovery.raw

Then I ran xfs_repair on it and recovered all the files. In the old days I would have to physically install a second hard drive in the corrupted box – did I mention that I did all this remotely from off-site through an ssh session.

Amazing thing #2

I needed to find all the Makefiles for an older version of my projects and update them. This command searches through a bunch of folders for files which contain the string “1.6″ and loads them all up in a text editor for me. It sure beats manually going through dozens of folders and eyeballing every file.

find /usr/src -name Makefile | xargs grep -l "1.6" | xargs kate

Update on TwinHan remote for Mythbuntu 8.10

twinhan remoteI’ve just upgraded my HTPC to the new Mythbuntu 8.10. I must say that setup is a helluva lot easier than previous versions of Myth although I found my ATI card did not work at all and I had to exhume an ancient nVidia card from my parts box. And I had to hack the xorg.conf file to make the TV output work so the setup is not 100% seamless.

Anyway, onto the odd device, my TwinHan remote control. Setting this up is much easier under Mythbuntu 8.10. Here’s the step-by-step:


Step 1 – Configure LIRC

Plug the IR receiver into a USB port. Wait a moment for it to register and then type the following command:

ls /dev/input/by-id

It should produce output like this. This step is just to verify the correct device name for the remote.

usb-Twinhan_Tech_Remote_Control_1111111-event-kbd
usb-Twinhan_Tech_Remote_Control_1111111-event-mouse
usb-Twinhan_Tech_Remote_Control_1111111-mouse

Now edit the file /etc/lirc/hardware.conf and enter values for REMOTE_DRIVER and REMOTE_DEVICE:

REMOTE_DRIVER="devinput"
REMOTE_DEVICE="/dev/input/by-id/usb-Twinhan_Tech_Remote_Control_1111111-event-kbd"

Due to a bug in this version of Ubuntu, you will also need to run the following command:

lshal | grep input.product

It will spit out a few lines of text. Verify that it produces a line like this:

  input.product = 'Twinhan Tech Remote Control'  (string)

Then edit the file /usr/share/hal/fdi/preprobe/20thirdparty/lirc.fdi and make it read like so:

<?xml version="1.0" encoding="UTF-8"?>

<deviceinfo version="0.2">
  <device>
     <match key="info.product" contains_ncase="Twinhan Tech Remote Control">
        <merge key="info.ignore" type="bool">true</merge>
     </match>
  </device>
</deviceinfo>

Finally, download this file:

lircd.conf

and put it in /etc/lirc/

At this stage, I had to reboot so that everything loaded properly. Once you have rebooted, you can test the remote control by typing:

irw

Now every time you press a key, you should see it printed on the screen. Press Ctrl-C when you are done.

STEP 2 – Configure MythTV commands

We are getting closer now. The next step is to set up a file called ~/.lirc/mythtv which contains the mappings between the keys on the remote and the functions in MythTV. Once again, I have already prepared this file which you can download here:

lircrc-mythtv

Rename this file to mythtv and move it to ~/.lirc/ Once that is done, restart MythTV. Here are the key mappings you will end up with:

Key Function
REC Record
TELETEXT OSD
RECALL MENU
PREVIEW INFO
REW/FFWD Forward/backward in MythMusic
CAPTURE Previous playlist item in MythMusic
RECORDLIST Next playlist item in MythMusic

STEP 3 – Configure MPlayer

The final step is to configure the mapping between the remote and the commands in MPlayer. Since MPlayer is a separate program, it needs to be configured separately to MythTV. To configure it, we need another lircrc file but this time is has to be called ~/.lirc/mplayer. Download it from here:

lircrc-mplayer

Rename it to mplayer and put it in ~/.lirc/ and that should be that! Here are the key mappings for MPlayer:

Key Function
MUTE Mute
VOL+/- Adjust volume
CH+/- Skip fwd/back 60 seconds
REW/FFWD Skip fwd/back 10 seconds
PREVIEW Show/hide subtitles
TELETEXT Show/hide OSD
TAB Cycle through audio tracks

If you do not like the key mappings I have chosen, you may edit the files in ~/.lirc. The format should be fairly easy to follow.

Currency Calculation in PHP

Thanks to some help from Stack Overflow, the new and excellent Q&A site for programmers, I have put together a PHP class which can perform a currency conversion using up to date exchange rates pulled live from Yahoo. Here is the code for y’all to share:

<?php

// fx.php - PHP Code to convert currencies using Yahoo's currency conversion service.
// by Adam Pierce <adam@doctort.org> 22-Oct-2008
// This code is public domain.

class ForeignExchange
{
	private $fxRate;
	
	public function __construct($currencyBase, $currencyForeign)
	{
		$url = 'http://download.finance.yahoo.com/d/quotes.csv?s='
			.$currencyBase .$currencyForeign .'=X&f=l1';

		$c = curl_init($url);
		curl_setopt($c, CURLOPT_HEADER, 0);
		curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
		$this->fxRate = doubleval(curl_exec($c));
		curl_close($c);
	}

	public function toBase($amount)
	{
		if($this->fxRate == 0)
			return 0;
			
		return  $amount / $this->fxRate;
	}
	
	public function toForeign($amount)
	{
		if($this->fxRate == 0)
			return 0;
			
		return $amount * $this->fxRate;
	}
};

?>

Because it creates an object, that object will remember the exchange rate so it doesn’t need to look up the rate again and again if you want to do multiple currency conversions on the same web page.

Usage Example:

<?php

// Create an object to convert Australian Dollars to Euros.
    require 'fx.php';
    $fx = new ForeignExchange('AUD', 'EUR');

// This function formats a value with 2 decimal places.
    function fmtMoney($amount)
    {
        return sprintf('.%.2f', $amount);
    }

    $auPrice = 25.50;

    echo '<p>Your price is AU$'. fmtMoney($auPrice)
        .' which is approximately &euro;'. fmtMoney($fx->toForeign($auPrice)) .'</p>';
?>

…enjoy.