Xbox software update – Stream video from Linux (Dec/2007)

Microsoft released a software update that expands the number of video formats that the XBox will play. This is quite exciting for me because I usually have to watch anything I download on my unimpressive 15″ computer monitor but now I can stick it on a USB key and watch it on my TV from the comfort of my sofa (which actually isn’t comfortable at all!).

Give Peas a Chance Even better than a USB key, we found out how to stream video from Ubuntu Gutsy. The protocol that the Xbox uses to communicate with Windows Media Center PC’s is UPnP. To run your own UPnp server on Ubuntu 7.10 you need to install “ushare” (open source streaming software developed for the “GeexBox” Linux distribution):
  1. sudo emacs /etc/apt/sources.list
    • add “deb http://www.geexbox.org/debian/ unstable main”
  2. sudo apt-get update;sudo apt-get install ushare
  3. ushare -n Arbitary_UPnp_Server_Name -c pathToTargetMediaDir -x -i eth0

To get to the media in the XBox dashboard, you go to the “Media” tab, select “Videos”, then you should see “uShare” listed amongst the sources list. As a reference, the uShare version is currently 1.1 and the XBox dashboard version is 2.0.6683.0. Note: For some reason .avi files don’t show unless you rename them to .mov.

I would say thank you to Microsoft for this update except this isn’t really a fix, it’s more of an uncrippling. Why did they cripple it so it can’t play xVid in the first place? They must have been hoping people would just use WMV format videos but they must have received enough feedback to tell them that this isn’t the case.

My first Weightwatchers meeting (10/Nov/07)

weight watcher There’s no reason whatsoever why I shouldn’t be able to lose weight by eating less, but I can’t, so I have had to resort to extreme measures. I’m going to go to Saturday morning weigh-ins. In my first meeting I was the only bloke so it’s more than a little daunting. Especially as how we have to clap when so-and-so has lost ½ a pound.

I feel being over the medically healthy weight just feels like I’m voiding my warranty. 🙂 I’m 18 stone 2 lbs but the maximum weight for 5 foot 11 is 13 stone.

I need to keep the meetings up, apparently “we could still drop a dress size by Christmas!” weightwatchers logo

Frustrated with Cook book Preparation times

Give Peas a Chance I like food recipes to estimate how long it takes to prepare and cook a meal but so far I found that I can never do it as quick as it says. I’m sure they exaggerate their cooking times?

Guess I’m just slow!

Xbox 360 – Oct/2007 (Christmas present from Kix)

Xbox 360 Our original Xbox (4 ½ years old now) has become too flaky, games crash and DVDs skip. We needed a DVD player and it’d be a shame to lose all our games so buying a new XBox makes sense. Halo 3 took any doubt out of the decision. I do feel suckered into the slick Microsoft marketing trap but it does it’s job as an entertainment system so I don’t feel ripped off.

The online capabilities of the Xbox is pretty impressive, I downloaded a few demo’s but I was disappointed with the fact there is no movie rentals available – certainly a wasted opportunity for Microsoft (I hear they have them in the USA – what gives?). Halo 3 online works flawlessly.

I put my original Xbox on Ebay – it got won with a bid of just £12.50! 🙁

Perl Pie

Holy Pearl “How do I change “pelican” to “pecan” in all the files in a directory?”. “Dude, use Perl Pie”!

I’m pretty familiar with Perl, having used it on and off whenever there’s a string manipulation related job to be done. I like Perl despite all it’s faults. I like writing Perl (not so keen on reading it though 🙂 ). I’ve been using Perl one-liners where I probably should be using Shell scripts but I used to forget what the right flags are until I heard the term “Perl Pie”.

perl -p -i -e 's/before/after/g' your.files*

-e is for “execute” – It allows you to define Perl code to be executed by the compiler

-p is for “process” – It adds a loop around your -e code so that it is applied to each line of any specified files and the contents of $_ are printed out and errors are thrown if a file can’t be read. You can think of it like it adds this:

while (<>) {
  # your -e code goes here
} continue {
  print or die "Can't open blah: $!\n";
}

-i is for “In-place Editing” – Without it, no files will be changed. With it, Perl renames the input file and reads from this renamed version while writing to a new file with the original name. If -i is given a string argument, then that string is appended to the name of the original version of the file. for example, Sometimes it’s handy to use -i~ so Perl creates a backup file before making your changes. if -i has no arguments, the file names don’t change.

Replacing our roof (Sep/07)

We’re having our roof tiles replaced. It was something that we were told we needed to have done in the survey when we were buying the house. Our neighbour was doing his roof and we thought we’d do it at the same time so as to get a seamless join between the two houses.

our roof needs replacing Our current slates seem pretty old and are slipping off in places.
scaffholding up on our house Being Done:

  • Remove old slates, battens and felt.
  • New “breathable” felt, then new battens and roof tiles.
  • New front guttering.
  • Render join between neighbours as necessary.

Of course, last night, while we had half a roof it poured with rain. I went into the attic to see if there were any leaks but it seemed ok. It was loud though! sounded like I was inside a drum.

Starting the new bathroom (Sep/07)

After a summer break we’ve turned our attention back to the house. Our current project is the bathroom. So far, we have put in a fan, a bathroom regulations light, a frosted window and we have had the room plastered. Now we need to tile the floor, buy the bathroom suite and do the plumbing.

The Kite Runner (Khaled Hosseini)

Fiction, 7/10 – July/Aug/Sep 2007

This novel is about the relationship of two children growing up in Afghanistan just before the Russian invasion and the rise of the Taliban. The distressing event that occurs on the day of a bitter sweet victory in a local Kite fighting tournament haunts both of them and marks the end of the happy period in the book (the majority being very dark). Mimicking his conscience, war and the associated horror invade the life of Amir, the main character.

