Log in

No account? Create an account
[ki|ry]an Code & Photography [entries|archive|friends|userinfo]
Kian Ryan

[ website | [ki|an]ryan ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

[Links:| Gallery ]

An Android App In 20 Minutes [Oct. 19th, 2009|12:48 pm]
Kian Ryan
This post appears on kian ryan - code, photography, bob available here. If you want to leave a comment, please do so on this page.

On Saturday I presented a short talk on building a basic android application in 20 minutes. This was the full process, from generating the shell project, to writing the code, generating the layouts, testing on the emulator, signing the application and uploading the binary. I wasn’t able to do this as “live” as I would have liked - I’ll perfect the routine in time for Barcamp Manchester, but the group did a good job of being a dummy audience.

For those interested the application is called “Barcamp Blackpool” (available on the Marketplace). It downloads the latest 20 tweets with the bcblackpool hash tag and displays them as a list. Clicking on an individual item will then launch a browser session showing the tweet on the twitter website. Basic but functional. The source code for the application is available on Google Code.

If there are other things people would like to see in a 20 minute Android demo - please feel free to comment on this post and I’ll see what I can do for Barcamp Manchester.

Social Bookmarking

Barcamp Blackpool [Oct. 19th, 2009|12:19 pm]
Kian Ryan
This post appears on kian ryan - code, photography, bob available here. If you want to leave a comment, please do so on this page.

This weekend saw the first Barcamp Blackpool, held at the Blackpool Pleasure Beach. Many thanks go to @ruby_gem for organising the event, and to the various sponsors, including Yahoo for sponsoring the all important bar and Pixel Programming for ensuring we had a venue and noms. My apologies to to all those I may have caused hangovers to for the following day. We also managed to lose Phil Winstanley for a few hours.

Talks were wide ranging, from some light-hearted ones on upcoming social network Pokebook through to code reviews of the new W3C website and my own talk on building and publishing an Android application in 1 hour 30 minutes 20 minutes (code to follow).

Evening entertainment was provided by Paul Sylvester, who provided the BEST MAGIC SHOW I HAVE EVER SEEN (don’t let the website fool you). So much so, there’s speculation about hiring him for one of the next Geek Girl Dinners.

Social Bookmarking

You know, XKCD is right… [Oct. 19th, 2009|11:05 am]
Kian Ryan
This post appears on kian ryan - code, photography, bob available here. If you want to leave a comment, please do so on this page.

XKCD - Bag Check

You know, it’s absolutely right. We’ve got so obsessed over security of liquids, toothpastes and belt buckles that people appear to have overlooked that laptops, iPods and mobile phones are potentially a hell of a lot more lethal. Maybe we should just point to all people with beards and laptops and scream “terrorist” instead.

Social Bookmarking

Fundamentalists Welcome [Oct. 11th, 2009|10:16 am]
Kian Ryan
This post appears on kian ryan - code, photography, bob available here. If you want to leave a comment, please do so on this page.

Our industry is passioned and opinionated. This is a statement of fact. Be it Emacs vs Vi, Linux vs Windows, iPod vs … errr[1], people often fall in love with tools, philosophies and companies. And this is fine. Within the industry we call them “holy wars”, since the genuine fundamentalists have gone long past the tenets of logic and rationale (at least to the naked eye).

And like all good religions, their virtuous leaders are exalted[2]. Ballmer, Jobs and Stallman, each seen as personifications of the ideals they represent. Ballmer identifies with the corporate world, where big commercial software dominates. A big man with a bald head and a known temperament, he’s a figure people associate with boardrooms and big money. Jobs appears as a slight of a man, usually seen at keynotes with a trademark roll-neck and jeans he’s become the representative of design and cool, embraced by the younger generation. Stallman is another large guy, but rather than corporate groomed appears in t-shirts with long ragged hair and beard to match. A visual throwback to the hippy days, he comes with the embodiment of “free”, leading the free software revolution.

As any good personification of an ideal, their attitudes and ideas tally with their images. Ballmer has spoken repeatedly about the values of the corporate workplace and denounced free software as evil, Jobs speaks regularly on the functions of design and Stallman denounces any software or standards not truly free as evil.

And this is fine.

Because these contrasting attitudes set up a triangle of views with these figureheads and beliefs as cornerstones. There are those that will naturally gravitate towards these polarising opinions and those that will middle around the centre, or leaning between two points of view, subscribing to different tenants of each.

Some people will insist on using nothing but free software. Some people will insist on using nothing but beautiful, design driven products. Some people are driven by the business world and purely by suits and management. Some people may be primarily driven by business, but enjoy rollneck sweaters and iPods at the weekend. Some people may use free software on top of their proprietary systems. Some people may use free software on top of their business OS to talk to their design driven MP3 player[3].

And this is also fine.

The strength of a community is based upon the mix of people within it. Even within domain-specific communities, there will be a range of philosophies and beliefs which everyone will not subscribe to. And although we may occasionally decry these firm believers, and believe them to be as much a fundamentalist as their own religious leader we should respect (even if we disagree) their position because they provide the cornerstones of diversity for the community. The more diverse a community, the larger the range of interests and the higher the liklihood of intelligent (if sometimes a little crazy) discourse. The better the quality (not necessarily quantity) of debate, the more life exists within a community, and the higher the longer the community is likely to last. I would like to see those communities I take part in last for a very long time.

Humanist vs Belief
Free vs Commercial
Pragmatic vs Puritan
Emacs vs Vi

So I say welcome to the fundamentalists.
I say welcome to the middlers.
All communities need both.

[1] I’m kidding, there’s plenty of alternatives. I use a Sansa Clip myself. [2] For the sake of simplicity, I’m restricting the set to three. I realise that in reality the triangle is more like a multi-sided polygon, but it creates a more dramatic image this way.
[3] Did I get all the combinations there?

Social Bookmarking

Internet Explorer User-Agent Strings [Oct. 1st, 2009|05:36 pm]
Kian Ryan
This post appears on kian ryan - code, photography, bob available here. If you want to leave a comment, please do so on this page.

Internet Explorer can be a right PITA when it wants to be. I’m using Thickbox to render on page dialogues in one of my projects. Thickbox relies on testing $jquery.browser.version for determining the version number of Internet Explorer.

!(jQuery.browser.msie && jQuery.browser.version < 7

Apart from the fact that it doesn’t always work. Below is what you would expect to be presented as a user agent string for IE8:

Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB6; SLCC2; 
.NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; 
.NET CLR 4.0.20506; InfoPath.2)

So far today, I’ve seen three customers with the following string

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; 
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 1.1.4322; 
.NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; .NET CLR 
3.0.4506.2152; .NET CLR 3.5.30729)

