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

<channel>
	<title>Kris' Blog</title>
	<atom:link href="http://krisselden.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://krisselden.com</link>
	<description>Focused on software development.</description>
	<pubDate>Thu, 27 Mar 2008 03:06:56 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
	<language>en</language>
			<item>
		<title>GameServiceContainer.&#8203;GetService&#60;T&#62;() please&#8230;</title>
		<link>http://krisselden.com/2007/05/29/gameservicecontainergetservice-please/</link>
		<comments>http://krisselden.com/2007/05/29/gameservicecontainergetservice-please/#comments</comments>
		<pubDate>Tue, 29 May 2007 14:09:53 +0000</pubDate>
		<dc:creator>Kris</dc:creator>
		
		<category><![CDATA[Development]]></category>

		<category><![CDATA[xna]]></category>

		<guid isPermaLink="false">http://krisselden.com/2007/05/29/gameservicecontainergetservice-please/</guid>
		<description><![CDATA[One of the most annoying parts of the XNA framework is that the GameServiceContainer lacks generics. After working with Castle container, the XNA container seems ugly.
If .Net had mixins I would just add it myself but until then please vote for my feature request and here is a workaround.
If you have trouble with the Microsoft [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most annoying parts of the XNA framework is that the GameServiceContainer lacks generics. After working with <a href="http://www.castleproject.org/container/index.html">Castle container</a>, the XNA container seems ugly.</p>
<p>If .Net had <a href="http://www.rubycentral.com/book/tut_modules.html">mixins</a> I would just add it myself but until then please vote for my <a href="https://connect.microsoft.com/feedback/ViewFeedback.aspx?FeedbackID=278485&#038;SiteID=226">feature request</a> and here is a <a href="http://www.zaknafein.hjcrusaders.com/?p=23">workaround</a>.</p>
<p>If you have trouble with the Microsoft Connect link, click on the My Participation link to add a connection.</p>
]]></content:encoded>
			<wfw:commentRss>http://krisselden.com/2007/05/29/gameservicecontainergetservice-please/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The operation completed successfully.</title>
		<link>http://krisselden.com/2007/05/10/the-operation-completed-successfully/</link>
		<comments>http://krisselden.com/2007/05/10/the-operation-completed-successfully/#comments</comments>
		<pubDate>Fri, 11 May 2007 02:14:45 +0000</pubDate>
		<dc:creator>Kris</dc:creator>
		
		<category><![CDATA[Development]]></category>

		<category><![CDATA[.net]]></category>

		<category><![CDATA[wpf]]></category>

		<guid isPermaLink="false">http://krisselden.com/2007/05/10/the-operation-completed-successfully/</guid>
		<description><![CDATA[The stacktrace says it all.
System.Runtime.InteropServices.COMException (0x80070000): The operation completed successfully. (Exception from HRESULT: 0x80070000)
   at MS.Internal.HRESULT.Check(Int32 hr)
   at System.Windows.Media.SafeProfileHandle.ReleaseHandle()
   at System.Runtime.InteropServices.SafeHandle.InternalFinalize()
   at System.Runtime.InteropServices.SafeHandle.Dispose(Boolean disposing)
   at System.Runtime.InteropServices.SafeHandle.Finalize()
We made this go away by calling GC.WaitForPendingFinalizers() but this can cause deadlocks in WPF since some Finalize() methods use [...]]]></description>
			<content:encoded><![CDATA[<p>The stacktrace says it all.</p>
<pre class="line5"><code>System.Runtime.InteropServices.COMException (0x80070000): The operation completed successfully. (Exception from HRESULT: 0x80070000)
   at MS.Internal.HRESULT.Check(Int32 hr)
   at System.Windows.Media.SafeProfileHandle.ReleaseHandle()
   at System.Runtime.InteropServices.SafeHandle.InternalFinalize()
   at System.Runtime.InteropServices.SafeHandle.Dispose(Boolean disposing)
   at System.Runtime.InteropServices.SafeHandle.Finalize()</code></pre>
<p>We made this go away by calling GC.WaitForPendingFinalizers() but this can cause deadlocks in WPF since some Finalize() methods use Dispatcher.Invoke().</p>
]]></content:encoded>
			<wfw:commentRss>http://krisselden.com/2007/05/10/the-operation-completed-successfully/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Square inscribed on a wedge (Updated)</title>
		<link>http://krisselden.com/2007/03/01/square-inscribed-on-a-wedge/</link>
		<comments>http://krisselden.com/2007/03/01/square-inscribed-on-a-wedge/#comments</comments>
		<pubDate>Thu, 01 Mar 2007 05:24:17 +0000</pubDate>
		<dc:creator>Kris</dc:creator>
		
		<category><![CDATA[Development]]></category>

		<category><![CDATA[c#]]></category>

		<category><![CDATA[math]]></category>

		<category><![CDATA[wpf]]></category>

		<guid isPermaLink="false">http://krisselden.com/2007/03/01/square-inscribed-on-a-wedge/</guid>
		<description><![CDATA[My first xbap (works in IE only with .Net 3.0).
public static Rect GetSquareInscribedOnWedge(double a, double r, Point center)
{
    double t = Math.Tan(a/2);
    double x = Math.Sqrt(r*r/(1/(t*t) + 4/t + 5));
    return new Rect(center.X - x, center.Y - x/t - 2*x, 2*x, 2*x);
}
I&#8217;m too tired to say [...]]]></description>
			<content:encoded><![CDATA[<p>My first <a href="http://www.krisselden.com/wp-content/uploads/SquareInscribedOnWedge.xbap">xbap</a> (works in IE only with .Net 3.0).</p>
<pre class="line5"><code>public static Rect GetSquareInscribedOnWedge(double a, double r, Point center)
{
    double t = Math.Tan(a/2);
    double x = Math.Sqrt(r*r/(1/(t*t) + 4/t + 5));
    return new Rect(center.X - x, center.Y - x/t - 2*x, 2*x, 2*x);
}</code></pre>
<p>I&#8217;m too tired to say anything about it. I&#8217;ll write more later.</p>
]]></content:encoded>
			<wfw:commentRss>http://krisselden.com/2007/03/01/square-inscribed-on-a-wedge/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Rails deployment</title>
		<link>http://krisselden.com/2007/02/25/rails-deployment/</link>
		<comments>http://krisselden.com/2007/02/25/rails-deployment/#comments</comments>
		<pubDate>Mon, 26 Feb 2007 03:03:15 +0000</pubDate>
		<dc:creator>Kris</dc:creator>
		
		<category><![CDATA[Development]]></category>

		<category><![CDATA[capistrano]]></category>

		<category><![CDATA[mongrel]]></category>

		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://krisselden.com/2007/02/25/rails-deployment/</guid>
		<description><![CDATA[I&#8217;ve been meaning to learn capistrano, but I have a tendency to avoid server configuration, setup and deployment related tasks. Until now, I&#8217;ve been running my rails app with svn checkout and script/server -d on production.
To my surprise, there was no headache and it was actually pretty straightforward. At least with these helpful links:

Time For [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been meaning to learn capistrano, but I have a tendency to avoid server configuration, setup and deployment related tasks. Until now, I&#8217;ve been running my rails app with svn checkout and script/server -d on production.</p>
<p>To my surprise, there was no headache and it was actually pretty straightforward. At least with these helpful links:</p>
<ul>
<li><a href="http://blog.codahale.com/2006/06/19/time-for-a-grown-up-server-rails-mongrel-apache-capistrano-and-you/">Time For A Grown-Up Server: Rails, Mongrel, Apache, Capistrano and You</a></li>
<li><a href="http://mongrel.rubyforge.org/wiki/MongrelCluster">Mongrel Cluster</a></li>
<li><a href="http://mongrel.rubyforge.org/wiki/Apache">Apache Best Practice Deployment</a></li>
</ul>
<p>While the first link covers everything, I used the other two to setup mongrel cluster and apache.</p>
]]></content:encoded>
			<wfw:commentRss>http://krisselden.com/2007/02/25/rails-deployment/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Validating fullwidth alphanumeric input in .Net</title>
		<link>http://krisselden.com/2007/02/19/validating-fullwidth-alphanumeric-input-in-net/</link>
		<comments>http://krisselden.com/2007/02/19/validating-fullwidth-alphanumeric-input-in-net/#comments</comments>
		<pubDate>Tue, 20 Feb 2007 03:52:09 +0000</pubDate>
		<dc:creator>Kris</dc:creator>
		
		<category><![CDATA[Development]]></category>

		<category><![CDATA[.net]]></category>

		<category><![CDATA[ffxi]]></category>

		<category><![CDATA[globalization]]></category>

		<guid isPermaLink="false">http://krisselden.com/2007/02/19/validating-fullwidth-alphanumeric-input-in-net/</guid>
		<description><![CDATA[One of the things that attracted me to playing Final Fantasy XI (a MMORPG) was the opportunity to play on the same server with Japanese players. I’ve been a fan of anime since I was a kid and always curious about Japanese culture.
I noticed that when a Japanese player says 5000 gil (Final Fantasy currency) [...]]]></description>
			<content:encoded><![CDATA[<p>One of the things that attracted me to playing <a href="http://www.playonline.com/ff11us/">Final Fantasy XI</a> (a <a href="http://en.wikipedia.org/wiki/MMORPG">MMORPG</a>) was the opportunity to play on the same server with Japanese players. I’ve been a fan of anime since I was a kid and always curious about Japanese culture.</p>
<p>I noticed that when a Japanese player says 5000 gil (Final Fantasy currency) it looks wide and spaced funny like &#8220;５０００　ｇｉｌ.&#8221; As Japanese players are generally considered to be more <a href="http://en.wikipedia.org/wiki/Leetspeak">l33t</a> by the American players, some even try to mimic this by adding spaces like so &#8220;5 0 0 0  g i l.&#8221; People even <a href="http://www.windower.net/forums/viewtopic.php?t=2050">hack</a> the game to input Japanese text on the American client.</p>
<p>So when my brother called me in a bind about a missed requirement to accept double byte credit card numbers, I knew exactly what he was talking about.<br />
Luckily the web browser deals with the input and on the ASP.NET side it is decoded into a Unicode string. From there it is actually quite simple.</p>
<p>No, int.Parse(string) does not work.</p>
<p>You could loop over each character in the string and use char.IsNumber(char) for validation. You&#8217;d probably want to be more specific char.<a href="http://msdn2.microsoft.com/en-us/library/system.char.getunicodecategory.aspx">GetUnicodeCategory</a>(char) since we don&#8217;t need to support roman numerals.</p>
<pre class="line5"><code>protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
{
    foreach (char c in args.Value)
        if (char.GetUnicodeCategory(c) != UnicodeCategory.DecimalDigitNumber)
            args.IsValid = false;
}</code></pre>
<p>You probably want to normalize it before saving it into the database. You could use (int)char.<a href="http://msdn2.microsoft.com/en-us/library/system.char.getnumericvalue.aspx">GetNumericValue</a>(char) but even easier is to use string.<a href="http://msdn2.microsoft.com/en-us/library/ebza6ck1.aspx">Normalize</a>(<a href="http://msdn2.microsoft.com/en-us/library/system.text.normalizationform.aspx">NormalizationForm</a>.FormKD). You could even normalize the string before validation and run your existing validation on the normalized string.</p>
<p>Output from the <a href="http://msdn2.microsoft.com/en-us/library/f177hahy(VS.80).aspx">Immediate Window (Ctrl-Alt-I)</a></p>
<pre class="line9"><code>'\xFF15'
65301 '５'
Char.IsNumber('５')
true
Char.GetUnicodeCategory('５')
DecimalDigitNumber
Char.GetNumericValue('５')
5.0
"５０００　ｇｉｌ".Normalize(System.Text.NormalizationForm.FormKD)
"5000 gil"</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://krisselden.com/2007/02/19/validating-fullwidth-alphanumeric-input-in-net/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
