<?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/"
	>

<channel>
	<title>Justin DuJardin</title>
	<atom:link href="http://www.justindujardin.com/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.justindujardin.com/blog</link>
	<description>&#124;O_o&#124; &#124;x_X&#124; &#124;-_-&#124; &#124;o_O&#124;</description>
	<lastBuildDate>Sun, 27 Jun 2010 15:41:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Getting Back To My Roots</title>
		<link>http://www.justindujardin.com/blog/?p=1155</link>
		<comments>http://www.justindujardin.com/blog/?p=1155#comments</comments>
		<pubDate>Sat, 12 Jun 2010 19:56:00 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[House]]></category>
		<category><![CDATA[Meditation]]></category>

		<guid isPermaLink="false">http://www.justindujardin.com/blog/?p=1155</guid>
		<description><![CDATA[This spring has been a great opportunity to get out into my yard and do some much needed maintenance.   In the past I would have hired someone to come out and take care of these things for me, but this year I have been consciously seeking out home maintenance activities that I can find enjoyment [...]]]></description>
			<content:encoded><![CDATA[<p>This spring has been a great opportunity to get out into my yard and do some much needed maintenance.   In the past I would have hired someone to come out and take care of these things for me, but this year I have been consciously seeking out home maintenance activities that I can find enjoyment in.</p>
<p>It has been almost two months now, and I&#8217;ve been making regular visits to my yard, working away bit by bit, stopping when my yard waste container is full.   As I&#8217;ve been weeding, dead-heading, raking, and trimming, I have realized something quite amazing.  Each time I take on work in the yard, I feel a strange sense of calm come over me, and I unintentionally end up losing hours in it.  Put simply, I love it.</p>
<p>This is somewhat uncharacteristic of me, so I have been meditating on why it is that I find myself so feeling so fulfilled while working in the yard.  Certainly it could just be that I&#8217;m getting older and more mature, but I find such explanations to be unsatisfying.  The truth that I have come to realize is that it gives me an opportunity to view life from a completely different perspective, one of plants and bugs.<span id="more-1155"></span></p>
<p>While working in the yard all of my concerns in life seem less pressing.  To be clear, they do not go away as if being ignored in favor of distracting myself with something else, but rather they simply seem to loosen their grip on me.   I can spend hours quietly contemplating my life, and all the things I normally would; but given the continually surprising perspective on life that I run into, it&#8217;s much harder to get bogged down under the apparent weight of it all.</p>
<p>Working in my yard I am able to connect with life in ways that I rarely get to otherwise.  I now better understand why so many great minds find comfort in gardening.  What a fantastic venue for quiet meditation and exercise.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.justindujardin.com/blog/?feed=rss2&amp;p=1155</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Implicit Types (var) in C#</title>
		<link>http://www.justindujardin.com/blog/?p=1017</link>
		<comments>http://www.justindujardin.com/blog/?p=1017#comments</comments>
		<pubDate>Wed, 09 Jun 2010 01:22:57 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Philosophy]]></category>

		<guid isPermaLink="false">http://www.justindujardin.com/blog/?p=1017</guid>
		<description><![CDATA[After some thought I&#8217;ve come up with two simple rules to go by when using implicitly typed variables to make sure that you don&#8217;t end up seeing their nasty, code obfuscating side.  But I&#8217;m getting ahead of myself, first the important question that someone is bound to not be asking right about now:
What are Implicit [...]]]></description>
			<content:encoded><![CDATA[<p>After some thought I&#8217;ve come up with two simple rules to go by when using implicitly typed variables to make sure that you don&#8217;t end up seeing their nasty, code obfuscating side.  But I&#8217;m getting ahead of myself, first the important question that someone is bound to not be asking right about now:</p>
<p><strong>What are Implicit Types?</strong></p>
<pre class="brush: csharp;">
// Explicit
List&lt;string&gt; userNames = new List&lt;string&gt;();

// Implicit
var userNames = new List&lt;string&gt;();
</pre>
<p>Implicit types in C# are basically placeholder types that the compiler figures out for you.  They may hold any type to begin with, but once they are assigned a value of a certain type, that type is noted by the compiler and will error if you try to assign a different type later.</p>
<pre class="brush: csharp;">
// Okay! quote is being assigned a string value
var quote = &quot;Things that try to look like things often do look more like things than things.&quot;;

// Compile Error! Cannot convert source type 'float' to target type 'string'
quote = 4.0f;
</pre>
<p><strong><span id="more-1017"></span>When are Implicit Types Bad?</strong><br />
The use of implicit types becomes a problem when a type cannot be determined without access to external or non-local bits of code.  Here&#8217;s an example of what I mean; are you able to tell me what type will be printed to the console below assuming that the elem is valid?</p>
<pre class="brush: csharp;">
// Allow the compiler to determine the type
var elem = _listOfElements[idx];

// What type will be printed here?
Console.WriteLine(elem.GetType());
</pre>
<p><strong>When are Implicit Types Useful?</strong></p>
<p>The thing I&#8217;ve found implicit types most useful for is saving keystrokes and making refactoring large swaths of code easier.  Consider the following example to illustrate why this can be useful.  It is notable that if you&#8217;re the compiler, these statements end up being exactly the same.</p>
<pre class="brush: csharp;">
// Explicit
Dictionary&lt;string, Luggage&gt; thisDict = new Dictionary&lt;string, Luggage&gt;();

// Implicit
var thatDict = new Dictionary&lt;string, Luggage&gt;();
</pre>
<p>Not only does the implicitly typed variable take fewer keystrokes to type out initially, but if you have to change the type of the variable at a later point you only need to change it once, rather than changing it on both sides.   The real impact here is time saved when changing tens or hundreds of occurrences of complex type variables like this across many files.</p>
<p><strong>Two Rules.</strong></p>
<p>I mentioned at the top that I had come up with two rules for making sure that you get all the upsides and none of the downsides of implicit typing, so here they are:</p>
<blockquote><p>1. Only use implicit typing when the type can be readily determined by looking at the local context surrounding the line.</p>
<p>2. Never use implicit types on numbers.</p></blockquote>
<p>By following these two simple rules, you&#8217;ll reduce the number of keystrokes you have to type, as well as maintain the ability to determine the type correctly without Intellisense (e.g. Code snippets in a webpage.)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.justindujardin.com/blog/?feed=rss2&amp;p=1017</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Canvas Element Positioning Performance</title>
		<link>http://www.justindujardin.com/blog/?p=1076</link>
		<comments>http://www.justindujardin.com/blog/?p=1076#comments</comments>
		<pubDate>Thu, 13 May 2010 00:32:19 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Canvas]]></category>
		<category><![CDATA[DependencyProperty]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Silverlight 3]]></category>

		<guid isPermaLink="false">http://www.justindujardin.com/blog/?p=1076</guid>
		<description><![CDATA[C# and Silverlight provide a rich set of layout controls that can be used in constructing elegant user interfaces, including a do-it-yourself Canvas class that allows you to manually position elements on it&#8217;s surface.
Positioning Elements in Code

With a Canvas you&#8217;re almost always going to want to have some code that positions the child elements.  To [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">C# and Silverlight provide a rich set of layout controls that can be used in constructing elegant user interfaces, including a do-it-yourself <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.canvas.aspx" target="_blank">Canvas</a> class that allows you to manually position elements on it&#8217;s surface.</p>
<p style="text-align: left;"><a href="http://www.justindujardin.com/blog/wp-content/uploads/2010/05/Silverlight_Canvas_Element_Positioning.jpg"><img class="size-medium wp-image-1078 alignright" title="Canvas Positioning    Performance" src="http://www.justindujardin.com/blog/wp-content/uploads/2010/05/Silverlight_Canvas_Element_Positioning-300x236.jpg" alt="" width="300" height="236" /></a><strong>Positioning Elements in Code<br />
</strong></p>
<p style="text-align: left;">With a Canvas you&#8217;re almost always going to want to have some code that positions the child elements.  To move things about, the property you are concerned with is not, as you might expect, a Position or Left/Top property on the child element, but rather it is a property of the Canvas that can be set on a child element.</p>
<p style="text-align: left;">There are two ways I have seen used to set the Canvas.Left or Canvas.Top property on a child element, and in some cases you&#8217;ll want to distinguish between the two.</p>
<p style="text-align: left;">The first way is to call SetValue on the Child element with the DependencyProperty  you want to set, Canvas.LeftProperty or Canvas.TopProperty.   The second way is to call Canvas.SetLeft or  Canvas.SetTop and pass in the UIElement to set it on.</p>
<p style="text-align: left;"><span id="more-1076"></span></p>
<p style="text-align: left;"><strong>When Speed Matters</strong></p>
<p style="text-align: left;">In some situations it can be helpful to understand the difference in performance of the various ways of setting these properties.</p>
<p style="text-align: left;">I could not find any information comparing the performance of these two methods so I wrote a small unit test (below) that could tell me which was faster.  It turns out that on average, calling the Canvas.SetLeft/SetTop methods are about 3 times faster than calling Element.SetValue with the DependencyProperty.</p>
<p style="text-align: left;">When you think about that for a moment, it begins to make sense, because the Element.SetValue method takes a DependencyProperty and a value, which means that it resolve the property to end up at it&#8217;s destination.  On the other hand the SetLeft/SetTop methods already know what data they&#8217;re setting (they even explicitly specify it in the naming!), which means they should have a pretty direct path to the data.</p>
<p style="text-align: left;"><strong>Testing Performance</strong></p>
<p>I&#8217;ve provided  below the source code that I used to generate the data  for this graph so you can try it for yourself.</p>
<table style="height: 108px;" border="0" cellspacing="0" cellpadding="3" width="412">
<tbody>
<tr style="text-align: center;">
<td></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">1,000,000</span></span></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">500,000</span></span></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">100,000</span></span></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">10,000</span></span></td>
</tr>
<tr>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">Canvas.SetLeft</span></span></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">446</span></span></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">220</span></span></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">46</span></span></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">5</span></span></td>
</tr>
<tr>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">Canvas.SetTop</span></span></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">456</span></span></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">222</span></span></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">46</span></span></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">5</span></span></td>
</tr>
<tr>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">Canvas.LeftProperty<br />
</span></span></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">1361</span></span></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">683</span></span></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">139</span></span></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">18</span></span></td>
</tr>
<tr>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">Canvas.TopProperty<br />
</span></span></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">1354</span></span></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">680</span></span></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">137</span></span></td>
<td><span style="font-family: arial,sans,sans-serif;"><span style="font-size: x-small;">14</span></span></td>
</tr>
</tbody>
</table>
<pre class="brush: csharp;">
public void TestCanvasElementPositioning()
{
   long elapsedSetValueTop = 0;
   long elapsedSetTop = 0;
   long elapsedSetValueLeft = 0;
   long elapsedSetLeft = 0;
   var timer = new Stopwatch();

   var testCanvas = new Canvas();
   var testChild = new Ellipse();
   testCanvas.Children.Add(testChild);

   // How many iterations to time
   const long iterations = 10000;

   // Canvas.SetLeft
   timer.Start();
   for (int i = 0; i &lt; iterations; i++)
      Canvas.SetLeft(testChild, (double)i % 10);
   timer.Stop();
   elapsedSetLeft = timer.ElapsedMilliseconds;
   timer.Reset();

   // Element.SetValue(Canvas.LeftProperty)
   timer.Start();
   for (int i = 0; i &lt; iterations; i++)
      testChild.SetValue(Canvas.LeftProperty, (double)i % 10);
   timer.Stop();
   elapsedSetValueLeft = timer.ElapsedMilliseconds;
   timer.Reset();

   testCanvas = new Canvas();
   testChild = new Ellipse();
   GC.Collect();

   // Element.SetValue(Canvas.TopProperty)
   timer.Start();
   for (int i = 0; i &lt; iterations; i++)
      testChild.SetValue(Canvas.TopProperty, (double)i % 10);
   timer.Stop();
   elapsedSetValueTop = timer.ElapsedMilliseconds;
   timer.Reset();

   // Canvas.SetTop
   timer.Start();
   for (int i = 0; i &lt; iterations; i++)
      Canvas.SetTop(testChild, (double)i % 10);
   timer.Stop();
   elapsedSetTop = timer.ElapsedMilliseconds;
   timer.Reset();

   Assert.IsTrue(elapsedSetLeft &lt; elapsedSetValueLeft,
                 &quot;Expected SetLeft to be less than SetValue&quot;);
   Assert.IsTrue(elapsedSetTop &lt; elapsedSetValueTop,
                 &quot;Expected SetTop to be less than SetValue&quot;);
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.justindujardin.com/blog/?feed=rss2&amp;p=1076</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom Metadata tags in C# code</title>
		<link>http://www.justindujardin.com/blog/?p=983</link>
		<comments>http://www.justindujardin.com/blog/?p=983#comments</comments>
		<pubDate>Sun, 28 Mar 2010 19:36:59 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Things I Like]]></category>
		<category><![CDATA[Attribute]]></category>
		<category><![CDATA[Metadata]]></category>

		<guid isPermaLink="false">http://www.justindujardin.com/blog/?p=983</guid>
		<description><![CDATA[Some dynamic languages like C# and ActionScript allow you to put metadata inline with your code.  Metadata can be a really cool way to make extra data available to you at runtime.  To make full use of it, you need to know how to specify this metadata and then how to access it.
MetadataSample.cs
The sample below [...]]]></description>
			<content:encoded><![CDATA[<p>Some dynamic languages like C# and ActionScript allow you to put metadata inline with your code.  Metadata can be a really cool way to make extra data available to you at runtime.  To make full use of it, you need to know how to specify this metadata and then how to access it.</p>
<p><strong>MetadataSample.cs</strong></p>
<p>The sample below shows how to specify a custom Attribute called &#8220;SomeExtraData&#8221;, use it on a class &#8220;SomeClass&#8221; and retrieve the custom data in code for further use.<br />
<strong><br />
</strong></p>
<pre class="brush: csharp; wrap-lines: false;">
using System;
using System.Diagnostics;

namespace SilverShorts
{
   // This class makes the [SomeExtraData] tag below valid
   class SomeExtraData : Attribute
   {
      public string SomeField;
   }

   // Tag this class with a custom attribute
   [SomeExtraData (SomeField=&quot;SomeValue&quot;)]
   class SomeClass
   {
      public SomeClass()
      {
         // Retrieve the value of the SomeField item in the metadata
         // tag on this class.
         Type t = typeof(SomeClass);
         SomeExtraData attr = t.GetCustomAttributes(false)[0] as SomeExtraData;
         Debug.WriteLine(&quot;SomeExtraData.SomeField = &quot; + attr.SomeField);
      }
   }
}
</pre>
<p><strong>A word of caution</strong>: Be aware of how often you perform operations like querying custom attributes in the constructor above.  The system reflection calls can negatively impact performance if you abuse them.  I won&#8217;t preach about it, just use them only when you need to.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.justindujardin.com/blog/?feed=rss2&amp;p=983</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Silverlight 3, LINQ, and Bing! Oh, my!</title>
		<link>http://www.justindujardin.com/blog/?p=724</link>
		<comments>http://www.justindujardin.com/blog/?p=724#comments</comments>
		<pubDate>Wed, 10 Mar 2010 02:09:09 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Bing]]></category>
		<category><![CDATA[Image Query]]></category>
		<category><![CDATA[Linq to Xml]]></category>
		<category><![CDATA[Silverlight 3]]></category>

		<guid isPermaLink="false">http://www.justindujardin.com/blog/?p=724</guid>
		<description><![CDATA[In my last post I talked about Silver Shorts and showed off my example Bing Image search application.
For this post I want to go over the code that I created for doing a Bing image query, to demonstrate just how powerful and concise Silverlight 3 C# code can be.  To truly appreciate this, I [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.bing.com/"><img class="size-medium wp-image-879 alignright" title="Microsoft Bing" src="http://www.justindujardin.com/blog/wp-content/uploads/2010/03/bingLogo_lg-300x231.jpg" alt="" width="144" height="111" /></a>In my <a href="http://www.justindujardin.com/blog/?p=764">last post</a> I talked about Silver Shorts and showed off my<a href="http://www.justindujardin.com/blog/?p=764"> example Bing Image search application</a>.</p>
<p>For this post I want to <a title="Get the Silver Shorts Code" href="http://github.com/justindujardin/SilverShorts" target="_blank">go over the code</a> that I created for doing a Bing image query, to demonstrate just how powerful and concise Silverlight 3 C# code can be.  To truly appreciate this, I suggest <a title="Get the Silver Shorts Code" href="http://github.com/justindujardin/SilverShorts" target="_blank">checking out the code</a>, which totals about 225 lines for both the Image Search utility AND the Test Application.</p>
<p>To get started, let&#8217;s enumerate the requirements I came up with for the project:</p>
<ol>
<li>Image Search
<ul>
<li>Bing Image query based on textual search terms</li>
<li>Transform XML results into custom classes</li>
</ul>
</li>
</ol>
<p>We&#8217;ll refer back to these requirements as we build the code to make sure we stay on track.</p>
<p><span id="more-724"></span></p>
<h2>Image Search</h2>
<p>The image search has two parts, performing the query, and processing/returning the results.  C#, Silverlight, and LINQ to XML will make this a pretty trivial task for us.</p>
<p>We&#8217;re going to start by creating a static class to contain our image query code.  We&#8217;re creating a static class in this case because we will have no member data to store, and will have only one public method (Search) to access.  Here&#8217;s what it will look like as an outline, notice that it appears to conform to the goals for #1 above, that is, in its definition it contains a method for performing a query, and a private method for processing the results.</p>
<pre class="brush: csharp; highlight: [3,7,8,12]; wrap-lines: false;">
namespace djc.SilverShorts.Bing
{
   public class ImageResult {}
   static class ImageQuery
   {
      #region Public Search Interface
      public delegate void SearchResultCallback(List&lt;ImageResult&gt; results);
      static public void Search(string appId, string search, SearchResultCallback callback, int numImages = 10, int offsetIndex = 0, bool useSafeSearch = true) {}
      #endregion

      #region Xml to Object LINQ
      static private void _processXmlResults(string xml, SearchResultCallback callback) {}
      #endregion
   }
}
</pre>
<h2>Bing Image query based on textual search terms</h2>
<p>First we need to create a formatted Url string that the Bing service can understand, then we need to create a WebClient object and use it&#8217;s DownloadStringAsync method to perform the query.  Once we&#8217;ve done this, our new Search method looks like so:</p>
<pre class="brush: csharp; wrap-lines: false;">
      static public void Search(string appId, string search, SearchResultCallback callback, int numImages = 10, int offsetIndex = 0, bool useSafeSearch = true)
      {
         string requestString = &quot;http://api.bing.net/xml.aspx?&quot;
             + &quot;AppId=&quot; + appId
             + &quot;&amp;Query=&quot; + search
             + &quot;&amp;Sources=Image&quot;
             + &quot;&amp;Version=2.0&quot;
             + &quot;&amp;Market=en-us&quot;
             + (useSafeSearch ? &quot;&amp;Adult=Moderate&quot; : &quot;&quot;)
             + &quot;&amp;Image.Count=&quot; + numImages.ToString()
             + &quot;&amp;Image.Offset=&quot; + offsetIndex.ToString();
         Uri uri = new Uri(requestString, UriKind.Absolute);
         WebClient client = new WebClient();
         client.DownloadStringCompleted += _downloadStringCompleted;
         // Note that we're passing the callback delegate as user data
         client.DownloadStringAsync(uri, callback);
      }
</pre>
<blockquote><p>We&#8217;ve got a few hardcoded bits in here. For a more complete Bing query API implementation, see <a href="http://bingsharp.codeplex.com/" target="_blank">Bing Sharp</a>.</p></blockquote>
<p>The astute reader will note that we&#8217;ve registered a callback event handler function called _downloadStringCompleted that doesn&#8217;t exist in our initial class outline.  We&#8217;ll need to create this and use this event handler to trigger our _processXmlResults method.  We&#8217;ll make sure there was no error in the network query, and that a valid callback has been specified, then hand off control to our second bit of code that will transform the XML into custom class data.</p>
<pre class="brush: csharp; wrap-lines: false;">
      static private void _downloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
      {
         SearchResultCallback callback = e.UserState as SearchResultCallback;
         if (e.Error != null || callback == null)
            return;

         _processXmlResults(e.Result.ToString(), callback);
      }
</pre>
<h2>Transform XML results into custom classes</h2>
<p>At this point we&#8217;re ready to get into parsing the Bing XML  string into custom class data. Before we get there, let&#8217;s take a look at what the XML we&#8217;re going to be parsing will look like.  This structure will also inform how we implement our custom classes to hold the information we&#8217;ve retrieved.</p>
<p><strong>Bing Result XML Example</strong></p>
<pre class="brush: xml; highlight: [7,11,19]; wrap-lines: false;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
&lt;?pageview_candidate?&gt;
&lt;SearchResponse xmlns=&quot;http://schemas.microsoft.com/LiveSearch/2008/04/XML/element&quot; Version=&quot;2.0&quot;&gt;
   &lt;Query&gt;
      &lt;SearchTerms&gt;Waffles&lt;/SearchTerms&gt;
   &lt;/Query&gt;
   &lt;mms:Image xmlns:mms=&quot;http://schemas.microsoft.com/LiveSearch/2008/04/XML/multimedia&quot;&gt;
      &lt;mms:Total&gt;1200000&lt;/mms:Total&gt;
      &lt;mms:Offset&gt;0&lt;/mms:Offset&gt;
      &lt;mms:Results&gt;
         &lt;mms:ImageResult&gt;
            &lt;mms:Title&gt;Thank goodness for waffles&lt;/mms:Title&gt;
            &lt;mms:MediaUrl&gt;http://www.digsmagazine.com/images/nourisharticles/waffles.jpg&lt;/mms:MediaUrl&gt;
            &lt;mms:Url&gt;http://dwoolstar.blogspot.com/2005_05_01_archive.html&lt;/mms:Url&gt;
            &lt;mms:DisplayUrl&gt;http://dwoolstar.blogspot.com/2005_05_01_archive.html&lt;/mms:DisplayUrl&gt;
            &lt;mms:Width&gt;150&lt;/mms:Width&gt;
            &lt;mms:Height&gt;200&lt;/mms:Height&gt;
            &lt;mms:FileSize&gt;6895&lt;/mms:FileSize&gt;
            &lt;mms:Thumbnail&gt;
               &lt;mms:Url&gt;http://ts1.mm.bing.net/images/thumbnail.aspx?q=1383735232706&amp;amp;id=4778a42319f15e572deaa592c12334c5&lt;/mms:Url&gt;
               &lt;mms:ContentType&gt;image/jpeg&lt;/mms:ContentType&gt;
               &lt;mms:Width&gt;120&lt;/mms:Width&gt;
               &lt;mms:Height&gt;160&lt;/mms:Height&gt;
               &lt;mms:FileSize&gt;4218&lt;/mms:FileSize&gt;
            &lt;/mms:Thumbnail&gt;
         &lt;/mms:ImageResult&gt;
      &lt;/mms:Results&gt;
   &lt;/mms:Image&gt;
&lt;/SearchResponse&gt;
</pre>
<p>Now that we see the general information available to us, it&#8217;s time to go back to our empty ImageResult class that we defined above, and give it some meat.  We&#8217;re only concerned with the ImageResult elements and their children in this case, so we&#8217;ll copy them pretty directly.  The result looks like this:</p>
<p><strong>Custom ImageResult class</strong></p>
<pre class="brush: csharp; wrap-lines: false;">
   public class ImageResult
   {
      public string Title;
      public string MediaUrl;
      public string Url;
      public string DisplayUrl;
      public int Width;
      public int Height;
      public int FileSize;
      public class Thumbnail
      {
         public string Url;
         public string ContentType;
         public int Width;
         public int Height;
         public int FileSize;
      }
      public Thumbnail Thumb;
   }
</pre>
<p>Take a moment to look over the two codeblocks above and note the similarities in structure.   Once you see it, continue to the codeblock below and try to recognize the same similarities in structure.</p>
<p><strong>NOTE:</strong> It&#8217;s important to note that the C# classes I have do NOT need to have a direct mapping of member variable names to the XML elements we&#8217;ll be pulling data from.  To make this more clear, consider that the XML element for a thumbnail is &#8220;Thumbnail&#8221;, and our custom class variable is called &#8220;Thumb&#8221;.  Consider further that I could have called it SmallImage, Pinkynail, Luggage, or anything else and accounted for it accordingly in the LINQ query below.</p>
<p><strong>Using LINQ to transform XML</strong></p>
<p>Finally we&#8217;re to the point that we&#8217;re ready to take our XML and turn it into something that we can use in our Silverlight application somewhat generically.  Let us take a staged-approach to understanding the final, complex, nested query.  First we&#8217;ll look at a simpler query, then a more complex query, and finally we&#8217;ll put it all together into the actual query that jives with our intention and requirements.</p>
<p><strong>A Simple Query</strong></p>
<p>To better understand the final more complex query, let us consider a simpler query that doesn&#8217;t have a nested sub-query for thumbnails, and also does not have namespace&#8217;d elements.  It would look  like this:</p>
<pre class="brush: csharp; wrap-lines: false;">
var imageResults =
   // For each XML Element (ir) in the XML Document (doc.Descendants)
   from ir in doc.Descendants()
   // If the name is &quot;ImageResult&quot;
   where ir.Name.Equals(&quot;ImageResult&quot;)
   // Create a new ImageResult object
   select new ImageResult()
   {
      // Strings
      Title = ir.Element(&quot;Title&quot;).Value,
      MediaUrl = ir.Element(&quot;MediaUrl&quot;).Value,
      Url = ir.Element(&quot;Url&quot;).Value,
      DisplayUrl = ir.Element(&quot;DisplayUrl&quot;).Value,
      // Integers
      Width = Int32.Parse(ir.Element(&quot;Width&quot;).Value),
      Height = Int32.Parse(ir.Element(&quot;Height&quot;).Value),
      FileSize = Int32.Parse(ir.Element(&quot;FileSize&quot;).Value),
      Thumb = new ImageResult.Thumbnail()
   };
</pre>
<p><strong>A Slightly Less Simple Query</strong><br />
Once we understand what the above simplified query does, let us layer another bit of complexity on top of it, adding back in the Thumbnail objects nested query.  The query then looks like this:</p>
<pre class="brush: csharp; wrap-lines: false;">
   // For each XML Element (ir) in the XML Document (doc.Descendants)
   from ir in doc.Descendants()
   // If the name is &quot;ImageResult&quot;
   where ir.Name.Equals(&quot;ImageResult&quot;)
   // Create a new ImageResult object
   select new ImageResult()
   {
      Title = ir.Element(&quot;Title&quot;).Value,
      MediaUrl = ir.Element(&quot;MediaUrl&quot;).Value,
      Url = ir.Element(&quot;Url&quot;).Value,
      DisplayUrl = ir.Element(&quot;DisplayUrl&quot;).Value,
      Width = Int32.Parse(ir.Element(&quot;Width&quot;).Value),
      Height = Int32.Parse(ir.Element(&quot;Height&quot;).Value),
      FileSize = Int32.Parse(ir.Element(&quot;FileSize&quot;).Value),
      Thumb =
          // for each XML element (th) in the XML element (ir)'s Descendants
         (from th in ir.Descendants()
          // If the name is &quot;Thumbnail&quot;
          where th.Name.Equals(&quot;Thumbnail&quot;)
          // Create a new ImageResult.Thumbnail
          select new ImageResult.Thumbnail()
          {
             Url = th.Element(&quot;Url&quot;).Value,
             ContentType = th.Element(&quot;ContentType&quot;).Value,
             Width = Int32.Parse(th.Element(&quot;Width&quot;).Value),
             Height = Int32.Parse(th.Element(&quot;Height&quot;).Value),
             FileSize = Int32.Parse(th.Element(&quot;FileSize&quot;).Value)
          }).Single(), // &lt;-- Only one result for this sub-query
   };
</pre>
<p><strong>The Full <span style="text-decoration: line-through;">Monty</span> Query<span style="text-decoration: line-through;"><br />
</span></strong></p>
<p>Got it? Good.  Finally we add back in the namespace information, and the query becomes slightly more verbose (though not necessarily more complex).</p>
<pre class="brush: csharp; wrap-lines: false;">
// Parse the XML response text
XDocument doc = XDocument.Parse(xml);

// Elements in the response all conform to this schema and have a namespace prefix of mms:
// For our LINQ query to work properly, we must use mmsNs + ElementName
XNamespace mmsNs = XNamespace.Get(&quot;http://schemas.microsoft.com/LiveSearch/2008/04/XML/multimedia&quot;);

// Build a LINQ query to parse the XML data into our custom ImageResult objects
var imageResults =
   from ir in doc.Descendants()
   where ir.Name.Equals(mmsNs + &quot;ImageResult&quot;)
   select new ImageResult()
   {
      Title = ir.Element(mmsNs + &quot;Title&quot;).Value,
      MediaUrl = ir.Element(mmsNs + &quot;MediaUrl&quot;).Value,
      Url = ir.Element(mmsNs + &quot;Url&quot;).Value,
      DisplayUrl = ir.Element(mmsNs + &quot;DisplayUrl&quot;).Value,
      Width = Int32.Parse(ir.Element(mmsNs + &quot;Width&quot;).Value),
      Height = Int32.Parse(ir.Element(mmsNs + &quot;Height&quot;).Value),
      FileSize = Int32.Parse(ir.Element(mmsNs + &quot;FileSize&quot;).Value),

      Thumb =
         (from th in ir.Descendants()
          where th.Name.Equals(mmsNs + &quot;Thumbnail&quot;)
          select new ImageResult.Thumbnail()
          {
             Url = th.Element(mmsNs + &quot;Url&quot;).Value,
             ContentType = th.Element(mmsNs + &quot;ContentType&quot;).Value,
             Width = Int32.Parse(th.Element(mmsNs + &quot;Width&quot;).Value),
             Height = Int32.Parse(th.Element(mmsNs + &quot;Height&quot;).Value),
             FileSize = Int32.Parse(th.Element(mmsNs + &quot;FileSize&quot;).Value)
          }).Single(),
   };

// Execute the LINQ query and stuff the results into our list
results = imageResults.ToList();
</pre>
<p>That does it for the requirements of this demo.  If anything in this post could use clarification, please let me know.</p>
<h4>Silver Shorts : <a href="http://github.com/justindujardin/SilverShorts" target="_blank">Get  the Code on GitHub.com</a></h4>
]]></content:encoded>
			<wfw:commentRss>http://www.justindujardin.com/blog/?feed=rss2&amp;p=724</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Project Silver Shorts</title>
		<link>http://www.justindujardin.com/blog/?p=764</link>
		<comments>http://www.justindujardin.com/blog/?p=764#comments</comments>
		<pubDate>Sat, 06 Mar 2010 21:18:25 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://www.justindujardin.com/blog/?p=764</guid>
		<description><![CDATA[Last week I decided to install the Visual Studio 2010 RC for the purposes of messing around with  C#, Silverlight 3, and all the new WPF goodness that came with it.  I only intended  to dabble for a day or so, but ended up having my entire week consumed in what seemed like a [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.silverlight.net/"><img class="size-medium wp-image-867 alignright" title="Microsoft Silverlight" src="http://www.justindujardin.com/blog/wp-content/uploads/2010/03/silverlight_detail-300x222.jpg" alt="" width="192" height="142" /></a>Last week I decided to install the <a href="http://www.microsoft.com/visualstudio/en-us/products/2010/default.mspx" target="_blank">Visual Studio 2010 RC</a> for the purposes of messing around with  C#, <a title="Silverlight 3 : Official Site" href="http://silverlight.net/getstarted/silverlight3/">Silverlight 3</a>, and all the new WPF goodness that came with it.  I only intended  to dabble for a day or so, but ended up having my entire week consumed in what seemed like a moment.</p>
<p>If you have Silverlight installed, you can view the end result of my first experiment after the page break.  It is a simple Bing image searcher that displays thumbnails of the results on a canvas.</p>
<p><strong>What is Project Silver Shorts?</strong></p>
<p>More than anything Silver Shorts is an idea, a codename for a collection of demos in C#, most of which have yet to be written, targeting <strong>Silver</strong>light 3, that are intended to be <strong>Short</strong>.  As I stumble and bumble my way around .NET, finding new and interesting things to do with it, I will make my experiments available with full source code on GitHub (skip to the bottom if all you care about is code.)</p>
<p>For the developers in the audience, let&#8217;s take a look at a simple LINQ query I have fabricated to summarize the goals of Silver Shorts while simultaneously showing off how neat LINQ is.</p>
<pre class="brush: csharp; wrap-lines: false;">
var blogPosts =
   from exp in user.Experiences()
   where exp.IsAwesome
   select new BlogPost()
   {
      Title = exp.Concept,
      Content = exp.Details,
      CodeUrl = exp.GitUrl;
   };
</pre>
<blockquote><p>To be painfully and obnoxiously clear, this code example is not part of the actual demo program, it is only here to look pretty  and be a conversation piece.</p></blockquote>
<p><span id="more-764"></span><strong> </strong></p>
<p><div id="silverlightControlHost"><object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="300"><param name="source" value="./silverlight/BingImageQuery.xap"/><param name="background" value="white" /><param name="minRuntimeVersion" value="3.0.40723.0" /><param name="autoupgrade" value="true" /><param name="enableHtmlAccess" value="true" /><a href="http://go.microsoft.com/fwlink/?LinkID=149156" style="text-decoration: none;"><img src="http://storage.timheuer.com/sl4wp-ph.png" alt="Install Microsoft Silverlight" style="border-style: none; width:400px; height:200px"/></a></object><iframe style="visibility:hidden;height:0;width:0;border:0px" id="_sl_historyFrame"></iframe></div><br /></p>
<p><strong>What is LINQ?</strong></p>
<p>LINQ is a first class language extension that is available to any .NET language, and allows developers to treat their collections of objects and data as parts of an SQL-like query statement.  There are <a href="http://www.linq-to-sql.com/linq-to-sql/what-is-linq/" target="_blank">some resources</a> that <a href="http://www.silverlight.net/learn/quickstarts/linqtoxml/" target="_blank">exlain LINQ</a> <a href="http://www.hookedonlinq.com/" target="_blank">decently well</a> that I&#8217;ve managed to find.  I&#8217;ll go into more detail in future Silver Shorts about using LINQ to parse the above Bing Image search result XML into custom class data.</p>
<p>For now let us suffice to go over my LINQ query that tells you everything you need to know about Silver Shorts in less than 10 lines of code.</p>
<p><strong>Step 1 &#8211; Identify the data sources<br />
</strong></p>
<pre class="brush: csharp; highlight: [2,3,6,7,8]; wrap-lines: false;">
var blogPosts =
   from exp in user.Experiences()
   where exp.IsAwesome
   select new BlogPost()
   {
      Title = exp.Concept,
      Content = exp.Details,
      CodeUrl = exp.GitUrl;
   };
</pre>
<p>In this example we have a data source user.Experiences() which we&#8217;ll say is a collection of Experience objects.  Here we&#8217;re going to run a query against this data source and filter out only the experiences in which exp.IsAwesome is true.</p>
<p><strong>Step 2 &#8211; Projections of the User experience objects into BlogPost objects</strong></p>
<pre class="brush: csharp; highlight: [4,5,9]; wrap-lines: false;">
var blogPosts =
   from exp in user.Experiences()
   where exp.IsAwesome
   select new BlogPost()
   {
      Title = exp.Concept,
      Content = exp.Details,
      CodeUrl = exp.GitUrl;
   };
</pre>
<p>As the query executes, it finds objects that match the criteria we just mentioned, and from there our select statement will take the data from the Experience objects result and reformat it into a BlogPost.  For the purposes of our example, we&#8217;re assuming that we need to transform this data into a BlogPost object in order to be able to post it to a Wordpress Blog.</p>
<p><strong>Step 3 &#8211; Execution and putting it all together</strong></p>
<pre class="brush: csharp; wrap-lines: false;">
foreach( BlogPost bp in blogPosts )
{
   WordPress.post(bp);
}
</pre>
<p>An important thing to know about LINQ queries is that they are lazily executed.  That is to say, even though we have constructed our query statement above, it won&#8217;t actually do anything until we reference the data it is supposed to represent.   Generally speaking foreach loops are used to execute queries, but it is really whenever you reference your query &#8220;data&#8221; that it will be executed.</p>
<p>So in this foreach loop, the query is executed and the results are iterated across as BlogPost objects named (bp).</p>
<p><strong>Booty</strong></p>
<p>That just about does it for the inaugural post for Project Silver Shorts.   Next time we&#8217;ll go over the process of building the Image Search demo at  the top of this post, including constructing a LINQ query to parse the  XML results from the BING query, Asynchronous network access to perform the Query, and showing the results as thumbnail Images in a Grid.  Until then, enjoy your spoils.</p>
<h4>Silver Shorts : <a href="http://github.com/justindujardin/SilverShorts" target="_blank">Get the Code on GitHub.com</a></h4>
]]></content:encoded>
			<wfw:commentRss>http://www.justindujardin.com/blog/?feed=rss2&amp;p=764</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Valentinius J Daysworthy, Kidnapper of realistic expectations, Devourer of self-esteems par excellence, at your service.</title>
		<link>http://www.justindujardin.com/blog/?p=684</link>
		<comments>http://www.justindujardin.com/blog/?p=684#comments</comments>
		<pubDate>Sun, 14 Feb 2010 23:42:21 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.justindujardin.com/blog/?p=684</guid>
		<description><![CDATA[I think Love is a wonderful thing that should be celebrated, and to that end I&#8217;d like to wish all the lovers out there a great day with their significant others.
Confusing Love and Happiness

I take issue today with the institution of Valentines Day, which masquerades as a supporter of love, happiness, and all things good [...]]]></description>
			<content:encoded><![CDATA[<p>I think Love is a wonderful thing that should be celebrated, and to that end I&#8217;d like to wish all the lovers out there a great day with their significant others.</p>
<p><strong>Confusing Love and Happiness<br />
</strong></p>
<p>I take issue today with the institution of Valentines Day, which masquerades as a supporter of love, happiness, and all things good about personal relationships, concealing an insidious second purpose just beneath the surface.  VDay, with the help of our Advertising and Media, manages to juxtapose happiness and love for the purposes of making the argument that a persons happiness and fulfillment have a dependent relationship to love or, errm, relationships.</p>
<p><span id="more-684"></span><strong>The Hidden Associations in VDay</strong></p>
<p>To understand why I seem to loathe the existence of such a day we need only consider the long-held associations with it that reside silently in my mind.  To follow the somewhat chaotic jumping of logic below you must understand that the brain forms associations between all sorts of things and when you think about VDay it will look at memories from past relationships, heartbreaks, triumphs, failures, and anything remotely associated with your current feelings on VDay.</p>
<p>If you&#8217;ve ever been in a relationship during VDay your mind has not forgotten and will bring up the memories linked to relationships when you think about it, because it has formed an association between the two.  You can see then that if you&#8217;re in a relationship this year, likely thinking about VDay summons feelings of warmth and compassion, love, etc.  On the other hand if you&#8217;re single this year without a valentine, thinking about VDay may summon back unhappy memories from your collective pool of associated memories, perhaps a past VDay or relationship gone wrong.</p>
<p>The point here is that you, as a person, have an abundance of positive and negative associations already made up in your head for VDay, whether you know it or not.   Once you realize that, my argument that VDay sucks comes into focus.  Because within us all is the capacity to feel good or bad about VDay, the mere act of celebrating it suggests a good/bad relationship; you either have a valentine or you do not.</p>
<p><strong>If noone is your Valentine on VDay, you are unloved</strong></p>
<p>Once you&#8217;ve accepted my argument that associated past experience and memories are triggered when exposed to VDay&#8217;ish things, you need only look to the real world for examples of how knowledge of this can be exploited for financial gain.  Advertisers carefully craft their media to express to people very specific messages that support the argument that you NEED to participate or you don&#8217;t love your partner, or that you NEED to find a partner to participate with or you are not loved.</p>
<p><strong>Defeating VDay&#8217;s Negative Associations<br />
</strong></p>
<p>How can I defeat a day?   Well, I certainly can&#8217;t defeat February 14th as a calender day, I&#8217;ve tried that, it just comes back next year.    What I can do is choose to form new associations in mind with VDay.  In doing this, I can choose to respect the essence of VDay, which is the uplifting of love, without falling victim to it&#8217;s insidious consequences when viewed through a commercial lens.  What I mean by that is I have chosen today to be thankful for the love I have of knowledge.   The pursuit of more efficient ways to get things done, a deeper understanding of reality, a more complete understanding of my self; all these things I love to seek out, and this has been constant throughout my life.</p>
<p>So today I choose to show my love for knowledge and the pursuit of understanding, by associating this exercise in deconstructing my feelings on VDay with the day itself.</p>
<p><strong>Singularly Triumphant</strong></p>
<p>But why choose to associate writing this blog post with VDay?   Certainly it could be just by chance, but it has a particularly interesting feature in that associating this exercise with this day defines a sort of self-referencing association in that in this exercise I considered how I feel about this day, and in writing this blog I&#8217;ve put into words how I feel about this day.</p>
<p><span style="color: #000000;">Then again, perhaps &#8220;Gödel, Escher, Bach&#8221; actually is eating my brains.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.justindujardin.com/blog/?feed=rss2&amp;p=684</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Holy Mars Orbiter, Batman!</title>
		<link>http://www.justindujardin.com/blog/?p=561</link>
		<comments>http://www.justindujardin.com/blog/?p=561#comments</comments>
		<pubDate>Mon, 30 Nov 2009 01:08:52 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[Things I Like]]></category>
		<category><![CDATA[Mars]]></category>
		<category><![CDATA[Mars Orbiter]]></category>
		<category><![CDATA[NASA]]></category>

		<guid isPermaLink="false">http://www.justindujardin.com/blog/?p=561</guid>
		<description><![CDATA[In August  of 2005 NASA launched the Mars Reconnaissance Orbiter,  In March of 2006 it arrived at Mars and began to study the terrain and atmosphere in great detail.  Over the last 4 years the MRO has gathered more data on Mars than the sum of all other missions to Mars combined[2].
Today let&#8217;s take a [...]]]></description>
			<content:encoded><![CDATA[<p>In August  of 2005 NASA launched the Mars Reconnaissance Orbiter,  In March of 2006 it arrived at Mars and began to study the terrain and atmosphere in great detail.  Over the last 4 years the MRO has gathered more data on Mars than the sum of all other missions to Mars combined[2].</p>
<p>Today let&#8217;s take a look at some of the amazing pictures it has returned.  All of the amazing detail of the images you see on this page are provided by HiRISE which is one of 6 instruments carried on-board the Mars Reconnaissance Orbiter&#8230;</p>
<div id="attachment_591" class="wp-caption aligncenter" style="width: 310px"><a href="http://hirise.lpl.arizona.edu/PSP_010169_2650" target="_blank"><img class="size-medium wp-image-591 " title="Barchan Dunes in Chasma Boreale" src="http://www.justindujardin.com/blog/wp-content/uploads/2009/11/PSP_010169_2650-300x199.jpg" alt="Barchan Dunes in Chasma Boreale" width="300" height="199" /></a><p class="wp-caption-text">Barchan Dunes in Chasma Boreale</p></div>
<p><strong>High Resolution Imaging Science Experiment</strong> (<a href="http://hirise.lpl.arizona.edu/" target="_blank">link</a>)</p>
<p>HiRISE is operated by the <a href="http://www.arizona.edu/" target="_blank">University of Arizona Tucson</a> and has the most powerful telescopic camera ever flown to another planet at its disposal.  As of October 8th, 2009 the HiRISE project has released into the public domain almost <strong>1.2million</strong> images, totaling just under <strong>38Terabytes</strong> of data[3].</p>
<div id="attachment_580" class="wp-caption aligncenter" style="width: 310px"><a href="http://hirise.lpl.arizona.edu/ESP_014429_1940" target="_blank"><img class="size-medium wp-image-580 " title="Sand Dunes" src="http://www.justindujardin.com/blog/wp-content/uploads/2009/11/ESP_014429_1940-300x199.jpg" alt="Sand Dunes" width="300" height="199" /></a><p class="wp-caption-text">Sand Dunes</p></div>
<p><span id="more-561"></span></p>
<p><strong>Dust Devils </strong>(<a href="http://en.wikipedia.org/wiki/Dust_devil#Martian_dust_devils" target="_blank">wiki</a>) <strong><br />
</strong></p>
<p>Another interesting thing to come out of HiRISE are pictures like you see below in which dust devils on the Martian surface leave dark trails in their wake.  It&#8217;s as if the dust devils are using Mars like a massive etch-a-sketch board.  If you <a href="http://en.wikipedia.org/wiki/File:Marsdustdevil2.gif" target="_blank">click here</a>, you can see a dust devil on the surface taken by one of the rovers.</p>
<p style="text-align: center;">
<p style="text-align: center;">
<div id="attachment_589" class="wp-caption aligncenter" style="width: 310px"><a href="http://hirise.lpl.arizona.edu/PSP_005397_1270" target="_blank"><img class="size-medium wp-image-589 " title="Sand Dunes" src="http://www.justindujardin.com/blog/wp-content/uploads/2009/11/PSP_005397_1270-300x199.jpg" alt="Sand Dunes on Mars" width="300" height="199" /></a><p class="wp-caption-text">Dust Devils</p></div>
<p><span><strong>Near Surface Ice (<a href="http://hirise.lpl.arizona.edu/HiBlog/2009/09/25/water-ice-exposed/" target="_blank">blog</a>)</strong><br />
</span></p>
<p>There have been numerous pictures of Ice on the surface of mars, but recently people working at HiRISE have published findings that show evidence of ice being exposed and melting away just a few feet beneath the surface of the planet.   Not only that, but the locations of the craters having exposed ice are not in close proximity to the polar areas.</p>
<div id="attachment_609" class="wp-caption aligncenter" style="width: 310px"><a href="http://hirise.lpl.arizona.edu/HiBlog/2009/09/25/water-ice-exposed/" target="_blank"><img class="size-medium wp-image-609  " title="site2_fading_200pc_35meters_across_each" src="http://www.justindujardin.com/blog/wp-content/uploads/2009/11/site2_fading_200pc_35meters_across_each-300x147.jpg" alt="Exposed Ice from crater fades over time" width="300" height="147" /></a><p class="wp-caption-text">Exposed Ice from crater fades over time</p></div>
<p>You can read the full blog entry about it <a href="http://hirise.lpl.arizona.edu/HiBlog/2009/09/25/water-ice-exposed/" target="_blank">here</a>.</p>
<h2><strong>Mars Reconnaissance Orbiter Details</strong></h2>
<p>For those studious readers out there, the MRO carries a payload of six instruments to help achieve it&#8217;s stated goals of gaining a better overall understanding of Mars in general, and identifying potential landing locations for future missions.</p>
<p style="text-align: center;">
<div id="attachment_629" class="wp-caption aligncenter" style="width: 310px"><a href="http://hirise.lpl.arizona.edu/PSP_009663_2635" target="_blank"><img class="size-medium wp-image-629  " title="PSP_009663_2635" src="http://www.justindujardin.com/blog/wp-content/uploads/2009/11/PSP_009663_2635-300x199.jpg" alt="Ice Deposits" width="300" height="199" /></a><p class="wp-caption-text">North Polar Layered Deposit and it&#39;s Ice Cap</p></div>
<p><strong>High Resolution Imaging Science Experiment</strong></p>
<p>Photographs the surface of mars in extreme detail.   It is expected to cover about 1 percent of the surface during it&#8217;s experiment lifetime.</p>
<p><strong>Compact Reconnaissance Imaging Spectrometer for Mars </strong></p>
<p>Provides spectral information to help identify patches of water-related minerals.</p>
<p><strong>Context Camera </strong></p>
<p>Takes wider-swath pictures to provide context for smaller images taken by other instruments.</p>
<p><strong>Mars Climate Sounder</strong></p>
<p>Tracks variations in water vapor, dust, and temperature in the atmosphere.</p>
<p><strong>Mars Color Imager</strong></p>
<p>Produces global images of Mars to track changes in the weather and ozone.</p>
<p><strong>Shallow Subsurface Radar</strong></p>
<p>Probes to approximately 1/3 of a mile below the martian surface to extract information about the layers of potential rock/ice/water that may be hidden.</p>
<p>&#8212;</p>
<p>Pretty cool stuff if you ask me.  If you&#8217;re not satisfied with the images presented here, feel free to go digging through the HiRISE website archive of images, but I&#8217;d definitely recommend starting with the <a href="http://hirise.lpl.arizona.edu/science_themes/themes.php" target="_blank">Scientific Themes</a> section of images.</p>
<p>&#8212;</p>
<p>References</p>
<ol>
<li>NASA: Mars Reconnaissance Orbiter Mission Info &#8211; <a href="http://marsprogram.jpl.nasa.gov/missions/present/2005.html" target="_blank">http://marsprogram.jpl.nasa.gov/missions/present/2005.html</a></li>
<li>NASA: Mars Exploration Program Historical Log &#8211; <a href="http://marsprogram.jpl.nasa.gov/missions/log/" target="_blank">http://marsprogram.jpl.nasa.gov/miss</a><a href="http://marsprogram.jpl.nasa.gov/missions/log/" target="_blank">ions/log/</a></li>
<li>HiRISE Blog: October 2009 PDS Release statistics &#8211; <a href="http://hirise.lpl.arizona.edu/HiBlog/2009/10/08/october-2009-pds-release/" target="_blank">http://hirise.lpl.arizona.edu/HiBlog/2009/10/08/october-2009-pds-release/</a></li>
<li>HiRISE Blog: Water ice exposed! &#8211; <a href="http://hirise.lpl.arizona.edu/HiBlog/2009/09/25/water-ice-exposed/" target="_blank">http://hirise.lpl.arizona.edu/HiBlog/2009/09/25/water-ice-exposed/</a></li>
<li>NASA: Mars Reconnaissance Orbiter : Mission Fact Sheet &#8211; <a href="http://marsprogram.jpl.nasa.gov/mro/newsroom/factsheets/pdfs/MRO-060303.pdf" target="_blank">http://marsprogram.jpl.nasa.gov/mro/newsroom/factsheets/pdfs/MRO-060303.pdf</a></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.justindujardin.com/blog/?feed=rss2&amp;p=561</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Yo-Yo Ma : Appassionato</title>
		<link>http://www.justindujardin.com/blog/?p=511</link>
		<comments>http://www.justindujardin.com/blog/?p=511#comments</comments>
		<pubDate>Fri, 06 Nov 2009 22:00:47 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[Music]]></category>

		<guid isPermaLink="false">http://www.justindujardin.com/blog/?p=511</guid>
		<description><![CDATA[
It&#8217;s not often that I feel compelled to write and about music, but every once in a while something stands out as being so worthy of praise that it would almost be a crime not to.   After months of listening and consideration, I believe that Yo-Yo Ma&#8217;s Appassionato is just one such thing.
In a collection [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.yo-yoma.com/music/appassionato" target="_blank"><img class="size-full wp-image-530 alignright" title="Yo-Yo Ma Appassionato" src="http://www.justindujardin.com/blog/wp-content/uploads/2009/11/album_cover.jpg" alt="Yo-Yo Ma Appassionato" width="224" height="224" /></a></p>
<p>It&#8217;s not often that I feel compelled to write and about music, but every once in a while something stands out as being so worthy of praise that it would almost be a crime not to.   After months of listening and consideration, I believe that <a href="http://www.yo-yoma.com/music/appassionato" target="_blank">Yo-Yo Ma&#8217;s Appassionato</a> is just one such thing.</p>
<p>In a collection of recordings spanning almost 3 decades, Ma has put together a fantastic story about his passion for music.  Each track guides you effortlessly into a new chapter, all magnificently decorated with the nuance and detail that you might expect from a well written book.  From the lighthearted introduction of &#8220;Going to School&#8221; by <a href="http://en.wikipedia.org/wiki/John_Williams">John Williams</a>, to the provocative and enduring conclusion of &#8220;Gabriel&#8217;s Oboe&#8221; by <a href="http://en.wikipedia.org/wiki/Ennio_Morricone">Ennio Morricone</a>; Ma&#8217;s careful selection of recordings tells the story of his love for music that my words cannot do justice.</p>
<p>You may preview all the tracks on <a href="http://www.amazon.com/Appassionato-Yo-Ma/dp/B000KWZ7DS" target="_blank">Amazon&#8217;s page</a>.  Share and enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.justindujardin.com/blog/?feed=rss2&amp;p=511</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Kandel on Memory Storage</title>
		<link>http://www.justindujardin.com/blog/?p=489</link>
		<comments>http://www.justindujardin.com/blog/?p=489#comments</comments>
		<pubDate>Tue, 03 Nov 2009 00:41:13 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.justindujardin.com/blog/?p=489</guid>
		<description><![CDATA[
In response to a blog post I wrote recently, a friend kindly pointed out that I seemed to have overlooked the work of Dr. Eric Kandel and others with respect to molecular changes that occur in neurons during learning.  In 2000 Eric Kandel was awarded the Nobel Prize along with Arvid Carlsson and Paul Greengard [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-490" title="kandel_eric" src="http://www.justindujardin.com/blog/wp-content/uploads/2009/11/kandel_eric.jpg" alt="kandel_eric" width="200" height="283" /></p>
<p>In response to a <a href="http://www.justindujardin.com/blog/?p=419" target="_self">blog post</a> I wrote recently, a friend kindly pointed out that I seemed to have overlooked the work of Dr. Eric Kandel and others with respect to molecular changes that occur in neurons during learning.  In 2000 <a href="http://en.wikipedia.org/wiki/Eric_Kandel" target="_blank">Eric Kandel</a> was awarded the Nobel Prize along with <a title="Arvid Carlsson" href="http://en.wikipedia.org/wiki/Arvid_Carlsson" target="_blank">Arvid Carlsson</a> and <a title="Paul Greengard" href="http://en.wikipedia.org/wiki/Paul_Greengard" target="_blank">Paul Greengard</a> for their work detailing such molecular changes.  As it turns out because of their work, we actually have a pretty fantastic understanding about how things are committed to short and long-term memory, as well as the general way in which synaptic connections relate to the storage of things in memory.</p>
<p><strong>Nobel Lecture 2000</strong></p>
<p>My friend also provided a link to <a href="http://nobelprize.org/nobel_prizes/medicine/laureates/2000/kandel-lecture.html" target="_blank">the lecture</a> that Kandel gave while he was in Stockholm accepting the Nobel Prize.   I must admit that very little of the talk made <em>complete</em> sense to me, partly because the camera man chose not to show the screen while Kandel was using his laser pointer to go through the diagrams, and partly because I&#8217;m not a molecular biologist.   A few very cool insights did come out of watching the lecture, that are interesting enough to share&#8230;</p>
<p><strong><span id="more-489"></span>Remembering Through Repetition</strong></p>
<p>At one point or another in life you&#8217;ve probably run into someone that is keen on using repetition to help you remember things.   Be it a grade-school teacher or a parent trying to help you study for a test, this is a bit of common knowledge that has been around for years, and it would seem Kandel confirms that this is a legitimate way to commit things to long term memory.   In fact during his lecture he goes to great lengths to graph and show the effect repetition has on the length of time something is stored in memory for recall.   A single stimulation resulting in storage for just a few hours, while repeated stimulation (5 times) causes new protein synthesis, committal to long term memory, and recall for long periods of time.</p>
<p><strong>Stronger vs New Synaptic Connections</strong></p>
<p>Another interesting point Kandel and his fellows have brought to light is the distinction between what causes synaptic connections to strengthen, and what causes new synaptic connections to be formed.   In all of their testing cases, short-term memory storage involved only the modification of strength in existing synapses.   On the other hand, long-term memory storage has been associated with both modification of the strength of existing connections, as well as the formation of entirely new synaptic connections.  To be clear modification could mean strengthening or weakening of a synaptic connection.</p>
<p><strong>CREB2 the bouncer<br />
</strong></p>
<p>By far the most interesting thing to take away from this presentation was the process by which things are committed to long-term memory.   As I mentioned above, repetition seems to be the key factor in committing things to long term memory, but what&#8217;s more is that Kandel has figured out the reason for this.   In order for things to be committed to long-term memory, there needs to be new protein synthesis and part of new protein synthesis in a neuron requires activation of what is called the CREB1 transcription factor.   The catch is that CREB1 is repressed by another transcription factor called CREB2.   At this point you may have guessed that when you create the same stimulation in the neuron multiple times, eventually CREB2 let&#8217;s down its guard and CREB1 can be activated, which allows the process to continue and the memory to be committed to long-term storage.   Put in other words repeated stimulation acks like a secret handshake in the neuron that convinces CREB2 the bouncer to let in to the long-term memory storage party that&#8217;s happening just behind the door.  Kandel speculates that when there is a deficit in CREB2, this may be the reason behind certain individuals having photographic memories.  In fact they have observed this to be true in mice&#8230;</p>
<p><strong>Oh but to be a mouse<br />
</strong></p>
<p>In ending his lecture Kandel talked about some interesting thoughts about the clinical applicability of this research.   In particular he notes that as people tend to age, there are a number of disorders that affect their ability to convert short-term to long-term memory.   In experiments on mice Kandel and his team have been able to show that this is caused by a single defect that makes it difficult to initiate the transcriptional cascade process that was talked about earlier as being responsible for the storage of things into long-term memory.   By using their magic to overcome this deficit, they have been able to produce flash-bulb memory in mice.   As Kandel himself jests.. &#8220;So if you&#8217;re a mouse, we can really help you with age-related memory loss&#8221;</p>
<p>While we may not be to a point that we can come up with a convenient little pill to help us convert things to long-term memory storage, the idea that it is possible in the future is quite appealing.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.justindujardin.com/blog/?feed=rss2&amp;p=489</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
