mostlylucid

September 2007 Entries

Rory has left the umm...campus...

Rory Blyth has left Microsoft, this is really sad news, campus has just become a less interesting place...I never actually got up the nerve to talk to him. I've read his blog since about his 3rd post and it's been one of my favorites since then.I used to see him around the canteen and on the odd occasion when I had a meeting in his building. I'm sure it won't be the last we hear of him!

Fibonacci...coding efficiently (when doing nothing is the fastest route)

Just a little diversion, I posted previously about some code which I didn't think of until I was in the elevator following  a pretty important meeting (details may follow ). I asked how you'd make this code more efficient for multi-core CPUs...well I'll get to that but one thing I didn't point out was that with this as with any other computationally intensive code, the most efficient approach is not to do the operation in the first place.
Caching...not on the web but probably the simplest form of caching you could perform, store a previous result for future use. For the code I previously had we saw a double-expotential increase in the amount of computations that had to be performed with the result that you rapidly got to the point where even the fastest processor would grind to a halt. But one thing is obvious, you always use the previous two results to get the current one...so why not store these rather than recalculate each time? Which brings us to this:

using System;

namespace Fibonacci
{
    class Program
    {
        const int positions = 1000;
        static double[] valueArr = new double[positions];
        
        static void Main(string[] args)
        {
            for (int x = 0; x < positions; x++)
            {
                double val = CalFib(x);
                valueArr[x] = val;
                Console.WriteLine(val);
            }
            Console.Read();
        }

        static double CalFib(int n)
        {
            return n<=1? n : valueArr[n - 1] + valueArr[n - 2];
        }
    }
}

Simple, but a very nice way to demonstate the power of caching!

Remarkable Silverlight site

