Thursday, January 25, 2007

Damn missed again

Forned top 25 "Web Celebs"

A bit questionable this one. As with any list I guess. Again as usual with these sorts of things, it is very US centric. Don't ya just love those lists of "Best 100 Sportspeople in the world", that are all yanks, and include fatties from the NFL.

Anyway, I haven't heard of half of these people, which to me is a barometer that it is pretty crap. As the "WebCelebrities " are most likely bloggers from what I can tell, and still most blogs are read by geeks, rather than the mainstream, there are a few glaring omissions:

Joel, from Joel on Software
Drew from Fark
Kevin from Digg

Oh I seem to have been left of too.

Wednesday, January 17, 2007

Recursively Copying files in C#

In a project I am working on (an IIS admin interface for Boss) I need to copy all files from a Source Directory to a Destination Directory, but have the option to skip the copy if the file already exists.

I instantly thought of the SHFileOperation Shell32 Api call, and went as far as wrapping that in C#. That works fine, but either overwrites existing by default, or throws up a GUI interface asking the user if they want to overwrite. This is a web app so this wasn't an option.

I decide to roll my own, and discovered that it wasn't that hard. Worst part was recursing the directories, but I dusted off some old "C Programming 201" memories and got that sorted.

Anyway here is the code:

using System;
using System.Data;
using System.Configuration;
using System.Collections.Generic;
using System.IO;

///
/// Class that recursively copies all files in source dir to dest dir
/// Can overwrite existing or not.
///

public class DirectoryCopy
{

 private List _dirList;
 private bool _overwriteMode = false;

 public DirectoryCopy()
 {
 }

 ///
 /// Copy the Boss Files from install dir to website
 ///

 /// Path to Copy From
 /// Path to Copy To
 /// Base Path to truncate from destination path
 public void Execute(string pathFrom, string pathTo)
 {
  _dirList = new List();
  BuildFileListWithFiles(pathFrom);
  foreach (string file in _dirList)
  {
   try
   {
    string destFile = file.Replace(pathFrom, pathTo);
    CreateDirIfNotExist(Path.GetDirectoryName(destFile));
    System.IO.File.Copy(file, destFile, _overwriteMode);
   }
   catch (IOException) // if files exists then that cool just keep going
   {
    continue;
   }
  }
 }
///
/// Recursively copy files given a Source and Destination Directory.
/// Option to overwrite existing
///

/// Source Directory
/// Destination Directory
/// Overwrite if file existsts?
 public void Execute(string pathFrom, string pathTo, bool overWrite)
 {
  _overwriteMode = overWrite;
  this.Execute(pathFrom, pathTo);
 }

 private void CreateDirIfNotExist(string path)
 {
  if (!System.IO.Directory.Exists(path))
   System.IO.Directory.CreateDirectory(path);
 }

///
/// Get Sub Dirs and Files of a root directory
///

 private void BuildFileListWithFiles(string rootDir)
 {
  // Iterate through all directories
  string[] subdirectoryEntries = Directory.GetDirectories(rootDir);
  foreach (string subdirectory in subdirectoryEntries)
  {
   string[] files = Directory.GetFiles(subdirectory);
   _dirList.AddRange(files);
   BuildFileListWithFiles(subdirectory);
  }
 }
}

Apologies if the formating gets screwed.

Refactoring suggestions welcomed and encouraged.

Tuesday, January 16, 2007

Crap Bats Disaster

Ok, we almost pulled that one out of the fire. Brilliant fielding as usual and Patel was great - he bowled very well and caused a run out in the field.


However, this should detract from our woeful batting. In fact it should highlight the fact that if we had got a few more runs then we would have won. It is clear to me, that our fielding unit is as good as any team in world cricket. We are a balanced attack, and when Bond fires we can scare any team. The fact he hasn't really fired yet is highlighting how well the rest of the unit is going. Jimmy Franklin is probably the weak link, but he will make way for Oram or Styris or both.

If I was "The Ferocious Mr Fixit" here's how I would put it:

The Problem:
Our batting has the ability, but the line up is wrong.

The suspects:
McCullum is a fine finisher. He just looks ordinary against the new ball. He has all the shots in the book, but some players just can't handle the swinging ball. It also looks like he is trying too hard.

Fleming is badly out of touch. Astle is hit and miss but should stay. Taylor is class, but is running the risk of having his flair coached out of him as seems to happen to all young New Zealand players.

McMillan is a stop gap measure at best. Fulton looks ok, but needs to stop getting out in the 20's - application and concentration. Vettori is class, but again needs to get more out of himself, and the tail without McCullum to boost them looks very long.

The Fix:

Astle and Fleming to open. Astle told to play his game, and Fleming applies himself as the glue that holds the innings together.

Taylor at 3 and again just told to play his game, but prize his wicket and remember that he can't play the big shots from ball one.

Fulton Ok at four, but would be pushed down when Styris back.

Macca finally put down, and replaced by Fulton when Styris back, or a Marshall until then. A Marshall only needs 20 odd cos it saves 20 in the field.

McCullum at 6 or Oram when he fit. Vettori at 7 (or 8 when he Oram fit) and the rest of the tail. I would leave the bowlers as is, but replace Franklin with Oram when fit and rotate Mills, Patel and Gillespie depending on conditions.

The biggest change I would make, would be to not worry about scoring 100 in the first 15. I would tell the top order to nudge it around, and only look to hit the bad ball for 4. Goal would be 2 or 3 down for 100-120 at the 30 over mark. Let the middle/lower order get the bulk of the runs, as that is where our riches are. Taylor, Fulton, Oram, McCullum and Vettori are all potential match winners and the top order with runs on the board can score readily later on.

