<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[&#123; bob.yexley.net &#125;]]></title>
  <link href="http://bob.yexley.net/atom.xml" rel="self"/>
  <link href="http://bob.yexley.net/"/>
  <updated>2012-05-18T23:23:41-04:00</updated>
  <id>http://bob.yexley.net/</id>
  <author>
    <name><![CDATA[Bob Yexley]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <entry>
    <title type="html"><![CDATA[Stepping gingerly in front of the Node.js bandwagon]]></title>
    <link href="http://bob.yexley.net/stepping-gingerly-in-front-of-the-node-dot-js-bandwagon"/>
    <updated>2012-05-18T21:30:00-04:00</updated>
    <id>http://bob.yexley.net/stepping-gingerly-in-front-of-the-node-dot-js-bandwagon</id>
    <content type="html"><![CDATA[<p><img class="right" src="http://bob.yexley.net/images/nodejs-monitor.png" width="300" height="227" title="Node.js is a platform for easily building fast, scalable network applications using the JavaScript language" alt="Node.js"></p>

<blockquote><p><a href="http://nodejs.org">Node.js</a> is a platform built on [Google] Chrome&#8217;s JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.</p></blockquote>


<p>We&#8217;ve been using the <a href="http://lesscss.org">Less CSS</a> pre-processor at work recently, but we&#8217;ve only been using the JavaScript parser/generator for it, which is really only intended for development/debugging purposes&#8230;not a live, production environment. I&#8217;m not sure it really hurts much to use the JavaScript parser/generator, other than performance&#8230;It does it all dynamically on the client&#8230;on <em>every</em> page load, so it could be a little slow. Anyway, having a couple of hours of downtime at work recently while we were upgrading our VCS, I took the opportunity to start looking into pre-compiling and minifying our stylesheets using the server-side compiler for it, which is a <a href="http://nodejs.org">Node.js</a> module. That forced me to get Node.js installed and running on my workstation, and get the Less module installed. I was pleasantly surprised and impressed at how easy it was to get up-and-running with it&#8230;that prompted me to start exploring Node.js further.<!-- more --></p>

<p>Oblige me for a moment while I divert this conversation with a brief, personal side-story&#8230;</p>

<p><em>For my entire software development career, I&#8217;ve worked on mature, well-established platforms (Oracle, ColdFusion, .NET, etc). I&#8217;ve often told myself that, sooner or later, I would need to try to get ahead of the curve and learn/master a new technology or platform early on in its lifecycle so that by the time it became more mainstream, and widely used, I would have the experience with it that is needed to be marketable. Maybe this is that opportunity&#8230;with Node.js. Or am I too late?</em></p>

<p>OK&#8230;enough of that&#8230;I digress&#8230;</p>

<p>So I started poking around in the Node.js documentation, read through the <a href="http://www.nodebeginner.org/">Node Beginner Book</a> and browsed through some of the available modules. One of the first things I noticed was that the modules I&#8217;ve needed to implement a side-project I&#8217;ve wanted to write for quite a while now were available for Node&#8230;modules that I&#8217;ve not been able to find on any of the other platforms I&#8217;ve worked with recently. That got me pretty excited to start playing.</p>

<p>The next big thing that I was excited about was the fact that its based on the JavaScript language, which <a href="http://bob.yexley.net/javascript-modules-to-support-interactive-web-applications/">I&#8217;ve been enjoying more and more lately</a>. The dynamic nature of the language makes it incredibly flexible and powerful. The more I&#8217;ve learned about it, the more I like it. The really exciting thing about Node.js is that it allows for the development of both server-based <em>and</em> client-based applications, all with the same language.</p>

<p>For as young as the platform is, there&#8217;s already a thriving and growing community thats developing around it, with the Node Package library approaching (or did it pass already) 10,000 packages developed and contributed by the community, all for a platform that hasn&#8217;t even reached version 1.0 yet. The fact that its open source makes it nicely accessible and easy to get up-and-running with, and if you want to fork out a little bit of cash, there&#8217;s also some decent IDEs and debuggers for it as well (I&#8217;ve heard good things about <a href="http://www.jetbrains.com/webstorm/">Webstorm</a>). Double-bonus: it runs on all of the major platforms as well (at least, mostly&#8230;I&#8217;ve run into some modules that won&#8217;t install on Windows&#8230;which is having the bittersweet side-effect of forcing me to start to learn <a href="http://www.ubuntu.com/">Linux</a> a little better).</p>

<p>Anyway&#8230;I&#8217;m at risk of being long-winded here again. I&#8217;ve really only dipped my toes in the pool of Node.js so far&#8230;but the water was warm and inviting&#8230;I&#8217;m looking forward to learning more about it. Anyone have any suggestions for moving forward? Am I about to get run over?</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Armor of God series]]></title>
    <link href="http://bob.yexley.net/armor-of-god-series"/>
    <updated>2012-03-17T14:07:00-04:00</updated>
    <id>http://bob.yexley.net/armor-of-god-series</id>
    <content type="html"><![CDATA[<p><img class="left" src="http://bob.yexley.net/images/roman-soldiers-statue.jpg" width="300" height="285" title="Roman soldiers and their armor were the example that Paul drew from in this passage from Ephesians" alt="Roman soldiers statue">
This is (hopefully) the first of a series of posts that I&#8217;ve wanted to write for a long time now. If I recall correctly, I think I actually already wrote this very post a while back on a previous version of my site, and never got beyond this first post, so, I&#8217;m hoping I can stick with it this time and actually follow through and finish it. This is a subject I believe in very strongly and am very passionate about, so I&#8217;m looking forward to the opportunity to think through it in more depth as I write it all down.</p>

<p>I plan to take an in-depth look at the passage of <a href="http://bible.us/Eph6.10-18.ESV">Ephesians 6:10-18</a>. My goal with this series is to learn more about the subject on a personal level, and if it interests or helps someone else, so much the better. More than anything, I pray that it reflects honor and glory on God and is something that He will be proud of.</p>

<h2>The outline</h2>

<p>Here is a rough outline of how I plan to approach the subject (at least for now&#8230;subject to change):</p>

<ol>
<li><strong>Reality</strong>: This is not a metaphor, this is real, and we need to take it seriously and deal with it like every other reality in our lives.</li>
<li><strong>Call to action</strong>: This requires an active, daily discipline in practice. There is nothing passive about battle.</li>
<li>The <strong>belt of truth</strong>: keeping it all together</li>
<li>The <strong>breastplate of righteousness</strong>: guarding our vitals</li>
<li>The <strong>Gospel as shoes</strong>? Sharing the love</li>
<li>The <strong>shield of faith</strong>: self defense</li>
<li>The <strong>helmet of salvation</strong>: the brain bucket</li>
<li>The <strong>sword of the spirit</strong>: fighting back</li>
<li><strong>Prayer</strong>: suiting up</li>
</ol>


<h2>The format</h2>

<p>This is the typical format that I was planning to use for each section in the outline:</p>

<ol>
<li>The <strong>spiritual principle</strong>: discuss the spriritual principle for the section (truth, righteousness, faith, etc.)</li>
<li>The <strong>analogy</strong>: discuss the conceptual analogy that Paul uses in the passage to help us understand the principle (belt, breastplate, shield, etc.)</li>
<li>The <strong>enemy&#8217;s perspective</strong>: what is the enemy&#8217;s approach and tactics against us with regard to the subject? What are we fighting against?</li>
<li>The <strong>application</strong>: what can we do? What action can we take? How do we apply this to our own personal battle?</li>
</ol>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Creation vs Evolution: Can they both be right?]]></title>
    <link href="http://bob.yexley.net/creation-vs-evolution-can-they-both-be-right"/>
    <updated>2012-02-25T00:07:00-05:00</updated>
    <id>http://bob.yexley.net/creation-vs-evolution-can-they-both-be-right</id>
    <content type="html"><![CDATA[<p><em>This is the outline for a discussion that I&#8217;ll be leading for our small group, and is my attempt to put my thoughts together in a logical manner. Much of the content for this piece was sourced from chapter three of <a href="http://www.amazon.com/Case-Faith-Journalist-Investigates-Christianity/dp/0310234697"><strong>The Case For Faith</strong></a> by <a href="http://leestrobel.com/"><strong>Lee Strobel</strong></a>. Much of the content of that chapter is based on an interview he did with <a href="http://www.ecs.baylor.edu/engineering/faculty/index.php?id=29877">Dr. Walter Bradley</a>, so much of the content can be attributed to them, but has been summarized for the purposes of this document. It should also be noted that the book was published in 2000. Certainly much could have changed in the course of the past twelve years. In the short bit of time I took to research for this document, I found little to refute the information found in the book and from this field of research, but I am certainly open to education and learning, so please let me know if any of this information is inaccurate. To the best of my knowledge the information presented here is still relevant and accurate.</em></p>

<h2>The positions&#8230;</h2>

<h4>Creation</h4>

<p>The original bringing into existence of the universe by God</p>

<ul>
<li><a href="http://www.youversion.com/bible/esv/gen/1/27">God created man in his own image - Genesis 1:27</a></li>
<li><a href="http://www.youversion.com/bible/esv/heb/13/8">God is the same yesterday, today and forever - Hebrews 13:8</a></li>
</ul>


<h4>Evolution</h4>

<p><a href="https://www.google.com/search?q=define+evolution">The process by which different kinds of living organisms are thought to have developed and diversified from earlier forms during the history of the earth.</a></p>

<p><img class="right" src="http://bob.yexley.net/images/CharlesDarwin.jpg" width="300" height="280" title="Charles Darwin" alt="Charles Darwin">
<a href="http://en.wikipedia.org/wiki/Charles_Darwin">Charles Darwin</a>&#8217;s <a href="http://en.wikipedia.org/wiki/Natural_selection">theory of natural selection</a> suggests that naturalistic processes could account for the increasing complexity and diversity of living things.</p>

<blockquote><p>Darwin&#8217;s &#8220;greatest accomplishment&#8221; was to show how the development of life is &#8220;the result of a natural process, natural selection, without any need to resort to a Creator.&#8221;</p><footer><strong>Biologist Franciso Ayala</strong> <cite><a href='http://en.wikipedia.org/wiki/Francisco_J._Ayala'>en.wikipedia.org/wiki/&hellip;</a></cite></footer></blockquote>




<blockquote><p>As far as Christianity was concerned, the advent of the theory of evolution&#8230;was catastrophic&#8230;The decline in religious belief can probably be attributed more to the propagation and advocacy by the intellectual and scientific community of the Darwinian version of evolution than to any other single factor.</p><footer><strong>Michael Denton</strong> <cite><a href='http://en.wikipedia.org/wiki/Michael_Denton'>en.wikipedia.org/wiki/&hellip;</a></cite></footer></blockquote>


<p>So which perspective is right? Can they both be? Does one of them have to be wrong? What do the facts say? Does science, by its nature, automatically have to be correct and accurate? Can it be wrong? Much of it <em>is</em>, after all, theoretical/hypothetical in nature, right? What do you think? Can both evolution and creation be right?<!-- more --></p>

<h2>The implications</h2>

<p><a href="http://en.wikipedia.org/wiki/Will_Provine">Evolutionist William Provine of Cornell University</a> suggested that if Darwin&#8217;s theory is true, then there are five inescapable implications:</p>

<ul>
<li>There&#8217;s no evidence for God</li>
<li>There&#8217;s no life after death</li>
<li>There&#8217;s no absolute foundation for right and wrong</li>
<li>There&#8217;s no ultimate meaning for life</li>
<li>People don&#8217;t really have free will</li>
</ul>


<h2>The facts about evolution and natural selection</h2>

<p>Someone once said (and countless people have since reiterated the idea) &#8220;the more I learn, the more I realize how little I know.&#8221; The research that has gone into Darwin&#8217;s theories has often resulted in a similar sentiment for many.</p>

<p>The place where the theories of evolution and natural selection break down is ultimately at the heart of the problem: <em><strong><a href="http://en.wikipedia.org/wiki/Abiogenesis">the origin of life</a></strong></em> (also scientifically referred to as <a href="http://en.wikipedia.org/wiki/Abiogenesis">Abiogenesis</a>). Darwin&#8217;s theories are based on the idea that simple lifeforms could develop over long periods of time into increasingly complex creatures, but it never seeks to explain how those simple life forms came to be in the first place. Much scientific research has been dedicated to answering this question of, where or how did life originate, but all of it to the present has failed to produce a viable, scientific conclusion. In fact, more and more scientists are conceding the fact that scientific research is increasingly providing evidence of an intelligent designer as the source of the origin of life.</p>

<h3>Assembling life</h3>

<blockquote><p>The origin of life appears to be almost a miracle, so many are the conditions which would have to be satisfied to get it going.</p><footer><strong>Nobel Prize winner Sir Francis Crick</strong> <cite><a href='http://en.wikipedia.org/wiki/Francis_Crick'>en.wikipedia.org/wiki/&hellip;</a></cite></footer></blockquote>


<p>A living system must do at least three things: 1) process energy, 2) store information, and 3) replicate.</p>

<p>Non-living things do not do these things.</p>

<p>A single-celled organism has been described in the following way:</p>

<blockquote><p>a high-tech factory, complete with artificial languages and decoding systems; central memory banks that store and retrieve impressive amounts of information; precision control systems that regulate the automatic assembly of components; proof-reading and quality control mechanisms that safeguard against errors; assembly systems that use principles of prefabrication and modular construction; and a complete replication system that allows the organism to duplicate itself at bewildering speeds.</p></blockquote>


<p>There are eighty different types of amino acids, but only twenty of them are found in living organisms. In order to produce the protein molecules that can support a living organism, you would have to assemble a collection of roughly one hundred of these twenty types and link them together in precisely the right sequence, with precisely the right kind of chemical bonds (peptide bonds) in the correct places in order for them to form a protein capable of folding in a specific three-dimensional way in order for it to be able to support life. <em>That is simply <strong>one protein</strong> capable of supporting life&#8230;this is only the <strong>first</strong> step.</em></p>

<p>It would take roughly two hundred of these protein molecules with precisely the right functions, assembled together in a very specific way, to produce a typical living cell.</p>

<p>Living systems acquire the information they need about how these amino acids and proteins need to be arranged from DNA and RNA. The sequencing of the amino acids necessary to create the proteins for each cell is encoded in its DNA. The challenges posed by the idea of composing a single DNA molecule have been described as &#8220;beyond our imagination&#8221;.</p>

<p>This defines the challenge that science is faced with when considering attempts to answer the question of the origin of life&#8230;</p>

<h3>The theories</h3>

<p>Of the research that has been done concerning the origin of life, six common theories have emerged as the most popular&#8230;</p>

<h4>Random chance</h4>

<p>This theory proposes that on the early earth, given the right combination of chemicals interacting with each other in &#8220;warm little ponds&#8221;, given enough time (science has verified that the earth is less than five hundred billion years old), they would eventually produce some form of life.</p>

<p><em>Scientists simply don&#8217;t seriously consider this theory a realistic possibility at all anymore. Scientific research has concluded that, even under optimal conditions, and given a billion years, the chances of chemical evolution on this level to be successful are less than 1:10000000000000000000000000000000000000000000000000000000000000 (1:10&#94;60).</em></p>

<blockquote><p>The odds for all practical purposes are zero. That&#8217;s why even though some people who aren&#8217;t educated in this field still believe life emerged by chance, scientists simply don&#8217;t believe it anymore.</p><footer><strong>Dr. Walter Bradley</strong> <cite><a href='http://en.wikipedia.org/wiki/Walter_Bradley_(engineer)'>en.wikipedia.org/wiki/&hellip;</a></cite></footer></blockquote>


<h4>Chemical affinity</h4>

<p>This theory proposes that there must be some inherent attraction that would cause amino acids to spontaneously link up in the right sequence to create the protein molecules out of which living things are made; a sort of, &#8220;biochemical predestination&#8221;, if you will, the result of chemical bonding preferences.</p>

<p><em>Research involving computer algorithms to analyze all of the 250 known proteins resulted in conclusive evidence that sequencing had nothing at all to do with chemical preferences.</em></p>

<h4>Self-ordering tendencies</h4>

<p>This theory is officially titled &#8220;non-equilibrium thermodynamics&#8221;, and suggests that under certain circumstances, when energy is passed through a system at a fairly high rate, the system becomes unstable and will rearrange itself into an alternate, more complicated form. An example of this theory would be the way water molecules organize themselves spontaneously and form a vortex as they are drained from a bathtub. This tendency of molecules to &#8220;become more orderly&#8221; under given circumstances is the basis of this theory.</p>

<p><em>Energy itself is capable of creating patterns of simple order, but not anywhere even remotely close to the order required to arrange molecules of any kind in patterns as enormously complex as those required for the creation of a living organism. For example, a person could observe ripples on the sand at a beach and know that they were created by the action of waves, but if you saw the words &#8220;John loves Mary&#8221; and a heart with an arrow drawn in the sand, you know that energy alone didn&#8217;t create that.</em></p>

<h4>Seeding from space</h4>

<p>This theory proposes that the building blocks for life on earth came from somewhere else in space. Support for this theory arose from the discovery of amino acids on meteorites that had fallen to earth.</p>

<p><em>This theory does not answer the question of the origin of life, it simply moves it to another place.</em></p>

<h4>Vents in the ocean</h4>

<p>This theory proposes that exotic, hydrothermal vents discovered on the ocean floor could have provided an environment sufficient to facilitate the beginnings of life on earth.</p>

<p><em>This theory fairly ends at its suggestion. Like the seeding from space theory, it doesn&#8217;t address the assembly process of putting the right amino acids together in the appropriate sequence required to create a lifeform.</em></p>

<h4>Life from clay</h4>

<p>This hypothesis proposed that &#8220;life somehow arose on clays whose crystalline structure had enough complexity to somehow encourage prebiotic chemicals to assembly together.&#8221;</p>

<p><em>Crystalline clay might possibly be capable of providing some form of orderly information, but it would be very little, and it would be redundant; nothing anywhere close to that required to form life. The information it could provide would be analagous to a book filled with the words &#8220;I love you, I love you, I love you&#8230;&#8221; over and over and over again. It is orderly, but provides very little information.</em></p>

<h2>Contrasting implications</h2>

<p>In contrast to the implications of Darwin&#8217;s theory being true, the implications of God as the Intelligent Designer would be&#8230;</p>

<ul>
<li>There is overwhelming evidence (even beyond the Bible), even as observed and acknowledged by prominent figures in the scientific community, to support the theory of an intelligent designer (God)</li>
<li>God, who <a href="http://www.youversion.com/bible/esv/2tim/3/16">inspired the authoring of the Bible</a>, which in its entirety points to life after death, with Him, in paradise, by His grace, through faith in His Son, Jesus Christ</li>
<li>God himself establishes the foundation for absolute truth and sin (right and wrong)</li>
<li>The meaning of life <em><strong>is</strong></em> salvation&#8230;</li>
<li>&#8230;for those who choose it (through free will)</li>
</ul>


<h2>Conclusions</h2>

<blockquote><p>Today it takes a great deal of faith to be an honest scientist who is an atheist.</p><footer><strong>Dr. Walter Bradley</strong> <cite><a href='http://en.wikipedia.org/wiki/Walter_Bradley_(engineer)'>en.wikipedia.org/wiki/&hellip;</a></cite></footer></blockquote>




<blockquote><p>I build molecules for a living. I can&#8217;t begin to tell you how difficult that job is.</p><p>I stand in awe of God because of what He has done through His creation. Only a rookie who knows nothing about science would say science takes away from faith. If you really study science, it will bring you closer to God.</p><footer><strong>James Tour, Nanoscientist</strong> <cite><a href='http://en.wikipedia.org/wiki/James_Tour'>en.wikipedia.org/wiki/&hellip;</a></cite></footer></blockquote>


<p>These are just a couple of conclusions that two of the leading scientists in the field of origin of life study have come to as a result of their research. What do you think?</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[ASP.NET and SQL Server: passing timestamps back and forth]]></title>
    <link href="http://bob.yexley.net/asp-dot-net-and-sql-server-passing-timestamps-back-and-forth"/>
    <updated>2012-02-10T20:05:00-05:00</updated>
    <id>http://bob.yexley.net/asp-dot-net-and-sql-server-passing-timestamps-back-and-forth</id>
    <content type="html"><![CDATA[<p><img class="left" src="http://bob.yexley.net/images/starscream.jpg" width="300" height="287" title="Starscream was always my favorite Transformer" alt="Starscream">
<em>For some reason, whenever I think of or discuss the idea of serialization, my brain associates it with the concept of transformation&#8230;which <strong>always</strong> makes me think of Transformers. Is that weird?</em></p>

<p><a href="http://en.wikipedia.org/wiki/Serialization">Data serialization</a> can be a <a href="http://en.wikipedia.org/wiki/Sticky_wicket">sticky wicket</a> sometimes. Things don&#8217;t always get passed back and forth between a client and server the way you think or expect they will. Which means, sometimes you have to take matters into your own hands.</p>

<p>I was recently working on implementing some <a href="http://en.wikipedia.org/wiki/Concurrency_control">concurrency checking</a> into an app, and we decided to use <a href="http://msdn.microsoft.com/en-us/library/aa260631(v=sql.80).aspx">SQL Server timestamp</a> fields to check against before updating data being passed back to the server from the web app. Seemed straight-forward enough initially&#8230;but that was before that field started getting transformed into different datatypes and formats as it was passed through the different layers of the application. All of the different players involved (the various components of our app) apparently didn&#8217;t feel like playing nicely together with the timestamps. We ultimately came up with what I think is a fairly simple and straight-forward solution to the problem&#8230; <!-- more --></p>

<h2>The problem</h2>

<p>I&#8217;m using the most excellent <a href="http://code.google.com/p/dapper-dot-net/">Dapper</a> micro-orm for data access in this app, and when selecting a timestamp field from the database into a C# object, it sets the C# type of the field to a <code>byte[]</code> (byte array). When that object then gets passed to the web client, it gets passed as a <a href="http://www.json.org/">JSON</a> object, in which the property is just an array of integers. This didn&#8217;t <em>seem</em> like it would be a problem, until we tried coming back the other way with it to update the record.</p>

<p>When that JSON object was <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.6">PUT</a> (<a href="http://www.w3.org/QA/2008/10/understanding-http-put.html">see also</a>) back to the server, the <a href="http://www.asp.net/mvc">ASP.NET MVC</a> model binder wasn&#8217;t serializing the named property from the array of integers that had been sent to the client, back into a <code>byte[]</code> as I would&#8217;ve expected it to, the property was just <code>null</code> after model binding occurred, even though a valid integer array was present in the property on the return trip (as observed through <a href="http://fiddler2.com/fiddler2/">Fiddler</a>).</p>

<p>So the question at this point was, how do I get a byte array back and forth to and from the client in tact so that when it gets sent back to SQL Server on the backend, it will give me an accurate concurrency check? The answer actually turned out to be fairly simple&#8230;</p>

<h2>The solution</h2>

<p>The solution ultimately ended up being to just create our own, very simple (yet manual) <code>byte[]</code> to <code>string</code> serializer. Here&#8217;s what it looks like.</p>

<p>This converts the <code>byte[]</code> to a <code>string</code> before converting to JSON to send to the client:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>public static string ConvertToString(this byte[] source)
</span><span class='line'>{
</span><span class='line'>    string hex = BitConverter.ToString(source);
</span><span class='line'>    return hex.Replace("-", "");
</span><span class='line'>}</span></code></pre></td></tr></table></div></figure>


<p>And this converts the <code>string</code> back to a <code>byte[]</code> after model binding, when it gets back to the server, before sending it off to SQL Server for a concurrency check and/or update:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>public static byte[] ToByteArray(this string source)
</span><span class='line'>{
</span><span class='line'>    int length = source.Length;
</span><span class='line'>    byte[] bytes = new byte[length / 2];
</span><span class='line'>    for (int i = 0; i &lt; length; i +=2) {
</span><span class='line'>        bytes[i / 2] = Convert.ToByte(source.Substring(i, 2), 16);
</span><span class='line'>    }
</span><span class='line'>
</span><span class='line'>    return bytes;
</span><span class='line'>}</span></code></pre></td></tr></table></div></figure>


<p>So far its working pretty well for us and we haven&#8217;t run into any problems with it.</p>

<p>Anyone else run into an issue like this before? Is there a better way to handle this?</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[JavaScript modules to support interactive web applications]]></title>
    <link href="http://bob.yexley.net/javascript-modules-to-support-interactive-web-applications"/>
    <updated>2012-01-31T20:52:00-05:00</updated>
    <id>http://bob.yexley.net/javascript-modules-to-support-interactive-web-applications</id>
    <content type="html"><![CDATA[<p><img class="right" src="http://bob.yexley.net/content/logos/JavaScript-logo-small.png" width="300" height="300" title="JavaScript...it has NOTHING to do with Java" alt="JavaScript">
The web has evolved and the standards for browser applications have been raised to new levels over the past five years. People just expect more (and rightfully so) from web applications. It used to be that whenever I used any kind of JavaScript (to which, from this point forward, I will refer to as simply, JS, thankyouverymuch) in my web apps that I would pretty much just reference a <code>.js</code> file and randomly jam a bunch of functions in it, and hope someone (a team member, perhaps) didn&#8217;t notice them closely enough to attempt to use one in a way in which it wasn&#8217;t intended to be used. Knowhatimean? Ever been there, or done that? Perhaps you&#8217;re there now.</p>

<p>At some point&#8230;not sure exactly when&#8230;I guess it was probably about six or eight months ago or so&#8230;I finally got to a point where I said to myself, &#8220;self&#8230;there has <em><strong>GOT</strong></em> to be a better way.&#8221; So <a href="https://www.google.com/search?q=javascript+module+pattern">I did some Googling</a>&#8230;and as it turns out, I was right&#8230;<!-- more --></p>

<h2>The module pattern</h2>

<p>Some of the big things that I found myself longing for as the JS I was writing started to get more and more complex, was encapsulation, reuse and statefulness. The searching I did (check out the link above) quickly showed that the module pattern would give me all of that and more. I highly recommend starting with the first link in those results, its <a href="http://www.adequatelygood.com/2010/3/JavaScript-Module-Pattern-In-Depth">a fantastic article by ben cherry</a> that covers how to implement the module pattern with JS in very simple and understandable terms (seriously, if this subject interests you at all, go read it&#8230;this page isn&#8217;t going anywhere&#8230;you may not even want to come back after reading it&#8230;).</p>

<p>I started slowly with this pattern to support a few web applications that required some semi-complex client-side interactions, and have been very pleased with how it has worked out so far. Here&#8217;s a stripped down sample of the format that the modules I&#8217;ve been writing have taken:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>// pageModule.js
</span><span class='line'>var pageModule = (function () {
</span><span class='line'>
</span><span class='line'>// Private members
</span><span class='line'>  var selectors;
</span><span class='line'>
</span><span class='line'>// Public operations
</span><span class='line'>  return {
</span><span class='line'>      Init: function (params) { return init(params); },
</span><span class='line'>      AnotherFunction: function () { return anotherPrivateFunction(); }
</span><span class='line'>  };
</span><span class='line'>
</span><span class='line'>// Private operations
</span><span class='line'>  function init(params) {
</span><span class='line'>      selectors = params;
</span><span class='line'>      // ...
</span><span class='line'>  }
</span><span class='line'>
</span><span class='line'>  function anotherPrivateFunction() {
</span><span class='line'>      // ...
</span><span class='line'>  }
</span><span class='line'>
</span><span class='line'>})(); // pageModule</span></code></pre></td></tr></table></div></figure>


<p>A particularly appealing feature of this approach to writing JS is that it is totally isolated and easily testable using a JS unit test framework like <a href="http://docs.jquery.com/QUnit">QUnit</a> or <a href="http://code.google.com/p/js-test-driver/wiki/GettingStarted">JsTestDriver</a>.</p>

<h2>Pulling it into a web page</h2>

<p>I&#8217;ve found this approach to support interactive client-side functionality in web applications very nicely as well, though, this is an area where I admittedly have some questions as to my approach. I&#8217;ve been wondering if I sense a slight <a href="http://en.wikipedia.org/wiki/Code_smell">code smell</a> with the following approach, and would appreciate some feedback. But anyway, here&#8217;s how I&#8217;ve been using it.</p>

<p>Being the .NET developer that I am, the following is an example of a <a href="http://www.asp.net/web-pages/tutorials/basics/2-introduction-to-asp-net-web-programming-using-the-razor-syntax">razor view</a> from an ASP.NET MVC app, that uses the above module, but this same approach could be used with any web frameworks view engine.</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>// page.cshtml
</span><span class='line'>@model PageViewModel
</span><span class='line'>
</span><span class='line'>@{ ViewBag.Title = "Page Title"; }
</span><span class='line'>
</span><span class='line'>@section PageHeadContent {
</span><span class='line'>  ...
</span><span class='line'>}
</span><span class='line'>&lt;div id="PageContent">
</span><span class='line'>  &lt;ul class="some-list">
</span><span class='line'>      &lt;li>...&lt;/li>
</span><span class='line'>  &lt;/ul>
</span><span class='line'>&lt;/div>
</span><span class='line'>@section PageScripts {
</span><span class='line'>  ...
</span><span class='line'>  &lt;script src="http://bob.yexley.net/js/pageModule.js">&lt;/script>
</span><span class='line'>  &lt;script>
</span><span class='line'>      var pageModuleParams = {
</span><span class='line'>          PageContentContainer: '#PageContent',
</span><span class='line'>          ListOfStuff: '.some-list'
</span><span class='line'>      };
</span><span class='line'>      pageModule.Init(pageModuleParams);
</span><span class='line'>  &lt;/script>
</span><span class='line'>}</span></code></pre></td></tr></table></div></figure>


<p>See what I did there? So, the idea here is that the JS module itself knows absolutely nothing at all about the page that it is supporting. But, it can still fully support and manipulate DOM elements on the page, because the page feeds it the selectors it is (obviously) fully aware of by passing the <code>pageModuleParams</code> object into the module through the publicly exposed <code>Init</code> operation, which sets the internal <code>selectors</code> variable. From that point on, the module itself, internally, can wire up internal operations (event handlers, ajax calls, etc) that can act on elements of the page through selectors that were passed in from the page, and yet still remain totally decoupled from the page.</p>

<p>So what do you think? This approach has been working fairly well for me for a while now, but it wouldn&#8217;t surprise me a bit to know that there are much better ways to handle this. Any suggestions or recommendations? Learning new and better ways of doing things (especially if they make my life easier) is something I love&#8230;so I&#8217;m totally open to feedback here. Was this useful?</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[How to build a good fire]]></title>
    <link href="http://bob.yexley.net/how-to-build-a-good-fire"/>
    <updated>2012-01-29T21:34:00-05:00</updated>
    <id>http://bob.yexley.net/how-to-build-a-good-fire</id>
    <content type="html"><![CDATA[<p><a href="http://bob.yexley.net/images/how-to-build-a-fire/1.jpg"><img class="left" src="http://bob.yexley.net/images/how-to-build-a-fire/1s.jpg" width="300" height="244" title="A blazin warm fire" alt="A blazin warm fire"></a>About a year-and-a-half ago, Crys and I invested in a new wood burning stove for our home. Last winter and this winter so far, we&#8217;ve been burning wood to keep us warm. During that time I&#8217;ve built dozens of fires, and if there&#8217;s one thing I&#8217;ve learned for certain its that building a good fire is easier said than done. I&#8217;ve learned a handful of tricks that has made the task easier over time, and I can consistently get one going much better than I could last year when we started this. Most of what I&#8217;ve learned has been through bits and pieces from conversation over time, and more than anything, trial and error.</p>

<p>Building a good fire is a skill that I feel every good man should possess, but as time rolls on, fewer and fewer have it. Its a skill that I certainly intend to pass on to my sons. There are handful of things that I&#8217;ve learned are important for starting and maintaining a good fire. I thought I&#8217;d share some of what I&#8217;ve learned here. If you know of anything that I might be missing, share your ideas in the comments.</p>

<!-- more -->


<h3>A good foundation</h3>

<p>When we first had our stove installed, obviously, the first fire we built was in a bare metal box. That fact alone can add to the challenge. One of the things that I&#8217;ve learned can definitely help to get things started, and keep things going, is having a good bed of ashes to insulate the fire from underneath. This is helpful <em>all</em> the time, but especially if/when you&#8217;re trying to start a fire several hours after having let one go out. That bed of ash will serve as an insulation layer for coals and embers from the previous fire that can make it a breeze to get another one going. Ultimately, the point here is, don&#8217;t be too eager to shovel <em>all</em> of the ash out of your stove or fireplace. Keeping a bit of it around in there can be a big help.</p>

<h3>Structure and airflow</h3>

<p>Another thing I&#8217;ve learned the hard way is that just throwing some wood in there and chasing it with a match or lighter is <em><strong>not</strong></em> gonna get you a fire. The <em>way</em> you stack your wood is critical to your success&#8230;or failure. I&#8217;ve lost track of the number of times I&#8217;ve struggled to either get a fire going, or keep one going after getting it barely started, because of the fact that there was no space around the wood for airflow. Stacking or arranging your wood in such a way as to allow for airflow around it is essential.</p>

<p><a href="http://bob.yexley.net/images/how-to-build-a-fire/2.jpg"><img class="right" src="http://bob.yexley.net/images/how-to-build-a-fire/2s.jpg" width="150" height="112" title="This is how I stack my wood when I start a new fire" alt="This is how I stack my wood when I start a new fire"></a></p>

<p>The picture here illustrates the way I&#8217;ve come to stack my wood when I&#8217;m starting a new fire. Its always a little different of course, depending on the pieces of wood that I have available at the time, but the concept behind what I try to achieve with it is the same every time. Two smallers pieces of wood on each side, allowing me to stack another piece across the top of them. This forms a perfect space to get things started underneath, and allows for the needed airflow around the piece across the top as the kindling takes off.</p>

<h3>Start small and build up</h3>

<p>This is probably actually one of the more obvious and well-known factors, but its worth reiterating. Starting with realistic expectations can help with this. Don&#8217;t expect to have a blazing fire going within anything less than 20 or 30 minutes (and even that might be a bit of a stretch) unless you&#8217;re gonna throw some lighter fluid in there (which is <em><strong>NOT</strong></em> a good idea in a stove or fireplace&#8230;by the way).</p>

<p><a href="http://bob.yexley.net/images/how-to-build-a-fire/3.jpg"><img src="http://bob.yexley.net/images/how-to-build-a-fire/3s.jpg" width="150" height="112" title="I start with some paper" alt="I start with some paper"></a>
<a href="http://bob.yexley.net/images/how-to-build-a-fire/4.jpg"><img src="http://bob.yexley.net/images/how-to-build-a-fire/4s.jpg" width="150" height="112" title="...then I toss in some small kindling" alt="...then I toss in some small kindling"></a>
<a href="http://bob.yexley.net/images/how-to-build-a-fire/5.jpg"><img src="http://bob.yexley.net/images/how-to-build-a-fire/5s.jpg" width="150" height="112" title="Light the paper and the kindling takes off" alt="Light the paper and the kindling takes off"></a>
<a href="http://bob.yexley.net/images/how-to-build-a-fire/6.jpg"><img src="http://bob.yexley.net/images/how-to-build-a-fire/6s.jpg" width="150" height="112" title="Aaannndd here we go!" alt="Aaannndd here we go!"></a></p>

<p>I typically start with some paper, and throw a handful of very small pieces of kindling on it. My favorite kindling so far is a good piece of knotty pine, or some cedar (this is particularly nice if I can come across some, because it makes the room smell nice as it burns). I light the paper and it ignites the small kindling. Once the small kindling starts burning, I follow it&#8230;slowly&#8230;remember, getting over-zealous at this point can smother the fire quickly&#8230;with some gradually larger pieces of kindling.</p>

<p><a href="http://bob.yexley.net/images/how-to-build-a-fire/7.jpg"><img src="http://bob.yexley.net/images/how-to-build-a-fire/7s.jpg" width="150" height="112" title="Some larger kindling...slowly building" alt="Some larger kindling...slowly building"></a>
<a href="http://bob.yexley.net/images/how-to-build-a-fire/8.jpg"><img src="http://bob.yexley.net/images/how-to-build-a-fire/8s.jpg" width="150" height="112" title="With proper airflow and some gentle blowing, it will catch" alt="With proper airflow and some gentle blowing, it will catch"></a>
<a href="http://bob.yexley.net/images/how-to-build-a-fire/9.jpg"><img src="http://bob.yexley.net/images/how-to-build-a-fire/9s.jpg" width="150" height="112" title="It will get the big wood going" alt="It will get the big wood going"></a>
<a href="http://bob.yexley.net/images/how-to-build-a-fire/10.jpg"><img src="http://bob.yexley.net/images/how-to-build-a-fire/10s.jpg" width="150" height="112" title="And now we have a fire" alt="And now we have a fire"></a></p>

<p>Occasionally, as the fire builds, the flames will increase and decrease in intensity, and I find that I nearly always have to help things along by blowing on the flames a bit&#8230;sometimes more than others, but typically not all that much. I&#8217;ve gotten to the point now that, by using this approach, within about 30 minutes I&#8217;ve gotten things going well enough that the main piece of wood that I set across the the original stack has taken off, and I can just start maintaining things. Which brings me to my last tip&#8230;</p>

<h3>Keeping it going</h3>

<p><a href="http://bob.yexley.net/images/how-to-build-a-fire/11.jpg"><img src="http://bob.yexley.net/images/how-to-build-a-fire/11s.jpg" width="150" height="112" title="Create a ditch or trench in the coals" alt="Create a ditch or trench in the coals"></a>
<a href="http://bob.yexley.net/images/how-to-build-a-fire/12.jpg"><img src="http://bob.yexley.net/images/how-to-build-a-fire/12s.jpg" width="150" height="112" title="The airflow created by the ditch through the coals will get the new log burning in no time" alt="The airflow created by the ditch through the coals will get the new log burning in no time"></a></p>

<p>Once the fire is going well, and your big logs are burning nicely, eventually you&#8217;ll have to toss in another piece (or two&#8230;three&#8230;). If you&#8217;ve held off long enough, the main wood in your fire has been reduced to nothing more than coals and embers. I&#8217;ve found that, by using a good poker, you can push those coals around and pile them up on either side of the stove/fireplace, forming something of a &#8220;ditch&#8221; or trench through the middle of them. By placing another log on top of those coals with that &#8220;ditch&#8221; between them, you get a perfect path for circular airflow around that piece of wood, and it will take off within seconds. I make this point because I did have some trouble at times with logs not taking off and burning as well as they should have, and in a handful of extreme cases where I didn&#8217;t have a good bed of ash and coals beneath the fire I even snuffed the fire by not allowing sufficient airflow around the wood. Its worth driving the point home again about the importance of airflow. Without sufficient airflow, even the best of fires will die.</p>

<h3>Enjoy the warmth</h3>

<p>Crys and I have <em><strong>REALLY</strong></em> enjoyed our wood stove this past year. I think we would both agree that so far it has been our best home investment&#8230;or at very least, the one we enjoy the most. Its taken some time to get the hang of getting the most out of it, but I think we&#8217;re finally starting to nail it down to where we&#8217;re doing less fighting with it and more enjoying it.</p>

<p>Its worth noting here that many of these tips will be more applicable to the use of a wood stove, but many of these or similar concepts have been used with success even out in the open woods when I&#8217;ve been camping. The point to keep in mind is, your mileage may vary, depending on your situation. I hope some of these tips are helpful to someone at some point, and I&#8217;d love to hear about anything that I might myself be missing out on. What are some of your best wood-burning or fire-starting tips?</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Octopus Deploy - my new favorite toy]]></title>
    <link href="http://bob.yexley.net/octopusdeploy-my-new-favorite-toy"/>
    <updated>2012-01-25T08:57:00-05:00</updated>
    <id>http://bob.yexley.net/octopusdeploy-my-new-favorite-toy</id>
    <content type="html"><![CDATA[<p><a href="http://bob.yexley.net/images/OctopusDeployDashboard.png"><img class="right" src="http://bob.yexley.net/images/OctopusDeployDashboard-small.png" width="315" height="232" title="OctopusDeploy dashboard" alt="OctopusDeploy dashboard"></a>
Every .NET developer I know has war stories about past horrors of deployments gone wrong. My theory is that&#8217;s because there&#8217;s not a good, universally accepted way to handle deployments of .NET apps on windows. <a href="http://octopusdeploy.com">Octopus</a> steps in and offers a solution that, in my recent experience, dramatically simplifies the .NET deployment problem with a really elegant solution.</p>

<!-- more -->


<h2>The Problem</h2>

<p>I probably don&#8217;t really need to spend too much time here, do I? I mean, xcopy (with manual configuration, etc&#8230;yuck) is far too brittle and error-prone, MSDeploy/WebDeploy is just too much friction, third party installers and Wix are too much work (seriously, who has time for that?), and in enterprise/corporate environments, who really has the option of handling deployments through Visual Studio? What other options are there?</p>

<p>Well now, there&#8217;s Octopus.</p>

<h2>A <a href="http://simple.wikipedia.org/wiki/Cephalopod">Cephalopod</a> to the rescue</h2>

<p>I first heard about Octopus on twitter, I think it must&#8217;ve been about six months ago. Ever since then I&#8217;ve been looking for an opportunity to try it out to see if it was as good as it appeared to be. I&#8217;m getting pretty close to wrapping up an initial release of a new product at work right now, so I thought this would be a perfect opportunity to try it out.</p>

<h3>Getting up-and-running</h3>

<p>Installation and configuration of a product is critically important, in my opinion. This is where customers/users get their <em>true</em> first impression of a product beyond just reading about it, seeing a few screenshots or watching a demo video. This is a users first actual <em>use</em> of the product. It was the first place that I found Octopus to truly shine. The installation and configuration was super easy, and I got through the entire thing without a single hiccup. I was really impressed with how easy it was.</p>

<p>There are two main components (well, actually three, sorta&#8230;but we&#8217;ll get to the third a little later) to setting up and using Octopus: the <strong>web portal</strong>, and the <strong>tentacles</strong>. The web portal is where you handle your environment configuration and deployments. From there, once you&#8217;ve established your environment configuration, and the portal is aware of your envirnonment, it interacts with tentacles when you actually execute a deployment. Tentacles, are like&#8230;&#8221;agents&#8221;, if you will&#8230;that run as background services on target servers, and execute the &#8220;installation&#8221; of deployment packages when instructed to do so by the web portal.</p>

<p>Here&#8217;s how it all works.</p>

<h3>Making it happen</h3>

<p><a href="http://bob.yexley.net/images/OctopusDeployProcess.png"><img class="left" src="http://bob.yexley.net/images/OctopusDeployProcess-small.png" width="315" height="162" title="This is how it all works" alt="Octopus deploy process"></a>
Don&#8217;t be intimidated by this diagram. It <em>looks</em> complicated, but it&#8217;s really not all that bad. Several of the components of the diagram are most likely already a part of your daily workflow and setup anyway. You <em>do</em> have source code right? If not, why are you even reading this? Also, if you&#8217;re reading this, you probably have target environments that you deploy to as well. If you don&#8217;t have a build server, that&#8217;s OK too, I can help with that (I&#8217;ll get to that in a minute) (I don&#8217;t have a functional build server at work either&#8230;<em><strong>yet</strong></em>). The NuGet repository? Well, that&#8217;s easier than you might think too&#8230;and again, I&#8217;ll get to that in a minute. With all of the pieces in place, with a little bit of simple configuration, Octopus just helps connect the pieces together, and makes it really easy to get things from one place to another, and makes it easy to get everything into the state it needs to be in once it gets there (things like handling different connection strings and configuration settings per environment&#8230;really simple).</p>

<p>Once you have all of the piece in place, there&#8217;s just a handful of easy steps to go from the raw source code on your desktop, to up-and-running live in a target environment.</p>

<p>When you want to deploy a package to a target environment with Octopus, you have to queue a deployment. Queuing a deployment involves:</p>

<ul>
<li>Selecting the package you want to deploy. Octopus provides you with a dropdown list of package version numbers to choose from.</li>
<li>(Optionally) entering some release notes in a provided text area (accepts markdown).</li>
<li>Click the &#8220;queue deployment&#8221; button.</li>
</ul>


<p>Yes, it really is that easy. Once a package has been queued for deployment with its associated release notes, it can then be deployed with a click of a button. Clicking the deploy button prompts you with a dialog to select which of your configured environments you wish to deploy it to. Click submit and your deployment is off-and-running to the target environment.</p>

<p>That being said, lets talk about how Octopus gets the deployment packages it makes available for deployment.</p>

<h4>Feeding the Octopus</h4>

<p>Octopus uses the <a href="http://docs.nuget.org/docs/start-here/overview#NuGet_Packages">NuGet package format</a> for its deployment packages. You need to provide and configure Octopus with a NuGet package feed for each project you wish to automate deployment for. So to provide packages to Octopus for deployment, I had to do two things:</p>

<ol>
<li><h4>Creating NuGet Packages</h4>

<p>I had to figure out a way to generate NuGet packages based on the compiled output of my web application. Eventually our goal is to get to the point where we have an automated build (continuous integration) server that generates our packages as part of its build, and serves up a NuGet package feed. <a href="http://blogs.jetbrains.com/teamcity/2011/11/24/new-teamcity-7-0-eap-build-20702/">We&#8217;ll soon be able to do just that with TeamCity</a>. But&#8230;we&#8217;re not quite there yet, sooo&#8230; My immediate solution was to generate them myself. Last week I wrote about <a href="http://bob.yexley.net/pyke-a-net-build-tool-written-in-python/">Pyke, a .NET build module that I wrote</a>. As I was writing that module, I added functions for generating NuGet packages. As I mentioned in that post, we don&#8217;t currently have a functional build server in our organization (to reiterate the point&#8230;<em><strong>yet</strong></em>), so I currently run our build script locally, from my desktop. Our script currently has three main steps: 1) compile the app, 2) generate a NuGet package, and 3) copy that package out to a shared directory on our network, which also happens to be the source folder for the applications NuGet package feed&#8230;</p></li>
<li><h4>Creating and updating a NuGet Package feed</h4>

<p>The next step in figuring out how to deliver NuGet (deployment) packages to Octopus, was to create and source a NuGet package feed that I could provide to Octopus. This turned out to actually be a LOT easier than I expected it to be. The NuGet team has done a fantastic job all the way around that project, not only in implementation, but in documentation. I did some poking around in <a href="http://docs.nuget.org/">the NuGet docs</a>, and found and followed <a href="http://docs.nuget.org/docs/creating-packages/hosting-your-own-nuget-feeds#Creating_Remote_Feeds">these instructions on how to create your own remote (or internal) NuGet feed</a>. They&#8217;ve created <a href="http://nuget.org/packages/NuGet.Server">their own NuGet package</a> that you add to an empty ASP.NET web application, deploy it to an IIS server, and boom&#8230;you&#8217;re done. That package is configured to look in a folder for packages to serve up in its feed. I followed their instructions, and shared up the package folder as a network share, and that&#8217;s where I copy my generated packages to from my build script, and the feed is automatically updated immediately. It <em>literally</em> took me about five minutes to get up-and-running with a functional NuGet package feed for Octopus to work with. It doesn&#8217;t get a whole lot easier than that.</p></li>
</ol>


<h2>Putting it all together</h2>

<p>So, yeah&#8230;there&#8217;s a lot of words here, which probably makes it seem like a lot more work than it actually was. But ultimately, when all was said and done, this was all I had to do to get everything setup&#8230;</p>

<ol>
<li>Install the Octopus web portal. I had no issues with the installation at all, it took less than five minutes.</li>
<li>Install the Tentacle on my target web server. That too went without issue, and took less than two minutes.</li>
<li>Create a NuGet package feed hosted in IIS. As I just explained, it literally took about five minutes to put that together.</li>
<li>Run my build script to generate a package so my feed had something to serve up.</li>
<li>Configure my environment in the Octopus web portal. That was pretty straight-forward, and consisted of

<ol>
<li>Pointing it to my NuGet feed (where it found a package waiting to be deployed)</li>
<li>Pointing it to my target web server (where it discovered that there was a tentacle running, waiting for a package to install)</li>
<li>Creating a project, to which I added the above configured target server and package feed.</li>
<li>Done.</li>
</ol>
</li>
</ol>


<p>All total, if I had been able to perform all of those actions in sequence (I was putting all of this together in my &#8220;spare time&#8221; while doing my day-to-day development work), it would have taken me about an hour, tops, to get everything in place. The beauty of it is that, now that it <em>is</em> all in place, <em><strong>deploying new features and fixes to any of my environments takes a grand total of about two-and-a-half minutes</strong></em>.</p>

<p><em><strong>THAT</strong></em> is a beautiful deployment process. If you haven&#8217;t yet, you really owe it to yourself to check out Octopus for handling your deployment if you&#8217;re doing .NET development. For a relatively low-friction setup and configuration, it will save you immeasurable time and hassle.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Pyke - a .NET build tool written in Python]]></title>
    <link href="http://bob.yexley.net/pyke-a-net-build-tool-written-in-python"/>
    <updated>2012-01-22T22:55:00-05:00</updated>
    <id>http://bob.yexley.net/pyke-a-net-build-tool-written-in-python</id>
    <content type="html"><![CDATA[<p><img class="left" src="http://bob.yexley.net/content/logos/python-logo.png" width="319" height="100" title="Python" alt="Python">
<img class="left" src="http://bob.yexley.net/content/logos/dotnet-framework-logo.jpg" width="299" height="100" title="Microsoft .NET Framework" alt="Microsoft .NET Framework">
As most .NET developers do at some point or other, I was recently faced with a need for an automated build tool. For various reasons I&#8217;ve come to the point where I&#8217;m not really satisfied with any of the ones currently available, so I decided to write one. <a href="http://github.com/ryexley/pyke">Pyke</a> is the result of that itch. <!-- more --></p>

<h2>Not invented here syndrome?</h2>

<p>Yeah, I&#8217;ll admit it, I have a tendency to be an opinionated developer. Maybe even a little more than most. But having worked with both <a href="http://nant.sourceforge.net/">NAnt</a> and <a href="http://msdn.microsoft.com/en-us/library/wea2sca5(v=vs.90).aspx">MSBuild</a> more than I&#8217;d care to admit in the past, I have no desire at all anymore to willingly drown myself in angle brackets just to automate a few simple tasks. I tried my hand at using <a href="http://rake.rubyforge.org/">Rake</a> with <a href="http://albacorebuild.net/">Albacore</a> a time or two as well, and for one reason or another, I was never able to actually get it working for the simplest of tasks&#8230;my guess would that it was because I was trying (heaven forbid) to actually use Ruby on Windows. The two just don&#8217;t seem to get along.</p>

<p>When I started this little project, I actually inteded and attempted to write it in <a href="http://technet.microsoft.com/en-us/library/bb978526.aspx">Powershell</a>. I don&#8217;t know if its just me (I kinda doubt it, because I&#8217;ve talked about this with others who agree with me), but the documentation and available examples on the internet leave much to be desired with regards to just getting started doing some incredibly basic tasks like file I/O (walking directory structures recursively, creating/updating/deleting files, etc), and I just couldn&#8217;t get going with it. After two to three hours working with it, I wasn&#8217;t even able to get basic function to walk a directory working.</p>

<p>So I decided to give Python a shot&#8230;</p>

<h2>Learning something new</h2>

<p>As a professional software developer, its a fairly widely held belief that its important to expand your skills by learning a new language each year. I&#8217;ve agreed with that sentiment ever since I first heard it, but I&#8217;ve never embraced it seriously enough to actually follow through and do it. I decided this (and another prospective side-project) was potentially a good opportunity to try to learn Python. <a href="http://twitter.com/brandonforreste">One of my best friends</a> has been a Python fanboy for quite a while now, and has often encouraged me to give it a shot, so I figured I would at least have one good resource to turn to if I got stuck on anything, but it turned out I didn&#8217;t need to. <a href="http://docs.python.org/">The online documentation for Python</a> is really good, with lots of good examples available as well. Overall it has taken me a total of probably around 10 hours work time to get Pyke to the state its in now, which I&#8217;m pretty happy with (though it still needs some work).</p>

<p>Also, I&#8217;m hosting the project on <a href="http://github.com">Github</a>, so it has had the additional bonus of being a great opportunity to get to learn <a href="http://en.wikipedia.org/wiki/Git_(software)">git</a> better, which is cool.</p>

<h2>What does it do?</h2>

<p>Another part of the reason why I decided to just roll my own was because my needs were really fairly straight forward. I don&#8217;t really need all that much from a build tool. My immediate needs were pretty simple:</p>

<ul>
<li><strong>Generate a version number</strong>: I just needed something that could automate the generation of a unique version number.</li>
<li><strong>Apply the version to assemblies</strong>: Find all of the AssemblyInfo files in a given directory structure, and create new ones with a set of custom assembly metadata applied.</li>
<li><strong>Compile to a custom output directory</strong>: Pretty simple, just compile a given solution or project, and push the output to a given directory.</li>
<li><strong>Generate a NuGet package</strong>: I wanted it to be able to build a <a href="http://docs.nuget.org/docs/start-here/overview">NuGet</a> package and upload it to an internal Nuget package feed (which, since its internal, really just means copying the generated package to a network share).</li>
<li><strong>Utility functions</strong>: I also need it to have a few basic utility functions for build cleanup and moving things around.</li>
</ul>


<p>Told ya&#8230;not really all that much to it. There are obviously a few more things that I&#8217;d like it to do when all is said and done (see the TODO list on <a href="http://github.com/ryexley/pyke">the github page</a>), but for now, its suiting my needs nicely. I&#8217;ve been actively working with it for the past week and it has done exactly what I asked of it, and given me no problems at all so far.</p>

<h2>How does it work?</h2>

<p>I&#8217;m working on getting some comprehensive usage samples put together for all of the features, but here is a stripped-down example that should at least give you a quick taste of how to use it.</p>

<p>First, you&#8217;ll need to download pyke.py (see the &#8220;How can I get it?&#8221; section below) and drop it in the folder that your build script will be in. No installation necessary, just stick it in the same folder, and reference it in your build script. Then, a build script (I call mine build.py) would look something like this.</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
<span class='line-number'>31</span>
<span class='line-number'>32</span>
<span class='line-number'>33</span>
<span class='line-number'>34</span>
<span class='line-number'>35</span>
<span class='line-number'>36</span>
<span class='line-number'>37</span>
<span class='line-number'>38</span>
<span class='line-number'>39</span>
<span class='line-number'>40</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>import pyke, os, shutil
</span><span class='line'>
</span><span class='line'>p = pyke.pyke(basedir = os.curdir)
</span><span class='line'>projectFile = "YourApp.csproj"
</span><span class='line'>version = p.getVersion()
</span><span class='line'>assemblyInfo = {
</span><span class='line'>  "ClsCompliant" : "false",
</span><span class='line'>  "ComVisible" : "false",
</span><span class='line'>  "Title" : "Your assembly title",
</span><span class='line'>  "Description" : "Some description for your assembly",
</span><span class='line'>  "Company" : "Your company here",
</span><span class='line'>  "Product" : "Your product name here",
</span><span class='line'>  "Copyright" : "Your copyright information here",
</span><span class='line'>  "Version" : "1.0",
</span><span class='line'>  "InformationalVersion" : version,
</span><span class='line'>  "FileVersion" : version
</span><span class='line'>}
</span><span class='line'>
</span><span class='line'># Build the web project in release configuration
</span><span class='line'>p.build(projectFile = projectFile, configuration = "release", assemblyInfo = assemblyInfo)
</span><span class='line'>
</span><span class='line'># Create a clean directory, with everything where it needs to be, in preparation for packaging
</span><span class='line'>packageSourceDir = os.path.join(p.basedir, "PackageSource")
</span><span class='line'>if not os.path.exists(packageSourceDir) :
</span><span class='line'>  os.makedirs(packageSourceDir)
</span><span class='line'>else :
</span><span class='line'>  p.cleanDir(packageSourceDir)
</span><span class='line'>
</span><span class='line'># Build Nuget package
</span><span class='line'>deploymentPackagesFolder = os.path.join(p.basedir, "DeploymentPackages")
</span><span class='line'>if not os.path.exists(deploymentPackagesFolder) :
</span><span class='line'>  os.makedirs(deploymentPackagesFolder)
</span><span class='line'>
</span><span class='line'>nb.packageNuget(targetDir = packageSourceDir, specName = os.path.splitext(projectFile)[0], version = version, outputDir = deploymentPackagesFolder)
</span><span class='line'>
</span><span class='line'># Cleanup
</span><span class='line'>p.cleanDir(p.buildOutputDir)
</span><span class='line'>p.cleanDir(packageSourceDir)
</span><span class='line'>os.rmdir(p.buildOutputDir)
</span><span class='line'>os.rmdir(packageSourceDir)</span></code></pre></td></tr></table></div></figure>


<p>Like I said, that&#8217;s a fairly basic example, and there are other options as well, but that&#8217;s a decent summary of the basics. Also understand that, build.py is obviously just another python script, so you can do anything you want/need in it to support your build process. Pyke just makes some of those things a little easier (at least I think so anyway).</p>

<h2>How can I get it?</h2>

<p>Pyke is <a href="http://github.com/ryexley/pyke">hosted on github</a>, so you can either clone the project, or just <a href="https://github.com/ryexley/Pyke/zipball/master">download the zip</a>, whichever you&#8217;re more comfortable with.</p>

<h2>Enough already&#8230;</h2>

<p>Yeah, I really need to wrap this up, I know. This ended up being a bit more long-winded than I had expected it would be&#8230;if you made it this far&#8230;congratulations&#8230;YOU HAVE NO LIFE!  :) No, seriously&#8230;thanks for taking the time to read about Pyke, and if you happen to have any more time&#8230;</p>

<p>One last thought&#8230;I&#8217;ll share the same disclaimer here that I added to the README on the project page:
<em>Pyke is <strong>literally</strong> the first python code I have <strong>ever</strong> written. I&#8217;m nearly 100% positive that there is a LOT of code in it that could probably be done better. <strong>Constructive feedback is always welcome</strong>.</em></p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Switching to Octopress]]></title>
    <link href="http://bob.yexley.net/switching-to-octopress"/>
    <updated>2012-01-21T21:58:00-05:00</updated>
    <id>http://bob.yexley.net/switching-to-octopress</id>
    <content type="html"><![CDATA[<p>I won&#8217;t spend a whole lot of time here trying to explain my reasons for why I&#8217;ve decided to port my blog over to <a href="http://octopress.org">Octopress</a>&#8230;most people that ever see it aren&#8217;t going to care anyway, and for the scarce few that might actually read it often enough to recognize the difference, if you&#8217;re really curious, I&#8217;ll leave it to you to ask if you are interested. The short of it is, Octopress brings a number of things to the table out of the box that I wanted in a blog platform that I&#8217;ve long felt I was fighting with <a href="http://wordpress.org">WordPress</a> to get. I still think WordPress is a fantastic platform for many, many scenarios&#8230;but Octopress does a number of things that are very appealing to a those of us with geek-like tendencies such as myself, which is why I&#8217;m making the switch.</p>

<p>The more important consequence of the port is going to be the impact on current feed subscribers (are there any? really?) and search engines, as some of my older content will go away, and my URL structure will end up being at least a little bit different. Different enough that people that find links to posts from my old blog through search engines may not find what they&#8217;re looking for immediately. I&#8217;ll do my best to get as much of my older content that generated interest ported over here as soon as possible, and maybe more importantly, get a good <a href="http://en.wikipedia.org/wiki/HTTP_404">404 page</a> setup as soon as possible too.</p>

<p>Ultimately my hope is that some of the things that it (Octopress) brings to the table will make it a little bit less painful for me to actually get on the ball and write some of the things I&#8217;ve been dying to write about (though I&#8217;m fairly certain that it <em>won&#8217;t</em> buy me any more time&#8230;which is ultimately one of the biggest hinderances to my writing). I&#8217;ve been working on and with some really fun stuff at work, and learning a lot from it, and I&#8217;d really like to share some of it and get some feedback on it from people I know are smarter than I. I&#8217;d like for my blog to be a two-way street where I can share and learn at the same time. Hopefully I can share enough to be able to make that happen.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Using Less CSS with Visual Studio and IIS Express]]></title>
    <link href="http://bob.yexley.net/using-less-css-with-visual-studio-and-iis-express"/>
    <updated>2011-04-27T15:47:00-04:00</updated>
    <id>http://bob.yexley.net/using-less-css-with-visual-studio-and-iis-express</id>
    <content type="html"><![CDATA[<p>I recently started working on a personal ASP.NET MVC project on which I wanted to use <a href="http://lesscss.org/">Less CSS</a> for styling. I quickly ran into a problem when I discovered that a <a href="http://learn.iis.net/page.aspx/868/iis-express-overview/">IIS Express</a> doesn&#8217;t have &#8220;.less&#8221; registered as a valid <a href="http://en.wikipedia.org/wiki/Internet_media_type">MIME type</a>, so it won&#8217;t serve up the file at all. So that forced me to dig around to figure out how to add a mimetype to the IIS Express configuration. I found a working solution, and thought it could potentially help someone else out.</p>

<p>To add the .less extension as a valid MIME type to IIS express follow these steps:</p>

<ol>
<li>Open a windows command prompt</li>
<li>Switch to the directory that IIS Express is installed in (on my 64 bit Windows 7 system, it was installed in C:\Program Files (x86)\IIS Express)</li>
<li>Execute the following command:</li>
</ol>


<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>appcmd set config /section:staticContent /+[fileExtension='.less',mimeType='text/css']</span></code></pre></td></tr></table></div></figure>


<p>Boom. Works great. Now I&#8217;m rollin&#8217; with Less CSS in my ASP.NET MVC project developing on IIS Express. Sweetness.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[jQuery ajax calls to ASP.NET MVC controller actions and Internet Explorer caching]]></title>
    <link href="http://bob.yexley.net/jquery-ajax-calls-to-asp-dot-net-mvc-controller-actions-and-internet-explorer-caching"/>
    <updated>2011-04-20T17:17:00-04:00</updated>
    <id>http://bob.yexley.net/jquery-ajax-calls-to-asp-dot-net-mvc-controller-actions-and-internet-explorer-caching</id>
    <content type="html"><![CDATA[<p>Over the past couple of days at work I&#8217;ve been working on getting a progress bar and some other elements of a page updated by making an ajax call with jQuery to an ASP.NET MVC (3) controller action. Everything was working great, with the exception of Internet Explorer (I&#8217;m currently using v9, but the issue we&#8217;ve been having is also known to exist in IE8 as well). The progress bar and all dynamically updated page elements were getting updated just fine in Google Chrome, Firefox (4) and Safari (5, for Windows), but Internet Explorer wouldn&#8217;t update any page elements after the first ajax call was completed.</p>

<p>So, as you can imagine, we spent a good amount of time Googling to try to figure out what might be the problem with IE. Somehow, one of my co-workers stumbled on an article (I actually think it was a StackOverflow thread, but I can&#8217;t be sure) that mentioned that the issue might have something to do with browser caching. So, we gave it a shot and disabled caching on the controller action, and everything started working fine in IE. St00pid IE.<!-- more --></p>

<p>So, here&#8217;s what we ultimately ended up with for the working solution. I realize, (as it seems so many things I do) it kinda feels like a bit of a hack, but it works. As always, feedback is welcome&#8230;</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
<span class='line-number'>31</span>
<span class='line-number'>32</span>
<span class='line-number'>33</span>
<span class='line-number'>34</span>
<span class='line-number'>35</span>
<span class='line-number'>36</span>
<span class='line-number'>37</span>
<span class='line-number'>38</span>
<span class='line-number'>39</span>
<span class='line-number'>40</span>
<span class='line-number'>41</span>
<span class='line-number'>42</span>
<span class='line-number'>43</span>
<span class='line-number'>44</span>
<span class='line-number'>45</span>
<span class='line-number'>46</span>
<span class='line-number'>47</span>
<span class='line-number'>48</span>
<span class='line-number'>49</span>
<span class='line-number'>50</span>
<span class='line-number'>51</span>
<span class='line-number'>52</span>
<span class='line-number'>53</span>
<span class='line-number'>54</span>
<span class='line-number'>55</span>
<span class='line-number'>56</span>
<span class='line-number'>57</span>
<span class='line-number'>58</span>
<span class='line-number'>59</span>
<span class='line-number'>60</span>
<span class='line-number'>61</span>
<span class='line-number'>62</span>
<span class='line-number'>63</span>
<span class='line-number'>64</span>
<span class='line-number'>65</span>
<span class='line-number'>66</span>
<span class='line-number'>67</span>
<span class='line-number'>68</span>
<span class='line-number'>69</span>
<span class='line-number'>70</span>
<span class='line-number'>71</span>
<span class='line-number'>72</span>
<span class='line-number'>73</span>
<span class='line-number'>74</span>
<span class='line-number'>75</span>
<span class='line-number'>76</span>
<span class='line-number'>77</span>
<span class='line-number'>78</span>
<span class='line-number'>79</span>
<span class='line-number'>80</span>
<span class='line-number'>81</span>
<span class='line-number'>82</span>
<span class='line-number'>83</span>
<span class='line-number'>84</span>
<span class='line-number'>85</span>
<span class='line-number'>86</span>
<span class='line-number'>87</span>
<span class='line-number'>88</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>// BatchStatus.js
</span><span class='line'>var pending = 0;
</span><span class='line'>var percentComplete = 0;
</span><span class='line'>
</span><span class='line'>$(function () {
</span><span class='line'>  $('.status-messaging').hide();
</span><span class='line'>  UpdateProgressBar(percentComplete);
</span><span class='line'>  GetStatus(statusUrl);
</span><span class='line'>});
</span><span class='line'>
</span><span class='line'>function GetStatus(url) {
</span><span class='line'>  $.ajax({
</span><span class='line'>    type: 'GET',
</span><span class='line'>    dataType: 'json',
</span><span class='line'>    url: url,
</span><span class='line'>    success: function (results) {
</span><span class='line'>      percentComplete = results.PercentComplete;
</span><span class='line'>      pending = results.Statuses['Pending'] != undefined ? results.Statuses['Pending'] : 0;
</span><span class='line'>      UpdateProgressBar(percentComplete);
</span><span class='line'>      UpdateCounts(results);
</span><span class='line'>    },
</span><span class='line'>    complete: function () { GetStatusComplete(); }
</span><span class='line'>  });
</span><span class='line'>}
</span><span class='line'>
</span><span class='line'>function GetStatusComplete() {
</span><span class='line'>  if (pending != 0 || percentComplete &lt; 100) {
</span><span class='line'>    GetStatus(statusUrl);
</span><span class='line'>  }
</span><span class='line'>}
</span><span class='line'>
</span><span class='line'>function UpdateProgressBar(percentComplete) {
</span><span class='line'>  $('#progressbar').progressbar({
</span><span class='line'>    value: percentComplete,
</span><span class='line'>    complete: function () { $('.status-messaging').fadeIn(); }
</span><span class='line'>  });
</span><span class='line'>}
</span><span class='line'>
</span><span class='line'>function UpdateCounts(results) {
</span><span class='line'>  var currentPending = results.Statuses['Pending'] != undefined ? results.Statuses['Pending'] : 0;
</span><span class='line'>  var currentComplete = results.Statuses['Succeeded'] != undefined ? results.Statuses['Succeeded'] : 0;
</span><span class='line'>  var currentFailed = results.Statuses['Failed'] != undefined ? results.Statuses['Failed'] : 0;
</span><span class='line'>
</span><span class='line'>  $('.attributes-table tr.status-normal td:nth-child(2)').html(currentPending);
</span><span class='line'>  $('.attributes-table tr.status-completed td:nth-child(2)').html(currentComplete);
</span><span class='line'>  $('.attributes-table tr.status-failed td:nth-child(2)').html(currentFailed);
</span><span class='line'>}
</span><span class='line'>
</span><span class='line'>// StatusController.cs
</span><span class='line'>[HttpGet]
</span><span class='line'>[NoCache]
</span><span class='line'>public virtual JsonResult GetBatchStatus(long id)
</span><span class='line'>{
</span><span class='line'>    var result = new BatchStatus();
</span><span class='line'>    var status = _batchServiceClient.GetBatchEditProgress(id);
</span><span class='line'>
</span><span class='line'>    foreach (var batchResult in status)
</span><span class='line'>        result.Statuses.Add(batchResult.Status, batchResult.Count);
</span><span class='line'>
</span><span class='line'>    var total = result.Statuses.Sum(r => r.Value);
</span><span class='line'>
</span><span class='line'>    if (result.Statuses.ContainsKey("Pending"))
</span><span class='line'>        result.PercentComplete = Convert.ToInt32(System.Math.Round((float)((total - result.Statuses["Pending"]) * 100) / total));
</span><span class='line'>    else
</span><span class='line'>        result.PercentComplete = 100;
</span><span class='line'>    return Json(result, JsonRequestBehavior.AllowGet);
</span><span class='line'>}
</span><span class='line'>
</span><span class='line'>// NoCacheAttribute.cs
</span><span class='line'>public class NoCacheAttribute : ActionFilterAttribute, IActionFilter
</span><span class='line'>{
</span><span class='line'>    public override void OnResultExecuting(ResultExecutingContext filterContext)
</span><span class='line'>    {
</span><span class='line'>        filterContext.HttpContext.Response.Cache.SetExpires(DateTime.Now.AddDays(-1));
</span><span class='line'>        filterContext.HttpContext.Response.Cache.SetValidUntilExpires(false);
</span><span class='line'>        filterContext.HttpContext.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
</span><span class='line'>        filterContext.HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);
</span><span class='line'>        filterContext.HttpContext.Response.Cache.SetNoServerCaching();
</span><span class='line'>        filterContext.HttpContext.Response.Cache.SetNoStore();
</span><span class='line'>
</span><span class='line'>        base.OnResultExecuting(filterContext);
</span><span class='line'>    }
</span><span class='line'>
</span><span class='line'>    public override void OnResultExecuted(ResultExecutedContext filterContext)
</span><span class='line'>    {
</span><span class='line'>        base.OnResultExecuted(filterContext);
</span><span class='line'>    }
</span><span class='line'>}</span></code></pre></td></tr></table></div></figure>



]]></content>
  </entry>
  
</feed>

