mostlylucid

October 2007 Entries

Probably be taking a break from this for a few days

Sorry, have to prioritize work right now. With some stuff going on in my private (yup, too private even for my blog!) life I need to focus on the stuff I get paid for. All being well I'll be back in about two weeks...

Screwing around with SubText

Well, I knew it would happen eventually, I've spent the evening playing with the SubText code (the blog engine this site runs on). I am an inveterate fiddler...I love to hunt through code, figure out how it works (break it invariably) then optimize it. Looks like my machine is still causing my IDE to 'stutter' (lock up for indeterminate periods) but I've been spelunking (good word!) around how requests are processed and pages are composed and there's a few changes I want to make. Note, this isn't a criticism...I just like messing with stuff ; for the record, Phil Haack did a great job keeping this thing going, I like it way better than any other engine out there including Community Server, the 'official' .TEXT successor. 
One of my main reasons to fiddle is that SubText was based on the original .TEXT by Scott Watermasysk which was never really updated for .NET 2.0, so no 'proper' MasterPages, Generics (that I can see) or other .NET 2.0 features. So, anyway plan is to fiddle a fair bit with how this thing works; if you're at all interested, the 'broken version' (more likely than not!) will be on my home machine at http://home.mostlylucid.net it seems like the almighty Comcast has stopped blocking port 80...if you can't see that site well, they've started again.

Anyhoo, not much to see yet but this is my pet project...as usual any changes I make, I'll stick on this blog for all to deride :-)

Buggy software make me mad!

I so want to code freely and easily with VS 2008 Beta 2 but it's getting in the way, freezes a whole lot! Considering spending a couple of hours installing a more stable internal release tomorrow...we'll see (oh, and expect a few new bits to pop up on my blog soon!).
P.S. yes I realize it's Beta 2 and that my home machine is about as stable as a blancmange on a rollercoaster but still!

Geeky obsession...Pens...no, really!

I came across this post where someone discovered that their favorite pen was discontinued and had to find an alternative one...I don't know why but it never occurred to me that other people had this preference. For the last 17 years I've had a favorite pen...only one type which I always end up drifting back to, the Pilot Precise V-5  ; below...apparently the #1 Rolling Ball pen in America, I'm so common!

7421

Stupid post I know but it just never entered my head that:

1. this was quite such a preference for me. I mean, 17 years, the most committed relationship I've ever had is to a pen!

2. other people had similar thoughts.

Oh, and for the record I'm currently using a Muji Black Ink Aluminium Barrelled Rollerball (great, very fine pen and it looks uber-geeky)...because the 12 Pentel Precise Pens I had in my office have been 'relocated'...Oh, and I occasionally veer to a Fisher Bullet Space Pen for a few months; I've lost about 10 of these things...but being able to keep a pen in your pocket which never leaks and is really compact was too compelling when I was on the road.

Crazy busy at work, back soon!

Things have been insane at work over the past few days...back to this soon! Plan to get a nice 'Amazon book suggestion' tool on the site; going to let readers suggest books on various topics by entering an ISBN and then provide the country appropriate URL to buy that book. Still fiddling with the new Amazon web services bits but it's nearly there...

See you at the weekend (probably!)

Miracle of miracles...

Up before midday on a Sunday...must be the first time in about 5 years. Went to see my doctor about the sleeping problems I've been having of late; which have had a huge knock-on effect for the rest of my day (4-5 hours sleep a night is not a good thing)...also led me to have marathon 12+ hours sleep sessions on the weekend. Anyway, long story short I'm trying Ambien for a couple of weeks (strictly short term only). This was my second night (normally I won't use it at weekends, just getting used to the effects). It's amazing the difference that 8 hours of deep sleep has...normally I'd get about 20 minutes then wake up the continue that cycle throughout the night, waking up feeling lousy and more often than not having a headache. This weekend I've had 2 perfect nights' sleep and I feel like a different person!
Anyhow, this is the beginning of my third week of working on myself, no coffee at work, working on the sleep and getting out a bit more. What prompted this? Well it was a few things; I got to thinking about it after reading Rory's blog over the last couple of months, watching the interview with Jeff Sandquist, oddly reading Microserfs again. I also got to thinking about a friend of mine from years ago ; Stuart who basically had a nervous breakdown due to overwork (due in no small part to me - something I will be forever sorry for).
I realized that I was heading the same way as Stuart, luckily being off sick a couple of weeks ago and unable to work game me some time to think about the direction I was heading in...the discovery that being worried less about work actually helps me work far better is insanely surprising!
Anyway, still at the beginning of a long road; and frankly a pretty embarrassing one for an ex-psychologist...but part of the point in my restarting this blog was honesty! Next up, back into the dating scene (or more specifically *into* the Seattle dating scene)!
So, any Seattle women up for meeting a fat Scotsman with low self confidence :-)