Somewhere, somehow, the user agent string has become corrupted (and hence the MSIE 6.0). There’s some information on this available on Microsoft communities.

The way around this is to do some explicit regular expression checking on the useragent string. For those that didn’t know about this previously, it’s demonstrated by Jamie Thompson. He introduces a new property called $.browser.msie6 which is used to check for the presence of the IE6 string without the IE7 string.

$.browser.msie6 =
    && /MSIE 6.0/i.test(window.navigator.userAgent)
    && !/MSIE 7.0/i.test(window.navigator.userAgent);

You then adapt thickbox.js to test for this new property.

if ( !(jQuery.browser.msie6)) { // take away IE6
    $("#TB_window").css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'});

Which works great for IE6, great for IE7, fine for vanilla IE8 (which doesn’t suffer from the above bug), but falls down on corrupted IE8. Not to panic, simply adjust $.browser.msie6 to look for this additional string.

$.browser.msie6 =
    && /MSIE 6.0/i.test(window.navigator.userAgent)
    && !/MSIE 7.0/i.test(window.navigator.userAgent)
    && !/MSIE 8.0/i.test(window.navigator.userAgent);

The downside to this fix is that if and when Microsoft comes out with Internet Explorer 9, then you’ll need to adjust this script again to take this into account. I therefore propose a slight departure, using regular expressions to test for values above 6:

$.browser.versionOver6 = function() {
    var re = /MSIE (\d+)/ig;
    var match;
    while (match = re.exec(window.navigator.userAgent)) {
        if (match[1] > 6) {
            return true;
    return false;

<p>$.browser.msie6 =
    $.browser.msie &amp;&amp;

This modified version should work on all future versions of IE. Browsers which report a MSIE 6.0 as well as a MSIE 7.0, MSIE 8.0, MSIE 9.0, etc will now also report as not IE6, which should make filtering off IE6 fixes a little easier.


Social Bookmarking

Guathon - After Tea [Sep. 29th, 2009|03:44 pm]
Kian Ryan
This post appears on kian ryan - code, photography, bob available here. If you want to leave a comment, please do so on this page.

Here we go Visual Studio 2010 & ASP.NET 4.0

  • Lots of content not being covered. At least he’s clear about this.
  • Now built on WPF - woof. Multi monitor support.
  • Demos being done on the MVC codebase :-)
  • Code navigation - select param, highlights all instance usages.
  • Intellisense - Mid term search, no longer need to type start of term. Filters based on camelcasing woot. Someone has been using Quicksilver.
  • Oh dear - resharper is in trouble. Navigate to - “goto Type”. Although now quite as neat - needs keyboard interaction.
  • View call heirarchy - more Resharper features :-) (althought being able to keep searches around is a nice feature.
  • Col based code selection as well as line selection.
  • TDD support - “Consume First”, stops intellisense from attemting to autocomplete when writing not-yet-existing classes. Then becomes aware of class and allows you to define/work with properties. Nice.
  • TDD support - generate class (wait - this wasn’t in 08? More resharper?)
  • MY GODS - 2010 really is 2008 + Resharper (so far). Remind me to reiterate my love for Resharper.
  • CodeSnippets in VS2010 feel like completion in TextMate. Nice mechanism. Extended for ASP.NET, download extra snippets.
  • #scottgufact - Scott Gu works at Redmond, you don’t.
  • Debug history - useful landmarks in lifecycle.
  • Historic debugging - allows step forward/step back through source code.
  • Test tool - run on client, captures information on state of crash. Sends state back to developer. Developer can debug from the state of the crash. That’s pretty damn neat. Can also capture screenshots/video.
  • .NET 4.0, new version of CLR (guessing because of dynamics, etc).
  • Visual Studio 2010 filters intellisense and properties for target framework. Uses reference libraries.
  • ASP.NET 4 - emphasis on clean HTML and SEO (routing, user configurable ClientIDMode), etc.
  • Are we back on web apps vs web sites? (Scott jumped straight to web app rather than web site).
  • New web app template looks good. Jquery, logins, etc included out of the box. Very nice.
  • ClientIdMode - Predictable is the new black (and will save front end developers having migraines when given ASP.NET apps).
  • CSS rendering for controls - YES! THE TABLES ARE BANISHED! RenderTable=false
  • Finer grained control over the viewstate.
  • Improvements coming to the WYSIWIG designer - who uses the designer for ASP.NET? Really?
  • Routing support for ASP.NET 4 - quite elegant :-) Page.RouteData.Values. Doesn’t to URL rewriting, more subtle mechanism.
  • IIS SEO Toolkit. Analysis tool for SEO optimisation of sites. Target site does not need to be running on IIS. Can perform some optimisations to IIS sites - hence linked to IIS manager.
  • It looks like VS 2010 javascript support no longer sucks. A seriously robust engine. Involves intellisense which can keep track of quite impressive object definition at design time. Woot!
  • ASP.NET Ajax - new things for those people that use it (I’ve never got on with it).
    • ADO.NET Entity Framework - more T4 support good. Model first and POCO to boot.
  • Apparently LINQ 2 SQL is not dead - improvements coming. I remain sceptical.
  • Design surface no longer has a “dump and replace” attitude. This may rendel DBML Tools redundant.
  • Inbuilt fake support, reliance on T4 - looks like MS is buying hard into T4 for code gen. I see this as a positive thing.
  • I admit - the chart control is cute :-)
  • WAIT? Multiple config file support - build config dependant. I do this already! I will no longer be special! Don’t like deployment support from within VS, prefer to do it clean from a build server.
  • Release specific configs only contain overwrites - this is useful.
  • If you can tie the Deployment Projects up with build servers (I’m looking at you CCNet), you’ve got a rather powerful test & deployment environment.
  • Seriously folks - this is one of the really nice things…

[Please note these posts are done from my G1. Typos and errors may/will/are included].

Social Bookmarking

Guathon - Before Tea [Sep. 29th, 2009|01:17 pm]
Kian Ryan
This post appears on kian ryan - code, photography, bob available here. If you want to leave a comment, please do so on this page.

Covered so far:

  • Websitespark (we know about this already
  • Web Platforms Installer (Apt for windows - this looks good - can developers submit apps to it?)
  • MVC (we’re here for two hours on this - basic intro and new stuff on 2.0)
    • Support for jQuery.validate in MVC2
    • (Usual MVC basics - saw this at Mix 07)
    • Humm, routes supports reg-ex. Is this new to 2.0?
    • Ahh - scaffolding, etc is T4. That’s been an itching question. I severely like the layout of the default generated views.
    • MVC2 - new “filter” attributes. [HttpPost] replaces [AcceptVerbs(Http.Post)]. Small but nice detail.
    • Ohh, you can mark which attributes are bindable in the class - you don’t have to do it in UpdateModel.
    • “buddy class” - way to get around partial method limitation. Haven’t seen this before… Link the buddy class to the type class using [Metadatatype(typeof(buddy))]
    • Er, okay. This is new stuff in the validation. Direct validation attributes using the buddy class. COOL! System.ComponentModel.DataAnnotations.
    • The binding has changed quite a bit. I like the new architecture, much less messy, much stronger.
    • MicrosoftMvcJQueryValidation.js <– nice one.
    • Complex validation - base off a webservice.
    • New helpers: Html.EditorFor, Html.DisplayFor. Strongly typed lambda syntax - compile time checking.
    • Templates allow override of HTML generated for EditorFor and DisplayFor. Uses partial views. Name partial view to type (e.g. Decimal). Drop in “EditorTemplates” folder. Can be applied to shared folder and/or view specific. Nice.
    • Can also generate templates not related to type, pass to “EditorFor” as a parameter. Also nice.
    • Can use the buddy class with [UIHint] attribute to specify type to field. Big emphasis on DRY. Ohhh nice.
    • Whole model can be CRUD rendered on the fly. [ScaffoldColumn] can be used to inclue/exclude properties.
    • Unit testing time… First up the unit testing sales pitch.
    • “Vs 08 adds all this value added … crap” as the Gu goes mad with the delete key.
    • Unit testing models, unit testing controllers (nothing new here so far).
    • Simple testing on controllers to ensure they render views, etc.
    • Here we go - the hiccups with tight binding to the DB for tests. Ohh, dependancy injection.
    • IService, Db imp of service. Pass into constructor.
    • Use 3rd party dependancy injection or “poor mans - pass through the controller”.
    • Pass collection of objects to “FakeService”. How should you happen multiple services?
    • No shame in writing tests to test the database and tests against the fake services.

Social Bookmarking

First Techcrunch - Now Forbes [Sep. 28th, 2009|09:49 am]
Kian Ryan
This post appears on kian ryan - code, photography, bob available here. If you want to leave a comment, please do so on this page.


Apparently, hitting the “publish button” on articles that aren’t finished, or in some cases even started is all in vogue this year. First of all techcrunch manage foot-in-mouth syndrome over Spingate, and now Forbes has managed one, publishing an internal memo or note over the Polanski affair. Link available as long as it’s live.

This begs several questions:

  • Who is Frank?
  • Who are the sources in the Justice Department.
  • Does no one even look for the draft button anymore?

Social Bookmarking

Fencing for Geeks [Sep. 23rd, 2009|08:06 am]
Kian Ryan
This post appears on kian ryan - code, photography, bob available here. If you want to leave a comment, please do so on this page.

Sheffield Open 2006

Since a few people have been asking recently… I am currently coaching at two clubs in the North-West: Manchester and Altrincham. Beginner geeks are welcome to turn up to either, and will be welcomed by a smile and a circuit board.

Manchester - Manchester Fencing Club
This club caters for all fencers from beginners to international.
I’m here every other week (other coaches are availible at other times). Ping for details.
West Hill School, Stalybridge, SK15 1LX
Thursday 1900-2130

Altrincham - Salle Kiss This club is a new club, currently catering to beginners. A good environment for beginners to feel comfortable.
Altrincham Grammar School For Boys, Altrincham, WA14 2RS
Wednesday 1900-2100

Fees vary from club to club. For your first session, stick a tenner in your pocket and you’ll get plenty of change (I don’t handle money and can rarely remember what fees are from one week to the next).

I’m horribly unfit!

Isn’t that the point? Seriously, we cater for all shapes, sizes and fitness. Turn up and give it a try. The sport is fun, addictive, painless (mostly) and we provide all the kit you need. Just bring yourself, a pair of trainers or squash shoes, tracksuit bottoms and a t-shirt. You’ll want some water and a towel as well.

To make it a bit more fun (and to leave out those first week blues), why not organise a couple of you to turn up together?

Oh, and you’ll get to hit me in a large leather jacket repeatedly. What could be more fun?


Drop me a quick e-mail or comment to let me know you’re coming. It’s also useful to know how big you are (chest size and height) so I know if I need to grab some larger jackets from elsewhere.

But I’m a Foreigner!

Not a problem - there are plenty of clubs out there. Have a look at the British Fencing Club directory, and contact the club secretary (using that old-tech thing called a phone). That’s why they’re listed.

Social Bookmarking

Ecommerce Headaches - Prices & VAT [Sep. 21st, 2009|03:05 pm]
Kian Ryan
This post appears on kian ryan - code, photography, bob available here. If you want to leave a comment, please do so on this page.

Hector the Tax Inspector I felt this warranted a blog post.

I’m currently writing an e-commerce system for some very nice people which is quite literally all-singing, all-dancing. When we originally wrote the prices part of the system, we had a very serious conversation about how pricing and VAT would be handled. It went something like this:

Client) We want to store prices inclusive of VAT.
Me) Are you sure? Inclusive of who’s VAT?
Client) We want the prices to be nicely rounded, and then we take the VAT off the total price.
Me) Are you sure? This has some interesting international implications.
Client) Yes, we’re sure. Here - go do pretty things.
Me) Ok.

