mhinze.com archive

this is an archive of the old blog, ended 6/16/08




    Archive for April, 2007

    links for 2007-04-20

    Friday, April 20th, 2007

    .NET Tip: Active Directory's pwdLastSet to DateTime in C#

    Thursday, April 19th, 2007

    to get a DateTime representing the last time a user's password was changed in active directory:

     

    IADsLargeInteger plsVal = (IADsLargeInteger) de.Properties["pwdLastSet"].Value;
    long filetime = plsVal.HighPart * 4294967296 + plsVal.LowPart;
    DateTime PasswordLastSet = DateTime.FromFileTime(filetime);
     

    converted from just one of the (vb.net) tidbits i found today in a truly most excellent wrapper for active directory…  just what i was looking for.  That is ActiveDs.IADsLargeInteger btw.

     

     

    Technorati tags: , ,

    links for 2007-04-19

    Thursday, April 19th, 2007

    links for 2007-04-18

    Wednesday, April 18th, 2007

    Hiding Affiliate Links Switcheroo

    Wednesday, April 18th, 2007

    michael gray posted an article about hiding affiliate links, but the best tip was in the first comment.

    Link out to the real site in your static link (use nofollow if you want), then use a javascript onload function to replace the links on the fly with the affiliate ones (and even remove the nofollow, if you want to trick the nofollow-highlighers).

    Without javascript it is just recommending the official site. With javascript it’s an affiliate site. Sure you might lose the 18 non-javascript users, but the others will use the affiliate links (check your logs for the numbers). Just make sure to test it across the standard browsers (check your logs).

    not a bad idea at all.  here's the proof of concept in javascript. 

    here i apply an additional class to each link that describes the affiliate link to use.  in the POC i create two arrays: one for the class names and the other for the links.  i would use a server side technology for the production task of filling these arrays.

    also i would use a 301 redirect on the server instead of including my affiliate links anywhere that people or robots can see them.

    i'm using this great getElementsByClassName because it supports multiple classes on your anchor elements.

     

    <a class="lendingtree otherclass" rel="nofollow" href="http://www.lendingtree.com">
    Here is an affiliate link</a>.
    And <a class="myfico otherclass" rel="nofollow" href="http://www.myfico.com">
    here's another one</a>.
    <script type="text/javascript">
    function getElementsByClassName(strClass, strTag, objContElm) {
        strTag = strTag || "*";
        objContElm = objContElm || document;
        var objColl = objContElm.getElementsByTagName(strTag);
        if (!objColl.length &&  strTag == "*" &&  objContElm.all) objColl = objContElm.all;
        var arr = new Array();
        var delim = strClass.indexOf('|') != -1  ? '|' : ' ';
        var arrClass = strClass.split(delim);
        for (var i = 0, j = objColl.length; i < j; i++) {
            var arrObjClass = objColl[i].className.split(' ');
            if (delim == ' ' && arrClass.length > arrObjClass.length)
                continue;
            var c = 0;
            comparisonLoop:
                for (var k = 0, l = arrObjClass.length; k < l; k++) {
                    for (var m = 0, n = arrClass.length; m < n; m++) {
                        if (arrClass[m] == arrObjClass[k]) c++;
                        if (( delim == '|' && c == 1) || (delim == ' ' && c == arrClass.length)) {
                            arr.push(objColl[i]);
                            break comparisonLoop;
                        }
                    }
                }
        }
        return arr;
    }
    // To cover IE 5.0's lack of the push method
    Array.prototype.push = function(value) {
      this[this.length] = value;
    }
    
    // array of classes and links - they need to match up
    var classes = new Array("lendingtree", "myfico");
    var afflinks = new Array("http://example.com?x=123123&y=1123123", "http://example.com?z=asdk#ikjlk");
    
    // for every affiliate link class
    for (var i = 0; i < classes.length; i++) {
    // get the anchor elements that have that class
        var links = getElementsByClassName(classes[i],"a",document);
    // for every anchor (a)
        for (var j = 0; j < links.length; j++) {
    // set the href to our corresponding affiliate link
            links[j].href = afflinks[i];
    // clear the rel attribute
            links[j].rel = "";
        }
    }
    </script>

     

     

    Technorati tags:

    links for 2007-04-17

    Tuesday, April 17th, 2007

    links for 2007-04-16

    Monday, April 16th, 2007

    links for 2007-04-15

    Sunday, April 15th, 2007

    links for 2007-04-14

    Saturday, April 14th, 2007

    desktop tower defense

    Saturday, April 14th, 2007

    don't even start down this time-wasting path

    sort of like a nano-sized dwarf fortress

    © 2007 mhinze.com