From child to adult, Amir bears an emotional scar which he eventually “pays for” even though he and his father manage to escape to America.

A very moving, sad book, rich in emotion. The author is from Afghanistan and I hope for his sake, none of the writing is autobiographical, for it is disturbing. He has a huge talent for irony, something that he explicitly points out as being an important skill of writing.

Kite fighting sounds like a fun sport. I’d love to go and see a real tournament.

My Family Tree (Aug/07)

I’ve been using geni to compose my family tree. I haven’t done any of my own research so far – my first aim is to simply combined the records from my Dad’s side, my Mum’s side, and my wife’s family. I’ve already entered 185 names but only scratched the surface of the archive material that I have.

Doing it online is fantastic. It’s easy to share and collaborate with other people, it’s safe from accidental loss and it’s free. I’m also hoping that one day someone comes across it and discovers they are part of the family and grows the tree. Maybe one day we will all join tree’s to Adam and Eve. 🙂

The two celebrities that I’ve found so far are my great-great-great-grandfather’s brother, Sir George Gilbert Scott (1811-1878) a famous architect that has many great works to show for (e.g. the Albert Monument) and my great-great-great-great-great-grandfather, Thomas Scott (1747-1821) nicknamed, “The Commentator” because he wrote a best-selling commentary of the Bible.

Many thanks to Carole King (My Paternal Grandfathers niece) for the Fotherby family tree, Mark Bodley Scott (my Maternal Grandfather) for the Bodley Scott family tree and Sarah Cowland (my mother-in-law) for the Cowland family tree.

Finding the Median in Linear time

some eggs
Here are three C++ programs to find the median of a set of numbers. The first is short and simple. The last is fiddly and fast.

Simple but not linear (n*log n time):

Sort using STL sort (presumably quicksort), then find the middle value:


#include 
#include 

int main() {
  int A[7] = {23, 1, 33, -20, 6, 6, 9};
  std::sort(A,A+7);
  std::cout << "The medium is: " << A[3] << std::endl;
}

Linear time (But too much memory used in recursion):

The running time of the following algorithm is linear rather than logarithmic. The reasoning behind this is that each recursive call takes linear time (on average), and each recursive call reduces the size of the problem by a constant factor:


#include 
#include 
using namespace std;

// Find Kth element using recursion
int getKElem(vector A,int K) {
  int a = *A.begin();  // Pick randomly a number a from A = {a1, ..., an}.

  // gather all numbers smaller, equal and bigger than a.
  vector S, E, B;
  for(vector::const_iterator ci = A.begin(); ci!=A.end(); ci++) {
    if (*ci < a)      S.push_back(*ci);
    else if (*ci > a) B.push_back(*ci);
    else              E.push_back(*ci);
  }

  if (S.size() >= K) return getKElem(S,K);
  else if (S.size()+E.size() >= K) return a;
  else return getKElem(B,K-S.size()-E.size());
}

int main() {
  int myints[7] = {23, 1, 33, -20, 6, 6, 9};
  vector A (myints, myints + sizeof(myints) / sizeof(int) );

  cout << "Element " << A.size()/2 << " is: " << getKElem(A,A.size()/2) << endl;
}

Linear time with decent memory footprint:

Here is the algorithm with the recursion unraveled:


#include 
#include 
using namespace std;

// Find Kth element without recusion
int findKMedian(vector A,int K) {
  int l,m;
  l=0;
  m=A.size()-1;
  while (l A (myints, myints + sizeof(myints) / sizeof(int) );

  cout << "Element " << A.size()/2 << " is: " << findKMedian(A,A.size()/2) << endl;
}

Programming interviews Exposed (Aug 2007)

Programming, 9/10 – Aug 2007

This book should really be kept a secret because if everyone read it before a programming interview, all the good jobs would be taken. It’s an excellent refresher to put you back to fresh-out-of-uni programming knowledge level. It covers Programming Problems, Logic Puzzles and Knowledge based problems with a very good explanation after each question.

For me, it would be good if the code examples were in C++ (over C).

Programming Pearls (Jon Bentley)

Programming, 8/10 – Aug 2007

The chapters on algorithms and efficiency (performance, code tuning and space tuning) make this book brilliant. The explanation and benchmarking of the different sorting and searching technique’s (especially quicksort) are almost fundamental reading for anyone that has a programming interview with a top company.

Beware, in amongst the pearls there are some poos (some parts are a little dull) – In fact, on one page, it actually says: “Warning Boring Material ahead”.

Harry Potter and the Deathly Hallows (J. K. Rowling)

Fantasy, 8/10 – July 2007

I was dreading the possibility of a dark close to this series but I was delighted with the happy fairy tale ending (Harry Potter is a children’s book after all). I’m going to miss Harry, but I’ve decided if I ever have children, I’ll definitely read it to them.

Harry is a hero but not through talent, skill or intelligence. He triumphs through determination, bravery and most of all, luck. Harry is unbelievably lucky. I was thinking that as the series progressed and Harry got older, he would start becoming more skilled and powerful and beat Voldemort in a fair fight at the end. It was not to be – It was luck all the way. Poor Voldemort must be feeling a bit hard done by really. It seems in the Potter world, wands are not well understood by the majority of Wizards and Witches. It is not the case that a Wizard is the master of a wand, in fact it’s quite the opposite. I would have liked wand law to have been explained a bit better.

In conclusion, Magic is Magical. 🙂

The Flood never happened

Thank goodness the flood never reached us. The only thing that happened was that we had a few inches of water in our cellar and the park got closed off due to a potentially toxic oil leak. So we moved all our things back downstairs and decided that when we buy our next house we are going to make sure it’s not on a flood plain.
One good thing about the flood was that it invoked a sense of community spirit – I’ve never spoken to so many people from our street before.