garyshort.org


I am a Technical Evangelist for Developer Express, my work blog is here but this one is more fun. :-)

February 2007 Entries

Smalltalk Cookbook #1.13

Problem

You want to access portions of a string. For example, you have read a comma delimited record and you want to extract the fields.

Solution

Use the built in String method subStrings: This method breaks up a string at the given character. Evaluate the following in Dolphin Smalltalk for an example:-

Imagine you have a comma delimited customer record containing the fields firstName, lastName, emailAddress, phoneNumber and faxNumber; you can extract the first name like so:-

('Gary,Short,gary@here.com,02745 555 888, 02745 555 777' subStrings: $,) at: 1

You can access all the fields thusly:-

('Gary,Short,gary@here.com,02745 555 888, 02745 555 777' subStrings: $,)
do: [:each | Transcript show: each; cr ]

Technorati tags:

800 Vista Compatible Applications…

... and Visual Studio 2005 isn't one of them!

Well okay, that's not strictly true; VS 2005 is on "works with Vista list" it's just not on the "Certified for Vista" list, which means you have to put up with all those warning dialogs when you install it. Not to mention the fun you have when trying to debug something. :-)

Software Patent Common Sense

Yesterday the UK Government responded to an e-petition asking the government to "make software patents clearly unenforcible." The Government's full response can be found here, but the gist of it shows common sense, at last, in this area.

"...if this advance lies solely in the field of software, or another non-technical field such as methods of doing business, the patent will not be granted."

Technorati tags: ,

Desktop Wallpaper from Flickr Feed

Do you get fed up looking at the same desktop wallpaper day after day? Yeah, me too, so I wrote a little C# console application that reads a flickr feed of images, picks one at random and then sets it as your desktop wallpaper. Now all I need to do is to set it up as a scheduled task to run a couple of times a day and I'll get a nice new wallpaper to look at. :-) For those who are interested, the salient code is below.

class Program
{
    //Define constants we'll use later
    public const string RSS_URI = "YOUR_FLICKR_RSS_URI_HERE";

    //Define the external function we need
    [DllImport("user32.dll", CharSet = CharSet.Auto)]
    private static extern Int32 
        SystemParametersInfo(UInt32 uiAction, UInt32 uiParam, 
        String pvParam, UInt32 fWinIni);
    private static UInt32 SPI_SETDESKWALLPAPER = 20;
    private static UInt32 SPIF_UPDATEINIFILE = 0x1;
    
    //Application entry point
    static void Main(string[] args)
    {
        //Download RSS info
        XPathDocument xpd = null;
        try
        {
            xpd = new XPathDocument(RSS_URI);
        }
        catch (XmlException xe)
        {
            Console.Write("The following xml error " +
            "occurred: " + xe.Message);
            return;
        }

        //Create a name space manager 
        //and add the media namespace
        XPathNavigator xpn = xpd.CreateNavigator();
        XmlNamespaceManager nsm = 
            new XmlNamespaceManager(xpn.NameTable);
        nsm.AddNamespace("media", 
            "http://search.yahoo.com/mrss/");
        
        //Select all image URLs
        XPathNodeIterator ni = null;
        try
        {
            ni = xpn.Select(
                @"/rss/channel/item/media:content",nsm);
        }
        catch (XPathException xpe)
        {
            Console.Write("The following XPath exception " +
                "occurred: " + xpe.Message);
            return;
        }

        //Download an image at random
        Random rng = new Random(DateTime.Now.Millisecond);
        int randomInt = rng.Next(0, ni.Count+1);
        int i = 0;
        while (i < randomInt)
        {
            ni.MoveNext();
            i++;
        }
        string imageURL = 
            ni.Current.GetAttribute("url", String.Empty);

        WebClient wc = new WebClient();
        try
        {
            wc.DownloadFile(imageURL, "temp.jpg");
        }
        catch (WebException we)
        {
            Console.Write("The following web exception " +
                "occurred: " + we.Message);
            return;
        }

        //Convert image to BMP
        Image bmp = Image.FromFile("temp.jpg");
        bmp.Save("temp.bmp", ImageFormat.Bmp);
         
        //Set image as desktop wallpaper
        SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, 
            "temp.bmp",SPIF_UPDATEINIFILE);
    }
}
Technorati tags: , , , ,

Thinking Day 2007

This afternoon, my wife, daughters and son took part in the annual 'Thinking Day' Parade for Scouts and Guides. Congrats to my youngest daughter who carried the Union Flag on the parade, and to my son who carried the Cub Scout Banner. There's a short video of the parade below.

Mac | Windows

Technorati tags:

Partnering for the Future

"A project we've called Partnering for the Future (PFTF) has been bubbling under at our Reading offices for about 6 months now and finally we lifted the lid on it this week resulting in lots of press coverage after Claire and Karl hosted a press roundtable."

Source: Steve Clayton

In the above article, Steve talks about the new PFTF initative. What particularly caught my eye was the mention of SaaS. Our latest prodcut (NetBake) is SaaS enabled, but only to the first level of maturity (multiple instance, single tenancy), what we need to do in the future is to move towards level four of the maturity model (single instance, multiple tenancy) to get the most out of our investment.

