Banking knowledge

August 26th, 2010 / 1 Comment » / by Owen

Since the day I started programming I wanted to work for an Investment Bank. Along with those who write operating systems and device drivers, I held developers at banks to be the top dogs of my industry.

The difficulty in breaking into working in finance always seemed to be the prerequisite of banking experience and finance knowledge. As it happened, I got my current contract with UBS without this requirement being an issue; I’m now seeing why a good working knowledge is so important.

I’ve found some great sites since starting, these give a good overview of many of the important financial instruments and terminology in use;

They are just two of the ones I use to keep my head above the water… which I’ve managed to do, so far.

Tags: , , ,

Duplicate Music Files

August 10th, 2010 / No Comments » / by Owen

I’ve started to notice an awful lot of duplicates in my music collection… personally I blame iTunes and it “Organize” feature for the mess I’m left with.

If you Google “Remove Duplicate Mp3s” you’ll get a whole host of web sites with solutions, most of them smell a lot like dodgy sites so I wasn’t too keen on downloading any of them.

I figured this might be an opportunity to write a little console app to solve my problem.

Below is the commented code to achieve this;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
namespace DuplicateExample
{
    class Program
    {
        public static void Main(string[] args)
        {
            // get the full list of files matching mp3
            string[] files = Directory.GetFiles(@"d:\music",
                                                "*.mp3",
                                                SearchOption.AllDirectories);

            // iterate through the files
            foreach (var file in files)
            {
                // load contents of file in to byte[]
                var contents = new byte[file.Length];
                using (var fs = new FileStream(file, FileMode.Open))
                    fs.Read(contents, 0, file.Length);

                // create the md5 object
                var md5 = MD5.Create();
                byte[] hashBytes = md5.ComputeHash(contents);

                // convert the hash bytes into a hash string
                var sb = new StringBuilder();
                for (int index=0;index<hashBytes.Length;index++)
                    sb.Append(hashBytes[index].ToString("x2"));

                // now you can use the hash string as a dictionary key
                var hash = sb.ToString();
            }
        }
    }
}

Tags: , , ,

Nemo and the Anglerfish

August 4th, 2010 / 1 Comment » / by Owen

As I mentioned in a previous post, my son recently had surgery on his nose, so although I have the relative luxury of going to work, my wife has been house bound for the most part wAnglerfishith the kids.

On Sunday I sat down to watch Finding Nemo with him to try and stop him climbing the walls. For those who’ve not had the genuine pleasure of watching it, there is a scene where Nemo’s day and Dorie swim down to the depths of the ocean where it’s very dark. They see a pretty bright light and swim towards it.

When they get to the light, the fish appears out of the murk. Now, this is a pretty cool fish, I assumed there was a certain amount of poetic license going on, but it turns out it’s real – it’s an Anglerfish.

So not only does it have a light on the end of a fishing rod, but that’s the least interesting thing about this fish, here are some more facts.

  • There are around 200 species of Anglerfish
  • They can grow up to a meter in size
  • Only the female has the light
  • The males are smaller and live to literally bond with a female…. when they find a female they latch on with their sharp teeth
  • Over time the male fuses to the female combining skin and blood vessels
  • Over time, all organs in the male stop functioning and the eyes disappear. The only thing left functioning is the testes
  • A female can have up to six parasitic males attached to her.

An amazing fish, and not something I ever expected to blog about, but worth further reading.

Tags: , , , ,

Adenoid Surgery

July 30th, 2010 / No Comments » / by Owen

On Wednesday my 2 and 1/2 year old son had his adenoids removed. I was aware that this is a fairly common thing but I didn’t appreciate just how routine it actually is.

For some background reading, here is the explanation of adenoids.

We went into the childrens ward for 12 midday, as he is only little he was one of the first batch from the 7 ENT kids to be getting treated. I say batch because that was essentially how it was done. A group of 4 then 3, down to the waiting room in the surgical ward to go in.