New ASP.NET MVC Framework

I've talked to a few people about this over the past few weeks, I am tremendously excited about where this will be going. Scott Hanselman has posted a link to some presentations on this. Over the past few years I've written 5-6 of this type of framework (MVC / MVP based, URL redirection etc...nowhere near as complete or elegant of course!) and ASP.NET adding this type of functionality is a massive move forward. Of course this is only the beginning!

Update to my favorite Live.com service

I have to say, Skydrive is the best thing Live has done so far in my opinion...very easy way to share files. I use it a lot to share stuff with my family back in the UK, my parents aren't very computer savvy but the Skydrive interface is really simple to use (they're used to folders and such...).
I'm going to be very cheeky and just paste a bit of the mail which one of the PMs (Program Managers) from that team sent round today:

"We’re excited to announce that at 3pm, today, we’re updating Windows Live SkyDrive (http://skydrive.live.com) with some new features, and with more storage!  Here are the highlights of these updates.

· 1 GB of storage – Everyone now gets 1 GB of space.

· RSS feeds – You can subscribe to RSS feeds on public folders.  You will receive a notification anytime someone changes the folder.

· Add a contact from the SkyDrive website – You no longer have to go to Hotmail or Messenger to add contacts to share with.  You can now add contacts on the SkyDrive website.

· See who uploaded a file – On the page that tells you all the details about a file, you can now see who uploaded the file.

· Share with non Live IDs—In the past, only Live ID contacts would appear in your contact picker.  Now, you can share with any e-mail address.  The owner of the non Live ID e-mail address will receive an e-mail with instructions on how to access the shared folder.

· A bunch of more little features and fixes.

Our team blog will be updated at 3pm, and it will highlight some of our new features: http://skydriveteam.spaces.live.com/default.aspx."

So, very nice updates...and you can't argue with a full gig of free online storage for just about anything you want! Oh, and if you use Live Writer there's a neat little plugin for embedding Skydrive stuff.
Just for fun here's the code for the little tracking module I wrote a couple of weeks ago (messy code I should add!):



Of course the other cool thing is that I don't pay for the bandwidth that download takes up!
P.S., fo the record here's the SkyDrive team post on the update...

Bah...I can't get no sleep...at least I have a good book!

Well another night where I can't sleep...alarm clock is set for 5:30am (have to do some work before a meeting) and I'm currently tracking about 5 hours sleep tonight. Weirdest thing is that I fell asleep on the sofa during Cavemen; probably best all round...managing to make a sitcom with no com is quite an achievement...really is dire! Hmm...wonder if I should try a 'proper' sleeping aid?
Anyway one good thing about my inability to sleep is that it gave me some time to catch up on my reading; currently reading Halting State by Charles Stross essentially it's a sci-fi crime drama set in Edinburgh of 2018. I lived in Edinburgh and worked in the software industry there for about 5 years, it's a very accurate book...even down to the recruitment consultant's offices! Highly recommend this book, it's about a bank robbery inside a MMORPG about half way through but as usual from this author it's just brilliant.
Just noticed, this guy is really prolific, in 2006 alone he published 5 books! Anyway, so far I've read a bunch of his books and every one has been great - haven't read the 'Merchant Princes' ones though, seem a bit on the 'crappy Neal Stephenson' vibe. For the record, Neal Stephenson was my absolute favorite author at one point with Snow Crash and Diamond Age (two of the best cyberpunk books ever...well, after early William Gibson) but the whole 'Baroque Cycle' is just slow, boring literary masturbation in my opinion... Cryptonomicon was on the verge but at least it's still readable. I mean Quicksilver is 960 pages about: "Adventure, romance, politics, history, theology, magic, science, money and calculus", makes you want to dig your eyes out with a spoon!
So one for the comments...what's your favorite books?

When computers attack...

