Cambridge Startup Weekend

So, Startup Weekend is coming to Cambridge and I have to say that I am really looking forward to it. There is something about the idea of spending 54 hours making a new business happen which takes me back to my early days, my younger days, and even my student Varsity days. I have to say I’m curious to see if the intensity still works as well as it always did when press deadline, or just a project timescale kept me up all night.

I’m looking forward to taking a few ideas along and finding some quality people to work with. I suspect it could also lead to a fair amount of blogging as well. I will be blogging on the weekend here and on twitter I should imagine.

In the meantime, I’m hoping lots of people will sign up, and take part in what looks to be a brilliant idea, and will hopefully be a brilliant event.

Share:
  • Digg
  • StumbleUpon
  • Facebook
  • Twitter
  • Google Bookmarks
  • DZone
  • email
  • LinkedIn
  • Slashdot
Posted in swCamb | Leave a comment

ISIN Validation with Javascript

As part of a recent integration project, I found that I needed to use ISIN codes as a common key. ISINs are an internationally recognised way of labelling exchange listed securities. As with many things my first call for an overview was wikipedia, although investopedia and the motley fool are fantastic sites for finding out more about finance industry concepts.

While the wikipedia article was great, I was disappointed to find the link to the javascript validator was dead. Given that the input end of this particular project is built in ExtJS, this meant it was back to the drawing board. So, in the spirit of giving back, here is a simple javascript implementation of an ISIN validator.

/**
 * @author sellistonball
 */

/**
 * Calculates a check digit for an isin
 * @param {String} code an ISIN code with country code, but without check digit
 * @return {Integer} The check digit for this code
 */
function calcISINCheck(code) {
       var conv = '';
       var digits = '';
       var sd = 0;
       // convert letters
       for(var i =0; i < code.length; i++) {
              var c = code.charCodeAt(i);
              conv += (c > 57) ? (c - 55).toString() : code[i]
       }
       // group by odd and even, multiply digits from group containing rightmost character by 2
       for (var i = 0 ; i < conv.length; i++) {
              digits += (parseInt(conv[i])*((i % 2)==(conv.length % 2 != 0 ? 0 : 1) ? 2 : 1)).toString();
       }
       // sum all digits
       for (var i = 0; i< digits.length; i++) {
              sd += parseInt(digits[i]);
       }
       // subtract mod 10 of the sum from 10, return mod 10 of result 
       return (10 - (sd % 10)) % 10;
}
function isValidISIN(isin){
       // basic pattern
       var regex = /^(BE|BM|FR|BG|VE|DK|HR|DE|JP|HU|HK|JO|BR|XS|FI|GR|IS|RU|LB|PT|NO|TW|UA|TR|LK|LV|LU|TH|NL|PK|PH|RO|EG|PL|AA|CH|CN|CL|EE|CA|IR|IT|ZA|CZ|CY|AR|AU|AT|IN|CS|CR|IE|ID|ES|PE|TN|PA|SG|IL|US|MX|SK|KR|SI|KW|MY|MO|SE|GB|GG|KY|JE|VG|NG|SA|MU)([0-9A-Z]{9})([0-9])$/;
       var match = regex.exec(isin);
       if (match.length != 4) return false;
       // validate the check digit
       return (match[3] == calcISINCheck(match[1] + match[2]));
}

Known caveats include that I have not 100% checked all the country codes, and they may need the odd one or two added, but the mod 10 algorithm is thoroughly tested. I have included a few simple test cases here.