Steph and I agreed that I would go into the anesthesia room with him for his cannula; something I don’t plan to do again anytime soon. I think that the person who was doing the cannula was new and still getting practice; which leads me to the point of this post.

While my very rugged little boy was yelping with pain because they were having problems getting a good vein I was ready to deck those responsible for hurting my boy… 10 mins later when I had recovered from seeing my slumped little fella lying unconcious in my arms I started to return to my default way of thinking.
If doctors, nurses etc don’t get the opportunity to do procedures like a cannula (he was supervised by two others) then how are they ever going to become good at it and not cause pain.
Realistically, my son felt a few minutes of pain which he has since forgotten while the anesthetist got invaluable practice dealing with toddlers anesthetic.

The NHS is awful when it comes to time keeping, admin and bureaucracy; but the moment you get to the point of the care being administered I don’t think it can be faulted. Yes, people have horrendous experiences, but they are the exception.

The NHS is what we have, and we’re very lucky to have it… at some level it’s running 24/7 and operates like a huge machine that most of us can’t comprehend keeping running. Like most things it could be improved on, but I took my son home fit, well and happy so they have my full backing.

Tags: , ,

WPF Adorners – a brief introduction

July 23rd, 2010 / No Comments » / by Owen

WPF Adorners allow us to place an overlay over a UIElement to alter it’s appearance. The following example is somewhat contrived since there are much more appropriate ways to achieve the same result.

I’m going to overlay with a reddy/pinkish hue when attention is needed to the UI element.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
namespace AdornerExample
{
    public class AttentionRequiredAdorner : Adorner
    {
        // initialise the base class with the control to be adorned
        public AttentionRequiredAdorner(UIElement adornedElement)
            : base(adornedElement)
        {
            // we want events to pass straight through to the adorned element
            IsHitTestVisible = false;
        }

        protected override void OnRender(DrawingContext drawingContext)
        {
            // get the area of the UIElement to be adorned
            var adornRectangle = new Rect(AdornedElement.DesiredSize);

            var renderBrush = new SolidColorBrush(Colors.Salmon)
                                  {Opacity = 0.3,};
            var renderPen = new Pen(new LinearGradientBrush(Colors.Pink, Colors.Red, 90)
                                        {Opacity = 0.6,}, 2.5);
            drawingContext.DrawRectangle(renderBrush, renderPen, adornRectangle);
        }
    }
}

I’m going to use a text box to apply my custom adorner to, I could just as easily use any other UIElement.
In my xaml, I’ll create the TextBox.

<TextBox x:Name="myTextBox" Width="150" Height="20" />

We need to get the AdornerLayer for the UIElement control, in this case myTextBox. Once we have the AdornerLayer, we can add an AttentionRequiredAdorner, passing it the UI Element to adorn.

1
2
var adornerLayer = AdornerLayer.GetAdornerLayer(myTextBox);
adornerLayer.Add(new AttentionRequiredAdorner(myTextBox));

Our text box now has the AttentionRequiredAdorner applied.

Tags: , , ,

Microsoft SmallBasic

July 22nd, 2010 / No Comments » / by Owen

I spend quite a bit of time looking at the Microsoft MSDN site, I am after all primarily a Microsoft developer.

Microsoft Small Basic - a good start

I maybe quite behind on the curve with this one, but I’ve discovered Small Basic. I’ve not taken time to look at it, I don’t think it’s quite aimed at me. It did cross my mind if I could get my son interested, but at 2 yrs old I think I might be a little premature, maybe next year.

For a long time I thought the only way to be a good developer was to do everything your self; essentially reinventing the wheel wherever possible. That thinking is quite deep seated in me so I have a constant battle to resist it. The idea that it is now even easier for beginners to learn the principles of programming doesn’t make me recoil.

It’s true that I think you’ve either got an aptitude for development or you haven’t. I’ve met enough people to see that you can make a career out of it whether you’re any good or not. A good beginner is going to quickly identify the limitations of Small Basic and graduate to something more; those who don’t reach that limit can enjoy playing with development and one day may become a sensible end user as a result.

Tags: ,