Sport is about playing to your strengths. Our strength is our middle/lower order. Just because other teams look to get off to a flyer doesn't mean we need to. Play safe, sensibly and leave the hitting to the guys who can.

From time to time it wont work. That is obvious, but the current system hasn't worked for a long time. New Zealand and Fleming in particular used to be the innovators in the One Day game. We had to, to overcome our limitations. I think it's time to innovate again. For the sake of all New Zealand sporting fans.

Crap Bats do it again

What a tremendous cricket team we have. Rolled for 205 against what could laughably described as England's attack. I'm sure the Bangers would have made more than 205 against Anderson, Collingwood etc.

It is the lunch break as I write this, comforted by the knowledge that this is England, and we are in with a punchers chance against them. If Bondy could get a couple early and Lucas and Patel bowl well England could do their usual Hari Kari. I can't see it to be honest, they have looked the better team for this half of the match anyway.

I'll post a follow up when (if) we lose and make some suggestions as how to fix this disaster we call a batting line up.

Monday, January 15, 2007

Gave in to temptation

After drooling over them for a while, I have finally ordered a MacBook Pro. Just got the base 15 Inch Core Duo 2 2.13, but it should rock. I upgraded to 2gb of ram as I intend to use Parallels and the word on the street suggests 2gb is the sweet spot.

Ordered it from Harvey Norman and because it isn't standard (also ordered the glossy screen) it has to come from Oz and should take 3-4 weeks. I could walk to Oz and back in 3-4 weeks, hopefully that time frame is worst case scenario, but nothing would surprise me from Harvey Norman.

I intend on doing .NET dev work in Parallels, from the reading I have been doing, it should be fine. If not I can use Bootcamp and duel boot, but that is a last resort.

Anyway, more to follow when it arrives...

Wednesday, January 10, 2007

I've hit the century, My 100th Post - it's a theory about a sea change in the computer industry

Ok. I've had time to think since the unveiling of the iPhone. In my opinion, the iPhone will be to the cell phone what the iPod was to the mp3 player. These things are gunna sell like chocolate bars at a fat camp. It doesn't take a genius to work that out.

What will Apple do on the back of this? They own the portable music industry. The will own the portable phone industry. The one place they still don't own is the Personal Computer industry. They did once. The Apple II was the computer industry. The original Mac popularised the GUI interface. And then a usurper called Microsoft came and took it all away (along with IBM I guess).

Can Apple turn this around? I think on the back of the iPhone and iPod popularity, people will look at Mac's as a viable alternative to Windows, especially now that you can run Windows apps natively on OSX.

The one thing holding them back is the price of the hardware. Sure cool has a price, but not that much. If Apple allowed OSX run on generic X86 hardware. Well that would just rock. I really and honestly think if they did that they could make huge inroads into the MS monopoly. The question is: Do they want to?

I guess they think of themselves as a hardware company rather than a software company. Their history is creating computer hardware and software, and it would be hard for them to let go, but please Steve, do it. You could once and for all get one back on your old nemesis.

Tuesday, January 09, 2007

Could this be the ultimate device

Phone, iPod, WiFi internet device, video player, PDA the new Apple iPhone appears to do it all.

I have an HTC Apache which probably does all this too, but is ugly and way to like a PDA to be useful as a phone. The iPhone is under 2 cm thick! If it lives up to expectation this could be the ultimate device.

Not sure when it will be available, but the queue starts here!

I tried, I really did

Linux. Gone. Buggar.

I had to revert back to Windows on my dev pc. I just couldn't get the Ipw3945 wireless drivers to work. I tried everything, and read everything - including the 25 odd page forum topic in Gentoo forums.

So back to Windows it is. Luckily I am now doing dev in VMWare so it was easy as pie to get running again.

Notes from the experience:

- Check you hardware against Linux before you install, although if I had it still would have said the Intel Wireless should work
- Virtual Machines rock. If you aren't developing in VM's then you should. My guest OS is only Windows 2000 which means don't need that much memory on the guest to make it run well. I have 2gb on my dev pc which I think about right.
- Without scientific quantifiable data to back me up, Linux is much faster at surfing the net than Windows. I don't know if this has anything to do with the TCP/IP stack on Windows or what, but pages load so much quicker in Linux. Under Win the page seems to sit there for a second before doing anything whereas in Linux it is pretty much instantaneous.

I guess for all it's issues, Windows has made the Computing experience very easy. Biggy ups to MS for that at least.

Thursday, January 04, 2007

Linux (again)

I had reason to reinstall my laptop the other day. I had been running Vista but didn't want to activate it, so was going to reinstall XP.

I decided to do all my dev etc in a Virtual Machine, because I tend to rebuild my dev machines alot. I figured if all the dev stuff was inside a VM, it would be easier to reinstall etc.

Anyway, so I figured if I was doing that, why not run Linux as the Host OS. I like Linux, it just feels better than XP and even Vista. The security is great and works as it should and IE malware etc is just not a concern. There is one glaringly obvious problem with Linux.

Drivers, Drivers, Drivers!

Windows installs in about 30 minutes, either installs the correct drivers out of the box, or just simply install from the CD and hey presto, you're away. Linux, well that's another story.

Sometimes you are lucky and can find a driver and it installs easy. Most of the time it doesn't. Take for example the Intel Wireless Driver in my Dell laptop. To get that to work, you need to compile a new kernel. Come on people. As long as the average user needs to compile the freaking kernel to get something going, Linux ain't going to be mainstream. Period.

Yes, I understand the awesome power of doing this, but I have been trying to get my laptop going for over a day now, and the upside by far outweighs the downside.

Anyway, the kernel compile has finished so I must reboot and try again....