Bah...just tried to login to the admin system on this blog...ain't working for some reason...meanwhile I was only trying to do this because Outlook has hung whilst trying to book a meeting. Luckily I'm about to head off...well not that luckily, a rather painful series of blood test awaits...

To struct or not to struct

I've been commenting on this post by Bernal Schooley on a method using structs to 'simplify' using ViewState. Bernal has had a couple of posts around ViewState and methods of making it's use simpler. I have to say the comments on the posts are more useful for me that the posts themselves (as is often the way...comments are still on the blog right ).
One problem I do have is advocating the use of structs for this stuff...now don't get me wrong, I am aware of some advantages around structs; which go away slightly when using Generics as the constant boxing/unboxing no longer happens...There does seem to be a lot of misunderstanding around structs though...they're not always faster!
Structs are stored on the stack rather than the heap, this makes accessing and using them faster (often dramatically faster!) . However you have to be aware of the limitations around structs...one biggie is that over 16 bytes you lost a lot of the advantage of this speedup - don't be storing a ton of data in a struct (well, not a ton...over 16 bytes!).
The other biggie is boxing structs...again in this case you've flipping them onto the heap rather than the stack...so you lose the 'stack' advantage again...
So, story is structs can be great but be careful with them...there's a newbie mistake in thinking that structs are these great, lightweight objects you can use however you want...they're not. Unless you can *really* justify using a struct, don't bother! In my entire .NET programming career I used structs maybe 5 times...and for very specific reasons!

43 Exceptionally useful AJAX applications

Just thought this was cool.
I find the popularity of AJAX amusing...wrote my first AJAX app 7 years ago! Is it just me or there a LOT of BAD AJAX apps around now? So many Javascript errors!

Kava Tea, we'll see if it works!

I'm trying Kava Tea instead of coffee this week, well, coffee *at work*; me driving in the morning without my Peets Major Dickasons blend would be just too dangerous to both myself and other road users! The one time I tried giving up coffee completely led to a scar on my car's front bumper and the loss of my car pool driving privileges (now I don't car pool at all...).
Supposedly Kava has an anti-anxiety effect...so I'm hoping it calms me down and helps me structure my thinking a bit more easily.

I'm so excited...

Sad but I am so looking forward to this:

World's biggest Futurama fan right here...I preordered within 10 minutes of the DVD appearing on Amazon :-)

Getting back to me...

If you've been reading the posts on this blog recently you'll have noticed that my posts have been very downbeat...to say the least! The cold which I've had for over a week now has really sapped my energy...combined with the extreme anxiety I caused myself over some stuff at work, it's really left me in a pretty depressed state. So, aim for this weekend is to pull myself out of it!  Steps I'm taking:

  1. Bought Halo 3...
  2. Currently listening to my 'guaranteed feel better music'...won't bore you with it...partly because it's not fit for public consumption and partly because you'll think I'm REALLY nuts!
  3. Sleeping! I really don't do well with sleep deprivation...all of my mental barriers come down and I get a bit emotional.
  4. Reading non-technical books...for various reasons which I've unsubtly alluded to on this blog I've been reading a lot of technical books lately...good for learning, not good for escapism!
  5. No computer...I mean it, I just need a break from this for a couple of days...planning to take a week in a month or so completely away from the computer (back home I used to head into the wilds of Scotland...need to find an equivalent here...which takes cats!)
  6. No work...I really should do something for deadline sake but it's more important right now that I take a break.

So, see you all on Monday; traffic is actually picking up here surprisingly, not back to the 10000 hits a day the old site used to get but getting there! Also a few hits (which aren't me) from work...which is a little worrying!

Another day...

Well, still got the cold...currently drugged up with Nyquil, Advil PM and Melatonin (none of which interact, I checked :-)) to try and get a decent night's sleep. I'm so looking forward to this weekend...have to work through it but at least I'll get some more sleep! Also still trying to figure out how much to feed my cat...one pouch seems too little, two seems too much (and one and a half...well it's fiddly!) I'd rather have a fat cat than a hungry one, so two is winning right now.
Well, another not hugely exciting or technical post...I'll get back to those when I feel a bit more human!

Old Movie - Weird Science...

Ok, I had to...I do love dem 80s teen comedies!

New Science Show - Wired Science

