mostlylucid

March 2005 Entries

Databinding bits...

Fantastic post on some interesting issues with Databinding…I love this sort of nitty-gritty stuff!

Heading off on holiday...

Well, it being the Easter weekend (in the UK we get tomorrow and Monday as ‘public holidays’) I’ve decided to take a holiday, as a result I’ll be off line for at least a week. I like to take a break from computers occasionally – helps defrag my coding lobe…
Also just got the Simpsons Season 5 box set…which is nice…
Reading matter for the time I’m away:

Expert C# Business Objects
Expert Service-Oriented Architecture in C#: Using the Web Services Enhancements 2.0

Sadly, I’m quite looking forward to reading these…especially the second one which covers something I know relatively little about (relative to who I have no idea…but I know more than the dog…)
If you need to contact me urgently, I’ll check email occasionally (on my swishy yet strangely un-salubrious smartphone) and I’ll have my home phone diverted to my mobile…  

LZMA SDK (Software Development Kit)

LZMA SDK (Software Development Kit)

This is a really interesting new compression algorithm, has a nice beta SDK with examples in C#. Would be really interesting to merge this into #ZipLib…we really do need a rework of #ZipLib and other algos to support the new System.IO.Compression namespace and it’s streams…

Random brain fart...

Note to self...introduce myself in future always with the honorific 'your nemesis'. Noticed it in a random thread which has nothing to do with me.’..I just love the idea…(oh, and no link back because this has nothing to do with that thread…)

Transact-SQL Tips

Transact-SQL Tips

Interesting tip on SQL Server hierarchies (using the standard parent-child hierarchies as opposed to Nested Sets)

Scott Galloway

Really odd IIS 6.0 'bug' when updating Stylesheets...

