<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <id>tag:www.refactormycode.com,2007:users131</id>
  <link type="application/atom+xml" href="http://www.refactormycode.com/users/131" rel="self"/>
  <title>Andre Steenveld</title>
  <updated>Sun May 25 19:48:29 -0700 2008</updated>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor7735</id>
    <published>2008-05-25T19:48:29-07:00</published>
    <title>[JavaScript] On Week Of Date</title>
    <content type="html">&lt;p&gt;At the cost of creating 2 extra date objects for a very short period of time i refactord startOfWeek( ) and endOfWeek( ) out of the script.&lt;/p&gt;

&lt;pre&gt;Date.prototype.getFormatedWeek = function( ){ 
    var months = [
        &amp;quot;January&amp;quot;, &amp;quot;February&amp;quot;, &amp;quot;March&amp;quot;, &amp;quot;April&amp;quot;, &amp;quot;May&amp;quot;, &amp;quot;June&amp;quot;, 
        &amp;quot;July&amp;quot;, &amp;quot;August&amp;quot;, &amp;quot;September&amp;quot;, &amp;quot;October&amp;quot;, &amp;quot;November&amp;quot;, &amp;quot;December&amp;quot;
    ];    
    
    return function( ){
        var begin  = new Date( new Date( this ).setDate( this.getDate( ) - this.getDate( ) ) ); 
        var end    = new Date( new Date( this ).setDate( this.getDate( ) + 7 ) ),
            output = months[ begin.getMonth( ) ] + &amp;quot; &amp;quot; + begin.getDate( )
            
        output += begin.getYear( ) !== end.getYear( )
            ? &amp;quot; &amp;quot; + begin.getFullYear( ) + &amp;quot; - &amp;quot;
            : &amp;quot; - &amp;quot;;
        
        output += begin.getMonth( ) !== end.getMonth( )
            ? months[ end.getMonth( ) ] + &amp;quot; &amp;quot;
            : &amp;quot;&amp;quot;;
        
        return output + end.getDate( ) + &amp;quot;, &amp;quot; + end.getFullYear( );        
    }; 
}( );