In the middle of watching this show right now, basically Wired magazine on TV. I can't convey how great this show is...something sorely lacking on American TV, entertaining, accessible science. I've embedded one of the segments below on chemistry sets and the dilution of chemistry sets and chemistry teaching here. Luckily I was exposed to the insane British science teaching tradition...memories of Sugar and Potassium Permanganate (sp?) bombs and hydrogen filled balloons being ignited. I still have a vivid memory of a teacher being thrown across the room by a malfunctioning van de graaf generator!

Zune 2

I've been intentionally quiet on this so far; too much risk of leaking something inadvertently...not that I knew anything, it's all kept very hush hush! Anyway, I think Engadget has the best coverage here. My favourite quote though is from the Wired article...

As Chris Stephenson, the GM of Global Marketing for Zune told me, "Apple has established a benchmark for the industry. They've really brought the media player to the mainstream." But he still sees an advantage for Microsoft.

"We're not the hardware company they are," he said, laughing. "But then again, they're not the software company that we are."

NOW I get it...we can never really compete in terms of the cool new hardware, we're not that type of company but we can be amazing in software, integration etc...and you know what, I want to buy the new black Zune (I never really liked the original one)!

Bah, went back to work too early!

Can't go off again now (looks bad) but I really shouldn't have gone back today...felt like I was dying all day...wrapped up in a blanket and throwing down coffee and the generic cold remedy we get at work (for prospective MS employees, we get free drugs...not good ones but..) like they were going out of fashion.
Oh, and had my first death threat today...in response to my pro-evolution post...gotta love Christians!

Note to self...

Being sick for 4 days when you're already struggling to meet a deadline != a good idea! Hmm...can I actually live in my office?

P.S. should add for potential future employers, ain't necessarily my fault I'm struggling!
Complex project + lots of dependencies does not make for a stress free environment!

Amazing news, see the .NET framework source

As an MS employee I've been able to see this code for a couple of years but this is a huge step for the .NET community, for the first time you can browse and step through the .NET source code in debug. Amazing learning resource! Yes, you too can see all the .NET source!

In the middle of a mental reboot...

I've been coasting...I admit it and it's time I did something about it!
This started before I came to Microsoft and got slowly worse over the past 2 years...my rate of learning new stuff decreased and I rested on my considerable laurels. But it has to stop...my reader has probably noticed the flurry of new posts on this blog...this is an indicator that I'm finally engaging with life again...time for a reboot.
When I left my last job pre-MS I had basically burnt myself out...I was trying to cram too much work into too little time and it caused the bit of my brain which loved coding to shut down...I lost interest in the greatest passion in my life, learning new code; discovering the next great thing, building software which no-one else ever thought of...and well, I just couldn't do it any more.
Coming to Microsoft gave me a chance to find out what I wanted to do, I could do a 'normal' amount of work (for me, actually it was a lot of work...just not compared to what I was used to before!) across a wide variety of products and discover what I truly had a passion for again.
Being off sick for the past 4 days let me think deeply about that...I literally couldn't do my normal job so I had time to really think about it...now I know, now I am aware of where I should be and what I should be doing...and well...I can't really divulge what *it* is yet but I will, I can feel the little bit of my brain which shut down two years ago sparking back into life and it feels fantastic!
I have a million crazy ideas, I have a decent, fairly stable website and a plethora of new technologies to play with...hmm things could be about to get interesting!

Looking back...

Found a comment to an old post of mine by Jon Galloway (no relation). Hmm...how times change...I wonder :-)

"Without knowing what the hell I'm talking about, I wouldn't rule out a Microsoft job in your future. From your earlier post, you interviewed for a PM job for ASP.NET 5 years ago. Since then, you've clearly mastered ASP.NET and have a lot of good ideas on how it can improve. As an ASP.NET user, I'd be attempting cartwheels if I heard you were joining the ASP.NET team.
Times change - how many of the people you interviewed with are still in the ASP.NET group or even still at Microsoft 5 years later? And if you're human (and I suspect you may be), you're likely a very different person than you were 5 years ago, too. I doubt Microsoft has a one interview in your life policy (that would be very stupid in my opinion).
Now if only you spoke Microsoft/American... Hint: start by prefixing each sentence with "So..."."

 

Very funny...makes me want to get spun up on ASP.NET even more...as for joining the ASP.NET team...hmm...watch this space (no, nothing definite...but wheels within wheels as they say :-)).

