I have been wanting to figure out a reliable way of doing this for a while, and suddenly the necessity arose for me to do it, so I have a solution. As far as I can tell if you have a date field in an object and an array of those objects, then the results of sorting the array are indeterminate.

public class myClass
{
    public var some_date: Date;
}

var myArray:Array = new Array();
myArray.push(new myClass);

myArray.sortOn("some_date");
myArray.sortOn("some_date", Array.NUMERIC);

The above code (so long as the some_date field was populated) never gave me reliable result for the sort order. I googled in vain for a solution and found a couple, but was never really happy with them. I had a flash of inspiration this morning which is really very obvious now I have done it, but is a nice elegant way of handling this situation.

Basically I add a public getter for a new field which just returns the Date objects time value as a Number, e.g.

public class myClass
{
    public var some_date: Date;
    [Transient] public function get some_date_time():Number
    {
        return some_date.time;
    }
}

var myArray:Array = new Array();
myArray.push(new myClass);
myArray.sortOn("some_date_time", Array.NUMERIC);

This works a treat and gives me reliable sorting results every time.

In case you are wondering why I use [Transient] it is because I am using RPC and remote objects for the connection back to my server and my classes are generally [Managed]. Without the (undocumented) [Transient] metadata some_date_time would be treated as a legitimate field and an attempt would be made to serialise it back to the server across the RPC boundary. This causes a warning to be thrown in the Flex server framework code which clogs up my logs and feels unprofessional.

Also, in case you are thinking that I am mad putting a space in my declaration of the Date field, here’s why…

var date:Date;

I can’t figure out how to turn the stupid smileys off…


Domain fatigue

04Jan09

There are a few irritants in my professional world and one in particular that bothers me, namely domain squatting. This is done by people who want to exploit their sernedipitous luck at having registered someone else’s name before them and then try to make a fast buck out of it by selling it back to the rightful owner and the only person in the world for whom it has genuine value.

A .com domain is a valuable marketing and branding tool and a key part of a companies online marque. For someone else to be able to swoop in and steal it, just because it is on the web, is frankly ridiculous.

In any other walk of life this behaviour would be called blackmail or extortion, but because the names are available in an apparently free market on a first-come, first-served basis – even if you have spent a hundred years building a brand – it is seen as a tolerable and even legitimate practice. If I happen to have lodged the name CocaCola.com before The CocaCola Company did I would legitimately own the rights to the domain. I can’t help but feel that is morally wrong.

Why are domain names not covered by a branch of the law adjacent to trademarks or even copyright?

I am discovering that this entirely pointless and negative industry stoops even lower. If you trip up in registering a domain name there are people watching – God knows how – who will step in and pinch it from under your nose and then try and sell it back to you above market price. This is an empty, opportunistic, negative, amoral scam. It is tantamount to theft by people who have nothing positive to add to the world of commerce. The perpetrators ought to be hunted down and banned from holding domains.

And it doesn’t stop at domains. Registration of company names is subject to the same corrosive and intellectually and morally bankrupt activity. My startup’s name is Dialectyx Solutions Ltd. It is that because Dialectyx Ltd., which was our original choice, was registered by someone else in the 72 hours between us doing a search and submitting the registration papers. That company name is now registered with a firm of solicitors in a small town about 25 miles away from us. Dialectyx Ltd. does not actively trade.

Coincidence? Hardly.

And right now I wait with baited breath while my latest domain registration attempt lingers in the odd limbo between paying for it and it actually starting to work. According to whois, the domain is still available. According to my registrant I have been billed. Right now I have no idea where I stand. Surely there’s a better way to do it than this? Surely there should be some protection against the shameless scammers who are sitting on valuable corporate assets?


Looks like someone has publicly been bold enough to recommend what many of the technorati did a long time ago, namely ditch IE. This news ought to be the final straw for the ubiquitous browser. It has been the Typhoid Mary for the majority of serious viruses and annoying malware attacks that I have had the misfortune to have witnessed over the last few years.

When friends notice that I use Firefox I am aften asked why. I could once dribble on about the Mozilla browser code base being superior, sticking to standards, not trying to impose proprietary things on unsuspecting users, openness and competition, and even once tabbed browsing and a host of little usability features. But at the end I wound up with a very unconvincing it’s just better.

Now I have a better answer.

So Firefox, this is your big chance. It is possible to imagine a scenario where a few corporations say, “look, we are fed up with constantly having to patch users computers with IE security fixes. The automatic updates are a nightmare and are responsible for the gradual slide in to inoperability of Windows itself. Let’s just do one last upgrade over to Firefox and switch IE off for good”.