// For backwards compatability
function loadDate( date ){ return date.getFormatedWeek( ); }&lt;/pre&gt;</content>
    <author>
      <name>Andre Steenveld</name>
      <email></email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/300-week-of-date/refactors/7735" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor6398</id>
    <published>2008-05-08T09:00:23-07:00</published>
    <title>[C#] On Pointers in C#</title>
    <content type="html">&lt;p&gt;I have found the problem. It appears that pointers to objects that are declared in the scope of a function don't stay alive after the function has returned. This other than in javascript for example.&lt;/p&gt;

&lt;pre&gt;using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace Pointers {
    class Program {
        unsafe static void Main( string[ ] args ) {
            Unsafe unsafeObject = new Unsafe( 1, 2, 3, 4 );

            Console.WriteLine(
                &amp;quot;FirstLocation[ &amp;quot; + unsafeObject.firstLocation-&amp;gt;ToString( ) + &amp;quot; ]\n&amp;quot; +
                &amp;quot;SecondLocation[ &amp;quot; + unsafeObject.secondLocation-&amp;gt;ToString( ) + &amp;quot; ]&amp;quot;
            );
            
            Console.Read( );
        }
    }

    unsafe struct Unsafe {
        public Safe* firstLocation, secondLocation;

        private Safe sfLocation, ssLocation;

        public Unsafe( int fl_x, int fl_y, int sl_x, int sl_y) {
            this.sfLocation = new Safe( fl_x, fl_y );
            this.ssLocation = new Safe( sl_x, sl_y );

            fixed( Safe* fl = &amp;amp;this.sfLocation )
            fixed( Safe* sl = &amp;amp;this.ssLocation ) {
                this.firstLocation = fl;
                this.secondLocation = sl;
            }
        }
    }

    struct Safe {
        public int x, y;

        public Safe( int x, int y ){
            this.x = x;
            this.y = y;
        }

        public override string ToString( ) {
            return this.x + &amp;quot;,&amp;quot; + this.y;
        }
    }
}
&lt;/pre&gt;</content>
    <author>
      <name>Andre Steenveld</name>
      <email></email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/291-pointers-in-c/refactors/6398" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Code291</id>
    <published>2008-05-06T10:39:27-07:00</published>
    <updated>2008-05-08T09:00:31-07:00</updated>
    <title>[C#] Pointers in C#</title>
    <content type="html">&lt;p&gt;I am trying to work out how unmanged objects work in C# but for some reason it looks like my objects arn't properly initized. Could someone help me out here? &lt;/p&gt;

&lt;pre&gt;using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace Pointers {
    unsafe class Program {
        static unsafe void Main( string[ ] args ) {
            Unsafe unsafeObject = new Unsafe( 1, 2, 3, 4 );

            Console.WriteLine(
                &amp;quot;FirstLocation[ &amp;quot; + unsafeObject.firstLocation-&amp;gt;ToString( ) + &amp;quot; ]\n&amp;quot; +
                &amp;quot;SecondLocation[ &amp;quot; + unsafeObject.secondLocation-&amp;gt;ToString( ) + &amp;quot; ]&amp;quot;
            );

            Console.Read( );
        }
    }

    unsafe struct Unsafe {
        public Safe* firstLocation, secondLocation;

        public Unsafe( int fl_x, int fl_y, int sl_x, int sl_y ) {
            Safe ffl = new Safe( fl_x, fl_y ),
                 fsl = new Safe( sl_x, sl_y );

            this.firstLocation = &amp;amp;ffl;
            this.secondLocation = &amp;amp;fsl;
        }
    }

    struct Safe {
        public int x, y;

        public Safe( int x, int y ){
            this.x = x;
            this.y = y;
        }

        public override string ToString( ) {
            return this.x + &amp;quot;,&amp;quot; + this.y;
        }
    }
}

## Expected output
FirstLocation[ 1,2 ]
SecondLocation[ 3,4 ]

## Given output
FirstLocation[ 14,67169456 ]
SecondLocation[ 19593296,19593248 ]
&lt;/pre&gt;</content>
    <author>
      <name>Andre Steenveld</name>
      <email></email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/291-pointers-in-c" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor6170</id>
    <published>2008-05-06T10:28:36-07:00</published>
    <title>[JavaScript] On Hex color between two colors</title>
    <content type="html">&lt;p&gt;You are welcome. And thanks for the offer of a donation but i don't need it, thank you.&lt;/p&gt;

&lt;pre&gt;&lt;/pre&gt;</content>
    <author>
      <name>Andre Steenveld</name>
      <email></email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/254-hex-color-between-two-colors/refactors/6170" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor5599</id>
    <published>2008-04-25T19:30:56-07:00</published>
    <title>[JavaScript] On Hex color between two colors</title>
    <content type="html">&lt;p&gt;It's twice as fast in FF and 1.5 times as fast in IE. I am quite sure it can be tweaked a little more though...&lt;/p&gt;

&lt;pre&gt;function calc_color( value, start, end, min, max ){
  var n = ( value - min ) / ( max - min );
    
  end = parseInt( end.substring( 1, 7 ), 16 );
  start = parseInt( start.substring( 1, 7 ), 16 );
         
  var result = start +
    ( ( ( Math.round( ( ( ( ( end &amp;amp; 0xFF0000 ) &amp;gt;&amp;gt; 16 ) - ( ( start &amp;amp; 0xFF0000 ) &amp;gt;&amp;gt; 16 ) ) * n ) ) ) &amp;lt;&amp;lt; 16 )
    + ( ( Math.round( ( ( ( ( end &amp;amp; 0x00FF00 ) &amp;gt;&amp;gt; 8 ) - ( ( start &amp;amp; 0x00FF00 ) &amp;gt;&amp;gt; 8 ) ) * n ) ) ) &amp;lt;&amp;lt; 8 )
    + ( ( Math.round( ( ( ( end &amp;amp; 0x0000FF ) - ( start &amp;amp; 0x0000FF ) ) * n ) ) ) ) ) ;

     return &amp;quot;#&amp;quot; + 
       ( ( result &amp;gt;= 0x100000 )
         ? &amp;quot;&amp;quot;
         : ( result &amp;gt;= 0x010000 )
           ? &amp;quot;0&amp;quot;
           : ( result &amp;gt;= 0x001000 )
             ? &amp;quot;00&amp;quot;
             : ( result &amp;gt;= 0x000100 )
               ? &amp;quot;000&amp;quot;
               : ( result &amp;gt;= 0x000010 )
                 ? &amp;quot;0000&amp;quot;
                 : &amp;quot;00000&amp;quot; ) + result.toString( 16 );  
}&lt;/pre&gt;</content>
    <author>
      <name>Andre Steenveld</name>
      <email></email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/254-hex-color-between-two-colors/refactors/5599" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor2041</id>
    <published>2008-02-03T19:18:57-08:00</published>
    <title>[JavaScript] On Recursively dump an object</title>
    <content type="html">&lt;p&gt;It is pretty bad practice to extend the object prototype and the native types, but it comes in handy here and there. Made a little revision and made sure you end up walking around in circles.&lt;/p&gt;

&lt;pre&gt;## code [javascript]
Object.prototype.dump = function( excludePrototype, maxDepth, depth ){
    depth    = depth || [];
    maxDepth = maxDepth &amp;gt;= 0 ? maxDepth : -1;
    excludePrototype = !!excludePrototype;
    
    // some working vars
    var output = [ &amp;quot;&amp;quot; ],
        key = &amp;quot;&amp;quot;,
        indent = &amp;quot;&amp;quot;;

    for( var i = 0; i &amp;lt; depth.length; i++ ){
        indent += &amp;quot;  &amp;quot;;}

    if( maxDepth === -1 || depth.length &amp;lt; maxDepth ){
        for( key in this ) if( ( this.hasOwnProperty( key ) || excludePrototype ) ){
            
            if( depth.contains( this[ key ] ) ){
              output[ 0 ] = &amp;quot;{circular reference}&amp;quot;;
            
            } else {
                depth.push( this[ key ] );
                output.push( 
                    indent + key + &amp;quot;: &amp;quot; + 
                    this[ key ].dump( excludePrototype, maxDepth, depth ) 
                );
                depth.pop( this[ key ] );
            
            }    
        }
    } else {
       output[ 0 ] = &amp;quot;{object}&amp;quot;;
    }

    return output.join(&amp;quot;\n&amp;quot;);
};

Array.prototype.contains = function( obj ){
    for( var i = 0; i &amp;lt; this.length; i++ ){
        if( this[ i ] === obj ){
            return true; }
    }

    return false;
};

// default dumpster method
var defaultDumpster = function(){ return this.toString(); };

String.prototype.dump =
Number.prototype.dump =
RegExp.prototype.dump =
Boolean.prototype.dump = defaultDumpster;

Function.prototype.dump = function(){ return &amp;quot;{function}&amp;quot;; };
Date.prototype.dump = function(){ return &amp;quot;{&amp;quot; + this.getTime() + &amp;quot;}&amp;quot;; };

## example [javascript]
var obj = {
    num: 123,
    str: &amp;quot;testString&amp;quot;,
    bln: true,
    arr: [ 1, 2, 3 ],
    fnc: function(){ return &amp;quot;moooo&amp;quot;; },
    rxp: /^.*$/gi,
    dt: new Date(),
    obj: {
        num: 123,
        str: &amp;quot;testString&amp;quot;,
        bln: true,
        arr: [ 1, 2, 3 ],
        fnc: function(){ return &amp;quot;moooo&amp;quot;; },
        rxp: /^.*$/gi
    }
}

obj.obj.obj = obj;

// Doesn't include the methods/properties declared in a objects prototype.
obj.dump( false ) 

// Iterate throught the first object and also dump evrything (not native) of the prototype.
obj.dump( true, 1 ); 

## Backwards compatability [javascript]

function odump(obj, depth, max){
    return obj.dump( true, max );
}&lt;/pre&gt;</content>
    <author>
      <name>Andre Steenveld</name>
      <email></email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/226-recursively-dump-an-object/refactors/2041" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor1067</id>
    <published>2007-12-10T12:33:02-08:00</published>
    <title>[JavaScript] On Get the last key</title>
    <content type="html">&lt;p&gt;V the for...in loop displays quite random behavior and you can't say anything about the &amp;quot;key&amp;quot; you have except that it is a member of the object you are looping through. I have written ( a quick and dirty ) Map class currently i am still writing some unit tests for it but any comments are quite welcome.&lt;/p&gt;

&lt;p&gt;Edit Some bug fixes:
&lt;br /&gt; - Get elements by index
&lt;br /&gt; - Make it work
&lt;br /&gt; - added unit tests&lt;/p&gt;

&lt;pre&gt;## The Map and some additional stuff [Javascript]
Object.extend = function( target, source ){
    var key = &amp;quot;&amp;quot;;
    for( key in source ){
        target[ key ] = source[ key ]; }

    return target;
};

var Map = ( function(){

    function getArrayIndex( arr, obj ){
        for( var i = 0; i &amp;lt; arr.length; i++ ){
            if( arr[ i ] === obj ){
                break;
        }    }

        return i;
    }

    // Our little container class, this will be the wrapper for everything we put
    // into the Map object. We want to inform the dev about the key index and that
    // sort of stuff but not let em mess with it...
    var MapItem = function( key, value, items, keys ){
        Object.extend( this, {
            getKey:        function(){ return key; },
            getIndex:      function(){ return getArrayIndex( items, this ); },
            getIndexOfKey: function(){ return getArrayIndex( keys, key ); },

            getValue: function(){ return value; },
            setValue: function( newValue ){
                value = newValue;
                return this;
            }
        });
    };

    // Key map a little class wich can help us keeping the order for the keys...
    var KeyIndexer = {
        create: function( ){
            // IE stupidface won't let me inheret from Array so we need a create method
            // and just rudly overwrite the methods.
            return Object.extend( [ ], {
                // Override the push function so can &amp;quot;push&amp;quot; another key into our collection
                // but istead of just sticking it to the end we will do a little sort first
                // and find the right position. ( Is overriding push() the right course of
                // action here? )
                push: function( key ){
                    for( var i = 0; i &amp;lt; this.length; i++ ){
                        if( /*jsl:ignore*/
                            ( key === this[ i ] )                     // In case we have deplicates
                            || ( i === ( this.length - 1 ) )          // In case we are at the last element
                            || ( key &amp;gt; this[ i ] &amp;amp;&amp;amp; key &amp;lt; this[ i ] ) // If we have a real fitting key
                        ){  /*jsl:end*/
                            break;
                        }
                    }

                    this.splice( i, 0, key );

                    return i;
                }
            });
        }
    };

    // The constructor for the Map class here is where the real magic happens.
    return function(){
        // Create some private collections so we can sort all kind of stuff
        var keyArray = KeyIndexer.create( ),
            indexArray = [ ],
            mapObject = { };

        Object.extend( this, {

            add: function( key, value ){
                // Create our item
                var item = new MapItem( key, value, indexArray, keyArray );

                // Add the correct properties and stuff to the collection
                keyArray.push( key.toString() );
                indexArray.push( item );
                mapObject[ key.toString() ] = item;
                return item;
            },
            remove: function( key ){
                var item = this.get( key );

                if( item === null ){ return false; }

                keyArray.splice( item.getIndexOfKey(), 1 );
                indexArray.splice( item.getIndex(), 1 );
                delete mapObject[ key ];

                return true;
            },

            // Some default getters and settings no real magic. If for some
            // reason or another the thing we are looking for is not
            // available we will return null.
            get: function( key ){
                if( typeof key === &amp;quot;string&amp;quot; ){
                    return mapObject[ key ] || null;

                } else if( typeof key === &amp;quot;number&amp;quot; ){
                    return indexArray[ key ] || null;

                }

                return null;
            },

            first: function( ){ return indexArray[ 0 ] || null; },
            last: function( ){ return indexArray[ indexArray.length - 1 ] || null; },

            firstByKey: function( ){ return mapObject[ keyArray[ 0 ] ] || null; },
            lastByKey: function( ){ return mapObject[ keyArray[ keyArray.length - 1 ] ] || null; },

            length: function(){ return keyArray.length; },
            toString: function(){ return &amp;quot;[ Map Object ]&amp;quot;; }
        });
    };
})();

## Bunch of (sloppy) unit tests [HTML]
&amp;lt;html&amp;gt;
    &amp;lt;head&amp;gt;
        &amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;./map.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;
        &amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;

function createHtmlElement ( elementObj ){
    elementObj = Object.extend({
        tagName: &amp;quot;!--&amp;quot;,
        attributes: { },
        innerHTML: &amp;quot; &amp;quot;,
        singelTag: false
    }, elementObj);

    var htmlString = [ &amp;quot;&amp;lt;&amp;quot;, elementObj.tagName ];

    for( var attribute in elementObj.attributes ){
        htmlString.push( &amp;quot; &amp;quot; + attribute );
        htmlString.push( attribute.substr(0, 2) === &amp;quot;on&amp;quot; ?
            &amp;quot;=\&amp;quot;(&amp;quot; + elementObj.attributes[attribute].toString() + &amp;quot;)( event );\&amp;quot; &amp;quot; :
            &amp;quot;=\&amp;quot;&amp;quot; + elementObj.attributes[attribute] + &amp;quot;\&amp;quot; &amp;quot; );
    }

    htmlString.push( elementObj.singelTag ? &amp;quot;/&amp;gt;&amp;quot; : &amp;quot;&amp;gt;&amp;quot; );
    htmlString.push( elementObj.innerHTML ); // &amp;lt;-- can be pretty large sometimes...
    htmlString.push( !elementObj.singleTag ? &amp;quot;&amp;lt;/&amp;quot; + elementObj.tagName + &amp;quot;&amp;gt;&amp;quot; : &amp;quot;&amp;quot; );

    return htmlString.join(&amp;quot;&amp;quot;);
}

function observe(element, name, handler) {
    if (element.addEventListener) {
        element.addEventListener(name, handler, false);
    } else {
        element.attachEvent(&amp;quot;on&amp;quot; + name, handler);
    }
}

var uniqeId = ( function(){
    var lastId = null;

    return function( ){
        var newId = &amp;quot;uid_&amp;quot; + ( new Date( ) ).getTime( ).toString( 36 );

        lastId = ( newId === lastId ? uniqeId( ) : newId );

        return lastId;
    };
})( );

var myKeys = [ uniqeId(), uniqeId(), uniqeId(), uniqeId() ],
    myValues = [
        { toString: function( ){ return &amp;quot;[ 00 &amp;quot; + myKeys[ 0 ] + &amp;quot; ]&amp;quot;; } },
        { toString: function( ){ return &amp;quot;[ 01 &amp;quot; + myKeys[ 1 ] + &amp;quot; ]&amp;quot;; } },
        { toString: function( ){ return &amp;quot;[ 02 &amp;quot; + myKeys[ 2 ] + &amp;quot; ]&amp;quot;; } },
        { toString: function( ){ return &amp;quot;[ 03 &amp;quot; + myKeys[ 3 ] + &amp;quot; ]&amp;quot;; } }
    ],
    myMap = new Map( );

var results = [
    [ &amp;quot;Creating a new map&amp;quot;, myMap instanceof Map ],
    [ &amp;quot;Because it is empty the first should be null&amp;quot;, !myMap.first() &amp;amp;&amp;amp; !myMap.last() &amp;amp;&amp;amp; !myMap.firstByKey() &amp;amp;&amp;amp; !myMap.lastByKey() ],
    [ &amp;quot;The map is empty so the length should be 0 aswell&amp;quot;, myMap.length() === 0 ]    
];

// Lets continue testing and add a item
myMap.add( myKeys[ 0 ], myValues[ 0 ] );

results.push( [ &amp;quot;The length should now be 1&amp;quot;, myMap.length() === 1 ] );
results.push( [ &amp;quot;We should get stuff out now...&amp;quot;, !!myMap.first() &amp;amp;&amp;amp; !!myMap.last() &amp;amp;&amp;amp; !!myMap.firstByKey() &amp;amp;&amp;amp; !!myMap.lastByKey() ] );
results.push( [ &amp;quot;Even when look by key.&amp;quot;, !!myMap.get( myKeys[ 0 ] ) ] );
results.push( [ &amp;quot;Getting by index.&amp;quot;, !!myMap.get( 0 ) ] );

// Add a bunch of objects to the map and test the item object
myMap.add( myKeys[ 2 ], myValues[ 2 ] );
myMap.add( myKeys[ 3 ], myValues[ 3 ] );

results.push( [ &amp;quot;Added some items te map should be 3 big now.&amp;quot;, myMap.length() === 3 ] );

results.push( [ &amp;quot;When getting the first item form the map.&amp;quot;, myMap.first().getKey() === myKeys[ 0 ] ] );
results.push( [ &amp;quot;The value should be the same aswell&amp;quot;, myMap.first().getValue() === myValues[ 0 ] ] );
results.push( [ &amp;quot;The index ofcourse should be 0.&amp;quot;, myMap.first().getIndex() === 0 ] );
results.push( [ &amp;quot;And it is the smallest key...&amp;quot;, myMap.first().getIndexOfKey() === 0 ] );

results.push( [ &amp;quot;When getting the last item form the map.&amp;quot;, myMap.last().getKey() === myKeys[ 3 ] ] );
results.push( [ &amp;quot;The value should be the same aswell&amp;quot;, myMap.last().getValue() === myValues[ 3 ] ] );
results.push( [ &amp;quot;The index ofcourse should be 2.&amp;quot;, myMap.last().getIndex() === 2 ] );
results.push( [ &amp;quot;And it is the biggest key...&amp;quot;, myMap.last().getIndexOfKey() === 2 ] );

results.push( [ &amp;quot;Getting by index and key.&amp;quot;, myMap.get( 1 ) === myMap.get( myKeys[ 2 ] ) ] );

// Now for some key magic
myMap.add( myKeys[ 1 ], myValues[ 1 ] );

results.push( [ &amp;quot;The last one pushed..&amp;quot;, myMap.last().getValue() === myValues[ 1 ] ] );
results.push( [ &amp;quot;A key wich should fit between 0 and 2&amp;quot;, myMap.last().getIndexOfKey() === 1 ] );

observe( window, &amp;quot;load&amp;quot;, function(){
    var output = [];

    for( var i = 0; i &amp;lt; results.length; i++ ){
        output.push( &amp;quot;&amp;lt;tr&amp;gt;&amp;quot;
            + &amp;quot;&amp;lt;td&amp;gt;&amp;quot; + results[ i ][ 0 ] + &amp;quot;&amp;lt;/td&amp;gt;&amp;quot;
            + &amp;quot;&amp;lt;td style='background-color: &amp;quot; + ( results[ i ][ 1 ] ? &amp;quot;#0F6&amp;quot; : &amp;quot;#F06&amp;quot; ) + &amp;quot;; border: black solid 1px;'&amp;gt;&amp;quot;
              + ( results[ i ][ 1 ] ? &amp;quot;Passed&amp;quot; : &amp;quot;Failed&amp;quot; )
            + &amp;quot;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;quot; );            
    }

    document.body.innerHTML = createHtmlElement({
        tagName: &amp;quot;table&amp;quot;,
        attributes: {
            style: &amp;quot;border: black solid 1px;&amp;quot;
        },
        innerHTML: createHtmlElement({
            tagName: &amp;quot;tbody&amp;quot;,
            innerHTML: output.join( &amp;quot;&amp;quot; )
        })
    });
});

        &amp;lt;/script&amp;gt;
    &amp;lt;/head&amp;gt;

    &amp;lt;body&amp;gt;
        &amp;lt;!-- stuff goes here --&amp;gt;
    &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;

&lt;/pre&gt;</content>
    <author>
      <name>Andre Steenveld</name>
      <email></email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/171-get-the-last-key/refactors/1067" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor666</id>
    <published>2007-10-31T07:42:20-07:00</published>
    <title>[JavaScript] On I care about older browsers without JS</title>
    <content type="html">&lt;p&gt;lol, how about not using document.write()? Since doing a write action on document is a javascript function by it self. Are you sure it wasn't a piece of serverside javascript though?&lt;/p&gt;

&lt;pre&gt;&lt;/pre&gt;</content>
    <author>
      <name>Andre Steenveld</name>
      <email></email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/121-i-care-about-older-browsers-without-js/refactors/666" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor633</id>
    <published>2007-10-29T10:52:57-07:00</published>
    <title>[JavaScript] On Stop Watch</title>
    <content type="html">&lt;p&gt;Just made a little class out of the stop watch.&lt;/p&gt;

&lt;pre&gt;## Javascript [javascript]
var StopWatch = function( startOnCreation ){

    this.start = function(){
        startTime = new Date( endTime === null ? 0 : endTime );
        endTime = null;
    };

    this.stop = function(){
        endTime = startTime.getTime();
        startTime = null;
    };

    this.startStop = function(){
        startTime === null ?
            this.startWatch() :
            this.stopWatch();
    };

    this.getTime = function(){
        return (
            startTime !== null ?
                startTime.getTime() :
                endTime
            ).toString();
    };

    this.reset = function( startOnReset ){
        endTime = null;

        if( !!startOnReset ){
            this.startWatch(); }
    };

    var startTime = null,
        endTime = null;

    this.reset( startOnCreation );
};

StopWatch.prototype.toString = function( ){
    return this.getTime().toString();
};

// --- Example 0 ---
var myStopWatch = new StopWatch();
myStopWatch.start();

    //
    // Do some complicated stuff...
    //

myStopWatch.stop();
print( &amp;quot;Time passed [ &amp;quot; + myStopWatch + &amp;quot;ms ]&amp;quot; ); // asuming we have a print method

// --- Example 1 ---
myStopWatch.reset(); // recycle the first instance

    //
    // Do come complicated stuff...
    //
    print( &amp;quot;[ &amp;quot; + myOtherStopWatch + &amp;quot;ms ] have passed.&amp;quot; );

myOtherStopWatch.stop();
print( &amp;quot;A total of [ &amp;quot; + myOtherStopWatch + &amp;quot;ms ] have passed.&amp;quot; );
&lt;/pre&gt;</content>
    <author>
      <name>Andre Steenveld</name>
      <email></email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/113-stop-watch/refactors/633" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor452</id>
    <published>2007-10-17T11:38:57-07:00</published>
    <title>[JavaScript] On Beautify JS Date to how recently the event occured.</title>
    <content type="html">&lt;p&gt;It's a bitwise operation what i basically does in this situation is cut of evrything after the decimal point. &lt;/p&gt;

&lt;pre&gt;&lt;/pre&gt;</content>
    <author>
      <name>Andre Steenveld</name>
      <email></email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/37-beautify-js-date-to-how-recently-the-event-occured/refactors/452" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor232</id>
    <published>2007-10-03T00:35:57-07:00</published>
    <title>[JavaScript] On Simple Form Validation</title>
    <content type="html">&lt;p&gt;What is your question exactly? It looks like you got most of the parts and only have to add the classnames to the elements and fix some minor bugs.&lt;/p&gt;

&lt;pre&gt;&lt;/pre&gt;</content>
    <author>
      <name>Andre Steenveld</name>
      <email></email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/48-simple-form-validation/refactors/232" rel="alternate"/>
  </entry>
</feed>