function testValidIsins() {
    assertTrue(isValidISIN('US0378331005');
}

function testInvalidCountry() {
    assertFalse(isValidISIN('ZZ0378331005');
}

function testInvalidCheckDigit() {
    assertFalse(isValidISIN('US0378331001');
    assertFalse(isValidISIN('US0378331002');
    assertFalse(isValidISIN('US0378331003');
    assertFalse(isValidISIN('US0378331004');
    assertFalse(isValidISIN('US0378331006');
    assertFalse(isValidISIN('US0378331007');
    assertFalse(isValidISIN('US0378331008');
    assertFalse(isValidISIN('US0378331009');
}

These tests rely on the JSUnit library, which is great for this sort of quick test when you don’t really need something as heavy as selenium.

For those of you using the excellent ExtJS library, here is a vtype definition of the validator two, and an example text field configured to input ISINs.

Ext.form.VTypes.isin = isValidISIN;
Ext.form.VTypes.isinText = 'Invalid ISIN';

Yes, it’s that simple. I hope all this is useful to someone.

Share:
  • Digg
  • StumbleUpon
  • Facebook
  • Twitter
  • Google Bookmarks
  • DZone
  • email
  • LinkedIn
  • Slashdot
Posted in Technology | 1 Comment

New website

Welcome to my new website.

It’s been a while since the site had a proper update, and I’ve been looking for an excuse to learn about wordpress, so here are, a slightly messed about version of wordpress, with a very messed about theme.

Hopefully using a blogging engine (which seems to serve a CMS purpose reasonably well) will encourage me to be more conscientious at writing down some of the stuff I should write down in a more public fashion. Hopefully that way it can be useful to everyone. Expect rants about security, the odd snippet of useful code (I hope), some experiences on the infrastructure side of things, some thoughts on information, visualisation and anything else which catches my fancy.

Please do get in touch if you have any comments, or thoughts about anything on this site, or would like to find out more about my consultancy and other work.

Share:
  • Digg
  • StumbleUpon
  • Facebook
  • Twitter
  • Google Bookmarks
  • DZone
  • email
  • LinkedIn
  • Slashdot
Posted in Personal, Technology | Leave a comment

iPad

Being something of a fan of the shiny simple easy things Apple tend to produce, I was a very early iPad adopter. This was mainly due to good intentions like reading long erudite tomes of novels on my long, less than erudite, train journeys. A few kilos of book might not seem like much, but when you’ve been commuting for a few years and have an eighteen hour day, the grams start to count.

So 0.73 kilos of iPad stacked up far better than 2.5 kilos of laptop, another kilo or so of book, and when I was away for any longer a few DVDs and an iPod. In fact all was going well until my partner discovered that it had Angry Birds on it, at which point, I no longer had an iPad. So once that pesky marketing trick of not having nearly enough supply had fixed itself, we became a two iPad household, and once more I can type blog posts on a shiny pretend keyboard.

Of course, being a new device, I feel the need to start writing programs for it. I’ll try and remember to actually post about it too.

Share:
  • Digg
  • StumbleUpon
  • Facebook
  • Twitter
  • Google Bookmarks
  • DZone
  • email
  • LinkedIn
  • Slashdot
Posted in Technology | Tagged | Leave a comment

Finally! Somewhere to live.

Finally!

At long last we have moved in. Round about March, April time, we decided that the lovely little one and half bedroom terrace in York Street was a bit small, so we started looking around. After a lot of very disappointing tours round websites, and the occasional refreshingly simple, though woefully incomplete iPad application, we gave up on the internet, and did the Regent Street parade. After having almost exactly the same conversations with several dozen slick agents in nice suits, we went back to the web and settled in for the long haul.

Eventually, after a lot of weekends fighting with calendars and maps, and wondering whether or when the agent was actually going to turn up, and several months of wondering around, we found a place. Of course it then fell through, after they had forced us into a quick sale on ours (which took three days). Another few months, and we finally found somewhere to buy, and with much stalling of our buyer lined it all up. Of course it only took a few more months from then to stop the arguments with the lawyers, the dozens of surveys, the buyers and sellers changing their minds every five minutes, and all the attendant annoyances. None of it was helped by one set of lawyers getting closed down by the regulators. In fact by my reckoning they still owe me several hundred quid in deposit.

If there is one theme, it’s that this takes a lot longer than it should. Set against a job where millions worth of stock change hands in microseconds, this was annoying enough. If there is another theme it is that the whole industry has a communication problem. While one set of agents was fantastic (many thanks Morris Armitage). The others don’t even deserve a link. When it comes to the lawyers, transparency a communication were again conspicuous in their absence. I don’t believe there was a single point when we really fully knew what was being done, who we were waiting for and what was actually being said on our behalf.

Ah well, after much ranting, raving, uncertainty and changing of minds and eventually monies, we have a lovely new house. If only the path had been that little bit smoother.

Share:
  • Digg
  • StumbleUpon
  • Facebook
  • Twitter
  • Google Bookmarks
  • DZone
  • email
  • LinkedIn
  • Slashdot
Posted in Personal | Tagged | Leave a comment

Coffee

Early Coffee Trickle

Early Coffee Trickle

Some years ago I got myself a little present.

Sitting in the window of the Whittards coffee shop in Cambridge, was something beautiful and shiny, which offered the promise of many dark delights. It was a Gaggia. It was half price, and it was going to be mine. So once they’d told me it was out of stock, and I had pointed out that if that was the case they didn’t need the one in the window display anymore, I took it home.

Yet more years ago, I was involved in a plan to start up a cafe, which was sadly elbowed by lack of funds and arcane landlords who decided that a remainder bookstore would be more cosmopolitan that a gastro-cafe hipster magnet. Anyway, over the course of the research, I spent some time with the lovely people of Matthew Algie coffee. They had a lovely way of making leaves in their lattes. I thought I would try and remember the technique. Pictures ensued.

Leaf Pattern in Coffee

A pretty good leaf pattern I thought

Coffee with Spots

But everyone loves spots

Share:
  • Digg
  • StumbleUpon
  • Facebook
  • Twitter
  • Google Bookmarks
  • DZone
  • email
  • LinkedIn
  • Slashdot
Posted in Personal | Leave a comment