Technorati tags: ,

When those Legacy Apps Have to go

"Legacy applications are old. But how old? I tend to think of my VB6 apps as legacy. But heck, they are modern compared to another app I have hanging around. I have avoided accepting the fact that I was working with an application that was at least 16 years old. The oldest file I can find in there is from early 1991."

Source: Julie Lerman

It's always hard to decide when it's time to re-write those legacy apps. The decision, for us, was easy. We had a 15+ year old COBOL application installed on a number of customer sites, these customers were starting to get really picky. I mean, they were looking for stuff like multiple windows, and right click menus etc, can you imagine! The cheek of it. Anyway, it became pretty apparent that the old system needed to go, and so we decided we'd replace it. We changed the old, monolithic, flat file based system, with a modern, 3 teir .Net application based on SaaS principles. If you want to know how we did it, check out the project page here.

Technorati tags: , , ,

Computing Award goes to Female for First Time

One of the most prestigious prizes in computing, the $100,000 Turing Award, went to a woman Wednesday for the first time in the award's 40-year history.

Source: CNN.com

Technorati tags: , , ,

‘Windows Vista Capable’ barely hits the mark

February 20, 2007 (Computerworld) -- Configuring a PC around the minimum hardware requirements of an application or operating system is lot like agreeing to live in a basement apartment. Sure, it will work as a place to live -- if you don't mind damp and dim living conditions.

Source: Computerworld

Turns out the sweet spot is 4GB.

Technorati tags: ,

Sometimes…

Michael's damned lucky I let him give me a lift home at night! :-)

Can you Define Web 2.0?

...Nah, neither can I, but this guy can.

Technorati tags:

MPAA Steals Code, Violates Linkware License

All licenses are equal, but some are more equal than others

A blogger who wrote his own blogging engine called Forest Blog recently noticed that none other than the MPAA was using his work, and had completely violated his linkware license by removing all links back to the Forest Blog site, and had not credited him in any way.

Source: TorrentFreak

Could the Disabled Bring Down E-Commerce?

"A qualifications body discriminated against a blind systems manager when it failed to make its computer-based exam accessible to her. The tribunal ruling is the first to find a US company with no presence in the UK liable under the UK's Disability Discrimination Act."

It turns out the the company involved provides a computer based exam. This exam was not accessible to the claimant and the company did not make an auxiliary service available to her. This is an offence under the Disability Discrimination Act.

The "take away" point from this story is that the company is not a UK company, it is an American company, however, the tribunal ruled that

"...the fact that the respondent was in a position to make arrangements within Great Britain for the Claimant to pursue a course and potentially receive a qualification from them in Great Britain, meant that they became persons who moved within the jurisdiction of the legislations," she continued. "The place where the claimant suffered the alleged less favourable treatment was within the jurisdiction of Great Britain and as such her complaints are ones that can be heard by the Tribunal."

This in turn has led Sarfraz Khan, Senior Legal Officer at the DRC, to say

"There is a possibility that the judgment might usefully inform a court considering a Part 3 web access case as to whether jurisdiction can be made out where that provider is ordinarily based outside of Great Britain but is providing access to goods and services within Great Britain through a website."

He went on to say

"...people ordering goods within Great Britain are likely to have them delivered by whatever means might be used by the company who are selling those products via the website but the website itself may not be accessible and in those circumstances a court might determine that they are liable."

What is being put forward here is that organisations whose sites are available in the UK fall under UK law with regard to accessibility. If this precedent is held, then sites could also fall under UK law with regard to commercial legislation, and if this is the case and the same principle is used to scrutinize UK based sites, then that would mean that UK based sites would have to comply with legislation from every country in which their site was available - potentially every country in the world!

In my view, this would spell the end of e-commerce. No company could afford the resource to ensure that their site complied with all legislation from every country, they would simply shut down their sites in order to resolve their liability. This can't be the purpose for which the DDA was enacted.

source: OUT-LAW.COM

BCS Tayside: Arguing for computers

BCS Tayside: Arguing for computers
Arguing for computers or, the computational advantages of being disagreeable Speaker: Chris Reed, University of Dundee
Thursday, February 15, 2007 7:00 PM
Dundee University
Dundee,

New Windows Mobile 6 Smartphone Software

"Microsoft Corp. today unveiled Windows Mobile® 6, the newest version of its mobile software platform. By improving usability and adding support for Microsoft® Office features previously available only on PCs, Microsoft Windows Mobile 6 delivers to the small screen a familiar and rich experience that meets the needs of work and life while on the go, all with a single device."

Source: Microsoft

Technorati tags: ,

Mary Jo Says Windows 7 is a Comin’

The countdown clock is officially ticking: Windows 7 due in 2009 by ZDNet's Mary Jo Foley -- The countdown clock officially is ticking. The goal is Windows 7 in 2009.

Technorati tags: ,

Dundee Council Tax

"DUNDEE WILL definitely not have the highest council tax in Scotland and it is virtually certain there will be no increase at all when the figure is set later this month.

