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

<channel>
	<title>i am josh</title>
	<atom:link href="http://iamjosh.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://iamjosh.wordpress.com</link>
	<description>Rails, Flex, and more...</description>
	<lastBuildDate>Mon, 26 Apr 2010 20:13:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='iamjosh.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>i am josh</title>
		<link>http://iamjosh.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://iamjosh.wordpress.com/osd.xml" title="i am josh" />
	<atom:link rel='hub' href='http://iamjosh.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Office 2010 64-bit</title>
		<link>http://iamjosh.wordpress.com/2010/04/26/office-2010-64-bit/</link>
		<comments>http://iamjosh.wordpress.com/2010/04/26/office-2010-64-bit/#comments</comments>
		<pubDate>Mon, 26 Apr 2010 20:02:50 +0000</pubDate>
		<dc:creator>josh</dc:creator>
				<category><![CDATA[OCS]]></category>

		<guid isPermaLink="false">http://iamjosh.wordpress.com/?p=77</guid>
		<description><![CDATA[Been a long time since I have posted to this blog and honestly, this post if a bit off topic, but I think helpful. We use Outlook at work and being the technologist that I am, I upgraded to the Office 2010 RTM last week &#8212; 64-bit of course. This morning I noticed that neither [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iamjosh.wordpress.com&amp;blog=1975248&amp;post=77&amp;subd=iamjosh&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Been a long time since I have posted to this blog and honestly, this post if a bit off topic, but I think helpful.</p>
<p>We use Outlook at work and being the technologist that I am, I upgraded to the Office 2010 RTM last week &#8212; 64-bit of course. This morning I noticed that neither my Outlook conferencing add-in was working nor was Communicator storing conversation history.  After some digging, I found the following:</p>
<p>Office 2010 Conferencing Add-in &#8212; January 2010 Add-in (support for 64-bit):</p>
<p><a href="http://office.microsoft.com/en-us/help/HA102368901033.aspx">http://office.microsoft.com/en-us/help/HA102368901033.aspx</a></p>
<p>Office Communicator 2007 R2 Update &#8212; January 2010:</p>
<p><a href="http://support.microsoft.com/kb/976135/">http://support.microsoft.com/kb/976135/</a></p>
<p>**If you work where I do, you can just install these updates over the top of what you had previously installed and still retain existing settings.</p>
<p><strong>References</strong></p>
<ul>
<li><a href="http://blog.insideocs.com/2010/01/18/january-2010-updates-for-live-meeting-and-the-live-meeting-conferencing-add-in-64-bit-now-available/">http://blog.insideocs.com/2010/01/18/january-2010-updates-for-live-meeting-and-the-live-meeting-conferencing-add-in-64-bit-now-available/</a></li>
<li><a href="http://blog.insideocs.com/2010/01/12/january-2010-updates-communicator-2007-r2-and-ocs-2007-r2/">http://blog.insideocs.com/2010/01/12/january-2010-updates-communicator-2007-r2-and-ocs-2007-r2/</a></li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iamjosh.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iamjosh.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iamjosh.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iamjosh.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/iamjosh.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/iamjosh.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/iamjosh.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/iamjosh.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iamjosh.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iamjosh.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iamjosh.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iamjosh.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iamjosh.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iamjosh.wordpress.com/77/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iamjosh.wordpress.com&amp;blog=1975248&amp;post=77&amp;subd=iamjosh&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://iamjosh.wordpress.com/2010/04/26/office-2010-64-bit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">josh</media:title>
		</media:content>
	</item>
		<item>
		<title>Displaying Animated GIFs in Flex</title>
		<link>http://iamjosh.wordpress.com/2009/02/03/animated-gifs-in-flex/</link>
		<comments>http://iamjosh.wordpress.com/2009/02/03/animated-gifs-in-flex/#comments</comments>
		<pubDate>Tue, 03 Feb 2009 23:03:54 +0000</pubDate>
		<dc:creator>josh</dc:creator>
				<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://iamjosh.wordpress.com/?p=71</guid>
		<description><![CDATA[This morning, I found myself wanting to add a nice-looking, but quick loading indicator into a Flex application. In the Ajax world, it&#8217;s simple&#8230;just use an animated GIF that can be downloaded from any number of sites. In Flex, it&#8217;s not quite that easy. The default Image component in Flex does not support animated images, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iamjosh.wordpress.com&amp;blog=1975248&amp;post=71&amp;subd=iamjosh&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This morning, I found myself wanting to add a nice-looking, but quick loading indicator into a Flex application.  In the Ajax world, it&#8217;s simple&#8230;just use an animated GIF that can be downloaded from any number of sites.  In Flex, it&#8217;s not quite that easy.  The default <code>Image</code> component in Flex does not support animated images, nor does Flex itself.</p>
<p>A quick Google search turned up the <a href="http://code.google.com/p/as3gif/">as3gif </a> library, which provides support for playing animated GIFs.  The download did not include a SWC, so I pulled the source code into Flex Builder and quickly compiled one, which I then included in my Flex project.</p>
<p>To enable animated GIF images, I extended the <code>Image</code> component to utilize as3gif as follows:</p>
<pre>
package iamjosh.samples.components
{
	import flash.net.URLRequest;

	import mx.controls.Image;
	import mx.core.UIComponent;

	import org.gif.player.GIFPlayer;

	public class AnimatedGIFImage extends Image
	{
		private var _gifImage  : UIComponent;

		public function AnimatedGIFImage()
		{
			super();
			this._gifImage  = new UIComponent();
		}

		override public function set source(value : Object) : void
		{
			if (!value is String)
			{
				throw new ArgumentError("Source must be of type String");
			}

			super.source = value;
		}

		override protected function createChildren() : void
		{
			super.createChildren();
			var player : GIFPlayer = new GIFPlayer();
			player.load(new URLRequest(this.source as String));
			this._gifImage.addChild(player);
		}

		override protected function updateDisplayList(unscaledWidth : Number, unscaledHeight : Number) : void
		{
			this.addChild(this._gifImage);
			super.updateDisplayList(unscaledWidth, unscaledHeight);
		}
	}
}
</pre>
<p>This class simply pulls in the source for the image and then utilizes the as3gif library.  Using the <code>AnimatedGIFImage</code> component is as simple as:</p>
<pre>
&lt;components:AnimatedGIFImage source="assets/images/loading.gif"/&gt;
</pre>
<p>Although I have not tested it thoroughly, the class should also support the basic capabilities of the <code>Image</code> component as well.  </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iamjosh.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iamjosh.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iamjosh.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iamjosh.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/iamjosh.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/iamjosh.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/iamjosh.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/iamjosh.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iamjosh.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iamjosh.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iamjosh.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iamjosh.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iamjosh.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iamjosh.wordpress.com/71/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iamjosh.wordpress.com&amp;blog=1975248&amp;post=71&amp;subd=iamjosh&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://iamjosh.wordpress.com/2009/02/03/animated-gifs-in-flex/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">josh</media:title>
		</media:content>
	</item>
		<item>
		<title>Striping a table with jQuery</title>
		<link>http://iamjosh.wordpress.com/2009/01/04/striping-a-table-with-jquery/</link>
		<comments>http://iamjosh.wordpress.com/2009/01/04/striping-a-table-with-jquery/#comments</comments>
		<pubDate>Sun, 04 Jan 2009 01:52:17 +0000</pubDate>
		<dc:creator>josh</dc:creator>
				<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://iamjosh.wordpress.com/?p=68</guid>
		<description><![CDATA[jQuery makes striping an HTML table very simple with what amounts to a one line function.  First, let&#8217;s start with our HTML: &#60;table class="striped"&#62; &#60;tr&#62; &#60;td&#62;Lorem&#60;/td&#62; &#60;td&#62;ipsum&#60;/td&#62; &#60;/tr&#62; &#60;tr&#62; &#60;td&#62;dolor&#60;/td&#62; &#60;td&#62;sit&#60;/td&#62; &#60;/tr&#62; &#60;tr&#62; &#60;td&#62;amet&#60;/td&#62; &#60;td&#62;consectetur&#60;/td&#62; &#60;/tr&#62; &#60;/table&#62; Should be pretty straightforward.  Notice that we haven&#8217;t done anything bayond a simple table here, no styling, nothing.  [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iamjosh.wordpress.com&amp;blog=1975248&amp;post=68&amp;subd=iamjosh&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>jQuery makes striping an HTML table very simple with what amounts to a one line function.  First, let&#8217;s start with our HTML:</p>
<p><code><br />
&lt;table class="striped"&gt;<br />
  &lt;tr&gt;<br />
    &lt;td&gt;Lorem&lt;/td&gt;<br />
    &lt;td&gt;ipsum&lt;/td&gt;<br />
  &lt;/tr&gt;<br />
  &lt;tr&gt;<br />
    &lt;td&gt;dolor&lt;/td&gt;<br />
    &lt;td&gt;sit&lt;/td&gt;<br />
  &lt;/tr&gt;<br />
  &lt;tr&gt;<br />
    &lt;td&gt;amet&lt;/td&gt;<br />
    &lt;td&gt;consectetur&lt;/td&gt;<br />
  &lt;/tr&gt;<br />
&lt;/table&gt;</code></p>
<p>Should be pretty straightforward.  Notice that we haven&#8217;t done anything bayond a simple table here, no styling, nothing.  Next, we can create a simple CSS style for our alternating rows:</p>
<p><code><br />
tr.alt {<br />
  background-color: #ebe9dc;<br />
  }<br />
</code></p>
<p>Finally, let&#8217;s create a Javascript function that we can call to stripe the table:</p>
<p><code><br />
jQuery.fn.stripe = function() {<br />
  return this.each(function(){<br />
    $('tbody &gt; tr:even', this).addClass('alt');<br />
  });<br />
};<br />
</code></p>
<p>Again, this function primarily boils down to one line, the rest is <a href="http://docs.jquery.com/Plugins/Authoring">boilerplate</a> jQuery plugin code that allows us to make calls to the function as follows <code>$('table.striped').stripe</code>.  </p>
<p>The power here is the line <code>$('tbody &gt; tr:even', this).addClass('alt');</code>.  Here, we are using selectors mixed with the scope of &#8220;this&#8221; (i.e. table&#8217;s with class &#8220;striped&#8221;) to select the even rows in the table and apply the class &#8220;alt&#8221; which we defined earlier in our style sheet to them.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iamjosh.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iamjosh.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iamjosh.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iamjosh.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/iamjosh.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/iamjosh.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/iamjosh.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/iamjosh.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iamjosh.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iamjosh.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iamjosh.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iamjosh.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iamjosh.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iamjosh.wordpress.com/68/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iamjosh.wordpress.com&amp;blog=1975248&amp;post=68&amp;subd=iamjosh&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://iamjosh.wordpress.com/2009/01/04/striping-a-table-with-jquery/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">josh</media:title>
		</media:content>
	</item>
		<item>
		<title>Adding Ant to Flex Builder 3</title>
		<link>http://iamjosh.wordpress.com/2008/08/11/adding-ant-to-flex-builder-3/</link>
		<comments>http://iamjosh.wordpress.com/2008/08/11/adding-ant-to-flex-builder-3/#comments</comments>
		<pubDate>Mon, 11 Aug 2008 15:46:57 +0000</pubDate>
		<dc:creator>josh</dc:creator>
				<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://iamjosh.wordpress.com/?p=66</guid>
		<description><![CDATA[I wanted to use Cairngen in a recent project and quickly noticed that the standalone version of Flex Builder 3 does not have Ant support available by default.  Getting it set-up is pretty easy though: In Flex Builder, Help -&#62; Software Updates -&#62; Find and Install&#8230; Select &#8220;Search for new features to install&#8221; and click [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iamjosh.wordpress.com&amp;blog=1975248&amp;post=66&amp;subd=iamjosh&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I wanted to use <a href="http://code.google.com/p/cairngen" target="_blank">Cairngen </a>in a recent project and quickly noticed that the standalone version of Flex Builder 3 does not have Ant support available by default.  Getting it set-up is pretty easy though:</p>
<ol>
<li>In Flex Builder, Help -&gt; Software Updates -&gt; Find and Install&#8230;</li>
<li>Select &#8220;Search for new features to install&#8221; and click Next</li>
<li>Pick &#8220;The Eclipse Project Updates&#8221; and click Finish</li>
<li>Expand &#8220;The Eclipse Project Updates&#8221; and &#8220;Eclipse 3.3.2&#8243;</li>
<li>Select &#8220;Eclipse Java Development Tools 3.3.2&#8230;&#8221; and click &#8220;Finish&#8221;</li>
<li>When prompted, select &#8220;Install All&#8221;</li>
<li>Restart Flex Builder</li>
</ol>
<p>When Flex Builder starts up again, you will have Ant support available (e.g. any build.xml files will have a little ant on the icon).  You can also verify by selecting Window -&gt; Other Views&#8230; and checked if an Ant directory exists.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/iamjosh.wordpress.com/66/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/iamjosh.wordpress.com/66/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iamjosh.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iamjosh.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iamjosh.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iamjosh.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/iamjosh.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/iamjosh.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/iamjosh.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/iamjosh.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iamjosh.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iamjosh.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iamjosh.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iamjosh.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iamjosh.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iamjosh.wordpress.com/66/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iamjosh.wordpress.com&amp;blog=1975248&amp;post=66&amp;subd=iamjosh&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://iamjosh.wordpress.com/2008/08/11/adding-ant-to-flex-builder-3/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">josh</media:title>
		</media:content>
	</item>
		<item>
		<title>Embedding Flash in Flex</title>
		<link>http://iamjosh.wordpress.com/2008/04/09/embedding-flash-in-flex/</link>
		<comments>http://iamjosh.wordpress.com/2008/04/09/embedding-flash-in-flex/#comments</comments>
		<pubDate>Wed, 09 Apr 2008 19:30:47 +0000</pubDate>
		<dc:creator>josh</dc:creator>
				<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://iamjosh.wordpress.com/?p=61</guid>
		<description><![CDATA[I recently ran into user interface design that included a component better built in Flash than Flex due to the high degree of interaction required (my time is short these days as well, so one of our designers will be building it). This raised the question of how to embed a Flash movie in a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iamjosh.wordpress.com&amp;blog=1975248&amp;post=61&amp;subd=iamjosh&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I recently ran into user interface design that included a component better built in Flash than Flex due to the high degree of interaction required (my time is short these days as well, so one of our designers will be building it).  This raised the question of how to embed a Flash movie in a Flex application and enable interaction between the two.</p>
<p>This is actually fairly straightforward when working with Flash Player 9 and ActionScript 3.  I started by building a very simple Flash component (I know nothing about Flash) &#8211; it simply contains a slider and a label that changes with the value of the slider:</p>
<p style="text-align:center;"><a href="http://iamjosh.files.wordpress.com/2008/04/simple-flash-component.png"><img class="aligncenter size-medium wp-image-62" src="http://iamjosh.files.wordpress.com/2008/04/simple-flash-component.png?w=222&#038;h=111" alt="" width="222" height="111" /></a></p>
<p>My goal is to embed this component in a simple Flex application that can read/display the current value of the slider.</p>
<p>Next, I created a new Flex application and included both the SWF and FLA file for my Flash component in the &#8220;src/assets&#8221; directory.  I then used a <code>SWFLoader</code> to load the Flash component into the application and position it properly on the screen.  I also added a few simple Flex components to display the currently selected value, etc.:</p>
<p style="text-align:center;"><a href="http://iamjosh.files.wordpress.com/2008/04/flexflash.png"><img class="aligncenter size-medium wp-image-63" src="http://iamjosh.files.wordpress.com/2008/04/flexflash.png?w=334&#038;h=157" alt="" width="334" height="157" /></a></p>
<p>Now, we need to wire everything together.  To do this, we need access to the Flash component from the <code>SWFLoader</code>via the content property.  With access to the component, we have access to public properties/methods, can listen for events, etc.  In fact, to synchronize the currently selected value between Flash and Flex, the slider in the Flash component will dispatch an event on change that the Flex component listens for.  Pertinent code snippets:</p>
<p><strong>Flash Action Code</strong> (remember, I&#8217;m not a Flash programmer):</p>
<pre>slider1.addEventListener(SliderEvent.CHANGE,dispatchSliderEvent);
function dispatchSliderEvent(evt : SliderEvent) : void
{
    dispatchEvent(new SliderEvent(SliderEvent.CHANGE, evt.value, null, null));
}
// returns the current value of the slider
function get sliderValue() : Number
{
    return slider1.value;
}</pre>
<p><strong>Flex</strong></p>
<pre>&lt;mx:Script&gt;
&lt;![CDATA[
    import mx.events.SliderEvent;
    private var _mainTimeline : *;
    [Bindable] private var _sliderValue  : Number = 0;

    private function swfLoaded(event:Event) : void
    {
        this._mainTimeline = this.swfLoader.content;
        this._mainTimeline.addEventListener(SliderEvent.CHANGE, updateValue);
        this.updateValue();
    }

    private function updateValue(evt : Event=null) : void
    {
        this._sliderValue = this._mainTimeline.sliderValue;
    }
]]
&lt;/mx:Script&gt;

&lt;mx:SWFLoader id="swfLoader" y="73" x="10" source="assets/Simple Flash Component.swf"
    complete="swfLoaded(event);"/&gt;</pre>
<p>Two items of note:</p>
<ul>
<li>I did not explicitly assign a type to the <code>_mainTimeline</code> object in order to be able to arbitrarily call methods on it (e.g. no compile-time checking)</li>
<li>There is a strange problem in trying to directly call the <code>_mainTimeline.sliderValue()</code> method in which the Flash component did not render properly, hence why I used an intermediate variable (<code>_slideValue</code>).</li>
</ul>
<p>That&#8217;s it, it really is fairly straightforward.  Although I have not tested it yet, Flex should be able to set values in the Flash component in much the same way.</p>
<p><strong>References</strong></p>
<ul>
<li><a href="http://seantheflashguy.com/blog/2007/09/27/flash-cs3-and-flex-2-communication-using-actionscript-30/" target="_blank">http://seantheflashguy.com/blog/2007/09/27/flash-cs3-and-flex-2-communication-using-actionscript-30/</a></li>
<li><a href="http://www.actionscript.org/resources/articles/501/1/Flex-2-and-Flash-9-Together/Page1.html" target="_blank">http://www.actionscript.org/resources/articles/501/1/Flex-2-and-Flash-9-Together/Page1.html</a></li>
</ul>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/iamjosh.wordpress.com/61/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/iamjosh.wordpress.com/61/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iamjosh.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iamjosh.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iamjosh.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iamjosh.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/iamjosh.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/iamjosh.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/iamjosh.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/iamjosh.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iamjosh.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iamjosh.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iamjosh.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iamjosh.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iamjosh.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iamjosh.wordpress.com/61/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iamjosh.wordpress.com&amp;blog=1975248&amp;post=61&amp;subd=iamjosh&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://iamjosh.wordpress.com/2008/04/09/embedding-flash-in-flex/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">josh</media:title>
		</media:content>

		<media:content url="http://iamjosh.files.wordpress.com/2008/04/simple-flash-component.png" medium="image" />

		<media:content url="http://iamjosh.files.wordpress.com/2008/04/flexflash.png" medium="image" />
	</item>
		<item>
		<title>Resources for JavaScript Performance</title>
		<link>http://iamjosh.wordpress.com/2008/04/04/resources-for-javascript-performance/</link>
		<comments>http://iamjosh.wordpress.com/2008/04/04/resources-for-javascript-performance/#comments</comments>
		<pubDate>Fri, 04 Apr 2008 20:19:49 +0000</pubDate>
		<dc:creator>josh</dc:creator>
				<category><![CDATA[ajax]]></category>

		<guid isPermaLink="false">http://iamjosh.wordpress.com/?p=60</guid>
		<description><![CDATA[I&#8217;ve been doing some research on AJAX best practices of late and found a few links worth sharing / archiving: Best Practices for Speeding Up Your Web Site (presentation) YSlow: Firefox extension from Yahoo for evaluating site performance with Firebug YUI Compressor: Compressor for CSS, JavaScript Yes, all are from Yahoo, but all seem to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iamjosh.wordpress.com&amp;blog=1975248&amp;post=60&amp;subd=iamjosh&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been doing some research on AJAX best practices of late and found a few links worth sharing / archiving:</p>
<ul>
<li><a href="http://developer.yahoo.com/performance/rules.html" target="_blank">Best Practices for Speeding Up Your Web Site</a> (<a href="http://www.slideshare.net/stoyan/high-performance-web-pages-20-new-best-practices?src=embed" target="_blank">presentation</a>)</li>
<li><a href="http://developer.yahoo.com/yslow/" target="_blank">YSlow</a>: Firefox extension from Yahoo for evaluating site performance with Firebug</li>
<li><a href="http://developer.yahoo.com/yui/compressor/" target="_blank">YUI Compressor</a>: Compressor for CSS, JavaScript</li>
</ul>
<p>Yes, all are from Yahoo, but all seem to be useful, especially the tooling.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/iamjosh.wordpress.com/60/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/iamjosh.wordpress.com/60/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iamjosh.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iamjosh.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iamjosh.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iamjosh.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/iamjosh.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/iamjosh.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/iamjosh.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/iamjosh.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iamjosh.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iamjosh.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iamjosh.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iamjosh.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iamjosh.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iamjosh.wordpress.com/60/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iamjosh.wordpress.com&amp;blog=1975248&amp;post=60&amp;subd=iamjosh&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://iamjosh.wordpress.com/2008/04/04/resources-for-javascript-performance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">josh</media:title>
		</media:content>
	</item>
		<item>
		<title>Encrypting Login Password without SSL in Ruby on Rails</title>
		<link>http://iamjosh.wordpress.com/2008/03/18/encrypting-login-password-without-ssl-in-ruby-on-rails/</link>
		<comments>http://iamjosh.wordpress.com/2008/03/18/encrypting-login-password-without-ssl-in-ruby-on-rails/#comments</comments>
		<pubDate>Tue, 18 Mar 2008 03:04:56 +0000</pubDate>
		<dc:creator>josh</dc:creator>
				<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://iamjosh.wordpress.com/?p=59</guid>
		<description><![CDATA[For a personal project, I am building a Rails site that has an administration section. Of course, I don&#8217;t want any nefarious person who snoops my network traffic to be able to login. SSL isn&#8217;t an easy option because (1) my site is on a shared host, (2) I don&#8217;t want to pay for an [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iamjosh.wordpress.com&amp;blog=1975248&amp;post=59&amp;subd=iamjosh&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>For a personal project, I am building a Rails site that has an administration section.  Of course, I don&#8217;t want any nefarious person who snoops my network traffic to be able to login.  SSL isn&#8217;t an easy option because (1) my site is on a shared host, (2) I don&#8217;t want to pay for an SSL certificate, and (3) I would prefer that my users do not need to accept a self-signed certificate.</p>
<p>Given these conditions, I felt that a private/public key pair would successfully obfuscate login credentials without SSL.  At a high level, my Rails application generates a 1024-bit RSA key on the fly and shares a public version with the client.  The client utilizes an open source RSA library for JavaScript to encrypt the credentials on the client before sending them back to the server, which then uses the private key to decrypt them.  I&#8217;m not an encryption expert, but I think the worst that could happen is that someone could decrypt the credentials for the one request they capture (feel free to correct me though).</p>
<p>Let&#8217;s get to the code.  To set the situation, I am following REST conventions for authentication, so I have a <code>SessionsController</code> with a <code>new</code> action and a <code>create</code> action.  The former is responsible for setting up the login and the latter for processing the user&#8217;s input.</p>
<p>First, the &#8220;new&#8221; action, which creates the RSA key, provides the public components to the view template, and stores the key (in PEM format) in session:</p>
<pre>
  def new
    key = OpenSSL::PKey::RSA.new(1024)
    @public_modulus  = key.public_key.n.to_s(16)
    @public_exponent = key.public_key.e.to_s(16)
    session[:key] = key.to_pem
  end</pre>
<p>Then in the view template (&#8220;new.html.erb&#8221;), we provide the public modulus and exponent (the necessary component of the public key) as well as input forms for the username and password:</p>
<pre>
  &lt;%= javascript_include_tag('rsa/jsbn', 'rsa/prng4', 'rsa/rng', 'rsa/rsa', 'rsa/base64', :cache =&gt; true) %&gt;

  &lt;% form_tag session_path, :id =&gt; 'login' do -%&gt;
  &lt;fieldset&gt;
    &lt;legend&gt;Please Login&lt;/legend&gt;
    &lt;label for="login" class="required"&gt;Login&lt;/label&gt;
    &lt;%= text_field_tag :username, params[:username] %&gt;&lt;br /&gt;
    &lt;label for="password" class="required"&gt;Password&lt;/label&gt;
    &lt;%= password_field_tag :upassword, params[:upassword] %&gt;&lt;br /&gt;
    &lt;%= hidden_field_tag :password, '' %&gt;
  &lt;/fieldset&gt;
  &lt;%= submit_tag 'Log in' %&gt;
  &lt;% end -%&gt;

  &lt;%= hidden_field_tag :public_modulus, @public_modulus %&gt;
  &lt;%= hidden_field_tag :public_exponent, @public_exponent %&gt;</pre>
<p>Two things to note here.  First, we are including the <a href="http://www-cs-students.stanford.edu/~tjw/jsbn/">four necessary JavaScript libraries</a> on this page only.  Second, we use a hidden field to store/commit the password &#8211; this field is populate via JavaScript.</p>
<p>My application utilizes <a href="http://www.jquery.com">jQuery</a>, so attaching a function to encrypt the password before form submission is straightforward:</p>
<pre>
  $(document).ready(function() {
    $("form#login").submit(function() {
      var rsa = new RSAKey();
      rsa.setPublic($('#public_modulus').val(), $('#public_exponent').val());
      var res = rsa.encrypt($('#upassword').val());
      if (res) {
        $('#password').val(hex2b64(res));
        $('#upassword').val('');
        return true;
      }
      return false;
    })
  });</pre>
<p>Before submission occurs, we encrypt the value of the &#8220;upassword&#8221; field, store an encrypted Base64 version in &#8220;password,&#8221; and clear &#8220;upassword.&#8221; If there is a problem, the form is not submitted.</p>
<p>On the server-side, this form is submitted to the <code>SessionsController#create</code> action:</p>
<pre>
  def create
    key = OpenSSL::PKey::RSA.new(session[:key])
    password = key.private_decrypt(Base64.decode64(params[:password]))
    user = User.authenticate(params[:username], password)
    if user
      reset_session  # reset session after login
      session[:user_id] = user.id
      flash[:notice] = "Welcome back, #{user.username}"
      redirect_to admin_url
    else
      flash[:error] = 'Invalid username/password entered'
      new and render :action =&gt; 'new'
    end
  end</pre>
<p>Here, we pull the key out of session and use it to decrypt the form input before attempting to authenticate the user.  It is important to note the the <code>private_decrypt</code> method wants binary data, so we need decode the Base64 text passed in the request (using Base64 seemed more appropriate than binary data here).  After the authenticate method is called, things proceed as usual.</p>
<p>So far, this is working fairly well.  There are a few options for improvement &#8211; perhaps a <code>before_filter</code> to preprocess any encrypted data.  I&#8217;d be interested in hearing other ideas on this topic as well.</p>
<p><b>References</b></p>
<ul>
<li><a href="http://www.ruby-forum.com/topic/120848#601572">Help with OpenSSL RSA</a></li>
<li><a href="http://www-cs-students.stanford.edu/~tjw/jsbn/">BigIntegers and RSA in JavaScript</a></li>
<li><a href="http://stuff-things.net/2007/06/11/encrypting-sensitive-data-with-ruby-on-rails/">Encrypting Sensitive Data with Ruby (on Rails)</a></li>
</ul>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/iamjosh.wordpress.com/59/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/iamjosh.wordpress.com/59/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iamjosh.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iamjosh.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iamjosh.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iamjosh.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/iamjosh.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/iamjosh.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/iamjosh.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/iamjosh.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iamjosh.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iamjosh.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iamjosh.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iamjosh.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iamjosh.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iamjosh.wordpress.com/59/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iamjosh.wordpress.com&amp;blog=1975248&amp;post=59&amp;subd=iamjosh&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://iamjosh.wordpress.com/2008/03/18/encrypting-login-password-without-ssl-in-ruby-on-rails/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">josh</media:title>
		</media:content>
	</item>
		<item>
		<title>jQuery: Focus on First Form Element</title>
		<link>http://iamjosh.wordpress.com/2008/03/10/jquery-focus-on-first-form-element/</link>
		<comments>http://iamjosh.wordpress.com/2008/03/10/jquery-focus-on-first-form-element/#comments</comments>
		<pubDate>Mon, 10 Mar 2008 14:04:03 +0000</pubDate>
		<dc:creator>josh</dc:creator>
				<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://iamjosh.wordpress.com/?p=58</guid>
		<description><![CDATA[All in all, jQuery is pretty cool. I just stated working with it for a personal project and have found it simple and fairly intuitive to use, not to mention the plethora of available plug-ins. I wanted to focus on the first input element in a form using jQuery. I haven&#8217;t tested this extensively, but [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iamjosh.wordpress.com&amp;blog=1975248&amp;post=58&amp;subd=iamjosh&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>All in all, jQuery is pretty cool.  I just stated working with it for a personal project and have found it simple and fairly intuitive to use, not to mention the plethora of available plug-ins.</p>
<p>I wanted to focus on the first input element in a form using jQuery.  I haven&#8217;t tested this extensively, but I came up with the following:</p>
<pre>
    $(document).ready(function() {
       // focus on the first text input field in the first field on the page
        $("input[type='text']:first", document.forms[0]).focus();
    });</pre>
<p>We are simply using a selector to pick the first input element of type &#8220;text&#8221; in the first form on the page (that&#8217;s the &#8220;document.forms[0]&#8221; stuff) and then focus on it.  Of course, this is limited only to text fields, but could be extended to other types as well.  I&#8217;d be interested in hearing about alternatives.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/iamjosh.wordpress.com/58/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/iamjosh.wordpress.com/58/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iamjosh.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iamjosh.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iamjosh.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iamjosh.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/iamjosh.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/iamjosh.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/iamjosh.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/iamjosh.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iamjosh.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iamjosh.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iamjosh.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iamjosh.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iamjosh.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iamjosh.wordpress.com/58/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iamjosh.wordpress.com&amp;blog=1975248&amp;post=58&amp;subd=iamjosh&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://iamjosh.wordpress.com/2008/03/10/jquery-focus-on-first-form-element/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">josh</media:title>
		</media:content>
	</item>
		<item>
		<title>Using RMagick and EXIF to get the date a photo is taken in Rails</title>
		<link>http://iamjosh.wordpress.com/2008/02/12/using-rmagick-to-get-the-date-a-photo-is-taken/</link>
		<comments>http://iamjosh.wordpress.com/2008/02/12/using-rmagick-to-get-the-date-a-photo-is-taken/#comments</comments>
		<pubDate>Tue, 12 Feb 2008 04:20:02 +0000</pubDate>
		<dc:creator>josh</dc:creator>
				<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://iamjosh.wordpress.com/?p=57</guid>
		<description><![CDATA[Wow, it&#8217;s been a long time since my last Rails-related post (actually months). That&#8217;s because it&#8217;s been about that long since I&#8217;ve done much in the way of Rails development. Over the past few weeks, I&#8217;ve been rebuilding my personal website in Rails 2.0, which (per my wife&#8217;s requirements) will include a photo gallery. My [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iamjosh.wordpress.com&amp;blog=1975248&amp;post=57&amp;subd=iamjosh&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Wow, it&#8217;s been a long time since my last Rails-related post (actually months).  That&#8217;s because it&#8217;s been about that long since I&#8217;ve done much in the way of Rails development. Over the past few weeks, I&#8217;ve been rebuilding my personal website in Rails 2.0, which (per my wife&#8217;s requirements) will include a photo gallery.</p>
<p>My <code>Photo</code> class utilized attachment_fu to easily support image uploads.  I also wanted to be able to display the date the photo <i>was taken</i>, not the date is was uploaded.  This information is encoded in the JPEG image file by the digital camera, we just need to pull it out.  Although there are several methods to do this, I chose to use RMagick as it is already included in my application for attachment_fu.  We can use the <code>get_exif_by_entry</code> method to get this (as well as a great deal of other) information:</p>
<pre>
class Photo  &lt; ActiveRecord::Base
  @@exif_date_format = '%Y:%m:%d %H:%M:%S'
  cattr_accessor :exif_date_format

  # some stuff

  def date_taken
    photo = Magick::Image.read(full_filename).first
    # the get_exif_by_entry method returns in the format: [["Make", "Canon"]]
    date  = photo.get_exif_by_entry('DateTime')[0][1]
    return unless date
    DateTime.strptime(date, exif_date_format)
  end

  #some more stuff
end</pre>
<p>That&#8217;s it.  Read the <a href="http://www.exif.org/">EXIF</a> information, provide it&#8217;s format, and create a new <code>DateTime</code> object.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/iamjosh.wordpress.com/57/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/iamjosh.wordpress.com/57/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iamjosh.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iamjosh.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iamjosh.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iamjosh.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/iamjosh.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/iamjosh.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/iamjosh.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/iamjosh.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iamjosh.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iamjosh.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iamjosh.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iamjosh.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iamjosh.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iamjosh.wordpress.com/57/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iamjosh.wordpress.com&amp;blog=1975248&amp;post=57&amp;subd=iamjosh&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://iamjosh.wordpress.com/2008/02/12/using-rmagick-to-get-the-date-a-photo-is-taken/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">josh</media:title>
		</media:content>
	</item>
		<item>
		<title>Data Services with Server-Side Validation</title>
		<link>http://iamjosh.wordpress.com/2008/01/31/data-services-with-server-side-validation/</link>
		<comments>http://iamjosh.wordpress.com/2008/01/31/data-services-with-server-side-validation/#comments</comments>
		<pubDate>Thu, 31 Jan 2008 13:16:00 +0000</pubDate>
		<dc:creator>josh</dc:creator>
				<category><![CDATA[Data Services]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://iamjosh.wordpress.com/?p=56</guid>
		<description><![CDATA[Out of the box, Flex provides a set of great validators for client-side validation of form input (e.g. for phone numbers), but for instances in which we need to involve the server, things become a bit trickier. Before we get into the how though, a quick discussion of the why. There are numerous situations in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iamjosh.wordpress.com&amp;blog=1975248&amp;post=56&amp;subd=iamjosh&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Out of the box, Flex provides a set of great validators for client-side validation of form input (e.g. for phone numbers), but for instances in which we need to involve the server, things become  a bit trickier. Before we get into the how though, a quick discussion of the why. There are numerous situations in which server-side validation is not only nice, but a must.  Consider an application that asks users to register themselves.  The application might ask the user to create a username, but that username must be unique.  We don&#8217;t want to send our entire list of username to the client, so instead we&#8217;ll utilize validation code on the server. In a <a href="http://iamjosh.wordpress.com/2008/01/30/aspect-oriented-validation-in-java/">previous post</a>, I detailed my approach for server-side validation.</p>
<p>In general, the design follows a similar pattern to Rails &#8211; we store a map of errors in an object within the model object itself. Persistent classes that implements the <code>Validateable</code> interface can be validated by our framework and an instance of <code>ValidateableErrors</code> will be injected into the object with a map of validation errors. If the validation framework encounters an error, it halts execution and sends the invalid object (with errors) back to the client.</p>
<p>Once Flex receives the updated object, the application needs to be able to display those errors. To do this, we&#8217;ll utilize a custom implementation of the <code>mx.validators.Validator</code> class. Before we dig into the validator class, let&#8217;s take a quick look at the ActionScript implementation of the <code>ValidateableErrors</code> class:</p>
<pre>
    [Bindable]
    public class ValidateableErrors
    {
        private var _errors : Object;

        public function ValidateableErrors(errors : Object) : void
        {
            this._errors = errors;
        }

        public function getFieldErrors(field : String) : Array
        {
            return this._errors[field] == null ?
                [] : [ this.createValidationResult(this._errors[field]) ];
        }

        private function createValidationResult(msg : String) : ValidationResult
        {
            return new ValidationResult(true, "", "SERVER_ERROR", msg);
        }
    }</pre>
<p>The first thing to note is that instead of using a <code>Dictionary</code>, we are in fact just using a plain old object as this is how LCDS deserializes Java <code>Maps</code> on the Flex side. Each of the keys in the map are now properties for this object.  We can this utilize the &#8220;[]&#8221; notation to retrieve the value of a given property.  The validation message is wrapped in a <code>ValidationResult</code> object, which is utilized by the validator to display error messages in the UI.</p>
<p>Let&#8217;s now take a quick look at the validator implementation:</p>
<pre>
    public class ServerErrorValidator extends Validator
    {
        private var _errors : ValidateableErrors;
        public var field : String;

        public function ServerErrorValidator()
        {
            this._errors = null;
            super();
        }

        public function set errors(errors : ValidateableErrors) : void
        {
            this._errors = errors;
            validate();
        }

        override protected function doValidation(value : Object) : Array
        {
            return this._errors.getFieldErrors(this.field);
        }
    }</pre>
<p>Our validator simply accesses the <code>ValidateableErrors</code> object referenced by the &#8220;errors&#8221; property for a given field. It then displays the error message via the return <code>ValidationResult</code> object.  We can make this a clearer by looking at an example:</p>
<pre>
    &lt;validation:ServerErrorValidator id="firstNameValidator" field="firstName"
        errors="{ this._user.validationErrors }" listener="{ this.firstName }"/&gt;
    &lt;validation:ServerErrorValidator id="lastNameValidator" field="lastName"
        errors="{ this._user.validationErrors }" listener="{ this.lastName }"/&gt;

    &lt;mx:Label x="10" y="10" text="User Validation Test" fontSize="16" color="#FFFFFF" fontWeight="bold"/&gt;
    &lt;mx:Panel x="10" y="42" width="480" height="200" layout="absolute" title="Create User"&gt;
        &lt;mx:Label x="10" y="10" text="First Name:"/&gt;
        &lt;mx:Label x="10" y="36" text="Last Name:"/&gt;
        &lt;mx:TextInput x="127" y="8" id="firstName"/&gt;
        &lt;mx:TextInput x="127" y="34" id="lastName"/&gt;
        &lt;mx:Button x="385" y="128" label="Create" click="createUser()"/&gt;
    &lt;/mx:Panel&gt;</pre>
<p>The <code>User</code> instance (&#8220;<code>_user</code>&#8220;) is defined elsewhere.  Although not ideal, we do need to instantiate one validator per field even though we only reference a single object.  The response from the data service&#8217;s &#8220;createItem&#8221; method is an updated version of the user object with the associated validation errors.  Flex takes care of updating the UI appropriately to display the errors.</p>
<p>This implementation has worked well thus far for my purposes; however, I do see room for improvement in displaying multiple errors messages per field and in making the solution as a whole more flexible. I do welcome feedback.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/iamjosh.wordpress.com/56/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/iamjosh.wordpress.com/56/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/iamjosh.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/iamjosh.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/iamjosh.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/iamjosh.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/iamjosh.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/iamjosh.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/iamjosh.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/iamjosh.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/iamjosh.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/iamjosh.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/iamjosh.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/iamjosh.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/iamjosh.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/iamjosh.wordpress.com/56/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=iamjosh.wordpress.com&amp;blog=1975248&amp;post=56&amp;subd=iamjosh&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://iamjosh.wordpress.com/2008/01/31/data-services-with-server-side-validation/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">josh</media:title>
		</media:content>
	</item>
	</channel>
</rss>