A couple of those in the press – maybe a public sector institution or two – and suddenly a tide of interest in Firefox will follow.

I’m sure the clever folks at Firefox are way ahead of me, so here’s hoping that they have some canny marketing around this once in a lifetime opportunity. They couldn’t have written a better script for the demise of the incumbent Gorilla.


I’ve been adding integration points between my apps and salesforce.com for the last couple of years and I think that it is cool that you can create mashups with a real piece of a company’s operational infrastructure. There’s no doubt that having their API available publicly across the web affords me some very intriguing opportunities in terms of value added application creation.

And, I have also managed to almost completely remove the need for any Administration interface in my application because I can devolve the data acquisition tasks to my users – even though they aren’t the most patient or technically able crowd. This makes a great story, and a much simpler solution.

I have grand visions of supplanting the entire salesforce.com user experience piece by piece by building it into process driven appealing interfaces that people will enjoy interacting with and are designed to fit in with people’s day to day activity – rather than the reverse. But that’s naked ambition. I’ll get there, but it’ll take me a while.

And meanwhile I have the sticky issue of suddenly being unable to access their API at all through the front door due to a bug which they must have introduced with a recent change to the cross domain security policy they enforce.

My particular situation may be reasonably unique in that I am writing Flex interfaces and hosting them on my own servers, i.e. I am not using the force.com platform, nor visualforce or anything like that, I am standing on my own little planet and relying on then keeping the radio on at their end so I can continue talking to them.

Just recently they changed channels. All of a sudden access to their app from outside stopped working from within my app. After posting on the force.com developer boards (here and here) I spent a frustrating couple of weeks in complete darkness. I even posted on StackOverflow (here and here), but (predictably) didn’t really get what I needed.

So, I dug out my curly pipe, put my deerstalker and cape on and turned detective.  I followed a few of the responders links back to their blogs and posted questions there to see if they would divulge the names of their salesforce.com contacts to me. At the same time I trawled the open source code I use for the Flex / salesforce.com bridge looking for any unsuspecting email addresses embedded in code headers. Sure enough I found some.

After about a week of sending out my messages in bottles, all of a sudden I got lucky and was put in touch with a support engineer and one of the original developers on the flex interface.

From that point on it was just a matter of proving that the issue was not just me being stupid and to create a test case which was reproducible outside my software. Thanks to James Ward’s furryhappymonsters.com I could show that me and all my users hadn’t just forgotten our passwords and security tokens in some mass amnesia event, but there genuinely was a problem.

Turns out that they did introduce an issue which means that if you connect to the API through the www front door you will get bounced because it cannot resolve you to your designated server (you have a designated server because they balance traffic load by providing affinity between accounts and servers at their end).

The workround I have had to implement until they fix the issue is to get my users to provide the server that they are attached to. This is a *horrible* thing to ask them to do as it makes me and my software look techy and klunky and if they get it wrong it fails and I look buggy and… sigh. Fortunately all they need to do to get their server is log in to salesforce.com directly and they can see it in their browser address bar, but even so, it is a horrible experience and exactly the opposite of the carefully crafted non-technical image I am trying to present.

As for a fix; now that salesforce.com has acknowledged there is a problem – which they did very graciously, I add – I don’t have a way of tracking it. And I think this is the most frustrating part of all. Unless you are really in the family it is hard to get much traction with them developer to developer. I think that if they really want their platform to take off they are going to have to move a long way towards the immediacy that you get from an open source developers forum trying to do the same thing.

Actually, at the end of the day, I think that they are likely to fail in their aspirations to make the force.com platform the operating system of the enterprise web future precisely because they are not culturally disposed to the mindset of openness and freedom that is relied upon by developers.  And that will turn developers off. Until that changes they’ll remain an expensive clique.

As for me tracking my issue, I am supposed to contact my partner representative (a person I have never had any contact with and from the spam I get has changed 9 times since I started working with their API) and get a tracking number. It would have been a lot easier for me if the support person I was talking to could have done that, but hey, that’s all part of what salesforce.com have to learn before they get it right.

Meanwhile I check daily in case they have done it yet.

Try it yourself if you have a salesforce.com account, I have posted details and instructions here.


I went to Canada 5 years ago and lived there for 4 years.  Before that I had lived and worked in London since being a student in the mid-80’s.  During the entire time, and in the year since I have been back, I have commuted on the tube.  I don’t use it quite as regularly as I did, but I now travel on it 3 out of 5 days in a given week.

