<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Jason Harper&#039;s blog</title>
	<atom:link href="http://jasonharper.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://jasonharper.wordpress.com</link>
	<description>Noise reduction</description>
	<lastBuildDate>Tue, 17 Jan 2012 20:50:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='jasonharper.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Jason Harper&#039;s blog</title>
		<link>http://jasonharper.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://jasonharper.wordpress.com/osd.xml" title="Jason Harper&#039;s blog" />
	<atom:link rel='hub' href='http://jasonharper.wordpress.com/?pushpress=hub'/>
		<item>
		<title>javascript String.format</title>
		<link>http://jasonharper.wordpress.com/2012/01/17/javascript-string-format/</link>
		<comments>http://jasonharper.wordpress.com/2012/01/17/javascript-string-format/#comments</comments>
		<pubDate>Tue, 17 Jan 2012 20:50:25 +0000</pubDate>
		<dc:creator>harperj1029</dc:creator>
		
		<guid isPermaLink="false">http://jasonharper.wordpress.com/?p=169</guid>
		<description><![CDATA[Here&#8217;s the fiddle for it.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jasonharper.wordpress.com&amp;blog=1693292&amp;post=169&amp;subd=jasonharper&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://jsfiddle.net/harperj1029/SL8LB/" target="_blank">Here&#8217;s the fiddle for it.</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jasonharper.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jasonharper.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jasonharper.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jasonharper.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jasonharper.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jasonharper.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jasonharper.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jasonharper.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jasonharper.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jasonharper.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jasonharper.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jasonharper.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jasonharper.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jasonharper.wordpress.com/169/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jasonharper.wordpress.com&amp;blog=1693292&amp;post=169&amp;subd=jasonharper&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jasonharper.wordpress.com/2012/01/17/javascript-string-format/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1c8b1ed4e9f15fb2f620d288d0ffd57a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Jay</media:title>
		</media:content>
	</item>
		<item>
		<title>Look up the default web in IIS</title>
		<link>http://jasonharper.wordpress.com/2011/11/08/look-up-the-default-web-in-iis/</link>
		<comments>http://jasonharper.wordpress.com/2011/11/08/look-up-the-default-web-in-iis/#comments</comments>
		<pubDate>Wed, 09 Nov 2011 01:34:05 +0000</pubDate>
		<dc:creator>harperj1029</dc:creator>
				<category><![CDATA[.net - General]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">https://jasonharper.wordpress.com/2011/11/08/look-up-the-default-web-in-iis/</guid>
		<description><![CDATA[Default as defined by port 80, no host headers and is running on the local machine: private string GetDefaultWebPath() &#160;&#160;&#160;&#160;&#160;&#160;&#160; { &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; string result = null; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; using (var de = new DirectoryEntry(&#34;IIS://Localhost/W3SVC&#34;)) &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; { &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; foreach (DirectoryEntry child in de.Children &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; .Cast&#60;DirectoryEntry&#62;() &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; .Where(d =&#62; d.SchemaClassName == &#34;IIsWebServer&#34; &#38;&#38; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; d.Properties[&#34;ServerState&#34;] &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; .Value.ToString() == [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jasonharper.wordpress.com&amp;blog=1693292&amp;post=165&amp;subd=jasonharper&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Default as defined by port 80, no host headers and is running on the local machine:</p>
<p>private string GetDefaultWebPath()   <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; string result = null;    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; using (var de = new DirectoryEntry(&quot;IIS://Localhost/W3SVC&quot;))    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; foreach (DirectoryEntry child in de.Children    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; .Cast&lt;DirectoryEntry&gt;()    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; .Where(d =&gt; d.SchemaClassName == &quot;IIsWebServer&quot; &amp;&amp;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; d.Properties[&quot;ServerState&quot;]    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; .Value.ToString() == &quot;2&quot; /* Started*/))    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; var bindings = child.Properties    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; .Cast&lt;PropertyValueCollection&gt;()    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; .Where(i =&gt; i.PropertyName == &quot;ServerBindings&quot;)    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; .ToList().Cast&lt;PropertyValueCollection&gt;();    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (bindings.Count() == 1 &amp;&amp; bindings    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; .First().Value.ToString() == &quot;:80:&quot;)    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; var root = child.Children    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; .Cast&lt;DirectoryEntry&gt;()    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; .FirstOrDefault(d =&gt; d.SchemaClassName == &quot;IIsWebVirtualDir&quot;);    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (root != null)    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; result = root.Properties[&quot;Path&quot;].Value.ToString();    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (string.IsNullOrEmpty(result))    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; throw new Exception(&quot;Could not determine the default web.&quot;);    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return result;    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jasonharper.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jasonharper.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jasonharper.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jasonharper.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jasonharper.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jasonharper.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jasonharper.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jasonharper.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jasonharper.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jasonharper.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jasonharper.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jasonharper.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jasonharper.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jasonharper.wordpress.com/165/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jasonharper.wordpress.com&amp;blog=1693292&amp;post=165&amp;subd=jasonharper&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jasonharper.wordpress.com/2011/11/08/look-up-the-default-web-in-iis/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1c8b1ed4e9f15fb2f620d288d0ffd57a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Jay</media:title>
		</media:content>
	</item>
		<item>
		<title>Ever wish JavaScriptSerializer had a non-generic Deserialize method (like DataContractJSONSerializer)?</title>
		<link>http://jasonharper.wordpress.com/2011/10/12/ever-wish-javascriptserializer-had-a-non-generic-deserialize-method-like-datacontractjsonserializer/</link>
		<comments>http://jasonharper.wordpress.com/2011/10/12/ever-wish-javascriptserializer-had-a-non-generic-deserialize-method-like-datacontractjsonserializer/#comments</comments>
		<pubDate>Wed, 12 Oct 2011 15:10:21 +0000</pubDate>
		<dc:creator>harperj1029</dc:creator>
				<category><![CDATA[.net - General]]></category>

		<guid isPermaLink="false">http://jasonharper.wordpress.com/?p=156</guid>
		<description><![CDATA[Well, Rex informed me of the handy MethodInfo.MakeGenericMethod which creates a constructed generic method, allowing us to avoid having to declare the generic types at design time.  So, now we can bolt on a Deserialize method (note, we cache the constructed generic methods) (formatted to appease wordpress) public static class JavaScriptSerializerExtensions { private static object [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jasonharper.wordpress.com&amp;blog=1693292&amp;post=156&amp;subd=jasonharper&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Well, Rex informed me of the handy MethodInfo.MakeGenericMethod which creates a constructed generic method, allowing us to avoid having to declare the generic types at design time.  So, now we can bolt on a Deserialize method (note, we cache the constructed generic methods) (formatted to appease wordpress)</p>
<pre>public static class JavaScriptSerializerExtensions
    {
        private static object _lock = new object();
        private static IDictionary&lt;Type, MethodInfo&gt; _deserializers
               = new Dictionary&lt;Type, MethodInfo&gt;();

        private static MethodInfo GetDeserializeMethod(Type type)
        {
            lock (_lock)
            {
                if (_deserializers.ContainsKey(type)==false)
                {
                    var mi = typeof(JavaScriptSerializer)
                        .GetMethod("Deserialize");
                    _deserializers[type] = mi.MakeGenericMethod(type);
                }
            }
            return _deserializers[type];
        }

        public static object Deserialize(
               this JavaScriptSerializer serializer, Type type, string json)
        {
            return GetDeserializeMethod(type).Invoke(
                serializer, new object[] { json });
        }
    }</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jasonharper.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jasonharper.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jasonharper.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jasonharper.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jasonharper.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jasonharper.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jasonharper.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jasonharper.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jasonharper.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jasonharper.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jasonharper.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jasonharper.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jasonharper.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jasonharper.wordpress.com/156/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jasonharper.wordpress.com&amp;blog=1693292&amp;post=156&amp;subd=jasonharper&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jasonharper.wordpress.com/2011/10/12/ever-wish-javascriptserializer-had-a-non-generic-deserialize-method-like-datacontractjsonserializer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1c8b1ed4e9f15fb2f620d288d0ffd57a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Jay</media:title>
		</media:content>
	</item>
		<item>
		<title>Get inspiration from .net&#8217;s LINQ in Javascript</title>
		<link>http://jasonharper.wordpress.com/2011/10/09/get-inspiration-from-nets-linq-in-javascript/</link>
		<comments>http://jasonharper.wordpress.com/2011/10/09/get-inspiration-from-nets-linq-in-javascript/#comments</comments>
		<pubDate>Sun, 09 Oct 2011 17:43:50 +0000</pubDate>
		<dc:creator>harperj1029</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">https://jasonharper.wordpress.com/2011/10/09/get-inspiration-from-nets-linq-in-javascript/</guid>
		<description><![CDATA[When you think about working with enumerable stuff client-side, you can get great inspiration from .net’s awesome LINQ goodness.&#160; For example, if you need a trivial way to sum up items in an array, you can bolt on a “sum” routine onto Arrays.&#160; For example, here’s a small one, which has a default implementation to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jasonharper.wordpress.com&amp;blog=1693292&amp;post=155&amp;subd=jasonharper&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When you think about working with enumerable stuff client-side, you can get great inspiration from .net’s awesome LINQ goodness.&#160; For example, if you need a trivial way to sum up items in an array, you can bolt on a “sum” routine onto Arrays.&#160; For example, here’s a small one, which has a default implementation to deal with strings or numbers:   </p>
<p>Array.prototype.sum = function (predicate) {    <br />&#160;&#160;&#160; predicate = predicate || function (match) {    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (typeof match == &quot;string&quot;) {    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return match.length;    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; return match;    <br />&#160;&#160;&#160; };    <br />&#160;&#160;&#160; var result = 0;    <br />&#160;&#160;&#160; for (var i = 0; i &lt; this.length; i++) {    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; result += predicate(this[i]);    <br />&#160;&#160;&#160; }    <br />&#160;&#160;&#160; return result;    <br />};</p>
<p>Here are a couple usage examples:</p>
<p>// Baked-in sum for strings   <br />var array1 = [&quot;hello&quot;,&quot;world&quot;];    <br />var length = array1.sum());    </p>
<p>// Baked-in sum for numbers    <br />var array2 = [10,20,30];    <br />length = array2.sum();    </p>
<p>// Custom for custom objects.    <br />var array3 = [{yearsOfExperience:3},{yearsOfExperience:5}];    <br />length = array3.sum(function(match){return match.yearsOfExperience;});</p>
<p>Here’s a Fiddle that demonstrates this (hit F12 in FF, Chrome, IE*+ and look at the console when running):&#160; <a title="http://jsfiddle.net/harperj1029/Zeaqa/" href="http://jsfiddle.net/harperj1029/Zeaqa/">http://jsfiddle.net/harperj1029/Zeaqa/</a></p>
<p>Think Linq!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jasonharper.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jasonharper.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jasonharper.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jasonharper.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jasonharper.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jasonharper.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jasonharper.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jasonharper.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jasonharper.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jasonharper.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jasonharper.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jasonharper.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jasonharper.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jasonharper.wordpress.com/155/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jasonharper.wordpress.com&amp;blog=1693292&amp;post=155&amp;subd=jasonharper&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jasonharper.wordpress.com/2011/10/09/get-inspiration-from-nets-linq-in-javascript/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1c8b1ed4e9f15fb2f620d288d0ffd57a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Jay</media:title>
		</media:content>
	</item>
		<item>
		<title>Use Powershell and Slickrun to display w3wp info</title>
		<link>http://jasonharper.wordpress.com/2011/03/27/use-powershell-and-slickrun-to-display-w3wp-info/</link>
		<comments>http://jasonharper.wordpress.com/2011/03/27/use-powershell-and-slickrun-to-display-w3wp-info/#comments</comments>
		<pubDate>Mon, 28 Mar 2011 01:10:14 +0000</pubDate>
		<dc:creator>harperj1029</dc:creator>
		
		<guid isPermaLink="false">https://jasonharper.wordpress.com/2011/03/27/use-powershell-and-slickrun-to-display-w3wp-info/</guid>
		<description><![CDATA[If you have multiple pools running within IIS locally, you’ll see corresponding w3wp.exe processes in visual studio when you try to attach for debugging purposes.  One quick way to figure out *which* one is the w3wp that you need to attach to is to display the process id and application pool for all the w3wp [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jasonharper.wordpress.com&amp;blog=1693292&amp;post=150&amp;subd=jasonharper&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you have multiple pools running within IIS locally, you’ll see corresponding w3wp.exe processes in visual studio when you try to attach for debugging purposes.  One quick way to figure out *which* one is the w3wp that you need to attach to is to display the process id and application pool for all the w3wp processes on your machine.  There’s plenty of old-school way to do that, or you can use a powershell script such as this:</p>
<p>gwmi win32_process -filter &#8220;name=&#8217;w3wp.exe&#8217;&#8221; | format-table -autosize name,processId,commandLine</p>
<p>So, you could pop that into a powershell file and call that either via an old-school batch file – or….. you could use a command line utility such as <a href="http://bayden.com/SlickRun/">SlickRun</a> and in-line the command into a “MagicWord” (Slickrun-speak for a named command) like this:</p>
<p><a href="http://jasonharper.files.wordpress.com/2011/03/image.png"></a><a href="http://jasonharper.files.wordpress.com/2011/03/slickrunpowershell.png"><img class="alignnone size-medium wp-image-151" title="SlickRunPowerShell" src="http://jasonharper.files.wordpress.com/2011/03/slickrunpowershell.png?w=300&#038;h=150" alt="" width="300" height="150" /></a></p>
<p>magic.</p>
<p>&nbsp;</p>
<p>Of  course, this is pretty simple too: http://www.ervinter.com/2009/04/23/get-process-id-from-multiple-application-pool-iisapp/</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jasonharper.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jasonharper.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jasonharper.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jasonharper.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jasonharper.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jasonharper.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jasonharper.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jasonharper.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jasonharper.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jasonharper.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jasonharper.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jasonharper.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jasonharper.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jasonharper.wordpress.com/150/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jasonharper.wordpress.com&amp;blog=1693292&amp;post=150&amp;subd=jasonharper&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jasonharper.wordpress.com/2011/03/27/use-powershell-and-slickrun-to-display-w3wp-info/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1c8b1ed4e9f15fb2f620d288d0ffd57a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Jay</media:title>
		</media:content>

		<media:content url="http://jasonharper.files.wordpress.com/2011/03/slickrunpowershell.png?w=300" medium="image">
			<media:title type="html">SlickRunPowerShell</media:title>
		</media:content>
	</item>
		<item>
		<title>Couple great tools for JavaScript and regex&#8230;</title>
		<link>http://jasonharper.wordpress.com/2011/03/26/couple-great-tools-for-javascript-and-regex/</link>
		<comments>http://jasonharper.wordpress.com/2011/03/26/couple-great-tools-for-javascript-and-regex/#comments</comments>
		<pubDate>Sat, 26 Mar 2011 23:43:53 +0000</pubDate>
		<dc:creator>harperj1029</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Regex]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">https://jasonharper.wordpress.com/2011/03/26/couple-great-tools-for-javascript-and-regex/</guid>
		<description><![CDATA[If you are whipping up some JavaScript and want a great place to build/run and perhaps share with other, then you need to check out JSFiddle.&#160; This tool is fantastic, and a great way to collaboratively work on JavaScript.&#160; For debugging and/or writing out to a console, consider using Firefox’s [awesome] firebug addin (IE Developer [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jasonharper.wordpress.com&amp;blog=1693292&amp;post=145&amp;subd=jasonharper&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you are whipping up some JavaScript and want a great place to build/run and perhaps share with other, then you need to check out <a href="http://jsfiddle.net">JSFiddle</a>.&#160; This tool is fantastic, and a great way to collaboratively work on JavaScript.&#160; For debugging and/or writing out to a console, consider using Firefox’s [awesome] firebug addin (IE Developer tools works pretty well too).</p>
<p>For times when you need to use regular expressions – and you’re either not strong at them, or have been away from them for more than 2 minutes (the time it takes to forget most of the syntax), then check out <a href="http://regexpal.com/">RegExPal</a>.&#160; This little utility is handy, and give great real-time visual indications of matches.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jasonharper.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jasonharper.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jasonharper.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jasonharper.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jasonharper.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jasonharper.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jasonharper.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jasonharper.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jasonharper.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jasonharper.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jasonharper.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jasonharper.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jasonharper.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jasonharper.wordpress.com/145/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jasonharper.wordpress.com&amp;blog=1693292&amp;post=145&amp;subd=jasonharper&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jasonharper.wordpress.com/2011/03/26/couple-great-tools-for-javascript-and-regex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1c8b1ed4e9f15fb2f620d288d0ffd57a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Jay</media:title>
		</media:content>
	</item>
		<item>
		<title>Mocking with Moq and Moles</title>
		<link>http://jasonharper.wordpress.com/2011/03/19/mocking-with-moq-and-moles/</link>
		<comments>http://jasonharper.wordpress.com/2011/03/19/mocking-with-moq-and-moles/#comments</comments>
		<pubDate>Sun, 20 Mar 2011 01:06:43 +0000</pubDate>
		<dc:creator>harperj1029</dc:creator>
				<category><![CDATA[Unit Testing]]></category>

		<guid isPermaLink="false">https://jasonharper.wordpress.com/2011/03/19/mocking-with-moq-and-moles/</guid>
		<description><![CDATA[I had the pleasure recently to do some unit testing work for some foundational classes (not, not TDD, but still…) and decided to quit stubbing and start Mocking.&#160; One of our colleagues recommended Moq, and that’s the one we went with.&#160; Moq is great, and I totally dig the mocking approach and am astonished yet [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jasonharper.wordpress.com&amp;blog=1693292&amp;post=144&amp;subd=jasonharper&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I had the pleasure recently to do some unit testing work for some foundational classes (not, not TDD, but still…) and decided to quit stubbing and start Mocking.&#160; One of our colleagues recommended <a href="http://code.google.com/p/moq/">Moq</a>, and that’s the one we went with.&#160; <a href="http://code.google.com/p/moq/">Moq</a> is great, and I totally dig the mocking approach and am astonished yet again at how little I’ve actually known about real unit testing.&#160; One little problem I ran into with <a href="http://code.google.com/p/moq/">Moq</a>, however, led me to another little gem (Hint: <a href="http://research.microsoft.com/en-us/projects/moles/">Moles</a>).&#160; See, I was unit testing already-existing classes, and the idea of refactoring to make them more unit test friendly was not part of the plan.&#160; Luckily nearly all the classes either directly supported dependency injection, so getting around dependencies in most cases was quite straight forward.&#160; However, there were a few scenarios where I needed to mock out non-virtual methods, or, gasp, static routines.&#160; Turns out Moq does not excel in this department, so I stumbled upon the awesomeness of <a href="http://research.microsoft.com/en-us/projects/moles/">Microsoft Moles</a>.&#160; Moles fit right into my scenario allowing me to swap out non-virtual and/or static routines that were inherent dependencies in the execution path of the routines I was unit testing.&#160; For example, if you are writing a unit test for the routine “Foo” and within that routine, there is a call to a static method that actually *does* something outside the scope of the unit test (ie, *it* has dependencies on something), then you can use Moles to basically swap out that routine (essentially hijack it and force that code to use whatever you tell it to use – perhaps replacing the static method with a do-nothing routine). </p>
<p>So, if you are unit testing, or perhaps even new to unit testing, I encourage you to consider looking at both of these tools.&#160; Perhaps start out with Moq, but if you encounter the same limitation, check out Moles.</p>
<p>J</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jasonharper.wordpress.com/144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jasonharper.wordpress.com/144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jasonharper.wordpress.com/144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jasonharper.wordpress.com/144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jasonharper.wordpress.com/144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jasonharper.wordpress.com/144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jasonharper.wordpress.com/144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jasonharper.wordpress.com/144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jasonharper.wordpress.com/144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jasonharper.wordpress.com/144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jasonharper.wordpress.com/144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jasonharper.wordpress.com/144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jasonharper.wordpress.com/144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jasonharper.wordpress.com/144/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jasonharper.wordpress.com&amp;blog=1693292&amp;post=144&amp;subd=jasonharper&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jasonharper.wordpress.com/2011/03/19/mocking-with-moq-and-moles/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1c8b1ed4e9f15fb2f620d288d0ffd57a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Jay</media:title>
		</media:content>
	</item>
		<item>
		<title>Feels like Windows Live is stepping it up</title>
		<link>http://jasonharper.wordpress.com/2011/03/16/feels-like-windows-live-is-stepping-it-up/</link>
		<comments>http://jasonharper.wordpress.com/2011/03/16/feels-like-windows-live-is-stepping-it-up/#comments</comments>
		<pubDate>Thu, 17 Mar 2011 02:06:02 +0000</pubDate>
		<dc:creator>harperj1029</dc:creator>
		
		<guid isPermaLink="false">https://jasonharper.wordpress.com/2011/03/16/feels-like-windows-live-is-stepping-it-up/</guid>
		<description><![CDATA[Yeah, I love Google like everyone else, but it does appear that Microsoft has some pretty snazzy stuff going on in the Windows Live space, perhaps taking a jab back at Google [docs &#124; apps].&#160; The deep integration of various office products and of course, SharePoint, provides numerous compelling options for collaboration.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jasonharper.wordpress.com&amp;blog=1693292&amp;post=143&amp;subd=jasonharper&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Yeah, I love Google like everyone else, but it does appear that Microsoft has some pretty snazzy stuff going on in the Windows Live space, perhaps taking a jab back at Google [docs | apps].&#160; The deep integration of various office products and of course, SharePoint, provides numerous compelling options for collaboration.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jasonharper.wordpress.com/143/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jasonharper.wordpress.com/143/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jasonharper.wordpress.com/143/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jasonharper.wordpress.com/143/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jasonharper.wordpress.com/143/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jasonharper.wordpress.com/143/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jasonharper.wordpress.com/143/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jasonharper.wordpress.com/143/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jasonharper.wordpress.com/143/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jasonharper.wordpress.com/143/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jasonharper.wordpress.com/143/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jasonharper.wordpress.com/143/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jasonharper.wordpress.com/143/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jasonharper.wordpress.com/143/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jasonharper.wordpress.com&amp;blog=1693292&amp;post=143&amp;subd=jasonharper&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jasonharper.wordpress.com/2011/03/16/feels-like-windows-live-is-stepping-it-up/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1c8b1ed4e9f15fb2f620d288d0ffd57a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Jay</media:title>
		</media:content>
	</item>
		<item>
		<title>oData, LinqPad and NetFlix</title>
		<link>http://jasonharper.wordpress.com/2010/06/15/odata-linqpad-and-netflix/</link>
		<comments>http://jasonharper.wordpress.com/2010/06/15/odata-linqpad-and-netflix/#comments</comments>
		<pubDate>Wed, 16 Jun 2010 01:57:43 +0000</pubDate>
		<dc:creator>harperj1029</dc:creator>
		
		<guid isPermaLink="false">https://jasonharper.wordpress.com/2010/06/15/odata-linqpad-and-netflix/</guid>
		<description><![CDATA[Playing with Linqpad and writing a couple oData queries against the Netflix odata api.&#160; Pretty nifty.&#160; Guess I need to get up to speed on this stuff.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jasonharper.wordpress.com&amp;blog=1693292&amp;post=139&amp;subd=jasonharper&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Playing with <a href="http://www.linqpad.net/">Linqpad</a> and writing a couple oData queries against the Netflix odata api.&#160; Pretty nifty.&#160; Guess I need to get up to speed on this stuff.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jasonharper.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jasonharper.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jasonharper.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jasonharper.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jasonharper.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jasonharper.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jasonharper.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jasonharper.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jasonharper.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jasonharper.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jasonharper.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jasonharper.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jasonharper.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jasonharper.wordpress.com/139/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jasonharper.wordpress.com&amp;blog=1693292&amp;post=139&amp;subd=jasonharper&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jasonharper.wordpress.com/2010/06/15/odata-linqpad-and-netflix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1c8b1ed4e9f15fb2f620d288d0ffd57a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Jay</media:title>
		</media:content>
	</item>
		<item>
		<title>jQuery plugin &#8211; &#8220;backgroundColorizer&#8221; &#8211; declarative approach</title>
		<link>http://jasonharper.wordpress.com/2010/02/14/jquery-plugin-backgroundcolorizer-declarative-approach/</link>
		<comments>http://jasonharper.wordpress.com/2010/02/14/jquery-plugin-backgroundcolorizer-declarative-approach/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 03:52:46 +0000</pubDate>
		<dc:creator>harperj1029</dc:creator>
				<category><![CDATA[1763993]]></category>

		<guid isPermaLink="false">http://jasonharper.wordpress.com/2010/02/14/jquery-plugin-backgroundcolorizer-declarative-approach/</guid>
		<description><![CDATA[OK, so I’m taking the cheesy backgroundColorizer plugin to a different place because of this guy’s super clever trick.&#160; Couple things had to happen.&#160; First, I made my &#60;body&#62; tag look like this: &#60;body xmlns:sys=&#34;javascript:Sys&#34;sys:activate=&#34;*&#34;&#62; Then I added this 1-time-only registration line below (this essentially tells the sweet little $.declare function to burn my “backgroundColorizer” [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jasonharper.wordpress.com&amp;blog=1693292&amp;post=138&amp;subd=jasonharper&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>OK, so I’m taking the cheesy <a href="http://jasonharper.wordpress.com/2010/02/13/the-most-basic-jquery-plugin-ever/">backgroundColorizer plugin</a> to a different place because of <a href="http://weblogs.manas.com.ar/bcardiff/2008/12/declarative-jquery-with-microsoft-ajax/">this guy’s super clever trick</a>.&#160; Couple things had to happen.&#160; First, I made my &lt;body&gt; tag look like this:    </p>
<p><span style="color:blue;">&lt;</span><span style="color:maroon;">body </span><span style="color:red;">xmlns</span><span style="color:blue;">:</span><span style="color:red;">sys</span><span style="color:blue;">=&quot;javascript:Sys&quot;</span><span style="color:red;">sys</span><span style="color:blue;">:</span><span style="color:red;">activate</span><span style="color:blue;">=&quot;*&quot;&gt;     <br /></span></p>
<p> <a href="http://11011.net/software/vspaste"></a>
<p>Then I added this 1-time-only <em>registration</em> line below (this essentially tells the sweet little $.declare function to burn my “backgroundColorizer” plugin as a registered behavior for each element this its attached to , activated by that global sys:activate=”*” piece we added to the &lt;body&gt; tag) (did that make any sense?):</p>
<pre class="code">$(<span style="color:blue;">function </span>() {
    $.declare(<span style="color:maroon;">&quot;backgroundColorizer&quot;</span>);
});</pre>
<p>Now, some html elements can simply look like this with no additional javascript needed:<br />
  <br />&#160;&#160; <span style="color:blue;">&lt;</span><span style="color:maroon;">ul </span><span style="color:red;">sys</span><span style="color:blue;">:</span><span style="color:red;">attach</span><span style="color:blue;">=&quot;backgroundcolorizer&quot;&gt;<br />
    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color:maroon;">li</span><span style="color:blue;">&gt;</span>one<span style="color:blue;">&lt;/</span><span style="color:maroon;">li</span><span style="color:blue;">&gt;<br />
    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color:maroon;">li</span><span style="color:blue;">&gt;</span>two<span style="color:blue;">&lt;/</span><span style="color:maroon;">li</span><span style="color:blue;">&gt;<br />
    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color:maroon;">li</span><span style="color:blue;">&gt;</span>three<span style="color:blue;">&lt;/</span><span style="color:maroon;">li</span><span style="color:blue;">&gt;<br />
    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color:maroon;">li</span><span style="color:blue;">&gt;</span>four<span style="color:blue;">&lt;/</span><span style="color:maroon;">li</span><span style="color:blue;">&gt;<br />
    <br />&#160;&#160;&#160; &lt;/</span><span style="color:maroon;">ul</span><span style="color:blue;">&gt;<br />
    <br />&#160;&#160;&#160; &lt;</span><span style="color:maroon;">table</span><span style="color:red;">sys</span><span style="color:blue;">:</span><span style="color:red;">attach</span><span style="color:blue;">=&quot;backgroundcolorizer&quot;</span><span style="color:red;">backgroundcolorizer</span><span style="color:blue;">:</span><span style="color:red;">oddColor</span><span style="color:blue;">=&#8217;lightGreen&#8217; </span><span style="color:red;">backgroundcolorizer</span><span style="color:blue;">:</span><span style="color:red;">evenColor</span><span style="color:blue;">=&#8217;Green&#8217;&gt;<br />
    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color:maroon;">tr</span><span style="color:blue;">&gt;&lt;</span><span style="color:maroon;">td</span><span style="color:blue;">&gt;</span>Jane <span style="color:blue;">&lt;/</span><span style="color:maroon;">td</span><span style="color:blue;">&gt;&lt;</span><span style="color:maroon;">td</span><span style="color:blue;">&gt;</span>Smith<span style="color:blue;">&lt;/</span><span style="color:maroon;">td</span><span style="color:blue;">&gt;&lt;/</span><span style="color:maroon;">tr</span><span style="color:blue;">&gt;<br />
    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color:maroon;">tr</span><span style="color:blue;">&gt;&lt;</span><span style="color:maroon;">td</span><span style="color:blue;">&gt;</span>Joe <span style="color:blue;">&lt;/</span><span style="color:maroon;">td</span><span style="color:blue;">&gt;&lt;</span><span style="color:maroon;">td</span><span style="color:blue;">&gt;</span>Smith<span style="color:blue;">&lt;/</span><span style="color:maroon;">td</span><span style="color:blue;">&gt;&lt;/</span><span style="color:maroon;">tr</span><span style="color:blue;">&gt;<br />
    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color:maroon;">tr</span><span style="color:blue;">&gt;&lt;</span><span style="color:maroon;">td</span><span style="color:blue;">&gt;</span>John <span style="color:blue;">&lt;/</span><span style="color:maroon;">td</span><span style="color:blue;">&gt;&lt;</span><span style="color:maroon;">td</span><span style="color:blue;">&gt;</span>Doe<span style="color:blue;">&lt;/</span><span style="color:maroon;">td</span><span style="color:blue;">&gt;&lt;/</span><span style="color:maroon;">tr</span><span style="color:blue;">&gt;<br />
    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color:maroon;">tr</span><span style="color:blue;">&gt;&lt;</span><span style="color:maroon;">td</span><span style="color:blue;">&gt;</span>Jane Q. <span style="color:blue;">&lt;/</span><span style="color:maroon;">td</span><span style="color:blue;">&gt;&lt;</span><span style="color:maroon;">td</span><span style="color:blue;">&gt;</span>Public<span style="color:blue;">&lt;/</span><span style="color:maroon;">td</span><span style="color:blue;">&gt;&lt;/</span><span style="color:maroon;">tr</span><span style="color:blue;">&gt;<br />
    <br />&#160;&#160;&#160; &lt;/</span><span style="color:maroon;">table</span><span style="color:blue;">&gt;<br />
    <br /></span></p>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>OK, here’s the worst and hackish part, where i took my plugin and put in embarrassingly cheesy code to get around the various “children” semantics.&#160; I’m sure this would break down immediately, but for this trivial sample it works ok:</p>
<pre class="code"><span style="color:#006400;">        // The &quot;backgroundColorizer&quot; pluggin allows you to essentially color alternative odd/even rows' background
        // (thrilling, eh?)
        </span>(<span style="color:blue;">function </span>($) {
            $.fn.extend(
            {
                backgroundColorizer: <span style="color:blue;">function </span>(options) {
                    <span style="color:blue;">var </span>defaults = { oddColor: <span style="color:maroon;">'red'</span>, evenColor: <span style="color:maroon;">'blue' </span>};
                    <span style="color:blue;">var </span>options = $.extend(defaults, options);
                    <span style="color:blue;">var </span>selector = <span style="color:blue;">this</span>;
                    <span style="color:blue;">if </span>(<span style="color:blue;">this</span>[0].tagName == <span style="color:maroon;">&quot;TABLE&quot;</span>) {
                        selector = $(<span style="color:maroon;">'tr'</span>);
                    } <span style="color:blue;">else </span>{
                        selector = <span style="color:blue;">this</span>.children();
                    }

                    <span style="color:blue;">return </span>$(selector).each(<span style="color:blue;">function </span>(index) {
                        <span style="color:blue;">var </span>obj = $(<span style="color:blue;">this</span>);

                        <span style="color:blue;">if </span>(index % 2 &gt; 0) {
                            obj.css(<span style="color:maroon;">&quot;background-color&quot;</span>, options.oddColor);
                        } <span style="color:blue;">else </span>{
                            obj.css(<span style="color:maroon;">&quot;background-color&quot;</span>, options.evenColor);
                        }
                    });
                }
            });
        })(jQuery);</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>&#160;</p>
<p>OK.&#160; So, there you have it.&#160; We’re using the declarative behavior approach of Microsoft’s ajax library to wrap around our JQuery plugin.&#160; Check out that link at the beginning of this post and after your brain stops curdling (as mine did) from that dude’s solution, then soak it up and savor.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jasonharper.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jasonharper.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jasonharper.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jasonharper.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jasonharper.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jasonharper.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jasonharper.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jasonharper.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jasonharper.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jasonharper.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jasonharper.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jasonharper.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jasonharper.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jasonharper.wordpress.com/138/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jasonharper.wordpress.com&amp;blog=1693292&amp;post=138&amp;subd=jasonharper&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jasonharper.wordpress.com/2010/02/14/jquery-plugin-backgroundcolorizer-declarative-approach/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1c8b1ed4e9f15fb2f620d288d0ffd57a?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Jay</media:title>
		</media:content>
	</item>
	</channel>
</rss>