City council administration leader Jill Shimi made the announcement yesterday following council tax levels being set by almost all the other Scottish local authorities on Thursday."

Source: The Courier

Gee, anyone would think it was an election year! :-)

Wow, the GUI of the Future

Check out this GUI, it'll blow your mind

Source: FastCompany

Steve Jobs to Step Down, Google CEO to Take Charge!

"According to the Apple vendor that takes us out to lunch OFTEN ;-) Steve Jobs will be stepping down and the CEO from Google will be taking his position. I know that this has not been made public yet but just sit back and wait. Everything else that this man has told us has come to pass, so lets just wait and see what happens. As my husband said kenswain.com, Google may be the only one who hates Microsoft more than Apple."

Source: angel-elf.com

Hmm, don't know about this one, I don't know anything about this blogger, so it could be a good scoop or it could just be some clever viral marketing, but either way it's juicy news.

Burndown Graphs

 Ah, this is what I like to see. :-)

Burndown Graph

Technorati tags: ,

Dream Build do What?

Hey does anyone at Microsoft know what's happening with this competition?

Technorati tags: ,

Threads and the Singleton Pattern

Recently I was having a chat with someone about the Singleton pattern and we were looking at a standard implementation, which looks something like this

public class Loner
{
    private Loner() { }
    private static Loner _Instance;
    public static Loner Instance
    {
        get
        {
            if (_Instance == null)
            {
                _Instance = new Loner();
            }
            return _Instance;
        }
    }
}

To get the Singleton instance you would call Loner.Instance. Now, do you see the problem? No, neither did I to start off with, until the guy I was chatting to asked what would happen if many threads called Loner.Instance at the same time.

Ahhh, light dawns. That's right; this implementation is not thread safe, if two or more threads arrive at the null test at the same time, you may get two or more "singleton" instances being created. Obviously, this breaks the pattern and is not good. We could fix this by inserting a mutex around the test and instance creation, in C# this is done by using a lock, like so

public class Loner
{
    private Loner() { }
    private static Loner _Instance;
    public static Loner Instance
    {
        get
        {
            lock (typeof(Loner))
            {
                if (_Instance == null)
                {
                    _Instance = new Loner();
                }
            }
            return _Instance;
        }
    }
}

Now, whilst this would work, and is indeed thread safe, the thing is locks are expensive and if you have many threads running this code, you may see a performance hit. Perhaps a better solution is this

public class Loner
{
    private Loner() { }
    private static Loner _Instance = new Loner();
    public static Loner Instance
    {
        get { return _Instance; }
    }
}

This is both thread safe and does not have the overhead of a lock.

Technorati tags: , ,

Paul Kuntz - Web Pioneer

Watch Paul chat to Scoble about the early days of the Web.

Technorati tags: ,

Snow Causes Transport Chaos

"Commuters are battling rush-hour chaos after heavy snowfalls across large swathes of England and Wales."

That sounds bad, tell me more.

"Luton, Stansted, Cardiff, Bristol and Birmingham airports have closed runways and train services have been hit."

Any other airports affected?

"The runway at Gatwick airport was closed because of the severe weather, but has now reopened. Passengers are being advised to check in as normal.

The runways at Luton, Stansted, Cardiff, Bristol, Birmingham and London City airports have also been temporarily closed.

British Airways warned that many short-haul flights from Heathrow airport would be cancelled after 1000 GMT.

Passengers are being advised to contact their airline before travelling."

Are the roads affected too?

"The Highways Agency - which sent out gritting lorries overnight - has warned of poor driving conditions, and urged drivers to travel only if necessary.

A spokesman for the AA's Roadwatch service said motoring conditions were worst in the south-east of the country, with Surrey, London, Buckinghamshire, Hertfordshire and Essex all affected by the snow."

And how about the schools, are they open?

"All schools in Birmingham, Solihull and Dudley have been closed, as well as some in Gloucestershire, Herefordshire, Worcestershire and East Anglia.

Nearly 100 schools are also closed in Wales but the figure is set to rise."

Wow, it sounds like a real snow storm has hit the UK, how much snow has there been?

"Up to 5cm (2in) of snow has already fallen"

What?! Is that all?! All this fuss and chaos around the country and there hasn't even been enough snow to come half way up the tyre on my car! What is wrong with this country?

Source: BBC

Technorati tags: , ,

School Revision 21st Century Style Redux

Remember back here, I said I'd gotten my local secondary school interested in the idea of preparing revision material in a format that the kids are already into? You know the sort of thing, online video, podcasts, mp3 and all that Jazz.

Well it looks like it's all coming together; the school have gotten the software and it wont be long until we start to produce some (hopefully) useful assets for the kids to use. Stick around, and I'll keep you undated.

Technorati tags: , ,

Making a Hash of Business Problems

In another "blast from the past" here's an article I wrote back in 2003 that solves the "you show me yours first" type of problems that sometimes come up in business.

Twitter Updates


    Follow me! :-)
    www.flickr.com
    GaryShort's photos More of GaryShort's photos