On a couple of my first journeys in London after being back from Canada I was delayed because of a “person under a train”.  I can’t remember having heard that for a very long time and other than the obvious contradictory thoughts of, “how awful, I hope they are OK” and “I’m annoyed they have made me late”, I didn’t think much more of it.

However since then I have noticed with increasing regularity that the reason for delays seems to be more people under trains.  About two months ago I started counting the number of trips that I was delayed for a “person under a train”.  Since a journey to London Bridge on September 16th I have been delayed no fewer than 7 times where that has been publicly announced as the reason.

I think that is a very high number.

What I can’t quite work out is whether these incidents are accidents, attempts at suicide or a creative form of excuse used cynically by the tube.  If they are accidents, then I am surprised that the zealous health and safety executive hasn’t jumped in because I can’t be the first person to notice.  If they are suicides, then there appears to be a remarkable increase in this grisly and inconvenient choice of means and if they are an excuse, then it is a clever and dastardly consiparcy – after all, who is going to complain about a delay caused by rescuing someone from under a train?

I’m going to keep looking for statistics to see whether there has been a sudden spike in suicide deaths on the tube commensurate with the indidence of “person under train” announcements that I am now morbidly counting.  As far as I can tell London Underground does not publish publicly the safety statistics for the network.

I’m not quite at the point of crying conspiracy, especially as the human and long time tube traveller in me can quite understand the thought of killing oneself, and especially not in such a public, unreliable and disruptive way.  I can’t help thinking that if I was at the point of taking my own life I would not go and buy a ticket at a station and stand amongst the silent commuting throng waiting for the next Southbound Charing Cross train.  But then…


Ho hum.  I have lost my initial enthusiasm for Stackoverflow.  I think there are several reasons why:

  1. I am just tired of it
  2. I am sick of reading the same questions posted over and over again
  3. The preponderance of C# programmers asking basic questions is at once demoralisaing and uninteresting
  4. The broader programming population is involved which means that the 99% of programmers (who can’t code their way out of a paper bag) are using it as a first resort rather than a last resort.
  5. Stupid lazy kids are posting their homework questions.
  6. I no longer care about my reputation
  7. The community approach to censure afforded by earnt reputation sounds great, but is really just an absence of policy which leads to capricious and incoherent behaviour by anyone with sufficient reputation to do it.

The conclusion I have come to is that it has settled into a place where two types of questions get asked, i) basic ones by people who are not very good and that they should already know the answer to and ii) extremely niche technical questions that only one other person in the world can answer.

The shine has worn off answering the first type, and often it is clear that the person asking has not even bothered reading a book or googling before they jump in, let alone asked a colleague or figured it out themselves.  For the latter there are probably better forums inhabited by domain experts who will give you answers that may at least stem from some technical experience.

Another thing that has bothered me is the inability to discuss anything.  The format is pretty didactic.  You ask a question, a bunch of people give you answers.  In reality you want more of a dialectic and discussion.  I think that regular topic-oriented message boards do a better job.

So I am drifting back to flexcoders and the numpy and scipy boards.  Maybe I am just paying the price for not developing everything I do using Microsoft technologies (in fact not developing *anything* using Microsoft technologies), but my Stack underfloweth.

The technical forums I mention have been doing this for some time and the difference that Stackoverflow brings is twofold, first the range of topics is much broader; generally a discussion forum is specific to a technology.  Secondly they have brought gameplay into answering questions with the reputation voting.  This second one is the innovation.

In spite of my waning enthusiasm it does bring one more very positive thought to mind.  The community question and answer phenomenon on the web is very powerful and it is amazing how many people will willingly and freely share their expertise.  I predict an increasing number of question and answer sites such as Stackoverflow will appear and more and more sites will start to include the Q&A and community based reputation voting approach.

For it to work well (and in spite of my gripes, Stackoverflow does work well) I think that the subject area has to be tight enough that there is a reasonably well defined boundary of expertise (general q&a sites will fail, look at LinkedIn, where the questions section is rubbish), but general enough that there is a large body of people who can contribute, and the people involved need to spend a lot of time in front of computers.  I think this limits the possible scope of q&a, but that’s probably a good thing. I can imagine it working for a  younger generation of professionals like accountants and tax specialists.

Anyway, for now I am going to ask a few pointed questions and see how quickly I can reduce my reputation back to zero.