Geek philosophy - The Singularity is Near

Are we living in a simulation?
Whilst randomly surfing I came across this site, basically it's a link site to a series of papers investigating the question of whether what we currently perceive as reality is really just a simulation of the past being run by some future entity. Obviously The Matrix was the biggest popular look at this but it is a fascinating (though by it's nature, unanswerable) question. Certainly gives the whole 'creation' argument a new spin...wikipedia entry here.

"In the beginning God created the heaven and the earth
And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters.
And God said, Let there be light; and there was light.
And God saw the light, that it was good: and God divided the light from the darkness."
-- Genesis 1: 1-4 (KJV)

 

What if what 'God said' was a whole bunch of code :-)
I am a believer in something called 'The Technological Singularity' and I recently finished a great book on the subject called 'The Singularity Is Near' by Ray Kurzweil. One of the really interesting things in this book is the notion that if we survive for another 25-30 years, technology will have advanced to the point where we can essentially live forever...quite compelling!
Anyway, just another of the bizarre notions which floats around in my mind, what better way to explain the universe than it being a man(or post-human)-made simulation...

Just a music post...

I can never remember the name of this song...oh, and if these posts annoy you I'm working on a 'mainstream' - no music or personal rants and an 'alternative' feed...song is Maps by the Yeah Yeah Yeahs...and well it reminds me of a crazy girl I used to date...

Canned Oxygen

Stumbled across this on Amazon today...honestly they sell pretty much everything now! I may just try this out, when I worked in a hospital a few (wow, 10!) years ago I used to take a hit of oxygen in the morning if I felt tired (especially after a big night out...I used to be sociable!)...makes you feel a lot more alert...and seemed to help headaches a lot too.
Anyway, a lot of medical types swear by  a hit of oxygen to perk them up...might just have to buy some!

For the paranoid...I'm not spying on you...

Just got a mail about my previous post. Just for the record, I'm not recording anything which isn't normally recorded in the IIS logs...never fear!

Hello New Zealand

A few years ago I had a little HttpModule which logged every request to the site as well as worked out what country the request came from (using this code). Anyway just wrote a new version of it and hooked it up to this site...hence the 'Hello New Zealand' title. Always interesting to know where people who read this site are from...oh and the primary purpose, helps me track down errors with requests...just got the Google readers hooked back up by pointing the old RSS feed address at the new feed!

For anyone that's interested, module's code is below...non-optimized but it does the job (oh, and swallows an exception...NEVER do this!). Essentially it's a standard little HttpModule which Asynchronously logs user requests...there's some issues which I'll get round to fixing eventually e.g, it shouldn't use a static to hold the IP table really, should use a Cache object which can be destroyed to save memory...also the DB insertion code uses a really hacky pattern to make my life easier...

 

UPDATE: Just noticed the code formatter I'm using is nasty! Hmm...have to look out the better one I knew about a while ago...

UPDATE2: Found it! http://www.jtleigh.com/people/colin/software/CopySourceAsHtml/ 

Before:

using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.IO;
using System.Data;
using System.Data.Sql;
using System.Configuration;
using System.Data.SqlClient;

namespace ML
{
    class TrackingModule : IHttpModule
    {
        static string connectionString = ConfigurationManager.ConnectionStrings["subtextData"].ConnectionString;


        static IPCountryTable table;
        public void Dispose()
        {

        }

        public void Init(HttpApplication context)
        {
            context.BeginRequest += new EventHandler(context_BeginRequest);

        }

        void context_BeginRequest(object sender, EventArgs e)
        {
            HttpContext context = System.Web.HttpContext.Current;

            LogRequestDelegate ld = new LogRequestDelegate(LogRequest);
            AsyncCallback cb = new AsyncCallback(EndLog);
            ld.BeginInvoke(context, cb, ld);
           
        }

        public delegate void LogRequestDelegate(HttpContext context);