I had to rebuild all of our office servers over the weekend (don't ask!) and after the rebuild we noticed a problem with saving changes to the server which the designers use for editing; when changing CSS files, after a few changes the server would stop reflecting those changes in the browser. So, say you change some CSS property, refresh the page...result...change isn't reflected in the browser. Well, I tried EVERYTHING to get this working (had the usual...'well it was working until recently'...which wasn't possible), tried changing IIS 6.0 HTTP headers to expire content immediately, changed the IE caching settings, the lot. Eventually, I did a google trawl and found the possible solution (he's still trying it) to this issue...a registry change to IIS 6.0 Kernel Mode caching...
The 'solution' is to add a DWORD key to HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\HTTP\Parameters called UriEnableCache with a value of 0. Apparently this change will disable Kernel Mode caching...hopefully solving this problem...all the registry settings are here

ASP.NET Page Lifecycle

ASP.NET Page Lifecycle

Really cool links from Eli Robillard on the Page Lifecycle…

Scott

Cool little tip - change buttons to look like linkbuttons

From the ‘don’t comprimise design for accessibility’ stable comes this little tip – how to make a submit button look like a link button:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<!-- dean.edwards/2004 -->
<!-- keeping code tidy! -->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <!-- compliance patch for microsoft browsers -->
        <!--[if lt IE 7]>
<script src="ie7-standard.js" type="text/javascript">
</script>
<![endif]-->
        <style type="text/css">
 input[type="submit"] { border: 0px inset;
 background-color: transparent;
 color: blue;
text-decoration: none;
 cursor: pointer; }
 input[type="submit"]:hover {
 color: red;}
        </style>
    </head>
    <body>
        <form ID="Form1">
            <input type="submit" value="My Link Button" ID="Submit1" NAME="Submit1" />
        </form>
    </body>
</html>

 

OK, not that simple, this also uses the excellent IE7 stuff from Dean Edwards to enable IE 6 to support CSS properly…for stuff like :hover and CSS selectors (input[type="submit"]).

Reason for this? LinkButtons use Javascript and are not usable from Text Readers…

Use Your Instant Messenger To Query Amazon

Use Your Instant Messenger To Query Amazon
I love this idea..hook up Lucene with a knowledgebase system…use MSNIM to provide an interactive FAQ system!

Scott Galloway

WTF! You can't use ASP.NET 2.0 on a box with Sharepoint installed!

Found here, this has to be the dumbest thing I ever heard! So, we have lovely new ASP.NET 2.0 with  a bunch of productivity enhancements, lovely web parts…but wait…you can’t start using it until next year (2006) because Sharepoint can’t run on the same box! We have to wait for Sharepoint Portal Server SP2…which won’t be until well after Whidbey is released…an remember there’s 30m+ Sharepoint licenses around!
Complete screw up if you ask me! 

Great way to enable IIS 6.0 compression...

A colleague of mine pointed this out, great little free tool to enable GZip compression in IIS 6.0…make ur sites feel like they’re actually quick

Recieve a '419' scam mail - forward it it the abuse address...

I get these ‘419’ mails a fair bit at my work mail address;where I don’t have the sam level of spam protection that I have at home; I used to just ignore them…then I realised that just because I don’t fall for them doesn’t mean that no-one else will. I recently started forwarding the recieved mail along with it’s headers to the abuse@ address for any domain I could find in the headers…so far I’ve had great responses from the email providers, usually resulting in the address used by the fraudsters being shut down within a few minutes of my mail.
So, if you get one, maybe you should be the same…you may just help someone else out by sending this stuff back to the abuse address where it came from…

Source for a C# compiler written in pure C#.

Source for a C# compiler written in pure C#.

Awesome idea…now what would be really fantastic is if CSC was written in C# – just seems like nice logic for a compiler to be written in the language it compiles

Scott Galloway

Interesting little CLR question...

I was chatting to someone on IM tonight (name withheld at the correspondents’ request) about a couple of basic coding matters…the assertion he made was that if you pass a reference type to a method it is exactly equivalent to passing a reference type with the ‘ref’ modifier…well, here’s a piece of code to test the theory. What would you expect the result to be and why (simple little console app in case anyone wants to try it out)…?

using System;

using System.Collections;

 

namespace ConsoleApplication3

{

    /// <summary>

    /// Summary description for Class1.

    /// </summary>

    class Class1

    {

        /// <summary>

        /// The main entry point for the application.

        /// </summary>

        [STAThread]

        static void Main(string[] args)

        {

            ArrayList al = new ArrayList(2);

            ArrayList al2 = new ArrayList(2);

            SetNull(al);

            SetNull(ref al2);

            Console.WriteLine(al ==null);

            Console.WriteLine(al2==null);

            Console.ReadLine();

 

        }

 

        private static void SetNull(ref ArrayList al)

        {

            al = null;

        }

 

        private static void SetNull(ArrayList al)

        {

            al=null;

        }

    }

}

UPDATE: As AndyB pointed out in the comments, this article has a great explanation of the differences between passing by ref and passing by val...oh, and of course, the bible also includes a great discussion of these issues...

Least surprising news ever: Microsoft to buy Groove Networks

Not claiming any powers of precognition or anything, this news was pretty obvious for about the last year. I realy think this will be a great step for both companies – and might it also indicate a bigger investment from Microsoft in ‘Social Software’? I’d watch this blog for more details on what this incredibly smart guy plans to do next…as CTO of Microsoft

[HELP] Question on Windows Server 2003 Wildcard Mapping and VS.NET

Here’s what I’m doing – I have a wildcard map set on my IIS 6 server to allow me to do “/” path mapping through my ASP.NET HttpHandler – problem is that VS.NET can no longer open the web project at that address…anyone any idea why?
UPDATE:  Looks like it has to do with Front Page Server Extension stuff...sooner that goes away the better (roll on VS.NET 2005!). Anyway, to get around this I used the instructions here which basically tell you how to avoid the nasty FPSE stuff and run Web Projects like a normal class library (which also makes them load faster as a nice side effect!)

Update on the Google Maps / AJAX Javascript stuff...

Following my referrer links found this blog (I love this whole interlinking stuff!) has some great content and I noticed this posting which links to this tutorial on XmlHttpRequest (the stuff behind AJAX) . Anyway, it’s a great tutorial and it should be fairly easy to change the server side implementation; tutorial uses PHP & MySQL but it really just involves XML processing which is a breeze using ASP.NET – the tricky bit is the Javascript which you CAN use across server side languages…

Current book list...

So, I’ve been off-blog for a couple of weeks…this is due to my usual intrinsic malaise as well as being heads down on a project at work. But, another reason is the multitude of books I’ve bought recently (these as usual also reflect my current obsessions )…

Pragmatic Version Control Using Subversion – this is a just phenomenal book on the wonderous Source Control system Subversion, covers everything you’d need to know if you wanted to shift off the decidedly aged SourceSafe and on to something more stable (and don’t want to wait / pay for VSTS)

A New Kind Of Science – hmm…interesting basically tries to explain all science using mathematics, cellular automata etc…not sure about this HUGE book yet…

Essential .NET Volume 1 -not new (actually pretty old now) but this is a book I try to read every year or so – pretty much THE book if you want to know the nitty gritty of how .NET works…if you think you’re a fairly advanced .NET developer and haven’t read this book…well you’re kidding yourself…

Lucene in Action – My current obsession, this book covers the Java version but the .NET Version is pretty much method compatible (case is the only thing which is different). This book shows the tremendous power of this Search engine framework…all you need to know…

Advanced .NET Remoting – second edition of the definitive .NET remoting book, also just a great example of how you should write a book on such an advanced topic, clear, great examples…the lot. But is is ADVANCED! See the next book for a gentler introduction…

Remoting with C# and .NET – great introduction to .NET Remoting…worth a read if you want to get a good idea of what remoting can (and can’t) do. Only criticism would be the coverage of Client and Server activated objects…felt this could do with more fleshing out.

Artificial Intelligence: A Guide to Intelligent Systems – another of my current obsessions, this is a great book introducing the various types of ‘intelligent’ systems, not too mathsy either.

Well, that’s my current list – haven’t finished them all yet but should keep me busy for a while!

 UPDATE: Should point out, thet the 'New Kind Of Science' review is not meant to be a recommendation as a scientific approach - more as an interesting read. I am totally aware that Wolfram's views are not universally accepted within the scientific community (e.g., http://www.kurzweilai.net/articles/art0464.html?printable=1 ) I'd only recommend it as a throught-provoking read for those interested in computational approaches to science..

Fairly interesting technique

So here’s the problem ,you want to store items in a Dictionary *but* you want to be able to access those items using different types of key (so in the example below, I use Guids, strings and longs)…here’s how I usually do this…as usual any comments or suggestions for better ways are appreciated…

using System;

using System.Collections;

 

namespace Configuration

{

    /// <summary>

    /// Summary description for ContentPageDictionary.

    /// </summary>

    public class ContentPageDictionary : DictionaryBase

    {

        private Hashtable cpKeys = new Hashtable();

        private Hashtable cpLongKeys = new Hashtable();

        public new void Clear()

        {

            this.Dictionary.Clear();

            cpKeys.Clear();

            cpLongKeys.Clear();

        }

        public  ContentPage this[string key]

        {

            get

            {

                return (ContentPage)base.Dictionary[key];

            }

            set

            {

                Dictionary.Add(key, value);

                cpKeys.Add(value.Guid, key);

                cpLongKeys.Add(value.ObjectId, key);

            }

        }

 

        public ContentPage  this[long key]

            {

        get

            {

            if(cpLongKeys.Contains(key))

            return  this[cpLongKeys[key] as string];

            return null;

        }

    }

        public ContentPage this[Guid key]

        {

            get

            {

                if(cpKeys.Contains(key))

                    return  this[cpKeys[key] as string];

                return null;

            }

        }

            public ICollection Keys

        {

            get { return (Dictionary.Keys); }

        }

 

        public ICollection Values

        {

            get { return (Dictionary.Values); }

        }

 

        public void Add(string key, ContentPage value)

        {

            Dictionary.Add(key, value);

        }

 

        public bool Contains(string key)

        {

            return (Dictionary.Contains(key));

        }

 

        public void Remove(string key)

        {

            Dictionary.Remove(key);

        }

 

        protected override void OnInsert(Object key, Object value)

        {

            if (key.GetType() != typeof (string))

                throw new ArgumentException("key must be of type string.", "key");

 

            if (value.GetType() != typeof (ContentPage))

                throw new ArgumentException("value must be of type ContentPage.", "value");

        }

 

        protected override void OnRemove(Object key, Object value)

        {

            if (key.GetType() != typeof (string))

                throw new ArgumentException("key must be of type string.", "key");

        }

 

        protected override void OnSet(Object key, Object oldValue, Object newValue)

        {

            if (key.GetType() != typeof (string))

                throw new ArgumentException("key must be of type string.", "key");

 

            if (oldValue.GetType() != typeof (ContentPage))

                throw new ArgumentException("value must be of type ContentPage.", "oldValue");

            if (newValue.GetType() != typeof (ContentPage))

                throw new ArgumentException("value must be of type ContentPage.", "newValue");

        }

 

        protected override void OnValidate(Object key, Object value)

        {

            if (key.GetType() != typeof (string))

                throw new ArgumentException("key must be of type string.", "key");

 

            if (value.GetType() != typeof (ContentPage))

                throw new ArgumentException("value must be of type ContentPage.", "value");

        }

 

    }

}

as simple as possible, but no simpler: Mapping Google

as simple as possible, but no simpler: Mapping Google – great article on the costs and benefits of the technique google maps uses (Javascript / IFrame) versus the GMail method (XmlHttp)

Scott (normal service will resume shortly…)