Seems fair enough. They want pretty rounded prices on the site which meant they didn’t have to think about VAT. Which is great for working in the UK. Then I received a change request asking us to display the VAT dependant upon which country the user was purchasing from. This would still be calculated as a percentage of the earlier specified total price.

Me) So if the user’s country has a VAT of 90%, you’re happy to only receive 10% of the total sale value?
Client) Erm…. Ah.

This is a little extreme, no-one as of yet uses a VAT of 90%. The UK has a rather modest 15%, but countries such as Norway have a rather more eye-watering 25%. Admittedly, if you’re shipping to Panama, you’re quids in, since VAT is only 5%.

There are several different ways pricing and VAT can be managed on an e-commerce site. When I brought this topic up in an IRC channel I frequent, I thought the following exchange illustrated the complexity and confusion rather nicely:

15:17 <@ccooke> kian: you need to store the VAT on the exact item at the exact moment it was stored.
15:18 < kian> ccooke: no you don’t.
15:18 < kian> ccooke: hold. for which scenario. a, b or c?
15:19 <@ccooke> which one’s which?
15:19 < kian> ccooke: a) static price, flexible VAT b) static base price + UK VAT, remove VAT add countries VAT, c) Price Ex VAT + WhateverVAT, d) sod this - pub.
15:20 <@ccooke> d!
15:20 < kian> I’m with you. Be there in three hours.