        public void LogRequest(HttpContext context)
        {
            if (context == null)
                return;
            if (!context.Request.Path.Contains(".aspx"))
                return;

            if (table == null)
            {
                string resourcePath = context.Server.MapPath(@"~\resources\");
                table = new IPCountryTable(16);
                table.LoadStatisticsFile(Path.Combine(resourcePath, "ripencc.latest"), true);
                table.LoadStatisticsFile(Path.Combine(resourcePath, "arin.latest"), true);
                table.LoadStatisticsFile(Path.Combine(resourcePath, "apnic.latest"), true);
                table.LoadStatisticsFile(Path.Combine(resourcePath, "lacnic.latest"), true);
            }


            string country = !string.IsNullOrEmpty(context.Request.UserHostAddress) ?  table.GetCountry(context.Request.UserHostAddress) : string.Empty;
            string requestUrl = context.Request.RawUrl;
            string userAgent = context.Request.UserAgent;
            string referrer = context.Request.UrlReferrer == null ? null : context.Request.UrlReferrer.ToString() ;
            string userIP = context.Request.UserHostAddress;
            string userHostName = System.Net.Dns.GetHostEntry(userIP).HostName;
            using(SqlConnection sconn = new SqlConnection(connectionString))
        {
            sconn.Open();
            using (SqlCommand scomm = new SqlCommand("INSERT INTO mostlylucid_Tracking (Country, RawUrl, UserAgent, UserReferrer, UserHostAddress, UserHostName) VALUES (@Country, @RawUrl, @UserAgent,@UserReferrer, @UserHostAddress, @UserHostName)", sconn))
           {
               scomm.Parameters.AddWithValue("@Country", country == null ? DBNull.Value : (object) country);
               scomm.Parameters.AddWithValue("@RawUrl", requestUrl == null ? DBNull.Value : (object)requestUrl);
               scomm.Parameters.AddWithValue("@UserAgent", userAgent == null ? DBNull.Value : (object)userAgent);
               scomm.Parameters.AddWithValue("@UserReferrer", referrer == null ? DBNull.Value : (object)referrer);
               scomm.Parameters.AddWithValue("@UserHostAddress", userIP == null ? DBNull.Value : (object)userIP);
               scomm.Parameters.AddWithValue("@UserHostName", string.IsNullOrEmpty(userHostName) ? DBNull.Value : (object)userHostName);
               scomm.ExecuteNonQuery();
           }
        }

        }

        public void EndLog(IAsyncResult res)
        {
            try
            {
                ((LogRequestDelegate)res.AsyncState).EndInvoke(res);
            }
            catch (Exception) { }
        }

    }
}

 

After MUCH better...this is pretty much identical to what I see in my IDE...yup, I use Verdana as a coding font...:

 

using System;

using System.Collections.Generic;

using System.Text;

using System.Web;

using System.IO;

using System.Data;

using System.Data.Sql;

using System.Configuration;

using System.Data.SqlClient;

 

namespace ML

{

    class TrackingModule : IHttpModule

    {

        static string connectionString = ConfigurationManager.ConnectionStrings["subtextData"].ConnectionString;

 

 

        static IPCountryTable table;

        public void Dispose()

        {

 

        }

 

        public void Init(HttpApplication context)

        {

            context.BeginRequest += new EventHandler(context_BeginRequest);

 

        }

 

        void context_BeginRequest(object sender, EventArgs e)

        {

            HttpContext context = System.Web.HttpContext.Current;

 

            LogRequestDelegate ld = new LogRequestDelegate(LogRequest);

            AsyncCallback cb = new AsyncCallback(EndLog);

            ld.BeginInvoke(context, cb, ld);

 

        }

 

        public delegate void LogRequestDelegate(HttpContext context);

 

        public void LogRequest(HttpContext context)