This site from Liquidboy is just the best showcase for Silverlight that I've ever come across. To be honest when I first heard about Silverlight I though...ah, it's our answer to flash...but the more I've learnt (both internally and externally) I'm realizing that this is the next big thing for UI development.
The stuff that people like Liquidboy are already doing with this really shows what's possible. I remember back in the late 90s when the company I worked for was creating Flash and Director based sites for some fairly big customers, but that really proved to be pretty niche (I remember banks were even trying whole sites based on Flash back then!). Now the next big thing is AJAX...but that still has limitations...frankly it's still HTML and Javascript when it comes down to it.
A coherent message for Web UI has been missing until recently...to build really compelling, rich UIs you still need to have fairly good coding skills, another leap is needed to really popularize truly rich UI. We see technologies such as Flex from Adobe coming up (slowly, I haven't even seen a Flex app yet!). This and whatever Microsoft plan to do in this space (Silverlight will be a component but it only answers part of the question right now) will be truly interesting...it looks like an interesting few years is ahead!

I am not an engineer (or wasn't)

I always found it interesting that there's a discipline called 'Software Engineer', the dictionary definitions for engineer are as follows:

  • design as an engineer; "He engineered the water supply project"
  • a person who uses scientific knowledge to solve practical problems
  • mastermind: plan and direct (a complex undertaking); "he masterminded the robbery"
  • the operator of a railway locomotive

    I never really thought that this was a good fit for what I saw a person who creates software as doing, a few years ago I read the book Hackers and Painters (second link is to the original essay)  by Paul Graham and the ideas he presented really clicked with me. In short, writing code is more like the work a carpenter engages in or even a paineter...there is a high degree of creativity in what we do, not just the mindless assembly of component parts; not putting down engineers...more the 'software factory' concept where devs and even whole teams are used as interchangeable parts assembling software. Now I've met devs who fall into this category, no real creativity in their work and happy to cut 'n paste their way through a development career...hey they're valuable for what they do but they're nowhere near being a 'proper dev'.
    Anyway, just a random thought I was having today when talking to an old friend who's working with an outsourced development team...they take specs and crank out code but they have no real buy-in to the product and the architecture they produced is causing huge problems
    (quote 'they just don't care...they deliver against each use-case but the code is clumsy, hard to read and hard to maintain').
    I lament at these slipping standards, when I was a consultant I saw this all the time...managment measuring progress against checkilists of use-cases with no insight into application quality (metrics help but they still can't get the 'feel' of the code). I still have memories of sitting in a lab running scalability tests against an application with the development team vascillating whenever the CTO asked them a question, meanwhile the app (which was developed literally at a cost of millions of pounds!) was inelegant, fulfilled it''s purpose but wasn't created with any passion...bah!
  •  

    "As simple as possible but no simpler" : my obsession with Muji

    I thought I'd share with all of you my obsession with all things Muji, for those who don't know Muji is a Japanese store which sells 'minimalist' items for everyday use. Now, they don't *seem* to be minimalist for any other reason that it makes the stuff cheaper, from the site's own 'What is MUJI?":

    "Lower priced for a reason."
    "This phrase encapsulates how we can provide our Muji products at lower prices. We
    launched our Muji brand by designing and developing products that might almost be
    regarded as substandard if based on traditional criteria, although they are, of course, actually
    of good quality.
    Through the careful selection of materials, streamlining manufacturing processes,
    and simplifying our packaging, we have continually introduced high quality Muji brand products onto the market, at lower than usual prices. Presently there are more
    than 7,000 items sold as Muji products. Muji's natural and simple design proposes rational
    lifestyles for today's world. Muji products - there is a reason why we can provide such good
    quality products at lower prices."

    I have to say though that even for such a disheveled individual as myself, the simplicity of what they sell really appeals...no branding of any kind, primary colors  and brushed metals...it just all feels so pure. Take for example this item, an atomizer:

    Atomizer
    Very simple, pared down to the form it requires and nothing more...in it's own way I find this more beautiful than the jewel encrusted gold items which would generally be seen as the ideal atomizer...why am I talking about minimalist Japanese stores...simple, it sums up my philosophy to coding (shamelessly stolen from somewhere or other...possibly Einstein)...
    "As simple as possible but no simpler"
    I've been chasing through a fair bit of source code over the past couple of weeks for both work and for fun, the best code in my opinion retains clarity by being factored down to the point that it's easily understandable by someone reading it for the first time.
    Showing off in code is not a good thing, making obfuscated, difficult to read spaghetti code does no-one any favors...this even extends to basic class and object design; it should be obvious when and where you initialize (and if necessary) destroy objects...when it's not, mistakes creep in very easily.
    So to everyone who writes code, get familiar with what it takes to write *good* code...not fancy, not jewel encrusted, tooled gold code, just basic pared down to the bones code...I guarantee it'll be less error prone and it might just be faster!

    Oh, and for tips read Brad Abrams' book "Framework Design Guidelines", learn what is says and take it to heart...

    P.S., Muji now has a US store, cheap, pretty good quality and pure...hard to beat!

    Thought of it in the elevator...

    static int CalFib(int n)
            {
                return n<=1?1:CalFib(n - 1) + CalFib(n - 2);
            }

    I hate when that happens...also remarkable just how inefficient this code becomes at higher values of n...

    As a challenge, anyone care to give a way of making this code work efficiently on a multi-core (or processor, or both!) system? I'll give a possible answer at the weekend.
    Hint, you might want to use System.Environment.ProcessorCount;...

    Is this thing on?

    Well, it kinda works...sorry if I just messed up everyone's feeds, search results et al...this wil be the last major change for a long time....So comments are back for old posts, performance is vastly improved (now using SQL rather than DasBlog's XML stuff)...

    Biodome Haiku...kind of...

    Brain melting
    HD Biodome on TV
    Ooh Kylie...

    (I know, nowhere near a Haiku...but man, Biodome is even dumber when you can see more of it!)
    Any comments in Haiku form if you please; or near enough...for this post be as insulting as you like, I deserve it for watching this shit!

    Jealous, me???

    So Rory has a hot actress from an iconic TV series try to kill him, I have my cat throw up on my feet in the middle of the night...hmm...something is serious out of whack!

    Amazon MP3 store

    Now this looks like a winner! Having one-click combined with DRM free MP3 downloads seems really sensible. The artist choice looks a bit limited at present...I'd guess some idiot record companies don't have a clue yet...This model seems sustainable and has the convenience factor we've all been waiting for.
    Hey, it wouldn't be a terrible idea for my own employers to link up with this...no DRM raises some really interesting possibilities ...makes sharing kinda difficult though; how do you get the person you share with to actually buy the song without having at least some kind of DRM wrapper to enforce it???
    I know it seems silly to be excited about what is after all another place selling music but this one looks right now to be what the customers want *and* lets the artists get some money for their songs being downloaded...and $0.89 a song, bargain (and I'll only pay that once...no matter what device I choose to buy in the future)!

    Comcast sucks!

    Not just me that thinks this! I save up a ton of content over the week to watch on the weekends as well as shows I'm not properly watching for later review...One of the lovely little features about my Comcast HD-DVR is that is occasionally decides that I shouldn't waste my time recording all this stuff and completely wipes all of it's content...not just one corrupted show mind you but everything on the disk including all of my series selections etc...I have to say that this device really sucks, it's juddery, occasionally refuses to change channel for minutes on end 'forgets' the channel subscriptions I have basically every function it has it screws up in some way. But hey Comcast is a monopoly with one of the biggest political lobbying arms in the country. Yes, I am aware that I work for MS before anyone says anything...we get beaten up for every little software bug but this thing takes the biscuit!
    Now I know that this stuff CAN work, I had a Sky DVR in the UK before coming here and it was faultless. It really is inexcusable that a consumer device can be quite so bad with seeming zero recourse (I called Comcast, they say *it just happens*). Of course the big wheeze is that with HD Cable the DRM means that you can't just buy a cheap off the shelf device for this stuff anymore...I hate Comcast! Rant over, to bed! Oh, and Tivo isn't an option right now due to my disastrous finances!

    Me like...Silverlight Tutorial Site

    Very nice UI...I wish had some design talent...hmm...wonder how much I could do. 3D spinning logos are about to make a comeback, you heard it here first (well, first since 1996 :-))

    That buzz-buzz-click noise...

    Aargh! I've done it again, another external hard drive smashed to the ground (carelessly)...now makes a buzz-buzz-click noise when I turn it on; and rattles a bit...which can't be good...Oh, for the day when cheap, reliable SSD disks arrive - who thought that a high speed spinning glass platters were a good idea in a device that *I* could own...dummies :-).
    Oh and I AM making progress in getting this blog updates, comments are now over...trying to discover where my old .TEXT blog held the associations between comment names and urls / emails now...Mind you the more I post right now the more content I have to move from *this* blog to SubText (XmlTextReader, yeuch...should check out the XPathDocument stuff in .NET 2.0 I suppose).
    Roit...just watched Heroes...good...The Big Bang Theory...pretty good...Chuck...umm...awful! To bed! Oh, and did we really need the Nissan Rogue ad 3 times in each ad break for Heroes...really???

    That buzz-buzz-click noise...

    Aargh! I've done it again, another external hard drive smashed to the ground (carelessly)...now makes a buzz-buzz-click noise when I turn it on; and rattles a bit...which can't be good...Oh, for the day when cheap, reliable SSD disks arrive - who thought that a high speed spinning glass platters were a good idea in a device that *I* could own...dummies :-).
    Oh and I AM making progress in getting this blog updates, comments are now over...trying to discover where my old .TEXT blog held the associations between comment names and urls / emails now...Mind you the more I post right now the more content I have to move from *this* blog to SubText (XmlTextReader, yeuch...should check out the XPathDocument stuff in .NET 2.0 I suppose).
    Roit...just watched Heroes...good...The Big Bang Theory...pretty good...Chuck...umm...awful! To bed! Oh, and did we really need the Nissan Rogue ad 3 times in each ad break for Heroes...really???

    I love this, the true cost of Halo!

    Think of the share price! I'll be able to switch to Organic Chicken!

    Yet another site tip...Sara Ford

    I *did* actually know about this site it's a collection of great VS.NET tips and tricks...really makes life easier...

    Another site tip...Eternally Confuzzled

    As part of my oft mentioned dev spin up, I've been getting my knowledge of data structures and algorithms back up to (almost) parity with where it was when  I left full time dev just over 2 years ago. Along with spending about $300 on various books (reviews soon!) I've been surfing around in search of great sites. One of the best I've found is Eternally Confuzzled which as well as having a great name has really good coverage of various data structures and algorithms. Most of the code samples there are in C++ but to be honest it's fairly easy to translate these concepts in the C#.

    UPDATE: Should add actually, I found the link to this site in the source for NGenerics, a terrific .NET based implementation of data structure and algorithms missing from the .NET framework using generics. It also has really useful documentation and is just the best way to learn how these algorithms work in C#!

    Software recommendation...7-Zip

    Now, I know Vista has support for compressed folders but there are (quite a few) times when you need something more powerful and flexible. I was a big fan of PowerArchiver for a while but it got a bit bloated for me and well it costs $19.95 and I'm cheap :-). Anyway the one utility I tried out which really fulfilled my needs (quick, cheap and flexible) was 7-Zip, supports all the popular compression formats, it's fast and it's has a really small footprint (818kb download!). Oh and for the devs out there the same people developed an SDK for the brilliant LZMA format. So all in all if you're hunting for a good compression tool and Winzip, Powerachiver and the like are bugging you to register 10 damn times a day give it a try! Oh, and do feel free to donate to 7-Zip if you find it useful...yes, contradiction to my previous argument but oddly I don't mind donating cash if no-one tries to force me to!

    MSDN magazine 'special' on multithreading, multi-cores and concurrency

    One of my obsessions is scalability and one of the main ways of achieving scalability in apps is to make the most appropriate use of the resources you have. With this in mind one of the rapidly growing ways of achieving this optimal resource use is spreading work across multiple processors. Up until now multithreading has been a bit of a pain to use correctly; note I said correctly, .NET makes it easy to do but a lot of people use it inappropriately and end up doing more harm than good. Reading through the October 2007 edition of MSDN magazine there's lots of stuff on some 'new' ways of multithreading in .NET (and C++), guidance around avoiding some of the more common problems such as deadlocks. I especially like the new PLINQ article (Parallel LINQ, get it?) in there, looks like a really nice way to achieve optimal resource use with relatively little penalties either in productivity or perf!
    Anyway, great magazine this month and worth setting aside a couple of hours for...

    Note to myself...new (to me) .NET blog

    This blog looks really interesting, some nice advanced stuff on WCF and WPF; two technologies I'm slowly spinning back up on after my dev hiatus...Also been working my way through Darren Neimke's blog. So much new stuff to learn, right after I get this blog updated I am going to work on a bunch of Silverlight playthings for it!

    Yes, I'm feeling sorry for myself


    I never said this blog would be laugh a minute...

    The night before

    I had a post all ready to go here but I just deleted it...sometimes being a loner frankly just means you're totally alone, not having someone to talk to (in the UK it's 4am) is really hard sometimes.

    Was moving here a mistake?

    Whatever happened to Robert Scoble?

    I've been out of the blogging fray for a while and am just getting back into it now. I used to be a real fan of Scoble (before MS as well as when he was here...) . I've just been reading through a bunch of posts on his site and my god it's boring! I'm sure if you're part of the 'blogging set' and hang in his circle it's fascinating but man, it just seems so insular now...I'll check back in with it occasionally but it's off my faves list!

    Blog Cliches

    Just rediscovered Jeff Atwood's Coding Horror blog again (also bought a couple of books he links to...). I love this blog...hate the archive function though. Anyway one of the many great posts on there is 'Thirteen Blog Cliches' - when I finally get round to Subtexting this blog I'm implementing a few of his ideas to make life more pleasant (I also hate the resizing Tag Cloud thing he mentions...). One of his points is that blogs aren't a diary...umm I kind of disagree with that one...this blog is absolutely a random dumping ground for whatever I'm thinking about at that particular moment in time...I've written about my dad having a heart attack, about ViewState Compression, changing jobs, music I like and stuff I find generally interesting.
    In short this  blog is about me, warts and all. I'm not Rory (one of my favorite bloggers, funny and sad at the same time...all the weirder that I see him about campus occasionally), I'm certainly not Scott Guthrie (scary smart, the way everyone at MS should be!)...what you see is what you get. I will post obscenely technical content here, I'll also post obscenely obscene content here. I'll probably get in trouble on occasion (I post stuff here which no-one knows about me...even my own family) but above all I'll try to be honest (sometimes I'll fail, but I'll try). I really admire Rory for some of his recent posts on his attempted suicide and subsequent recovery, I wouldn't have the balls to post about that; and for me it's these which make blogs the unique medium they are.
    Most of the views to this thing come from Google, I tend not to mix post content between technical and personal (and where possible tag appropriately). I have thought about using different URLs for technical content (so .net for technical, .com for personal) but I'm not sure yet.
    Anyway, speccing didn't go as well as I'd hoped to going to try and get an early night (worry keeps me awake...). Wish me luck tomorrow! 

    Blue Mind...

    Ok, one last post then I promise I'm on the specs (I am actually working between posts...just in case my boss reads this!). In days gone by I was into meditation in a big way; once scared my self when at university, was practicing ZaZen and somehow became 'disconnected' from my body...very strange! Anyway used to be into that and latterly some umm...substances which could be described as mind-expanding (entirely legal at the time incidentally...just not anymore :-)  oh ,and if you're a border patrol guy reading this ignore that last part!). Anyway I love what could be described as trippy music (not sure if it's as a result of these two things or just because I like it...). Two of my absolute favorites are of course on YouTube :-). The first is by a British artist called Alexi Murdoch, Blue Mind:

     

    Second is a cover of a John Lennon song which I like way better than the original (I know, blasphemy), Across the Universe (soon to be a major motion picture :-)) by Fiona Apple...right, specs!

    Ooh, new toys

    Yes I know...write the specs freakjob...but I have toys coming which I'm sadly excited about. Memory, a hard drive and a couple of swords (I like swords, no doubt my latent homosexuality manifesting itself as a pseudo-phallic obsession...told you, freakjob :-)). Here's a tip for you, if you have a geek in your life then you can never go wrong with giving them a couple of gigs of ram (find out the type first, there's lots of different ones now)...right specs!

    Tommorrow is Procrastination day..

    Not really :-) I suffer badly from procrastination, always have in fact I'd say it's my worst quality (apart from all the killing...but I was young then :-)). The odd thing is that I also suffer from extreme anxiety...and it builds into a vicious cycle as the more worried I am the less likely I am to actually do the thing I'm worried about...and it sucks!
    This is also one of the reasons I love coding, it's very a->b in that you have a definite start and end to a task with multiple small tasks in between these two points. Procrastination in coding therefore becomes pretty much irrelevant (hard to procrastinate for a 1 hour task :-)). Take today for example, I have a spec review due on Thursday...now I know what I have to do, I have everything in my head and could easily present that information...but writing it down is another matter entirely. I have always had a mental block for just writing stuff down (getting all Psychological here...not Pop-psych, I was a pro :-) I think it's for a fairly simple reason (side note: my cat has taken to sleeping in the space between my keyboard and monitors...very cute!); if I write something down the someone else can see it and judge it (umm...I also suffer from performance anxiety and impostor syndrome , can you believe I'm still single :-)). Anyway, I am writing this post when I should be writing my specs ... but I just thought I'd give the  very small number of people (stats for the blog are here...) an insight into the crazy bundle of weirdness that is me. Interestingly while I worked as a psychologist, I never met a fellow psychologist who wasn't a complete loon...

    Random toons.

    I don't know why but I woke up this morning with this tune running through my head and a memory of the most beautiful girl I ever loved...Hannah. Sometimes dreams just make you smile...soppy moment over :-)

    MotionPortrait...

    Now this is just freaky...basically a technology which converts a 2d photograph into a 3d model; hint, scroll down to the bottom of the page and click on the dog...it's just wrong!

    Note to self, avoid Frys electronics the day after MS hands out bonuses...

    Well, it's bonus time again at Microsoft and live seemingly almost everyone else at work I decided to head down to Frys electronics to see what interesting stuff they had; and ostensibly to get myself an XBOX 360 Elite...gave my old one back in the UK to my nephew and never got round to replacing it...Well it was like the company store in there! I swear every second person was an MS employee! Anyway very boring story short they were sold out of XBOX 360s of all types (side note: smell of burning from my PC...not a good sign, really need to replace the poor old thing!). The sales guy looked really confused that they'd had such a run on XBOX 360s today :-) . Oddly the place I found them was Circuit City right by the MS campus...either they got a shipment today or they were aware of the timing :-) So I now again have a 360...the elite costs more but man it looks good! Been playing demos and downloading movies all evening...the primary reason I wanted it wasn't actually games oddly enough, it was so I can stream all my media center content which I brought from the UK to my main TV.
    Also realizing how much of a company guy I'm becoming after taking a whole lot of pride in just how smooth and generally cool the 360 is! Please let the Zune 2 be just as cool...

    Porting update...

    Thought I'd give a quick update on my porting efforts from my old blog to SubText...well it's 2am and I just got all of the old posts ported into the SubText DB...tasks now are to get the comments ported an hooked up to the entries (717 of them with around 2000 comments !), then get the few new entries on this blog imported (means writings yet another convertor to take the dasBLog XML and import it...). Phew...after all of that I need to get it up and live; oh, and write another HttpHandler to rewrite and map the old format URLs to the new scheme so incoming links aren't broken....this is harder than I thought :-). All being well I should have it all copasetic by Sunday evening... 

    Playing around with the SubText source

    As I said in a previous post I'm getting back into development..as part of this I've been playing around with the source of SubText, the likely future engine for this blog. Whilst doing this I found an interesting (and it seems fairly common) pattern when using an ASP.NET provider where to avoid the performance issues with Activator.CreateInstance the author places the first instance created in a static field then returns that as a singleton each time it's requested. This is great in terms of raw performance...but I have a bit of a problem with it...scalability. Actually this will apply to any Abstract Factory pattern implementation which uses a singleton as an object store).
    The issue essentially boils down to the fact that by definition only one instance of the Provider class can now exist within the current appdomain...now you get it really quickly (as it's already instantiated) however it means you only ever use one DB connection (so kind of making Connection Pooling pointless) and of course if there's a long-running Db operation you have to wait until it completes for the next request to be processed. I should add that SubText uses output caching fairly heavily which does largely mitigate this issue for most requests at first, however as the blog and therefore the number of posts and users grows it's likely you have more requests for different bits of data; and so this data would be less likely to already have been cached so increasing concurrency becomes more and more likely.
    The upshot of this is that you get a cutoff point where the use of the singleton in this case ceases offering a performance improvement and actually causes a performance decrease. My solution was fairly simplistic (and I haven't tested this for perf so...it's an assumption right now!); don't return the static instance, rather return a memberwise clone of the instance (I found this article after I did this but the results shown are consistent with what I expected). In essence I reduce the impact of object instantiation with this technique whilst providing a new instance for each call; thinking about it I should really cache this for each thread meaning I don't clone each time it's called...but rather for each new thread that's created...fairly easy to do by sticking it in the current web context (which does limit it to web apps...).
    Anyhoo...just my little scalability obsession :-) Should get to bed, much speccing to do tomorrow :-(

    Writing convertors...

    My decision to switch this blog to subText means I'm going to have to write some weird convertors...right now the decision is whether to convert the dasBlog xml files to the DB schema used by subText or to convert my old DB directly (with the advantage that I'd also convert the old comments). Others have done this and used the BlogML format as an intermediary but to be honest what minimal investigation I've done into this method makes it look kinda fiddly. My choices are therefore to do a SQL->SQL conversion directly (but subText has a hashing form which I'd have to replicate...I guess) or SQL->MetaBlogAPI (preferred option as I know this API pretty well...) or XML->SQL (again hashing comes into play and I lose the comments) or XML->MetaBlogAPI (still lose comments, potentially pretty slow). Hmm, we'll see...lucky I enjoy coding :-)

    Kickin off my boots...

    So I'm on the crux of making a decision about my career; I usually avoid making decisions but boredom occasionally forces me into it! Stay tuned but let's say you might find a distinctly developery feel to my posts form now on ;-)

    Archaeology and nested Repeaters

    Just discovered that an article I wrote in the pre-cambrian era was uploaded to this server when I recreated this blog...so if you're interested in some techniques for nesting ASP.NET repeaters take a look...should add that this is REALLY old as in ASP.NET 1.0 days. I don't necessarily recommend what's in the article any more; though a quick search shows nothing which really trumps the methods I show in terms of raw performance...A nicer method in the .NET 3.0 days would almost certainly use Listviews and LINQ...and significantly less code (oh and the examples are broken right now...hopefully I'll get a lot more stuff working this weekend! 

    Is my memory going? Or did we just mess up Live Writer?

    I downloaded the new Beta 3 of Live Writer this morning for another machine; one of the wonderful 'bonuses' they added was installing apps I don't want (right now it's saying I need to close 'Windows Explorer' and that it might need to restart my machine). How DUMB is this decision, adding a barrier to install is not smart! I only want the Windlows Live writer app, it's compact and non-intrusive but now we have added a major barrier. So annoying!

    Comments not working...

    Not sure why but the comments system seems kinda screwed on this thing. For the time being you can mail me at blogcomments@mostlylucid.co.uk if you have any comments / questions / complaints :-)

    Playing with VS 2008 Beta 2

    I've been out of serious development for a couple of years (i.e., basically living in VS). As as way to revive my interest in development (which for a few reasons has been waning of late) I decided to re-launch this blog as well as play around with some coding additions to it. As part of this I've gotten my little server unpacked (yes, I have been here 9 months but still :-)) and play with VS again. I started off my spin-up by watching these excellent short videos by Scott Guthrie on the new features in Orcas (or more correctly now, Visual Studio 2008). On a side note we don't get cool code names in Office...just numbers...the one I'm working on now is Office 14.
    The training videos are fantastic and seeing how things like the CSS editing functions as well as LINQ has been really great.  So, as you do I decided to have a play with some of this stuff in VS 2008 Beta 2; man life is easier with this new stuff. I love the model LINQ provides to query data using PROPER code...I can imagine some purists just freaking out about the 'auto generation' aspects of LINQ but hey I think of it as being like moving from C++ to C#...what you lost in raw control you more than make up for in productivity!
    Anyway just checking in...other things happening...well, I got a hearing aid last week; I had an operation on my left ear a few months ago and I thought I'd try out a hearing aid before going through it again for my right (without it I'm about 60% deaf in my right ear...even after the op I'm about 20% deaf in my left). Also got a great new printer / fax / scanner / phone device which also has wireless...which I love! Oh, and busy writing specs for the next part of Project Server development...but not nearly as busy doing this as I should be :-)

    Changing platforms

    Hmm....been running dasBlog on this site (saves some cash as it doesn't require a DB..). It's nice but I feel it's slow and lacks some functionality (e.g., decent search). Will be switching over to SubText in about a week or so...

    American chocolate sucks...

    For anyone who knows me reading this...umm...it's hypothetical, I of course being a diabetic do not eat chocolate...oh no :-)
    So the title is pretty unequivocal, but sorry it does. Or at least the stuff I've tried does :-) Hersheys...so they have a milk chocolate bar which at first taste seems OK...but it has an aftertaste reminiscent of meat. Please, Americans try Cadburys Dairy Milk; it's not a 'purists' chocolate and the American one is a different formulation to the UK yet it tastes the same??? It's delicious, I mean it is just transcendent...if someone told me it was as addictive as heroin I might just believe them.
    Oh, and the odd thing...the American Cadburys Dairy milk is actually made by Hersheys :-)

    Who the hell are you?

    Well traffic is starting to pick up a little...always amazes me how this happens for solitary sites...guess I'd better tell you a little about myself.

    Name: Scott Galloway
    Age: 34
    Born: Scotland, UK
    Martial Status: Single (with cat)...big and fat and I lack self confidence so this ain't gonna change any time soon!
    Live: Fremont, Seattle, WA
    Work: Microsoft, Redmond, Seattle
    Work History: Currently Program Manager on the Project Server group, previously developer and architect for over 10 years
    Interests (what am I going to write about): the future (I am a devotee of the Technological Singularity theory); programming (I've written production code in pretty much any language you can think of...); databases; architecture (both computer and building); sci-fi; health....the gamut...what I'm trying to get over to you...this is not a purely technical blog, it will be full of mad ravings.
    Politics: Hmm...ultra liberal I guess, the only thing I really dislike is deliberate stupidity (i.e., just not bothering to engage your mind rather than not being able to). I'm pro pretty much everything, against any drug control, very pro-choice, pro euthanasia. Oh and I am very much anti organized religion (no problem with religious people, just don't preach to me and we'll be fine)
    Music: Very varied, but not listening to as much music as I used to (blame my Howard Stern obsession for that), I like everything ranging from the Killers through Alexi Murdoch to Radiohead, Muse, Edie Brickell, Roni Spektor, the View etc...etc...
    Books: I read a LOT, usually get through two paperbacks and one non-fiction book a week...spend WAY too much on Amazon! I also tend to get a bit OCD over a good book reading it straight through (I read the last Harry Potter book in 7 hours)
    Acitvities: Not nearly enough, I am a bit of a loner and my favorite weekend activity is sleeping...classic geek and I really need to get out more!. I do like heading to the cinema and to lots of gigs (Seattle is great for that).

    What else to tell you, well I can be dangerously honest...and this will no doubt get me in trouble at work at some point but I will try my best not to tell you any MS stuff which isn't public knowledge. Hmm...well I guess you'll find out more as I write on here again. Feel free to check out the archives (some broken links but that'll be fixed once I update the mostlylucid.co.uk URL).
    I am also getting back into coding, beginning to realize that coding is a meditation for me...I always loved being in 'The Zone' and it's odd how you miss it when you stop coding. You guys who code every day are lucky...I would kill to be a full time coder again but that ain't likely right now... 
    Oh, and going to give a plug for an old employer StormId, probably the greatest company I ever worked for (and I've worked for a whole bunch!). If you're in the UK looking for an ASP.NET coding job, look them up...I firmly believe that web agencies (as StormId is) are THE BEST place to learn how to create web sites. If you're a developer who can't do end-to-end development you're missing out; the ability to take a site from bid right through DB design to code to server setup and launching it is the single most fulfilling thing I believe a real developer can do. It sickens me when I meet devs who know no SQL...very sad!

    Anyway, a rambling post (better than the one I wrote at 4am this morning after a six-pack of Stella Artois, $9.99 for six stella, how could I not...THAT was insane :-)) 

    Woohoo! All of the mostllyucid.co.uk posts are now on this site!

    Well, took about 5 hours of coding but I got a little tool together to convert my old posts from www.mostllyucid.co.uk (currently dead but it will eventually point here). Nice to get them all back up again!

    I will be playing around with the site for the next few days so there will be a bit of churn. It was nice to get to do some coding again...not the prettiest code but hey it worked!

    Just for the hell of it, here's the code for the tool...

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Data;
    using System.Data.Sql;
    using System.Data.SqlClient;
    using System.Collections;
    using System.Xml;
    using System.IO;

    namespace BlogTranslator
    {
        class Program
        {
            static void Main(string[] args)
            {
                Program p = new Program();
                p.StartTranslate();
            }

            public void StartTranslate()
            {

                using(SqlConnection scon=  new SqlConnection("Data Source=MISTI;Initial Catalog=mostlylucid;Integrated Security=True"))
                {
                    Dictionary categoryDict = new Dictionary();
                    SqlCommand categoryComm = new SqlCommand("SELECT CategoryID, Name FROM            cs_Post_Categories", scon);

                    SqlCommand scomm = new SqlCommand("SELECT        PostID, ThreadID, ParentID, PostAuthor, UserID, SectionID, PostLevel, SortOrder, Subject, PostDate, IsApproved, IsLocked, IsIndexed, TotalViews, Body,                          FormattedBody, IPAddress, PostType, EmoticonID, PropertyNames, PropertyValues, SettingsID, AggViews FROM            cs_Posts WHERE        (ParentID = PostID)ORDER BY PostDate", scon);

                    SqlCommand postCatComm = new SqlCommand("SELECT        PostID, CategoryID FROM cs_Posts_InCategories ORDER BY PostID", scon);

                    scon.Open();
                    using (SqlDataReader dr = categoryComm.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            categoryDict.Add((int)dr["CategoryID"],(string)dr["Name"]);
                        }
                    }

                    Dictionary postCat = new Dictionary();
                    using (SqlDataReader dr = postCatComm.ExecuteReader())
                    {
                        StringBuilder sb = new StringBuilder();
                        int currPostId = 0;
                        while (dr.Read())
                        {
                            int thisPost = (int)dr[0];
                            if(thisPost != currPostId)
                            {
                                postCat.Add(currPostId, sb);
                                if (currPostId > 0)
                                    sb = new StringBuilder();
                                currPostId = thisPost;
                            }
                               sb.AppendFormat("{0};", categoryDict[(int)dr[1]]);

                        }
                    }
                    using (SqlDataReader dr = scomm.ExecuteReader())
                    {
                        DateTime currDay = DateTime.MinValue;
                        StringBuilder sp = new StringBuilder();
                        while (dr.Read())
                        {
                            DateTime postDate = (DateTime)dr["PostDate"];
                            DateTime thisDay = postDate.Date;
                            if (currDay != thisDay)
                            {
                                if (currDay > DateTime.MinValue)
                                {
                                    sp.Append("");

                                    using (TextWriter tw = File.CreateText(string.Format("c:\\DumpTest\\{0}.dayentry.xml", currDay.ToString("yyy-MM-dd"))))
                                    {
                                        tw.Write(sp.ToString());
                                    }
                                }
                                 sp = new StringBuilder(" xmlns:xsd=\" xmlns=\"urn:newtelligence-com:dasblog:runtime:data\">");

                                sp.AppendFormat("{0}", thisDay.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK"));
                                currDay = thisDay;
                            }
                            sp.AppendFormat("{0}{1}{2}{3}{4}", XmlEncode(dr["Body"] as string), ((DateTime)dr["PostDate"]).ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK"), ((DateTime)dr["PostDate"]).ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK"), Guid.NewGuid().ToString(), (string)dr["Subject"]);
                            int postId = (int)dr["PostId"];
                            if(postCat.ContainsKey(postId))
                            {
                            sp.AppendFormat("{0}", postCat[postId].ToString().TrimEnd(new char[1]{';'}));
                            }
                            else
                            {
                                sp.Append("");
                            }
                            sp.Append("admintruetruetruetrue
    ");

                        }
                    }
                    Console.Read();
                }
            }
            public static string XmlEncode (string s)
            {
                StringBuilder output = new StringBuilder ();
                foreach (char c in s)
                    switch (c) {
                    case '&' :
                        output.Append ("&");
                        break;
                    case '>' :
                        output.Append (">");
                        break;
                    case '<' :
                        output.Append ("<");
                        break;
                    case '"' :
                        output.Append (""");
                        break;
                    default:
                        if ((int) c > 128) {
                            output.Append ("�");
                            output.Append (((int) c).ToString ());
                            output.Append (";");
                        }
                        else
                            output.Append (c);
                        break;
                    }
                return output.ToString ();
            }

        }
    }

    Content of this blog is my personal opinion only...

    A friend from work just reminded me, even though I work for Microsoft, this blog is NOTHING to do with them. Everything on here is my personal opinion only and does not reflect upon anything anyone else at Microsoft or elsewhere believes.

    Idiocracy...hopefully not the real future!

    You know, watching US TV I have to say that the movie Idiocracy is looking more and more true. Stupidity and ignorance seem to be increasing in social acceptability with intelligence being trusted less and less.  Anyway, great movie...hope it isn't really the shape of things to come (this post may be colored by my watching MTV for the past couple of hours!)

    Trailer is here:

    The one statistic which got to me was a poll which states that in the USA more people would elect a gay person than an atheist; and even then Christians (assumed as only 'Catholic' appeared in the poll) are WAY more likely to get elected than almost any other group. This really saddens me, someone who chooses not to believe in the mythology of religion is MORE excluded than the group of people which the president specifically legislates against having certain civil rights (marriage)...though not by much!

    It didn't take me long to discover that it's pointless debating religion with people in this country...talk about Religion as a virus! Some years ago I spent a decent amount of time (a couple of months) finding out all I could about as many religions as I could; I read the Christian Bible, the Bhagavad Gita, the Book of Mormom, the Qur'an and even Dianetics, I also read as much background as I could on these books (and a couple more I can't recall) and at that point made my decision that I could not accept that any of these religions had any ground in reality. Sorry if you're mad at me but it's my opinion...all of the books above were written by individuals, in some cases these individuals had extremely political motives for aligning a population with the 'rules' in these books and even sublimated existing religions to ease their introduction. I see the point they had but I don't see religion as a valid concept moving forward...

    Ooh, first real rant on my new blog :-) Comment moderation will most certainly be ON for this one...intelligent arguments against my position are welcome, telling me I'm going to hell is pointless, for me it's like saying I'm going to Narnia :-) Oh and how much do I love Wikipedia!

    Top Gear yay!

    Playing around with video embedding...UK show Top Gear took the fastest production car on the planet (the Bugatti Veyron.) to it's top speed...253MPH...faster than an F1 (or Indy) car!

    Sites I like...

    Will be adding to this post occasionally but thought I'd mention a couple that I love:
    NotCot - more specifically the 'org' version of NotCot you wouldn't know it by looking at me but I'm a design nut and this site has some fantastic quirky designs ranging from romper suits to illustrations on wood. This is one of m,y top ten sites right now and the level of creativity shown buy the artists and designers linked to by this site just blows my mind (what, I've been reading the Electric Kool-Aid Acid Test and I tend to pick up the lingo :-)). Right coffee...favorite coffee Peets Major Dickasons Blend; one surprising thing I noticed over here is that ground coffee is a lot more popular than instant but the general quality of the ground coffee available is really variable...oh and a lot of people go for the really nasty flavored stuff (notice American spelling in use...gotta adapt :-)).

    Diabetes promotion...

    Just noticed that Scott Cate is having a promotion to donate the American Diabetes Association by selling the excellent EasySearchASP.Net...as a fellow sufferer of diabetes I though I'd give his effort a plug (though no-one reads this blog at the moment :-))

    So what have I been up to,,,

    Well, for the last 8 and a bit months I've been living in Seattle (Fremont for those who know Seattle) and working in the Project Server team at Microsoft in Redmond.
    It has been bit of a big change, I went from being an Application Development Consultant, immersed in the technical minutiae of a dozen different products and living a lot of my life in Visual Studio to my current life of focusing on getting the next version of Product  Server out. I'm not going to pretend that it hasn't been hard making the transition - it has - but it's also been pretty interesting seeing how MS develops software; and how different the process seems to be from other companies I've worked for and with...so I guess I'll be writing about that here (not sure how much I can get away with telling everyone but well...we'll see).
    I suppose I can also talk about the differences between here and the UK; which are different to those I expected...also about the things I miss from back home (though just discovered I can buy Salad Cream on Amazon...yay!).
    Let's see what else can I put here, well I am slowly getting back into development (discovery: it's hard to write code when you have no specific endpoint in mind!), reading a whole lot of stuff which I'll attempt to review here...and just living a pretty normal (and grammatically poor) life.
    Well, let's see what happens...one of my first tasks is going to be dasBlogizing my old mostlylucid.co.uk posts and article(s)...hopefully I put the old DB somewhere safe and can actually do this!

    Testing Livewriter...

    I have to say I am VERY impressed with this tool...DasBlog and Livewriter hooked right up..very slick. See that's that kind of software we CAN write at MS...

    Mum and Dad Zoo 189


    The return of mostlylucid

    Well, been away from blogging for a while...now I've decided to get back into it...let's see where this goes...