Monday, March 23, 2009

Almost Famous


Yours truly, looking embarrassed in the middle.


Here is the link to Phil's write up.


Friday, March 20, 2009

Voidspace on Dot Net Rocks


Michael Foord, aka Voidspace, is on a Dot Net Rocks episode talking about IronPython.


Wednesday, March 04, 2009

Currying with C# and Algotron


Friend and coworker Algotron just posted an intro and sample of currying with C#. I decided to try out currying with the idea of successive regular expressions on a string array - I found it easy to approach first with anonymous delegate syntax and then use lambda expressions. Once this was in place it was easy to understand the use of an extension method to curry any binary function. 

Func<string, string[], Func<string, string[]>> fil = 
delegate(string pattern, string[] lines){
return delegate(string pattern2)
return lines
.Where(p=> Regex.IsMatch(p, pattern))
.Where(p => Regex.IsMatch(p, pattern2))

Func<string, string[], Func<string, string[]>> regFil =
(pattern, input) =>
(pattern2) =>
.Where(p => Regex.IsMatch(p, pattern))
.Where(p => Regex.IsMatch(p, pattern2))

// assume some address data
string[] data = new string[]{"1234 Somewhere", "this", "777 dakota"};

var filterNumeric = regFil(@"\d", data); // make sure it has a number
var filterUCase = filterNumeric("[A-Z]"); // make sure it has an uppercase character

Console.Write(String.Join(",", filterUCase));

That's cool stuff, worth looking at for a while to try to understand.


Tuesday, March 03, 2009

IronPython + SilverlightFX


SilverlightFX is an interesting library for declaratively attaching behaviors to objects in XAML. People new to the Silverlight world will like how they can use it to get simple animations out of simple code. Here's a step by step:

1. If you don't have it done already, set up an IronPython / Silverlight project.

2. Download SilverlightFX

3. Copy SilverlightFX binaries into your /app directory.

3. Edit the AppManifest.xaml to include the SilverlightFX binaries. Here is an example:

<Deployment xmlns="" 
<!-- Add additional assemblies here -->
<AssemblyPart Source="Microsoft.Scripting.ExtensionAttribute.dll" />
<AssemblyPart Source="Microsoft.Scripting.Silverlight.dll" />
<AssemblyPart Source="Microsoft.Scripting.Core.dll" />
<AssemblyPart Source="Microsoft.Scripting.dll" />
<AssemblyPart Source="IronPython.dll" />
<AssemblyPart Source="IronPython.Modules.dll" />
<AssemblyPart Source="System.Windows.Controls.dll" />
<AssemblyPart Source="System.Windows.Controls.Data.dll" />
<AssemblyPart Source="Silverlight.FX.dll" />

4. Edit your app.xaml file to include references to the SilverlightFX namespaces. Here is an example:


5. Party on with some declarative effects.

<Border Grid.Row="1" x:Name="redRect" Opacity="0.2">
<TextBlock x:Name="outPut" TextWrapping="Wrap"
Text="Lorem ipsum dolor sit amet,..." />
<fxeffects:Fade FadeOpacity="1" />

6. Read Nikhil's related blog entries.