        {

            if (context == null)

                return;

            if (!context.Request.Path.Contains(".aspx"))

                return;

 

            if (table == null)

            {

                string resourcePath = context.Server.MapPath(@"~\resources\");

                table = new IPCountryTable(16);

                table.LoadStatisticsFile(Path.Combine(resourcePath, "ripencc.latest"), true);

                table.LoadStatisticsFile(Path.Combine(resourcePath, "arin.latest"), true);

                table.LoadStatisticsFile(Path.Combine(resourcePath, "apnic.latest"), true);

                table.LoadStatisticsFile(Path.Combine(resourcePath, "lacnic.latest"), true);

            }

 

 

            string country = !string.IsNullOrEmpty(context.Request.UserHostAddress) ?  table.GetCountry(context.Request.UserHostAddress) : string.Empty;

            string requestUrl = context.Request.RawUrl;

            string userAgent = context.Request.UserAgent;

            string referrer = context.Request.UrlReferrer == null ? null : context.Request.UrlReferrer.ToString() ;

            string userIP = context.Request.UserHostAddress;

            string userHostName = System.Net.Dns.GetHostEntry(userIP).HostName;

            using(SqlConnection sconn = new SqlConnection(connectionString))

        {

            sconn.Open();

            using (SqlCommand scomm = new SqlCommand("INSERT INTO mostlylucid_Tracking (Country, RawUrl, UserAgent, UserReferrer, UserHostAddress, UserHostName) VALUES (@Country, @RawUrl, @UserAgent,@UserReferrer, @UserHostAddress, @UserHostName)", sconn))

           {

               scomm.Parameters.AddWithValue("@Country", country == null ? DBNull.Value : (object) country);

               scomm.Parameters.AddWithValue("@RawUrl", requestUrl == null ? DBNull.Value : (object)requestUrl);

               scomm.Parameters.AddWithValue("@UserAgent", userAgent == null ? DBNull.Value : (object)userAgent);

               scomm.Parameters.AddWithValue("@UserReferrer", referrer == null ? DBNull.Value : (object)referrer);

               scomm.Parameters.AddWithValue("@UserHostAddress", userIP == null ? DBNull.Value : (object)userIP);

               scomm.Parameters.AddWithValue("@UserHostName", string.IsNullOrEmpty(userHostName) ? DBNull.Value : (object)userHostName);

               scomm.ExecuteNonQuery();

           }

        }

 

        }

 

        public void EndLog(IAsyncResult res)

        {

            try

            {

                ((LogRequestDelegate)res.AsyncState).EndInvoke(res);

            }

            catch (Exception) { }

        }

 

    }

}

Interesting post on relationship management...

Hat Heads vs. Bed Heads on the excellent A List Apart site. I'm a bed head...this is one of my very favorite sites, lots of posts on practical web design techniques as well as just generally good writing...well worth a browse!

Feeling better...

Well just woke up (about 2pm...) and I'm finally starting to feel better. Head is a lot clearer and the headache has eased off to a dull throb...some sinus pain still but I guess that's just an after effect of all the decongestants...back to work tomorrow...lots to do!

2am and I just woke up again...

Man I hate being sick! Had about 4 hours sleep and woke up with a thumping headache and sweating like crazy...about to take more Nyquil...wait for 30 minutes then pass out again. Going to have to make a trek out of the house tomorrow for more drugs (Dayquil and Nyquil)...first time since Friday...really sucks! Of course work is also piling up which I'll have to do when I'm better...bah!

Not so intelligent design...68% of Republicans don't believe in evolution

I just read this story, apparently 68% of Republicans don't believe in evolution...to paraphrase Eddie Izzard, "just because there's a few holes in your theory you don't just go...it's fucking magic mate" (clip is below). Not to defend the British political system but there'd be NOT a chance of a British politician getting elected if they claimed creationism was anything but religion. It just scares the crap out of me that religion has so much power in American politics and that power seems to be increasing year on year. My beliefs...to quote someone far more intelligent than myself:

"I do not believe in a personal God and I have never denied this but have expressed it clearly. If something is in me which can be called religious then it is the unbounded admiration for the structure of the world so far as our science can reveal it." - A. Einstein

 I believe that science unveils a universe far more miraculous (yes, I use the word miraculous intentionally) than has ever been encapsulated in a religion, the concept that evolution is somehow inferior to the mythology of creationism leaves me incredulous. The belief that evolution lacks beauty just exposes a lack of understanding of the scale and depth which defines evolution.