I’ve been recently working on an algorithm which sorts through a large list of possible advertising media and suggests a set of suitable candidates for inclusion in a campaign.  I’m doing this in conjunction with a company in Hong Kong called AdvertisingPlaza.com who have created a media buying market place.  They act as broker and middle-man between advertisers and the ad providers.  The media they have on their books if of a wide range, from TV ads, to billboards to newspapers and magazines and online ads.

I’m quite excited…

The revolution is that the media buyers being targetted are not media buyers at all but regular business people buying ad space.  This is something I have done a little of myself in the past and I struggled to know how and where to spend my money.  I never had the budget or ongoing need to merit using an agency to plan a campaign for me, so I guessed.  On reflection I probably got it partly right, but that means I also got it mostly wrong.

It turns out that this is not an uncommon scenario, so what we did (we being me and a brainy friend) is dream up a means of allowing a novice user to tell us about the following things:

  • what the demographic of the target audience is
  • what the intention of the campaign is
  • how much money they have to spend

and we then look through the list of media that are available and come up with a suggestion for them which matches who they are trying to reach, what they are trying to do and how much they want to spend.

We have them tell us these things by filling in an interactive online form – with sliders! – in a web page on the AdvertisingPlaza.com site (oh, btw, if you go looking there right now you won’t find it because we’re still beta testing with selected customers).  They press the magic button and in the background our algorithm chugs away and they are presented with a list that they can either just buy straight away, add to or change quantities, or contact the sales team to start haggling about price.

The clever bit is how we decide what we should include.  It turns out this is actually quite a complex problem, not least because the advertising media tend to overlap – by which I mean that a billboard and a newspaper and a TV ad will have some audience in common.  What’s more they individually have very different reaches and different impacts on the viewer.

Then there’s the question of cost.  It’s possible to come up with the perfect media campaign, but how do you maximise the effect and still stay within budget?

These were the problems that we set about tackling and we have come up with a very novel way of doing it which doesn’t mean a huge computational cost as well.  So how does it work?  Well, that would be telling.  Just as soon as we have some solid commercial success I’ll spill the beans, but until then it has to remain top secret.  Suffice to say it has Flex and Python in it…


Thou preparest a forum before me in the presence of mine nerdy peers: thou anointest my questions with answers; my stack floweth over.

I *really* like Stackoverflow.  I think it is partly the innate nerd in me and partly the socialist programmer.  I regularly contribute to several technical forums and I try and balance what I take from them with what I contribute to them.  A quick back-of-a-fag-packet summary of my posts shows that my answers far outweigh my questions, so I am a good little citizen as well – at least I hope I am.

I’m also quite an avid Facebook follower, but that phenomenon has definitely peaked.  I like the fact that I have a place to put my photos and I know there are certain friends whom I pretty much keep in touch with via that medium.  So it has found its place in the substrate of human interaction and will, I suspect, ever remain there, but the shine is off it.

What Stackoverflow has, which Facebook never will, is the single interest group fraternity.  They have also been very clever in using a self-regulated voting system so you can recommend and decommend (is that a word – if not it should be) people’s answers.  Like many social phenomena it is amazingly good at rewarding good behaviour and it is totally addictive.  Basically the rest of teh community gives you a reputation which is reflected in your profile as a point score.

I currently have 944 Reputation points (rubs fingertips together excitedly).

And the fact that those points have been obtained by other people voting for answers that I have posted makes it totally addictive.  Maybe I am disclosing an unfulfilled side of myself, but I do get a buzz out of providing a good answer and conversely it is cringingly awful when a question gets panned.

And as if the reputation were not enough it is actually informative and useful and watched by some seriously good techincal people.  It has almost replaced google as my go-to source for technical answers.  As the number of questions grows it becomes more and more authoritative.

The authors of the site are being haled as brilliant innovators and I think that they have the balance of playful addiction and useful resource just about right.

I suspect the allure of a large reputation number may wane, but the value of the resource is likely to remain.


I read this on the BBC news web site today…

http://news.bbc.co.uk/2/hi/americas/7640183.stm

The news is that a team of scientists at UCLA have “discovered” a new prime number with 13 million digits.

I can’t quite decide which is more pointless, the number (nobody could ever read it), the search for the number (how could we possibly verify it, and why do we care, we already know all its properties) or the news item that reported it (maybe complete suckers).  Amazingly the Scientists are up for a large cash prize, and gung-ho about discovering the next one.  *clunk*  That was the sound of my incredulity hitting the floor.

