<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Ryan Gillette</title>
	
	<link>http://www.ryangillette.com</link>
	<description>Where Technology and Imagination Collide</description>
	<lastBuildDate>Tue, 08 Jun 2010 14:48:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0-RC2-15172</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/ryangillette" /><feedburner:info uri="ryangillette" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Apple Releases Safari 4 for Mac and PC</title>
		<link>http://feedproxy.google.com/~r/ryangillette/~3/YWd6jB7uQrc/apple-releases-safari-4-for-mac-and-pc</link>
		<comments>http://www.ryangillette.com/news/apple-releases-safari-4-for-mac-and-pc#comments</comments>
		<pubDate>Tue, 24 Feb 2009 21:30:29 +0000</pubDate>
		<dc:creator>rgillette</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Acid2]]></category>
		<category><![CDATA[Acid3]]></category>
		<category><![CDATA[Google Chrome]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Microsoft Windows]]></category>
		<category><![CDATA[Safari]]></category>
		<category><![CDATA[Web Browser]]></category>

		<guid isPermaLink="false">http://www.ryangillette.com/?p=40</guid>
		<description><![CDATA[Today, Apple released Safari 4 beta for Mac and PC. I have installed both the Mac and PC implementations and they are both beautiful and unique to their corresponding operating systems. This news has a big impact on all new browsers, but especially Google Chrome (a very similar competitor) because there is now no compelling [...]]]></description>
			<content:encoded><![CDATA[<p>Today, Apple released <a href="http://www.apple.com/safari" onclick="window.open(this.href);return false;">Safari 4 beta</a> for Mac and PC.  I have installed both the Mac and PC implementations and they are both beautiful and unique to their corresponding operating systems.  </p>
<p>This news has a big impact on all new browsers, but especially <a href="http://www.google.com/chrome" onclick="window.open(this.href);return false;">Google Chrome</a> (a very similar competitor) because there is now no compelling reason to use or anticipate (Mac version) it; most of its differentiating features from Safari 3 have been matched and exceeded in Safari 4.  Safari appears to run separate processes in each tab, it has a bytecode JavaScript engine, has a <a href="http://gears.google.com" onclick="window.open(this.href);return false;">Google Gears</a> like database implementation, and it obviously uses the Webkit engine.  Additionally, it is the first and only browser to pass the <a href="http://acid3.acidtests.org/" onclick="window.open(this.href);return false;">Acid3</a> test to date.</p>
<p>This release is a huge step forward for Apple in not only the computer browser market, but eventually in the mobile browser market as well; imagine what the iPhone implementation of Safari 4 will bring.</p>
<img src="http://feeds.feedburner.com/~r/ryangillette/~4/YWd6jB7uQrc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ryangillette.com/news/apple-releases-safari-4-for-mac-and-pc/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ryangillette.com/news/apple-releases-safari-4-for-mac-and-pc</feedburner:origLink></item>
		<item>
		<title>A more concise way to match values in C#</title>
		<link>http://feedproxy.google.com/~r/ryangillette/~3/P_Gdnd3pwBg/more-concise-way-to-match-values-in-csharp</link>
		<comments>http://www.ryangillette.com/code/c-sharp/more-concise-way-to-match-values-in-csharp#comments</comments>
		<pubDate>Thu, 29 Jan 2009 03:07:11 +0000</pubDate>
		<dc:creator>rgillette</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Conditional]]></category>

		<guid isPermaLink="false">http://www.ryangillette.com/?p=29</guid>
		<description><![CDATA[From time to time, a developer will need to match a value in a series of values to accomplish conditional logic of some sort. Recently, while working with a project which had a status value, I needed a concise way match the value and do something useful. Normally, I would write C# code that looks [...]]]></description>
			<content:encoded><![CDATA[<p>From time to time, a developer will need to match a value in a series of values to accomplish conditional logic of some sort.  Recently, while working with a project which had a status value, I needed a concise way match the value and do something useful.</p>
<p>Normally, I would write C# code that looks like this:</p>
<pre class="brush: csharp;">
// Hard-coded for example
string status = &quot;ww&quot;;

if (status == &quot;ww&quot; || status == &quot;r&quot; || status == &quot;bw&quot; ||
    status == &quot;nb&quot; || status == &quot;qb&quot; || status == &quot;nt&quot;)
{
	// do something interesting
}
else if...
else if...
else...
</pre>
<p>However, after my hands tired out from typing (even with intellisense), I came up with the following:</p>
<pre class="brush: csharp;">
// Hard-coded for example
string status = &quot;ww&quot;;

if (new[] { &quot;ww&quot;, &quot;r&quot;, &quot;bw&quot;, &quot;nb&quot;, &quot;qb&quot;, &quot;nt&quot; }.Contains(status))
{
    // do something interesting
}
else if...
else if...
else...
</pre>
<p>If the array of values contains an equal value to the status, then success. As you can see, the code is much easier to read and requires less typing. Enjoy!</p>
<p>[<strong>Update:</strong> Changed to use implicitly typed array (requires C# 3.0) instead of List&lt;string&gt;. Thanks manitra!]</p>
<img src="http://feeds.feedburner.com/~r/ryangillette/~4/P_Gdnd3pwBg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ryangillette.com/code/c-sharp/more-concise-way-to-match-values-in-csharp/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://www.ryangillette.com/code/c-sharp/more-concise-way-to-match-values-in-csharp</feedburner:origLink></item>
		<item>
		<title>How to emulate namespaces in Javascript</title>
		<link>http://feedproxy.google.com/~r/ryangillette/~3/ir3fK4DbcdU/how-to-emulate-namespaces-in-javascript</link>
		<comments>http://www.ryangillette.com/code/javascript/how-to-emulate-namespaces-in-javascript#comments</comments>
		<pubDate>Tue, 19 Jun 2007 23:34:12 +0000</pubDate>
		<dc:creator>rgillette</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Namespace]]></category>

		<guid isPermaLink="false">http://www.azrotech.com/blog/2007/06/19/how-to-emulate-namespaces-in-javascript/</guid>
		<description><![CDATA[A common problem when coding very large Javascript applications is that the global namespace gets polluted, which causes the programmer to name their functions and variables something they do not want to name them (just for the sake of uniqueness). If Javascript had namespacing and classes, we wouldn&#8217;t have this problem. Good news, there is [...]]]></description>
			<content:encoded><![CDATA[<p>A common problem when coding very large Javascript applications is that the global namespace gets polluted, which causes the programmer to name their functions and variables something they do not want to name them (just for the sake of uniqueness).  If Javascript had namespacing and classes, we wouldn&#8217;t have this problem. Good news, there is a solution to allow for classes and namespacing it goes a little like this:</p>
<pre class="brush: jscript;">
var az = function() {
    var variable1 = &quot;test&quot;;
    var variable2 = &quot;test2&quot;;

    function testFunc() {
        alert(variable1);
    }

    return {
        init : function() {
            testFunc();
            this.testFunc2();
        },

        testFunc2 : function() {
            alert(variable2);
        }
    };
}();

az.init();
</pre>
<p>Let&#8217;s take a look at this in more detail!</p>
<p>You&#8217;ll notice that we have <code>variable1</code> and <code>variable2</code>. These variables can be thought of as <em>private</em> variables. Additionally, <code>testFunc</code> can be thought of as a private function.</p>
<p>Any of the code that lives within the <code>return</code> block can be thought of as public. These are the only functions that may be called externally. If you are calling a public function within the class, you must either put the full path to it (ex: <code>az.testFunc2()</code>) or prepend it with <code>this</code> (ex: <code>this.testFunc2()</code>).</p>
<p>So now you have a good example of how to represent a class in Javascript. But let&#8217;s take this a step further and emulate namespacing as well.</p>
<p>Let&#8217;s say we had the code above in addition to this code below:</p>
<pre class="brush: jscript;">
var az.util = function() {
    return {
        gebi : function(obj) {
            return document.getElementById(obj);
        }
    };
}();
</pre>
<p>Now we can call <code>az.util.gebi('id_to_get_element_of')</code>.</p>
<p>You can keep adding level after level to the namespacing so that you might have something like <code>az.util.date.convert.toSql()</code>.</p>
<p>Using this technique is great because you do not junk up your global namespace and you can organize your code very well.  In fact, each different &#8220;class&#8221; can live in its own file and you can create a mechanism to import the files as you need them (dramatically improving load time).</p>
<p><strong style="color:red">An interesting note:</strong> You may notice on the examples that there is not a line break between <code>return</code> and the opening brace. Adding a line break will cause the code to break (who knows why?!). Therefore, you will have to keep the opening brace on the same line as the return.</p>
<img src="http://feeds.feedburner.com/~r/ryangillette/~4/ir3fK4DbcdU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ryangillette.com/code/javascript/how-to-emulate-namespaces-in-javascript/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ryangillette.com/code/javascript/how-to-emulate-namespaces-in-javascript</feedburner:origLink></item>
		<item>
		<title>Dynamic Dojo Tooltips</title>
		<link>http://feedproxy.google.com/~r/ryangillette/~3/lD1hupM_2nQ/dynamic-dojo-tooltips</link>
		<comments>http://www.ryangillette.com/code/javascript/dynamic-dojo-tooltips#comments</comments>
		<pubDate>Tue, 19 Jun 2007 23:02:13 +0000</pubDate>
		<dc:creator>rgillette</dc:creator>
				<category><![CDATA[Dojo]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Dynamic]]></category>

		<guid isPermaLink="false">http://www.azrotech.com/blog/2007/06/19/dynamic-dojo-tooltips/</guid>
		<description><![CDATA[While messing with the dojo tooltip widget in one of our applications, I had the need to dynamically create a widget. Below is a sample statement of dynamically creating a tooltip widget. dojo.widget.createWidget('tooltip', { caption: 'what you want the tooltip to say', connectId: 'target_id_to_attach_tooltip' }); However, this is not complete because we need to attach [...]]]></description>
			<content:encoded><![CDATA[<p>While messing with the dojo tooltip widget in one of our applications, I had the need to dynamically create a widget.  Below is a sample statement of dynamically creating a tooltip widget.</p>
<pre class="brush: jscript;">
dojo.widget.createWidget('tooltip', {
	caption: 'what you want the tooltip to say',
	connectId: 'target_id_to_attach_tooltip'
});
</pre>
<p>However, this is not complete because we need to attach it to the body of the document like this:</p>
<pre class="brush: jscript;">
var new_tooltip = dojo.widget.createWidget('tooltip', {
	caption: 'what you want the tooltip to say',
	connectId: 'target_id_to_attach_tooltip'
});
document.body.attachChild(new_tooltip.domNode);
</pre>
<p>You&#8217;ll notice that the return value of <code>dojo.widget.createWidget</code> is an object and when we attach it to the body of the document, we use the <code>domNode</code> property of that object.</p>
<p>There is one more potential problem with dynamically creating these widgets. Let&#8217;s say that we have a dynamic table and each row of the table contains the target id for each tooltip. If the table gets reloaded with new data (rows have new ids), the old tooltips remain appended to the body. No big deal of you don&#8217;t mind a little trash left behind, but the problem comes into play when you load data back into that dynamic table that may have previously existed and generate a whole new set of tooltips to go along with it. Now you may have two or more of the same tooltip appended to the body that belong to the same target id. Some browsers might be fine with this and some might choke. To prevent these duplicates, we use the following code for each new tooltip widget that is created:</p>
<pre class="brush: jscript;">
function createTooltip(target_id, content) {

	// prepending 'tt_' to distinguish between target and tooltip id's
	var obj = document.getElementById('tt_'+target_id);

	if(obj != null)
		obj.parentNode.removeChild(obj);

	var tooltip = dojo.widget.createWidget('tooltip', {
		caption: content,
		connectId: target_id
	});

	tooltip.domNode.id = 'tt_'+target_id;
	document.body.appendChild(tooltip.domNode);
}
</pre>
<p>You might notice that we are actually adding an ID to the tooltip. This allows us to check in the future if that tooltip has already been created. If it has, the code above will destroy it and create a new tooltip in its place.  This should assist those searching for answers about dynamically creating dojo tooltip widgets.</p>
<img src="http://feeds.feedburner.com/~r/ryangillette/~4/lD1hupM_2nQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ryangillette.com/code/javascript/dynamic-dojo-tooltips/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.ryangillette.com/code/javascript/dynamic-dojo-tooltips</feedburner:origLink></item>
		<item>
		<title>Apple, you beautiful company</title>
		<link>http://feedproxy.google.com/~r/ryangillette/~3/zfa2fmDs0yc/apple-you-beautiful-company</link>
		<comments>http://www.ryangillette.com/news/apple-you-beautiful-company#comments</comments>
		<pubDate>Tue, 12 Jun 2007 07:51:48 +0000</pubDate>
		<dc:creator>rgillette</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Acid2]]></category>
		<category><![CDATA[Leopard]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Microsoft Windows]]></category>
		<category><![CDATA[Safari]]></category>
		<category><![CDATA[Standards Compliant]]></category>
		<category><![CDATA[Steve Jobs]]></category>
		<category><![CDATA[Web Browser]]></category>
		<category><![CDATA[Web Standards]]></category>
		<category><![CDATA[WWDC]]></category>

		<guid isPermaLink="false">http://www.azrotech.com/blog/2007/06/12/apple-you-beautiful-company/</guid>
		<description><![CDATA[Apple has done it again. They seem to be on a non-stop war path to take over every aspect of computing and make it just a little bit cooler. This time, they are diving straight into the browser war with the release Safari 3 for Windows. I have been using it all day and am [...]]]></description>
			<content:encoded><![CDATA[<p>Apple has done it again. They seem to be on a non-stop war path to take over every aspect of computing and make it just a little bit cooler.  This time, they are diving straight into the browser war with the release <a href="http://www.apple.com/safari">Safari 3 for Windows</a>.  I have been using it all day and am wowed at the correctness of its rendering.  It even passed the <a href="http://www.webstandards.org/action/acid2/">Acid2 Test</a> with flying colors.</p>
<p>The Acid2 Test was developed by the <a href="http://www.webstandards.org/">Web Standards Project</a> as a means to help vendors test their browsers so that they are compliant with Web Standards.  For a good laugh, try the Acid2 test with IE6 or IE7 (either one, they both render it terribly).</p>
<p>Also, Steve Jobs showed off the upcoming <a href="http://www.apple.com/macosx/leopard/">Mac OS 10.5 (Leopard)</a> at the WWDC and it looks absolutely incredible.  I need not explain it here, just check out the link and prepare to be amazed.</p>
<img src="http://feeds.feedburner.com/~r/ryangillette/~4/zfa2fmDs0yc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ryangillette.com/news/apple-you-beautiful-company/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.ryangillette.com/news/apple-you-beautiful-company</feedburner:origLink></item>
	</channel>
</rss><!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
