05.29.2007
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 Connect link, click on the My Participation link to add a connection.
05.10.2007
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 Dispatcher.Invoke().
03.01.2007
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’m too tired to say anything about it. I’ll write more later.
02.25.2007
I’ve been meaning to learn capistrano, but I have a tendency to avoid server configuration, setup and deployment related tasks. Until now, I’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:
While the first link covers everything, I used the other two to setup mongrel cluster and apache.
02.19.2007
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) it looks wide and spaced funny like “5000 gil.” As Japanese players are generally considered to be more l33t by the American players, some even try to mimic this by adding spaces like so “5 0 0 0 g i l.” People even hack the game to input Japanese text on the American client.
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.
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.
No, int.Parse(string) does not work.
You could loop over each character in the string and use char.IsNumber(char) for validation. You’d probably want to be more specific char.GetUnicodeCategory(char) since we don’t need to support roman numerals.
protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
{
foreach (char c in args.Value)
if (char.GetUnicodeCategory(c) != UnicodeCategory.DecimalDigitNumber)
args.IsValid = false;
}
You probably want to normalize it before saving it into the database. You could use (int)char.GetNumericValue(char) but even easier is to use string.Normalize(NormalizationForm.FormKD). You could even normalize the string before validation and run your existing validation on the normalized string.
Output from the Immediate Window (Ctrl-Alt-I)
'\xFF15'
65301 '5'
Char.IsNumber('5')
true
Char.GetUnicodeCategory('5')
DecimalDigitNumber
Char.GetNumericValue('5')
5.0
"5000 gil".Normalize(System.Text.NormalizationForm.FormKD)
"5000 gil"