Windows XP Address Bar

July 14th, 2010 / No Comments » / by Owen

It’s well document that with the release of Windows XP Service Pack 3 we lost the ability to have an address bar on the taskbar.

The most commonly reported way to resolve this seems to be replacing browseui.dll from SP2.

This is all a little excessive, the solution is quite simple.

  • Go to the desktop
  • Left click My Computer and drag to the screens edge
  • Let go
  • Right click the bar that has appeared, select Address from Toolbars
  • Bingo!!!!

Tags: ,

Remove duplicate text lines wth Python

July 8th, 2010 / No Comments » / by Owen

As part of my quest to learn new skills, I’ve turned to Python as the newest skill to learn.

In the past when I have needed to do something quick and dirty in code, I’ve needed to fire up Visual Studio, create a new console application and do whatever mundane task is required. (more often than not it involves parsing some file or other.)

Then came Powershell, it was great, particularly for SharePoint API prototyping work. The problem with Powershell was that while I preferred to work in the console window, the requirement to know the oddities of the Powershell syntax slowed productivity and the GUIs that were available at the time were slow and cumbersome.

My brother (Dan Rumney) waxed lyrical about Ruby last time I saw him and I believe he is also a major fan of Python.

Forward to today, I’ve been handed a csv file with 1489 rows and need to email a list made up of unique values from the first column. I decided that this was a good time to have a bash at writing a Python script to do the work. For this, I figure the Set collection in Python is pretty good since it only allows unique values.

1
2
3
4
5
6
7
file1Path = raw_input("Enter the path of the source file: ")
file2Path = raw_input("Enter the path of the destination file: ")
file1 = open(file1Path)
file2 = open(file2Path, "w")
curves = set(file1.read().split('\n'))
file2.write("".join([curve + '\n' for curve in curves]))
file2.close()

Tags: , , ,

When searching for perfection, know when to stop

July 8th, 2010 / No Comments » / by Owen

The past few weeks has had me working on what was essentially a piece of proof of concept work that needed to be realised.

In short, the application needs to take two generated results files and compare them. The problem being that these files may match as far as the business rules are concerned, but the format of them could be mismatched. As a result, the usual file diff apps can’t be used.

In it’s first incarnation, the app parsed the files as XML and compared the matching nodes, this was quick, however due to the schema, required a lot of hard coded values. The more scaleable and future proof solution was to run the files through a prewritten Excel function to output an object[,] with the results of the files. This output could then be parsed and a proper match.

This leads me to the point of this post. Some of the object[,] being returned from the Excel function were huge and to do a correct comparison of the files there are potentially 200 x 2 arrays each with between 1 and 14,000 objects in them. From a memory point of view this posed a huge headache when it came to the parsing.

For around 10 days I’ve been working to optimise performance in the face of a very large memory foot print. While demonstrating it, I finally accepted that it was time to stop trying to tweak and improve.

The lesson learnt is that while it’s a good thing to strive for perfection, sometimes we have to accept that ‘good enough’ is okay sometimes.

Tags: , ,

iPhone 4

July 7th, 2010 / No Comments » / by Owen

I don’t really pay much attention to the iPhone. I’m not an Apple hater particularly, I just think they’re as bad as Sky for selling nothing special for huge amounts of money. Credit to both companies for their ability to market.

Personally, I use HTC phones, simply because of their price point. When O2 released the iPhone and ever since, consumers have been charged an awful lot more for a device that, until recently, was technically not as well endowed.

All that said, I do think the moaning about the new iPhone and it’s antenna issues are getting silly. I am know radio expert, I did a long module on Radio and Radar while training as an engineer in the RAF and physics lessons at school; both taught me touching an antenna has an effect on attenuation. However, the area on the iPhone 4 that causes the drop in signal is not a place I would imagine many people be holding mid call.

I appreciate some people are genuinely being affected by this, but would bet that an awful lot more people are jumping on the band wagon to complain.
The answer is obvious, go for HTC (Android or Windows) and save money.

Tags: , ,