So, for your interest and ponderings, here are the three options I see:

Fixed Price, Flexible VAT

Price is stored, inclusive of VAT. VAT is calculated as a percentage of the price at point of sale with respect to the user’s country. So if you buy from the UK, you’re paying £100 of which 15% is VAT and if you buy from Norway, you’re paying £100 of which 25% is VAT.

Pros: Nice pretty prices. Cons: The amount of money you return from each sale is dependant upon where the user purchases your item from.

Price + “Home” VAT, Flexible VAT

Prices are stored, inclusive of “home” VAT. When calculating prices for foreign countries, the VAT for the home country is deducted before adding on the VAT for the user’s country. So if you buy from the UK, you’re paying £100 of which 15% is VAT, and if you buy from Norway, you pay £108 (100 * 1.25 / 1.15 ) of which 25% is VAT.

Pros: Pretty prices for home country, protected base price for foreign country. If home VAT rate changes, prices remain same (gain or loss dependant on home VAT). Cons: You could end up with some odd prices for non-home countries.

Price Ex VAT, Flexible VAT

Prices are stored, exclusive of any VAT. VAT is calculated on the shop at run time dependant on the user’s country. So if you buy from the UK, you’re paying £115 of which 15% is VAT, and if you buy from Norway, you pay £125 of which 25% is VAT.

Pros: Your base price does not fluctuate, therefore the value of the VAT is irrelevant. Cons: Potentially ugly, non marketing friendly prices. Price changes on VAT changes.

We’re still debating which one of these is the best option for the system we are currently building. We are currently using “fixed price, flexible VAT”, but this position may change as we delve into the implications more deeply.

If you’re still with us at this point, well done. I’ve spent an hour trying to get my head around this rather prickly topic, double checking import/export and VAT regulations as I go. But its a good example of how something so initially clean-cut as product pricing can lead into a headache of trouble.

It’s all about scope.

Social Bookmarking

[ viewing | most recent entries ]
[ go | earlier ]