 UPDATE: Sadly I need to close comments on this post...got some fundamentalist lunatics getting abusive...


Eddie Izzard At The Secret Policeman's Ball - The funniest movie is here. Find it

Latest thing I'm trying not to buy...

I'm what's generally called a spendthrift, honestly I buy the most ridiculous things (who *really* needs three lava lamps?). So the latest thing which I've become fixated on is the Hava Platinum HD:

This thing is kind of like a Slingbox only it appears as a tuner in Media Center. Looks very cool but I really don't need it; justifying it to myself by virtue of my hating the Comcast DVR and having a media center in my bedroom which doesn't get cable. Well, let's see what happens...got as far as the checkout but not yet succumbed.

Really nice method of determining where properties should be persisted to...

Was reading this post on ASP.NET Weblogs on the best method of saving and loading data to and from ViewState. I have to say that the method I always favoured was that mentioned by  Michael Teper ; with the getter and setters using the ViewState collection internally, but this does have a boxing / unboxing penalty associated with it. However someone also mentioned a CodeProject article on using a Persist attribute for this stuff...looks like a really nice solution....

Regina Spektor...weird but good!

This was the first album (as in shiny plastic, not downloaded)  I bought when I came to the states...beautiful, haunting music and irresistibly funky (yes, I know I just wrote that...but it's true damnit!). Anyway saw on Perez Hilton (sad enough that I read it, I refuse to link to it!)  that she just released a video to 'Better'...see below:

 

If you haven't heard of her before I really recommend that you give it a go...brilliant, poetic lyrics and wonderful music. Reminds me of the first time I heard Tori Amos...anyway, another toon from Regina is below (love YouTube!)

Got the cold...it sucks!

Pah...had a cold all weekend and it's still hanging on...symptoms are fairly easy to control with decongestants, Dayquil / Nyquil etc...but the way my body deals with sickness is making me sleep for vast lengths of time; in the past 3 days I've probably been awake for 10 hours in total!
So, plan is to get back to work tomorrow...well, we'll see...not looking too likely so far! It also sucks that my family are all about 5000 miles away...only thing worse than being sick is being sick with no-one to complain to about it...
Anyway, on the rare occasions I've been awake I've been catching up on reading...books of choice:
Pro C# with .NET 3.0, Special Edition (Pro)
Pro C# with .NET3.0, Special Edition
Excellent book, covers WCF, WPF, LINQ as well as very complete coverage of all .NET features...recommended! Also an excellent club in danger situations!


Programming WPF

Programming WPF 
Chris Sells and Ian Griffiths wrote this...all I need, really excellent book and very readable (which helps)

Professional ASP.NET 2.0 AJAX (Programmer to Programmer)

Professional ASP.NET 2.0 AJAX (Programmer to Programmer)
Again, all you need to know is that Matt Gibbs and Dan Wahlin wrote this, very complete coverage of everything you need to know about this technology (best Wrox book I've seen in a while too!) (image looks kinda flaky...just a book cover though!)

Data Structures and Algorithms Using C#

Data Structures and Algorithms Using C#
Oh dear...hmm...about the worst book I've read in a while...great idea and really valuable in theory but this book is terribly edited and full of errors. Also, oddly incomplete in it's coverage DO NOT BUY THIS BOOK!

 

So as you can see, getting back up to speed on development topics, I'm talking to some different teams at MS about getting back into a development related position...nothing immediate but it certainly figures in my plans!

Giving up on VS 2008 Beta 2

The Beta 2 of VS 2008 is great, apart from one pretty major issue: on occasion it seems to hang for several minutes. This hanging behavior seems especially prevalent when entering and exiting a debug session...which frankly makes debugging pretty much unusable. This might be something to do with my particular system (it's a hokey Vista pre-Beta upgrade to RTM...Search doesn't work on it at all) but 2005 hasn't got this issue...
Of course the real bugger is I forgot to save a backup when I upgraded this particular solution, rendering it unusable in 2005...hmm... 

The last lecture

You've no doubt read about this by now, Randy Pausch, a professor at CMU  was diagnosed with terminal pancreatic cancer and was asked to give a final lecture. The lecture itself is about dreams, realizing you own and helping other realize theirs, if you haven't watched it yet take an hour out of your day...I think we lose sight of the real point in our lives sometimes...this is a wake-up call.
Personally I remember working with very sick elderly people whilst on vacation at university, the message I got from every single one is that none of them wished they had worked more...spending time with family was far and away what they said made life richer. This video really got to me!

UPDATE found an embeddable thingy (umm...video player, seems like there should be a cooler name for these, umm...vidlet!) on Dan Woolston's blog...

Why I'm not posting about ASP.NET

Well, a friend had just emailed to ask this...I used to be a fairly prolific ASP.NET poster, interested in all sorts of esoterica which no-one else was (e.g, ViewState compression, Nested Repeaters etc...) . The basic reason is, I don't feel I have much to offer on the subject right now; my day-to-day job is no longer writing ASP.NET code and I feel that's where most of my more interesting posts came from. Hey, I will get back to it as I move further and further into development again.
Until then it's going to be fairly random on this thing...hopefully not too boring!