Now, I like maths and I like prime numbers, but I really don’t see the point in going to all these lengths to enumerate them.  You could argue that it is an interesting use of distributed computing (if indeed that is how it was achieved) but this seems like a wholly pointless application.  I mean, why not do something genuinely useful that may advance a field of research which has some human benefit.

A quick visit to the UCLA web site will reveal that they might be thinking the same thing.  I couldn’t find any reference to this story there at all.  I presume there must be one, but I couldn’t find it.  Not exactly trumpeting it from the rooftops at UCLA.

I am busy trying to think of something which has a similar level of pointlessness.  Suggestions welcome.


Jack

27Mar08

I wrote this some time ago but decided I would put it on my blog…

Tuesday, December 5th, 2006
Ottawa, Ontario, Canada

Tuesday is crisp, pale, cold and beautiful. The fall has been a disaster and we haven’t seen sunshine in 3 months. Today almost makes up for it all. The sun is shining. It may be weak lemon sunlight and baby blue sky, but that signals my perfect weather. I am born for the cold. I hate being hot. I was once asked where I would rather be, at the top of a mountain in winter, or on the beach in summer. Mountain. Winter. No doubt.

So Ottawa winters never scared me, although they are to be respected. They are as cold and brutal as any capital on earth. Ottawa is on the same line of latitude as Madrid, but the weather is no respecter of lines of latitude. While the Madrid residents may be throwing a sweater over their shoulders before a casual walk along the Ramblas and a bite of tapas, we are festooned in high performance clothes and jogging clumsily from the car to the office door.

Winter is cold. Harsh, unforgiving, brutal, impenetrable, dark and cold. But I am not afraid of it, and in order to survive you have to realise that a good pair of gloves, a nice hat, a fleece and a love of blue crisp days is the antidote to Winter; more, it is the survival skills necessary to live in the middle of a continent. I have gone beyond excusing the weather, it is what it is and there is a silent, natural, majestic beauty to the cold which is unmatchable.

I am sitting in a small, darkened room with taupe walls, forgettable pictures and the smell of antiseptic in the air, the low hum of the forced air heating providing a suitably bland soundtrack. There is a single bulb under a fitted cupboard illuminating a work surface and providing the only light in the room. I’m concentrating on a small TV screen on an arm just above head height right opposite me at the end of the room.

The image is grainy and black and white and indecipherable, strange images flash back and forth. Bubbles. Clouds. Static.

Then, suddenly a recognisable picture flashes past. And past again in the opposite direction. Did I catch that right? I am slightly confused about what I just saw. There it is again.

And then the whole world changes. The image fixes. Quite clearly in the middle of the screen in an upturned arc of black and white static noise is the discernable outline of a baby. Surrounded by space, lying on his back, legs outstretched, heart pumping madly.

I gulp and my eyes spring wide. He quickly flips over and turns his back. The image disappears. I look over at the lady sonographer who is casually typing with one hand and waving her wand with the other. Round we swing and there he is again, this time facing us, hands held up just by his shoulders as though in surrender. Big round eyes and a tiny nose. Hunched over in the foetal position. How else?

I sit down sharply. I didn’t realise I had been standing. I do know I have an astounded grin on my face, and I suspect my heart is beating as fast as his.

Jack.

Two clicks and the lady says 5.5 cms. My immediate reaction is to hold up my left hand and make a gap of 5.5 cms between my thumb and first finger. I look from my hand back up to the screen. He flips over again and disappears.

I look over at Hua Lin half lying, half sitting on the table with her smart black dress unbuttoned from mid-chest, her legs crossed at the ankle, wearing her knee-high shiny leather boots, her smooth belly slick with conducting gel and acting like nothing happened.

I still have 5.5 cms between finger and thumb. I show her. She smiles.

I have a few memorable moments in my life. Stepping out of an aeroplane 5,000 ft above the Hoover dam. That revolver shot just outside my hut in Ivory Coast. The moment in The Mean Fiddler in Harlesden when the whole crowd was dancing. When the lights came on in half the town in Cuba. When I realised that I could solve a quadratic equation and maths was easy. Lying on my back on the deck of a boat in the Irish Sea in the middle of the night. Watching my bike slide out from under me and across the road towards the oncoming traffic. The hole in 1 with my 7 iron when I was 17. Being upside down in my VW Scirocco on the A40 facing the wrong way in the fast lane. Winning my first auction bid for a film poster at Sotheby’s.

Now I have one more.