<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-9068934273738604863</id><updated>2012-02-16T02:19:06.134-05:00</updated><category term='so'/><title type='text'>Frederic Torres Blog</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>72</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-80655433354992802</id><published>2012-01-02T21:36:00.001-05:00</published><updated>2012-01-28T00:06:01.215-05:00</updated><title type='text'>Customizing an ASP.NET MVC app with a dynamic language</title><content type='html'>&lt;b&gt;Overview&lt;/b&gt;&lt;br /&gt;I like to configure and extend application or service written in C# by using a dynamic language. This form of architecture allows to create customizable application, and the customization is simple, immediate and clean.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Goal&lt;/b&gt;&lt;br /&gt;In this post I am going to show how to build customizable ASP.NET MVC application and the nice syntax obtained. &lt;center&gt;&lt;br /&gt;&lt;b&gt;&lt;i&gt;This is just a prototype to showcase my idea.&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;&lt;/center&gt;&lt;br /&gt;In my project I created a folder Dictionary, which contains Python and PowerShell files. For now we will focus on the Python files.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-ICLjRID4tuA/TwIazDF3BSI/AAAAAAAAAnE/xWc8bHUwFQU/s1600/CustomizableMVC01.jpg" imageanchor="1" style=""&gt;&lt;img border="0" height="400" width="236" src="http://4.bp.blogspot.com/-ICLjRID4tuA/TwIazDF3BSI/AAAAAAAAAnE/xWc8bHUwFQU/s400/CustomizableMVC01.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;The file App.py contains one Python dictionary with 2 entries. As you may reconized this file is also JSON compatible and even if you do not know Python, it is easy to read and understand.&lt;br /&gt;&lt;pre class="brush: python;"&gt;Dic = {&lt;br /&gt;&lt;br /&gt;    "ApplicationTitle"   : "My Customized App Title",&lt;br /&gt;    "ApplicationVersion" : 1.2&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;In my view, I reference the entries this way.&lt;br /&gt;&lt;pre class="brush: html;"&gt;&lt;h3&gt;    AppTitle:@ViewBag.ApplicationTitle &lt;br /&gt;AppVersion:@ViewBag.ApplicationVersion &lt;br /&gt;&lt;/h3&gt;&lt;/pre&gt;In my C# controler the only change is the base class.&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;public class HomeController : Dynamic4MVC.ControllerExtended {&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;So far the App.py file is just a static configuration file.&lt;br /&gt;&lt;br /&gt;I added a new entrie named SupportedDays. This entry is a list of string and it is initialized by invoking the function GetSupportedDays(). Now that's where using a dynamic language versus an XML file becomes interesting, because we can execute code to initialize data, when the Python file is loaded.&lt;br /&gt;&lt;pre class="brush: python;"&gt;def GetSupportedDays():&lt;br /&gt;    return ["Monday", "Wednesday", "Friday"]&lt;br /&gt;&lt;br /&gt;Dic = {&lt;br /&gt;&lt;br /&gt;    "ApplicationTitle"   : "My Customized App Title",&lt;br /&gt;    "ApplicationVersion" : 1.2,&lt;br /&gt;    "SupportedDays"      : GetSupportedDays()    &lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;In my view, I reference the entry SupportedDays this way.&lt;br /&gt;&lt;pre class="brush: html;"&gt;SupportedDays:&lt;br /&gt;    @foreach (var d in ViewBag.SupportedDays) {&lt;br /&gt;        @: @d,&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;We can go a little bit further, by implementing our own class, instantiating objects and invoke methods. The method ToString() will be automatically invoked by the Razor engine.&lt;br /&gt;&lt;pre class="brush: python;"&gt;class User(object):&lt;br /&gt;&lt;br /&gt;    def __init__(self, userName):&lt;br /&gt;        self.UserName = userName&lt;br /&gt;&lt;br /&gt;    def ToString(self):&lt;br /&gt;        return "user:%s" % self.UserName&lt;br /&gt;&lt;br /&gt;Dic = {&lt;br /&gt;    "Users" : [ &lt;br /&gt;           User("FTorres"), &lt;br /&gt;           User("RDescartes")&lt;br /&gt;    ]&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;In my view, I reference the entry Users this way.&lt;br /&gt;&lt;pre class="brush: html;"&gt;@foreach (var u in ViewBag.Users) {&lt;br /&gt;        @: User:@u&lt;br /&gt;}   &lt;br /&gt;&lt;/pre&gt;&lt;b&gt;Conclusion&lt;/b&gt;&lt;br /&gt;At this point we can build a nice DSL (Martin Fowler called them &lt;a href="http://martinfowler.com/bliki/DomainSpecificLanguage.html"&gt;Internal DSL&lt;/a&gt;) dedicated to the customization of the application.&lt;br /&gt;&lt;br /&gt;Python syntax is clean and succinct, and IronPython being a .NET language, there is no integration problem and it is fast. Mixing C# 4.0 and IronPython, is easy and very powerful. It is possible to do it with .NET C# 2.0/3.5 with a little bit more difficulties.&lt;br /&gt;&lt;br /&gt;JavaScript is also a possibilty with the &lt;a href="http://jurassic.codeplex.com/"&gt;Jurassic&lt;/a&gt; runtime which is slow compared to the JavaScript runtime in Chrome or IE9, though speed is not really a problem here.&lt;br /&gt;&lt;br /&gt;Mixing C# and PowerShell v 2 is easy, but the API is kind of ugly and cannot leverage the dynamic feature of C# 4.0 out of the box, like with IronPython. I had to write some internal wrapper described in my post &lt;a href="http://frederictorres.blogspot.com/2011/12/running-powershell-from-c-with-hint-of.html"&gt;Running PowerShell from C# with a hint of dynamic&lt;/a&gt;. With PowerShell v 3, the problem should be solved.&lt;br /&gt;&lt;br /&gt;Depending of your type of application, you may have to cache the dictionary in the Session object, the Application object or your mem cache, because loading and evaluating IronPython or PowerShell code is slow.&lt;br /&gt;&lt;br /&gt;Obviously, those who hate dynamic languages will find this post awful. A more valid question is to ask is: Is it reasonable to ship on a product machine code in a text file?&lt;br /&gt;&lt;br /&gt;To this question I generally find more Pros than Cons. That's just me.&lt;br /&gt;&lt;br /&gt;The source code is on github at &lt;a href="https://github.com/fredericaltorres/DynamicCsToPowerShell-Library"&gt;DynamicCsToPowerShell-Library&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-80655433354992802?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/80655433354992802/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2012/01/customizing-aspnet-mvc-app-with-dynamic.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/80655433354992802'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/80655433354992802'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2012/01/customizing-aspnet-mvc-app-with-dynamic.html' title='Customizing an ASP.NET MVC app with a dynamic language'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-ICLjRID4tuA/TwIazDF3BSI/AAAAAAAAAnE/xWc8bHUwFQU/s72-c/CustomizableMVC01.jpg' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-6227600637843633518</id><published>2011-12-30T22:42:00.019-05:00</published><updated>2011-12-31T14:34:07.898-05:00</updated><title type='text'>Running PowerShell from C# with a hint of dynamic</title><content type='html'>This is an adaptation of my post &lt;a href="http://frederictorres.blogspot.com/2011/06/running-javascript-from-c-with-hint-of.html"&gt;Running JavaScript from C# with a hint of dynamic&lt;/a&gt; using PowerShell.&lt;br /&gt;&lt;br /&gt;Here is a sample using the default api, to execute a powershell code snippet and then access a global variable defined in the PowerShell world from C#.&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;var script = @" $i1 = 123 ";            &lt;br /&gt;var ps = PowerShell.Create();&lt;br /&gt;ps.AddScript(script);&lt;br /&gt;ps.Invoke();            &lt;br /&gt;&lt;br /&gt;int i1 = (int)ps.Runspace.SessionStateProxy.GetVariable("i1");&lt;br /&gt;&lt;br /&gt;Assert.AreEqual(123, i1);&lt;br /&gt;&lt;/pre&gt;What bother me the most is the line 6. Here is the same code using the library DynamicCsToPowerShell.&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;var script = @" $i1 = 123 ";&lt;br /&gt;&lt;br /&gt;var dpsc = DynamicPowerShellContext.Create().Run(script);&lt;br /&gt;&lt;br /&gt;int i1 = dpsc.i1;&lt;br /&gt;&lt;br /&gt;Assert.AreEqual(123, i1);&lt;br /&gt;&lt;/pre&gt;Now compare line 6 from code snippet 1 and line 5 of code snippet 2. The goal of the library DynamicCsToPowerShell is to provide this kind of syntax.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Loading A Configuration File Defined With PowerShell&lt;/b&gt;&lt;br /&gt;Here is a script that implements a .NET hashtable in PowerShell. This can be viewed as a simple configuration file.&lt;br /&gt;&lt;pre class="brush: powershell;"&gt;# An Hashtable in PowerShell&lt;br /&gt;$Dic = @{&lt;br /&gt;&lt;br /&gt;    a = 1&lt;br /&gt;    b = 2&lt;br /&gt;    c = 3&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;Here is how to load, access and use the hashtable.&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;[TestMethod]&lt;br /&gt;public void Dictionary_IntLoadFromFile() {&lt;br /&gt;            &lt;br /&gt;    var ps1ConfigFile = @"..\IntDictionary.ps1";&lt;br /&gt;    var dpsc          = DynamicPowerShellContext.Create();&lt;br /&gt;    dpsc.LoadFile(ps1ConfigFile).Run();&lt;br /&gt;&lt;br /&gt;    Assert.AreEqual(3, dpsc.Dic.Count);&lt;br /&gt;&lt;br /&gt;    Assert.AreEqual(1, dpsc.Dic["a"]);&lt;br /&gt;    Assert.AreEqual(2, dpsc.Dic["b"]);&lt;br /&gt;    Assert.AreEqual(3, dpsc.Dic["c"]);&lt;br /&gt;&lt;br /&gt;    Assert.AreEqual(6, dpsc.Dic["a"] + dpsc.Dic["b"] + dpsc.Dic["c"]);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;First accessing the hashtable's elements is direct. But we can also execute operations on the elements without having to cast to the right type as shown in line 14. &lt;br /&gt;Obviously we are in the world of Dynamic Languages, so if you have a type mismatch, this will give a run time error.&lt;br /&gt;&lt;br /&gt;DynamicCsToPowerShell wraps Array and Hashtable from the PowerShell world into a special object that allow this syntax. Array nested in Hashtable or Hashtable nested in array are supported.&lt;br /&gt;&lt;br /&gt;At this point I did not find any out of the box syntax, to support this clean syntax, like it is possible with IronPython. Talking with &lt;a href="http://dougfinke.com/blog/"&gt;Doug Finke&lt;/a&gt; who is a PowerShell specialist, he mentioned that with PowerShell v 3 we should be able to do it.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Advanced Configuration File With PowerShell&lt;/b&gt;&lt;br /&gt;The ideas behind using a dynamic language to implement a configuration file are:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Using anything but XML&lt;/li&gt;&lt;li&gt;Having an IDE that will understand JSON, JavaScript, IronPython or PowerShell&lt;/li&gt;&lt;li&gt;Executing code when the config file is loaded.&lt;/li&gt;&lt;/ol&gt;Here I have the same PowerShell hashtable, but the value of the key c is set by the execution of the function F1(), when the script is executed.&lt;br /&gt;&lt;pre class="brush: powershell;"&gt;function F1([int] $i1, [int] $i2) {             &lt;br /&gt;&lt;br /&gt; return $i1 + $i2;&lt;br /&gt;}&lt;br /&gt;$Dic = @{&lt;br /&gt;&lt;br /&gt; a = 1  &lt;br /&gt; b = 2 &lt;br /&gt; c = (F1 2 1)&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Conclusion&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;When writing highly customizable application using this technique opens the door to more possibilities with less effort as the dynamic language provides the environment to formalize the customization. We can build our own DSL in the dynamic language.&lt;br /&gt;&lt;br /&gt;I do not find PowerShell as elegant as IronPython or JavaScript, but we can obtain the same result.&lt;br /&gt;&lt;br /&gt;The source code is on github at &lt;a href="https://github.com/fredericaltorres/DynamicCsToPowerShell-Library"&gt;DynamicCsToPowerShell&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-6227600637843633518?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/6227600637843633518/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/12/running-powershell-from-c-with-hint-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/6227600637843633518'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/6227600637843633518'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/12/running-powershell-from-c-with-hint-of.html' title='Running PowerShell from C# with a hint of dynamic'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-7030830090730166690</id><published>2011-11-06T22:25:00.013-05:00</published><updated>2011-11-10T09:44:09.472-05:00</updated><title type='text'>How to deploy a phone gap app to your iOS device</title><content type='html'>Because it is a pain in the Axx, to deploy a phonegap app from xCode 4.x to my device, I grabbed few screen shots, for next time.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;i&gt;Disclamer: I am just a Microsoft/Windows/.Net guy building iOS applications. I am trying to make things easier for me and maybe for you. This probably is incomplete, but if you are new to this world, this should help you a little.&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;You need to register to the iOS dev program to apple.&lt;/li&gt;&lt;li&gt;Install xCode 4&lt;/li&gt;&lt;li&gt;Install Phone Gap&lt;/li&gt;&lt;li&gt;I already created the certificate stuff, which I do not remember exactly.how I did this.&lt;/li&gt;&lt;li&gt;On the apple site (see url below in screen shot), you must register yourself and your device(s).&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;To create your new project in xCode follow &lt;a href="http://phonegap.com/start" target="_blank"&gt;Get Started Guide&lt;/a&gt;&amp;nbsp;from PhoneGap site.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;What I am going to cover here, is how to generate and install &amp;nbsp;the magic key, so xCode will deploy the app to your device.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Generate the app key from the apple web site&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-BbjSxDY3f0s/TrdRNhfLwcI/AAAAAAAAAi8/rieGhlw0Iq0/s1600/S01.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="491" src="http://4.bp.blogspot.com/-BbjSxDY3f0s/TrdRNhfLwcI/AAAAAAAAAi8/rieGhlw0Iq0/s640/S01.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-JlVrWBlCcvs/TrdRONTO1QI/AAAAAAAAAjE/F8_oFsd-Z9s/s1600/S02.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="491" src="http://2.bp.blogspot.com/-JlVrWBlCcvs/TrdRONTO1QI/AAAAAAAAAjE/F8_oFsd-Z9s/s640/S02.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;Create a new app&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-j29Zj_lFF0Q/TrdROeFGrPI/AAAAAAAAAjM/lBJOthquB5c/s1600/S03.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="491" src="http://3.bp.blogspot.com/-j29Zj_lFF0Q/TrdROeFGrPI/AAAAAAAAAjM/lBJOthquB5c/s640/S03.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;Enter the name of your app, this must be the same name as the xCode project name&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-Rpf1mqT6GVM/TrdRO5GEhcI/AAAAAAAAAjU/3CC3yAL8e9Q/s1600/S04.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="492" src="http://2.bp.blogspot.com/-Rpf1mqT6GVM/TrdRO5GEhcI/AAAAAAAAAjU/3CC3yAL8e9Q/s640/S04.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;Select the device you wish to deploy to. Your device must be registered in the apple web site.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-HTHsqjck9ew/TrdRPBauFlI/AAAAAAAAAjc/glIvb7Jj1nw/s1600/S05.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="492" src="http://3.bp.blogspot.com/-HTHsqjck9ew/TrdRPBauFlI/AAAAAAAAAjc/glIvb7Jj1nw/s640/S05.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;Use the certificate you created before&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-XE8RltcdIfs/TrdRPh1baEI/AAAAAAAAAjk/c8tdIa7WZVE/s1600/S06.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="492" src="http://4.bp.blogspot.com/-XE8RltcdIfs/TrdRPh1baEI/AAAAAAAAAjk/c8tdIa7WZVE/s640/S06.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;Enter an app's description&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-mDEeT2xovJg/TrdRQKLHo9I/AAAAAAAAAjo/ViLgA_Rde4w/s1600/S07.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="492" src="http://3.bp.blogspot.com/-mDEeT2xovJg/TrdRQKLHo9I/AAAAAAAAAjo/ViLgA_Rde4w/s640/S07.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;Here is the magic key&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-5KQ1tNiw32c/TrdVQ5pFuRI/AAAAAAAAAlU/YrnIFFd24t0/s1600/S08.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="492" src="http://3.bp.blogspot.com/-5KQ1tNiw32c/TrdVQ5pFuRI/AAAAAAAAAlU/YrnIFFd24t0/s640/S08.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;Download the provisioning file&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-tWVUbCJBZ0s/TrdRQhawaQI/AAAAAAAAAj4/NHsD9qHpi0M/s1600/S09.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="492" src="http://2.bp.blogspot.com/-tWVUbCJBZ0s/TrdRQhawaQI/AAAAAAAAAj4/NHsD9qHpi0M/s640/S09.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;Find the provisioning file in the finder, from chrome you can just click Show in finder.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-V64BUGNx8OQ/TrdRRMmD3bI/AAAAAAAAAkA/tVrb1ga-B0Q/s1600/S10.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="406" src="http://1.bp.blogspot.com/-V64BUGNx8OQ/TrdRRMmD3bI/AAAAAAAAAkA/tVrb1ga-B0Q/s640/S10.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;Open xCode and in the Windows menu, select Organizer&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-XaBDi5E0lMw/TrdRRc7FEDI/AAAAAAAAAkI/9jwHBeP1Ekc/s1600/S11.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="398" src="http://1.bp.blogspot.com/-XaBDi5E0lMw/TrdRRc7FEDI/AAAAAAAAAkI/9jwHBeP1Ekc/s400/S11.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;Drag and drop the file into the Provisioning section. Looks like you have to drop it twice&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Once in the LIBRARY and once in the DEVICES section.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-frkOqUMFOj0/TrviyCOoAfI/AAAAAAAAAlc/WY6FmLuc5yw/s1600/Screen+shot+2011-11-09+at+10.07.52+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="520" src="http://2.bp.blogspot.com/-frkOqUMFOj0/TrviyCOoAfI/AAAAAAAAAlc/WY6FmLuc5yw/s640/Screen+shot+2011-11-09+at+10.07.52+PM.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-SNrhIVkcyyA/TrdRR4wENzI/AAAAAAAAAkQ/8ZzA7e37k8c/s1600/S12.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="448" src="http://3.bp.blogspot.com/-SNrhIVkcyyA/TrdRR4wENzI/AAAAAAAAAkQ/8ZzA7e37k8c/s640/S12.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Open the PList file of your application&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-obbOAIxtTDY/TrdRSB_aGMI/AAAAAAAAAkY/TpQIe69OMnU/s1600/S13.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="476" src="http://2.bp.blogspot.com/-obbOAIxtTDY/TrdRSB_aGMI/AAAAAAAAAkY/TpQIe69OMnU/s640/S13.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;Enter the code in the property Bundle identifier&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/--N9htJ07blk/TrdRSdVBQGI/AAAAAAAAAkg/2Q-BSK2Wxcw/s1600/S14.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="640" src="http://2.bp.blogspot.com/--N9htJ07blk/TrdRSdVBQGI/AAAAAAAAAkg/2Q-BSK2Wxcw/s640/S14.png" width="618" /&gt;&lt;/a&gt;&lt;/div&gt;If your device is plugged to your mac, you can now select to run the application on the device and click run.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-7030830090730166690?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/7030830090730166690/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/11/how-to-deploy-phone-gap-app-to-your.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/7030830090730166690'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/7030830090730166690'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/11/how-to-deploy-phone-gap-app-to-your.html' title='How to deploy a phone gap app to your iOS device'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-BbjSxDY3f0s/TrdRNhfLwcI/AAAAAAAAAi8/rieGhlw0Iq0/s72-c/S01.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-3512033781108401431</id><published>2011-11-06T16:45:00.001-05:00</published><updated>2011-11-13T00:40:35.581-05:00</updated><title type='text'>ASP.NET projet will not start due to daylight savings time</title><content type='html'>On saturday november 7 around 1:30 AM, I was working on HTML5 development using Visual Studio and a regular ASP.NET project.&lt;br /&gt;&lt;br /&gt;Out of the blue the application refuse to start (using Cassini) and I get this error message&lt;br /&gt;&lt;br /&gt;&lt;hr /&gt;&lt;pre&gt;Server Error in '/' Application.&lt;br /&gt;&lt;br /&gt;Specified argument was out of the range of valid values.&lt;br /&gt;Parameter name: utcDate&lt;br /&gt;&lt;br /&gt;Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. &lt;br /&gt;&lt;br /&gt;Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.&lt;br /&gt;Parameter name: utcDate&lt;br /&gt;&lt;br /&gt;Source Error: &lt;br /&gt;&lt;br /&gt;An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.&lt;br /&gt;&lt;br /&gt;Stack Trace: &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[ArgumentOutOfRangeException: Specified argument was out of the range of valid values.&lt;br /&gt;Parameter name: utcDate]&lt;br /&gt;   System.Web.HttpCachePolicy.UtcSetLastModified(DateTime utcDate) +3192626&lt;br /&gt;   System.Web.StaticFileHandler.ProcessRequestInternal(HttpContext context, String overrideVirtualPath) +1130&lt;br /&gt;   System.Web.DefaultHttpHandler.BeginProcessRequest(HttpContext context, AsyncCallback callback, Object state) +347&lt;br /&gt;   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8920324&lt;br /&gt;   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp;amp; completedSynchronously) +184&lt;br /&gt;&lt;br /&gt;Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.225&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;hr /&gt;&lt;br /&gt;After a little bit of google, I concluded it was about some .NET assembly which had a problem with their timestamp. Since I know we were switching daylight savings time,&lt;br /&gt;I was pretty sure that rebooting the machine will do it.&lt;br /&gt;&lt;br /&gt;Well No. may be I should have waited until 02:00 AM the official time change.&lt;br /&gt;&lt;br /&gt;So I set the time on my Windows to one hours back and then every thing works.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Conclusion&lt;/b&gt;&lt;br /&gt;Dealing with Time zones and day light time saving is always a B-ATCH.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-3512033781108401431?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/3512033781108401431/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/11/aspnet-projet-will-not-start-due-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/3512033781108401431'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/3512033781108401431'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/11/aspnet-projet-will-not-start-due-to.html' title='ASP.NET projet will not start due to daylight savings time'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-7186612885588792255</id><published>2011-11-06T16:33:00.000-05:00</published><updated>2011-11-06T16:33:53.348-05:00</updated><title type='text'>quota_exceeded_err with Safari Mobile</title><content type='html'>When using html5 local storage on Safari Mobile (iOS 5), I got this error&lt;br /&gt;&lt;b&gt;quota_exceeded_err 22&lt;/b&gt; out of the blue on one specific web site I was working on.&lt;br /&gt;&lt;br /&gt;Turning the Safari settings &lt;b&gt;&lt;i&gt;private browsing&lt;/i&gt;&lt;/b&gt; off, solved the problem.&lt;br /&gt;&lt;br /&gt;Google will not tell me the all story for now.&lt;br /&gt;I am not the only one with this problem.&lt;br /&gt;&lt;br /&gt;This may save somebody few hours of debugging.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-7186612885588792255?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/7186612885588792255/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/11/quotaexceedederr-with-safari-mobile.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/7186612885588792255'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/7186612885588792255'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/11/quotaexceedederr-with-safari-mobile.html' title='quota_exceeded_err with Safari Mobile'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-4708999468501306366</id><published>2011-11-05T13:22:00.006-04:00</published><updated>2011-11-05T13:45:09.466-04:00</updated><title type='text'>JavaScriptDemoer</title><content type='html'>When I presented at the BOSTON .NET user group and last week at Code camp my talk "JavaScript in 60 minutes for C# developers", I had a lot questions about the tool I used to do the presentation. People were intrigued, so I made it public.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-scywkQOmTE4/TrVvXK5IUEI/AAAAAAAAAg0/7U8PHLtQj-w/s1600/JavaScriptDemoer.jpg" imageanchor="1"&gt;&lt;img border="0" height="206" src="http://4.bp.blogspot.com/-scywkQOmTE4/TrVvXK5IUEI/AAAAAAAAAg0/7U8PHLtQj-w/s400/JavaScriptDemoer.jpg" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;JavaScriptDemoer is a windows application to demo JavaScript and/or C# source code live.&lt;br /&gt;Each page displays:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;A slide written with the MARKDOWN language&lt;/li&gt;&lt;li&gt;An optional C# program, that must compile and may produce a console output.&lt;/li&gt;&lt;ul&gt;&lt;li&gt;.NET 4.0 must be installed.&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;A JavaScript program that must  compile and may produce a console output.&lt;/li&gt;&lt;ul&gt;&lt;li&gt;JavaScriptDemoer comes with nodejs 0.5.10 windows version&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;br /&gt;&lt;b&gt;More information and the source code is on github &lt;a href="https://github.com/fredericaltorres/JavaScriptDemoer"&gt;JavaScriptDemoer&lt;/a&gt;&lt;br /&gt;&lt;/b&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-4708999468501306366?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/4708999468501306366/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/11/javascriptdemoer.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/4708999468501306366'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/4708999468501306366'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/11/javascriptdemoer.html' title='JavaScriptDemoer'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-scywkQOmTE4/TrVvXK5IUEI/AAAAAAAAAg0/7U8PHLtQj-w/s72-c/JavaScriptDemoer.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-3259166642387610949</id><published>2011-10-22T23:32:00.003-04:00</published><updated>2011-11-13T00:44:34.731-05:00</updated><title type='text'>Listening to the Ruby Show and JavaScript Show</title><content type='html'>I used to listen to the &lt;a href="http://rubyshow.com/"&gt;Ruby Show&lt;/a&gt; hosted by Peter Cooper Jason Seifer and switched few months ago to the &lt;a href="http://javascriptshow.com/"&gt;JavaScript Show&lt;/a&gt; which is awsome.&lt;br /&gt;&lt;br /&gt;Listening to theses two, I was surprised by the relations between the Ruby and Python communities. See, I am a .NET developer, that wrote a little bit of Python in the past and now more JavaScript.&lt;br /&gt;&lt;br /&gt;I am aware of these wars of religion between programmers, but I thought Ruby people were nice.&lt;br /&gt;&lt;br /&gt;This inspired me.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-aIRTRFTG5z0/TqOJ6AELTaI/AAAAAAAAAgU/oTgSCvgrjiU/s1600/IDoNotUsuallyWriteCodeInRuby.png" imageanchor="1"&gt;&lt;img border="0" height="400" src="http://1.bp.blogspot.com/-aIRTRFTG5z0/TqOJ6AELTaI/AAAAAAAAAgU/oTgSCvgrjiU/s400/IDoNotUsuallyWriteCodeInRuby.png" width="310" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-3259166642387610949?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/3259166642387610949/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/10/listening-to-ruby-show-and-javascript.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/3259166642387610949'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/3259166642387610949'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/10/listening-to-ruby-show-and-javascript.html' title='Listening to the Ruby Show and JavaScript Show'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-aIRTRFTG5z0/TqOJ6AELTaI/AAAAAAAAAgU/oTgSCvgrjiU/s72-c/IDoNotUsuallyWriteCodeInRuby.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-4192949632787578420</id><published>2011-10-12T23:10:00.000-04:00</published><updated>2011-10-12T23:10:30.910-04:00</updated><title type='text'>Running my HTML5 iPhone app web page demo in Safari Mobile</title><content type='html'>May be a little bit confusing at first&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-UcEs80BxbCQ/TpZVWNsKGEI/AAAAAAAAAgE/D7X53iVnbzE/s1600/IMG_1907.png" imageanchor="1"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/-UcEs80BxbCQ/TpZVWNsKGEI/AAAAAAAAAgE/D7X53iVnbzE/s1600/IMG_1907.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Try this url to understand&lt;br /&gt;&lt;br /&gt;&lt;a href="http://frederictorres.net/iphone.asp?app=1"&gt;Chaka web page demo&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-4192949632787578420?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/4192949632787578420/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/10/running-my-html5-iphone-app-web-page.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/4192949632787578420'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/4192949632787578420'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/10/running-my-html5-iphone-app-web-page.html' title='Running my HTML5 iPhone app web page demo in Safari Mobile'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-UcEs80BxbCQ/TpZVWNsKGEI/AAAAAAAAAgE/D7X53iVnbzE/s72-c/IMG_1907.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-8638561269622579864</id><published>2011-10-02T21:09:00.004-04:00</published><updated>2011-10-26T13:12:00.608-04:00</updated><title type='text'>New England Code Camp 16 - October 29</title><content type='html'>&lt;a href="http://blogs.msdn.com/b/cbowen/archive/2011/10/01/new-england-code-camp-16-registration-and-more.aspx"&gt;New England Code Camp 16&lt;/a&gt; will be saturday October 16.&lt;br /&gt;&lt;br /&gt;I will present my talk "JavaScript in 60 minutes for C# developers" revised to fit in 60&lt;br /&gt;minutes, hopefully.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;JavaScript is everywhere desktop, laptop, phone, tablet, server side applications,&lt;br /&gt;and even in some database engines.&lt;br /&gt;It’s time to learn “The World’s Most Misunderstood Programming Language”.&lt;br /&gt;I will go over some of the JavaScript language features using C# samples as starting point,&lt;br /&gt;to show the simplicity and potential of the language.&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;Slide of the v1: &lt;a href="http://www.frederictorres.net/JavaScript/JavaScriptIn60MinutesForCSharpDevelopers/"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-8638561269622579864?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/8638561269622579864/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/10/new-england-code-camp-16-october-16.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/8638561269622579864'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/8638561269622579864'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/10/new-england-code-camp-16-october-16.html' title='New England Code Camp 16 - October 29'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-8914857706664285277</id><published>2011-09-25T16:30:00.078-04:00</published><updated>2011-09-25T21:46:07.158-04:00</updated><title type='text'>I am going to have to learn to read Objective C</title><content type='html'>Developing with MonoTouch, will require you to at least learn how to read Objective C.&lt;br /&gt;The reason why is that most of the documentation and samples are written in Objective C.&lt;br /&gt;With the latest MonoDevelop+XCode 4.1, interface builder will generate Objective C code, that will be parsed by MonoDevelop and converted into C# for MonoTouch.&lt;br /&gt;&lt;br /&gt;Reading Objective C, is therefore handy and required.&lt;br /&gt;&lt;br /&gt;If you wrote C or C++ in the past, it is not the end of the world.&lt;br /&gt;If you did not, it is going to feel weird.&lt;br /&gt;&lt;br /&gt;Here is a little Objective C sample generated by Interface Builder and its translation in C#.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;The h file.&lt;/b&gt;&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;@interface Test4ViewController : UIViewController {&lt;br /&gt;  IBOutlet UITextField *text1;&lt;br /&gt;  IBOutlet UITextField *text2;&lt;br /&gt;}&lt;br /&gt;- (IBAction)copy:(id)sender;&lt;br /&gt;@end&lt;br /&gt;&lt;/pre&gt;&lt;b&gt;The m file.&lt;/b&gt;&lt;br /&gt;An extension m file, contains the code. Generally we use c or cpp extension.&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;@implementation Test4ViewController&lt;br /&gt;  - (IBAction)copy:(id)sender {&lt;br /&gt;    [text2 setText:[text1 text]];&lt;br /&gt;  }&lt;br /&gt;@end&lt;br /&gt;&lt;/pre&gt;In C# h files do not exist, in Objective C they still do. The @interface keyword defines&lt;br /&gt;the interface of the class. The properties and signature of the methods are part of the @interface.&lt;br /&gt;The implementation is located in the @implementation block. The sequence :(type)name defines a parameter in a method. Calling a method or an expression needs to be enclosed in []. That is the basic to read&lt;br /&gt;&lt;br /&gt;&lt;b&gt;The C# code&lt;/b&gt;&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;class  Test4ViewController : UIViewController {&lt;br /&gt;  UITextField text1;&lt;br /&gt;  UITextField text2;&lt;br /&gt;  IBAction copy(id sender){&lt;br /&gt;    text2.setText(text1.text);&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-8914857706664285277?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/8914857706664285277/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/09/i-am-going-to-have-to-learn-to-read.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/8914857706664285277'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/8914857706664285277'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/09/i-am-going-to-have-to-learn-to-read.html' title='I am going to have to learn to read Objective C'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-8201921763406318912</id><published>2011-09-17T23:52:00.032-04:00</published><updated>2011-09-25T14:36:30.020-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='so'/><title type='text'>Subclassing an array in JavaScript</title><content type='html'>To implement the following C# code in JavaScript, the more common solution is to subclass an array, which comes with few problems. &lt;br /&gt;&lt;pre class="brush: javascript;"&gt;public class PersonList : List&amp;lt;Person&amp;gt; {&lt;br /&gt;    public string Name;&lt;br /&gt;    public PersonList(string name){&lt;br /&gt;        this.Name = name;&lt;br /&gt;    }&lt;br /&gt;    public int GetSumYears() {&lt;br /&gt;        var total = 0;&lt;br /&gt;        foreach (var p in this)&lt;br /&gt;            total += p.BirthDate.Year;&lt;br /&gt;        return total;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;Among other thing a bug in IE8. I personally focus on ECMAScript 5, so this is not my concern for this post, I also want to use ECMAScript 5, property get.&lt;br /&gt;&lt;br /&gt;A blog post by Juriy Zaytsev, &lt;a href="http://perfectionkills.com/how-ecmascript-5-still-does-not-allow-to-subclass-an-array/"&gt;How ECMAScript 5 still does not allow to subclass an array &lt;/a&gt; will tell you every thing about it.&lt;br /&gt;&lt;br /&gt;I also like to mention a post from Andrea Giammarchi &lt;a href="http://webreflection.blogspot.com/2008/05/habemus-array-unlocked-length-in-ie8.html"&gt;Habemus Array ... unlocked length in IE8, subclassed Array for every browser&lt;/a&gt;, which proposes a solution to implement a Stack object which I re-used to implement my List() object.&lt;br /&gt;&lt;br /&gt;This post is my implementation of the C# List&amp;lt;T&amp;gt; in JavaScript. First here is the kind of code I want to be able to write.&lt;br /&gt;&lt;br /&gt;The source code is now part of my library &lt;a href="https://github.com/fredericaltorres/fjs.lib"&gt;&lt;b&gt;fJs.lib&lt;/b&gt;&lt;/a&gt; on github.&lt;br /&gt;&lt;pre class="brush: javascript;"&gt;var l = new List();&lt;br /&gt;for(var i=0; i&lt;5; i++){&lt;br /&gt;    l.add(i);&lt;br /&gt;}&lt;br /&gt;l.addRange(5, 6, 7, 8, 9);&lt;br /&gt;print(l.toString()); // 0,1,2,3,4,5,6,7,8,9&lt;br /&gt;&lt;br /&gt;l.removeAt(0);&lt;br /&gt;l.remove(9);&lt;br /&gt;print(l.toString()); // 1,2,3,4,5,6,7,8&lt;br /&gt;&lt;br /&gt;var l2 = l.filter(function(v){ return v % 2 == 0; });&lt;br /&gt;print(l2.toString()); // 2,4,6,8&lt;br /&gt;&lt;br /&gt;var l3 = l.map(function(v){ return v*v; });&lt;br /&gt;print(l3.toString()); // 1,4,9,16,25,36,49,64,81,81&lt;br /&gt;&lt;br /&gt;print(l instanceof List);  // true&lt;br /&gt;print(l instanceof Array); // true&lt;br /&gt;&lt;/pre&gt;My first idea was to start with something like that&lt;pre class="brush: javascript;"&gt;function List() {&lt;br /&gt;    var&lt;br /&gt;        _list = [];&lt;br /&gt;&lt;br /&gt;    _list.add = function(v){&lt;br /&gt;        this.push(v);&lt;br /&gt;    }&lt;br /&gt;    return _list;&lt;br /&gt;}&lt;br /&gt;var l = new List();&lt;br /&gt;print(l instanceof Array); // true&lt;br /&gt;print(l instanceof List);  // false&lt;br /&gt;&lt;/pre&gt;But the object returned by the List() constructor is not an instance of List, which is confusing. So I re-used the Stack implementation of Andrea Giammarchi which solve this problem. Creating the object is a little bit more complex, but then adding the methods remain simple.Here is the List object properties and methods.&lt;pre&gt;&lt;b&gt;List&lt;/b&gt;&lt;br /&gt;  properties:&lt;br /&gt;     count&lt;br /&gt;  method:&lt;br /&gt; &lt;br /&gt;     add&lt;br /&gt;     addRange&lt;br /&gt;     all&lt;br /&gt;     any&lt;br /&gt;     concat&lt;br /&gt;     contains&lt;br /&gt;     exists&lt;br /&gt;     findAll&lt;br /&gt;     findIndex&lt;br /&gt;     remove&lt;br /&gt;     removeAll&lt;br /&gt;     removeAt&lt;br /&gt;     reverse&lt;br /&gt;     &lt;br /&gt;     filter&lt;br /&gt;     map&lt;br /&gt;&lt;/pre&gt;&lt;b&gt;The source code&lt;/b&gt;&lt;hr&gt;Here is the source code with some unit tests. I ran the code on NodeJS.&lt;pre class="brush: javascript;"&gt;//&lt;br /&gt;// Class List a match for the C# .NET List&amp;lt;T&gt; - Frederic Torres 2011&lt;br /&gt;// Mit Style License&lt;br /&gt;//&lt;br /&gt;// based on&lt;br /&gt;// - Andrea Giammarchi's Stack&lt;br /&gt;//      http://webreflection.blogspot.com/2008/05/habemus-array-unlocked-length-in-ie8.html&lt;br /&gt;// - How ECMAScript 5 still does not allow to subclass an array&lt;br /&gt;//      http://perfectionkills.com/how-ecmascript-5-still-does-not-allow-to-subclass-an-array/&lt;br /&gt;//&lt;br /&gt;var List = (function(){&lt;br /&gt;    var&lt;br /&gt;        MAX_SIGNED_INT_VALUE = Math.pow(2, 32) - 1;&lt;br /&gt;&lt;br /&gt;    function __isFunction(f) {&lt;br /&gt;&lt;br /&gt;        return typeof f === 'function';&lt;br /&gt;    }&lt;br /&gt;    function __toUint32(value) {&lt;br /&gt;&lt;br /&gt;        return value &gt;&gt;&gt; 0;&lt;br /&gt;    }&lt;br /&gt;    function __isInt(v){&lt;br /&gt;&lt;br /&gt;        return String(__toUint32(v)) === v;&lt;br /&gt;    }&lt;br /&gt;    function __removeAt(that, index) {&lt;br /&gt;&lt;br /&gt;        that.splice(index ,1);&lt;br /&gt;    }&lt;br /&gt;    function _list(length) {&lt;br /&gt;&lt;br /&gt;        if (arguments.length === 1 &amp;&amp; typeof length === "number") {&lt;br /&gt;            this.length = -1 &lt; length &amp;&amp; length === length &lt;&lt; 1 &gt;&gt; 1 ? length : this.push(length);&lt;br /&gt;        }&lt;br /&gt;        else if (arguments.length) {&lt;br /&gt;            this.push.apply(this, arguments);&lt;br /&gt;        }&lt;br /&gt;        Object.defineProperty(this, "count", {&lt;br /&gt;&lt;br /&gt;            get: function(){ return this.length; },&lt;br /&gt;        });&lt;br /&gt;    }&lt;br /&gt;    function _array() { };&lt;br /&gt;    _array.prototype           = [];&lt;br /&gt;&lt;br /&gt;    _list.prototype            = new _array();&lt;br /&gt;    _list.prototype.length     = 0;&lt;br /&gt;&lt;br /&gt;    _list.prototype.toString   = function () {&lt;br /&gt;&lt;br /&gt;        return this.slice(0).toString();&lt;br /&gt;    }&lt;br /&gt;    _list.prototype.add = function (v) {&lt;br /&gt;&lt;br /&gt;        this.push(v);&lt;br /&gt;    }&lt;br /&gt;    _list.prototype.addRange = function () {&lt;br /&gt;        var i;&lt;br /&gt;        for(i=0; i &lt; arguments.length; i++)&lt;br /&gt;            this.add(arguments[i]);&lt;br /&gt;    };&lt;br /&gt;   _list.prototype.clear = function (v) {&lt;br /&gt;&lt;br /&gt;        this.length = 0;&lt;br /&gt;    }&lt;br /&gt;   _list.prototype.removeAt = function (index) {&lt;br /&gt;        if(this.count==0)&lt;br /&gt;            throw new Error("Cannot removeAt from empty List");&lt;br /&gt;&lt;br /&gt;        if(index&gt;=0 &amp;&amp; index &lt; this.count)&lt;br /&gt;            __removeAt(this, index);&lt;br /&gt;        else&lt;br /&gt;            throw new Error("invalid index "+index+" for List");&lt;br /&gt;    }&lt;br /&gt;   _list.prototype.remove = function (val) {&lt;br /&gt;        var&lt;br /&gt;            elementRemoved = 0,&lt;br /&gt;            index = this.indexOf(val);&lt;br /&gt;&lt;br /&gt;        if(index===-1)&lt;br /&gt;            return 0;&lt;br /&gt;&lt;br /&gt;        while(index!==-1){&lt;br /&gt;            __removeAt(this, index);&lt;br /&gt;            elementRemoved++;&lt;br /&gt;            index = this.indexOf(val);&lt;br /&gt;        }&lt;br /&gt;        return elementRemoved;&lt;br /&gt;    }&lt;br /&gt;    _list.prototype.contains = function (val) {&lt;br /&gt;&lt;br /&gt;        return this.indexOf(val) !== -1;&lt;br /&gt;    }&lt;br /&gt;   _list.prototype.concat = function (l) {&lt;br /&gt;        var&lt;br /&gt;            i;&lt;br /&gt;        for(i in this)&lt;br /&gt;            if(__isInt(i))&lt;br /&gt;                this.add(l[i]);&lt;br /&gt;    }&lt;br /&gt;   _list.prototype.findIndex = function (lambda) {&lt;br /&gt;        var&lt;br /&gt;            i,&lt;br /&gt;            r = new List();&lt;br /&gt;&lt;br /&gt;        if(!__isFunction(lambda))&lt;br /&gt;            throw new Error("exists() requires a function as parameter");&lt;br /&gt;&lt;br /&gt;        for(i in this)&lt;br /&gt;            if((__isInt(i))&amp;&amp;(lambda(this[i])))&lt;br /&gt;                r.add(i);&lt;br /&gt;&lt;br /&gt;        return r;&lt;br /&gt;    }&lt;br /&gt;   _list.prototype.exists = function (lambda) {&lt;br /&gt;        var&lt;br /&gt;            i,&lt;br /&gt;            r = new List();&lt;br /&gt;&lt;br /&gt;        if(!__isFunction(lambda))&lt;br /&gt;            throw new Error("exists() requires a function as parameter");&lt;br /&gt;&lt;br /&gt;        for(i in this)&lt;br /&gt;            if((__isInt(i)) &amp;&amp; (lambda(this[i])))&lt;br /&gt;                return true;&lt;br /&gt;&lt;br /&gt;        return false;&lt;br /&gt;    }&lt;br /&gt;   _list.prototype.removeAll = function (lambda) {&lt;br /&gt;        var&lt;br /&gt;            goOn = true,&lt;br /&gt;            i;&lt;br /&gt;&lt;br /&gt;        if(!__isFunction(lambda))&lt;br /&gt;            throw new Error("exists() requires a function as parameter");&lt;br /&gt;&lt;br /&gt;        while(goOn){&lt;br /&gt;            goOn = false;&lt;br /&gt;            for(i in this){&lt;br /&gt;                if((__isInt(i)) &amp;&amp; (lambda(this[i]))) {&lt;br /&gt;                    __removeAt(this, i);&lt;br /&gt;                    goOn = true;&lt;br /&gt;                    break;&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;   _list.prototype.all = function (lambda) {&lt;br /&gt;        var&lt;br /&gt;            i,&lt;br /&gt;            r = new List();&lt;br /&gt;&lt;br /&gt;        if(!__isFunction(lambda))&lt;br /&gt;            throw new Error("exists() requires a function as parameter");&lt;br /&gt;&lt;br /&gt;        for(i in this)&lt;br /&gt;            if((__isInt(i)) &amp;&amp; (!lambda(this[i])))&lt;br /&gt;                return false;&lt;br /&gt;        return true;&lt;br /&gt;    }&lt;br /&gt;   _list.prototype.any = function (lambda) {&lt;br /&gt;        var&lt;br /&gt;            i,&lt;br /&gt;            r = new List();&lt;br /&gt;&lt;br /&gt;        if(!__isFunction(lambda))&lt;br /&gt;            throw new Error("exists() requires a function as parameter");&lt;br /&gt;&lt;br /&gt;        for(i in this)&lt;br /&gt;            if((__isInt(i)) &amp;&amp; (lambda(this[i])))&lt;br /&gt;                    return true;&lt;br /&gt;        return false;&lt;br /&gt;    }&lt;br /&gt;    _list.prototype.reverse = function () {&lt;br /&gt;        var&lt;br /&gt;            values = [],&lt;br /&gt;            i;&lt;br /&gt;&lt;br /&gt;        for(i in this)&lt;br /&gt;            if(__isInt(i))&lt;br /&gt;                values.unshift(this[i]);&lt;br /&gt;&lt;br /&gt;        this.clear();&lt;br /&gt;&lt;br /&gt;        this.push.apply(this, values);&lt;br /&gt;    }&lt;br /&gt;   _list.prototype.filter = function (lambda) {&lt;br /&gt;        var&lt;br /&gt;            i,&lt;br /&gt;            r = new List();&lt;br /&gt;&lt;br /&gt;        if(!__isFunction(lambda))&lt;br /&gt;            throw new Error("filter() requires a function as parameter");&lt;br /&gt;&lt;br /&gt;        for(i in this)&lt;br /&gt;            if(__isInt(i))&lt;br /&gt;                if(lambda(this[i]))&lt;br /&gt;                    r.add(this[i]);&lt;br /&gt;        return r;&lt;br /&gt;    }&lt;br /&gt;    _list.prototype.findAll = function (lambda) {&lt;br /&gt;        // Just to have the same .net method&lt;br /&gt;        return this.filter(lambda);&lt;br /&gt;    }&lt;br /&gt;   _list.prototype.map = function (lambda) {&lt;br /&gt;        var&lt;br /&gt;            i,&lt;br /&gt;            r = new List();&lt;br /&gt;&lt;br /&gt;        if(!__isFunction(lambda))&lt;br /&gt;            throw new Error("map() requires a function as parameter");&lt;br /&gt;&lt;br /&gt;        for(i in this)&lt;br /&gt;            if(__isInt(i))&lt;br /&gt;               r.add(lambda(this[i]));&lt;br /&gt;        return r;&lt;br /&gt;    }&lt;br /&gt;    _list.prototype.constructor = _list;&lt;br /&gt;    return _list;&lt;br /&gt;})();&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;b&gt;The unit tests.&lt;/b&gt;&lt;hr&gt;For now it is the unit tests of the poor until I include this in my own JavaScript library and probably add it on github.&lt;pre class="brush: javascript;"&gt;function isNodeJs() {&lt;br /&gt;    return (typeof require === "function" &amp;&amp; typeof Buffer === "function" &amp;&amp; typeof Buffer.byteLength === "function" &amp;&amp; typeof Buffer.prototype !== "undefined" &amp;&amp; typeof Buffer.prototype.write === "function");&lt;br /&gt;}&lt;br /&gt;function print(s){&lt;br /&gt;    console.log(s);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;if(isNodeJs()){&lt;br /&gt;&lt;br /&gt;    var Assert = {&lt;br /&gt;        isTrue      : function(e){ if(!e) throw new Error("IsTrue failed"); },&lt;br /&gt;        isFalse     : function(e){ if(!!e) throw new Error("IsTrue failed"); },&lt;br /&gt;        areEqual    : function(v1,v2){ if(v1!==v2) throw new Error("expected:"+v1+" is not equal to actual:"+v2); }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    var l = new List(1, 2, 3);&lt;br /&gt;    Assert.areEqual(3, l.count);&lt;br /&gt;    Assert.areEqual("1,2,3", l.toString());&lt;br /&gt;&lt;br /&gt;    var l = new List();&lt;br /&gt;    Assert.areEqual(0, l.count);&lt;br /&gt;    l.add(1);&lt;br /&gt;    l.add(2);&lt;br /&gt;    l.add(3);&lt;br /&gt;    Assert.areEqual("1,2,3", l.toString());&lt;br /&gt;    Assert.areEqual(3, l.count);&lt;br /&gt;&lt;br /&gt;    var l = new List(1, 2, 3);&lt;br /&gt;    l.removeAt(1);&lt;br /&gt;    Assert.areEqual(2, l.count);&lt;br /&gt;    Assert.areEqual("1,3", l.toString());&lt;br /&gt;&lt;br /&gt;    var l = new List(1, 2, 3);&lt;br /&gt;    Assert.areEqual(1,l.remove(2));&lt;br /&gt;    Assert.areEqual(2, l.count);&lt;br /&gt;    Assert.areEqual("1,3", l.toString());&lt;br /&gt;&lt;br /&gt;    var l = new List(1, 2, 3, 1, 1);&lt;br /&gt;    Assert.areEqual(3,l.remove(1));&lt;br /&gt;    Assert.areEqual(2, l.count);&lt;br /&gt;    Assert.areEqual("2,3", l.toString());&lt;br /&gt;&lt;br /&gt;    var l1 = new List(1, 2, 3);&lt;br /&gt;    var l2 = new List(4, 5, 6);&lt;br /&gt;    l1.concat(l2);&lt;br /&gt;    print(l1.toString());&lt;br /&gt;    Assert.areEqual("1,2,3,4,5,6", l1.toString());&lt;br /&gt;&lt;br /&gt;    var l = new List(1, 2, 3);&lt;br /&gt;    Assert.isTrue(l instanceof List);&lt;br /&gt;    Assert.isTrue(l instanceof Array);&lt;br /&gt;&lt;br /&gt;    var l = new List(1, 2, 3, 4);&lt;br /&gt;    var ll = l.filter(function(v){ return v % 2 == 0; });&lt;br /&gt;    Assert.areEqual("2,4", ll.toString());&lt;br /&gt;&lt;br /&gt;    var l = new List(1, 2, 3, 4);&lt;br /&gt;    var ll = l.map(function(v){ return v*v; });&lt;br /&gt;    Assert.areEqual("1,4,9,16", ll.toString());&lt;br /&gt;&lt;br /&gt;    var l = new List();&lt;br /&gt;    l.addRange(1, 2, 3);&lt;br /&gt;    Assert.areEqual("1,2,3", l.toString());&lt;br /&gt;&lt;br /&gt;    var l = new List(1, 2, 3);&lt;br /&gt;    l.clear();&lt;br /&gt;    Assert.areEqual(0, l.count);&lt;br /&gt;    Assert.areEqual("", l.toString());&lt;br /&gt;    l.add(1);&lt;br /&gt;    Assert.areEqual("1", l.toString());&lt;br /&gt;    Assert.areEqual(1, l.count);&lt;br /&gt;    l.addRange(2, 3, 4);&lt;br /&gt;    Assert.areEqual("1,2,3,4", l.toString());&lt;br /&gt;&lt;br /&gt;    var l = new List(1, 2, 3);&lt;br /&gt;    Assert.isTrue(l.contains(2));&lt;br /&gt;    Assert.isFalse(l.contains(12));&lt;br /&gt;&lt;br /&gt;    var l = new List(1, 2, 3);&lt;br /&gt;    Assert.isTrue( l.exists(function(v){ return v == 2;  }));&lt;br /&gt;    Assert.isFalse(l.exists(function(v){ return v == 12; }));&lt;br /&gt;&lt;br /&gt;    var l = new List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);&lt;br /&gt;    l.name='fred';&lt;br /&gt;    Assert.isTrue ( l.all(function(v){ return v &gt; 0;  }));&lt;br /&gt;    Assert.isFalse( l.all(function(v){ return v &gt; 5;  }));&lt;br /&gt;&lt;br /&gt;    var l = new List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);&lt;br /&gt;    l.name='fred';&lt;br /&gt;    Assert.isTrue ( l.any(function(v){ return v &gt; 0;  }));&lt;br /&gt;    Assert.isFalse( l.any(function(v){ return v &gt; 15;  }));&lt;br /&gt;&lt;br /&gt;    var l = new List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);&lt;br /&gt;    Assert.areEqual( "1,3,5,7,9", l.findIndex(function(v){ return v % 2 == 0; }).toString() );&lt;br /&gt;&lt;br /&gt;    var l = new List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);&lt;br /&gt;    l.removeAll(function(v){ return v % 2 == 0; });&lt;br /&gt;    Assert.areEqual( "1,3,5,7,9", l.toString() );&lt;br /&gt;&lt;br /&gt;    var l = new List(1, 2, 3, 4, 5);&lt;br /&gt;    l.reverse();&lt;br /&gt;    Assert.areEqual( "5,4,3,2,1", l.toString() );&lt;br /&gt;&lt;br /&gt;    print("---------------------");&lt;br /&gt;    var l = new List();&lt;br /&gt;    for(var i=0; i &lt; 5; i++){&lt;br /&gt;        l.add(i);&lt;br /&gt;    }&lt;br /&gt;    l.addRange(5, 6, 7, 8, 9);&lt;br /&gt;    print(l.toString()); // 0,1,2,3,4,5,6,7,8,9&lt;br /&gt;&lt;br /&gt;    l.removeAt(0);&lt;br /&gt;    l.remove(9);&lt;br /&gt;    print(l.toString()); // 1,2,3,4,5,6,7,8&lt;br /&gt;&lt;br /&gt;    var l2 = l.filter(function(v){ return v % 2 == 0; });&lt;br /&gt;    print(l2.toString()); // 2,4,6,8&lt;br /&gt;&lt;br /&gt;    var l3 = l.map(function(v){ return v*v; });&lt;br /&gt;    print(l3.toString()); // 1,4,9,16,25,36,49,64,81,81&lt;br /&gt;&lt;br /&gt;    print(l instanceof List);  // true&lt;br /&gt;    print(l instanceof Array); // true&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-8201921763406318912?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/8201921763406318912/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/09/subclassing-array-in-javascript.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/8201921763406318912'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/8201921763406318912'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/09/subclassing-array-in-javascript.html' title='Subclassing an array in JavaScript'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-1121162690114606594</id><published>2011-09-05T19:46:00.006-04:00</published><updated>2011-09-05T20:09:50.804-04:00</updated><title type='text'>Lessons learned porting C# code from Windows to MacOS and iOS</title><content type='html'>I started porting C# code to MacOS and iOS and found some interesting problems, how to correct them or what best practices to follow, to have the same code running correctly on all operating systems.   I will use this post to gather all my findings.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;&lt;b&gt;NewLine&lt;/b&gt;&lt;br /&gt;You probably know that text file line separator on Windows are defined as CR+LF and on MacOS  are defined as LF. The property System.Environment.NewLine will return the right value, but. Look at this code below  &lt;pre class="brush: csharp;"&gt;var t = b.ToString();&lt;br /&gt;if(t.EndsWith(System.Environment.NewLine))&lt;br /&gt;    t = t.Substring(0, t.Length-2);&lt;br /&gt;&lt;/pre&gt;I supposed that the length of NewLine is always 2. Wrong. Here is the right way.  &lt;pre class="brush: csharp;"&gt;var t = b.ToString();&lt;br /&gt;if(t.EndsWith(System.Environment.NewLine))&lt;br /&gt;    t = t.Substring(0, t.Length-System.Environment.NewLine.Length);&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;&lt;b&gt;TEMP Folder&lt;/b&gt;&lt;br /&gt;When I need to create a temporary file, I always used the following &lt;pre class="brush: csharp;"&gt;var t = b.ToString();&lt;br /&gt;var fileName  = String.Format(@"{0}\DSSharpLibrary_UnitTests.txt", Environment.GetEnvironmentVariable("TEMP"));&lt;br /&gt;&lt;/pre&gt;Well this code does not work on MacOS, but you can use the following code which will work on Windows, MacOS and iOS.  &lt;pre class="brush: csharp;"&gt;var t = b.ToString();&lt;br /&gt;var fileName  = String.Format(@"{0}DSSharpLibrary_UnitTests.txt", System.IO.Path.GetTempPath());&lt;br /&gt;&lt;/pre&gt;Note that GetTempPath() will return a '\' at the end in Windows or a '/' at the end on MacOS.  Do not prefix your file name with any slash.   &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-1121162690114606594?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/1121162690114606594/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/09/lessons-learn-porting-c-to-macos-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/1121162690114606594'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/1121162690114606594'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/09/lessons-learn-porting-c-to-macos-and.html' title='Lessons learned porting C# code from Windows to MacOS and iOS'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-1178339268772713930</id><published>2011-07-30T00:59:00.240-04:00</published><updated>2011-10-23T21:11:50.709-04:00</updated><title type='text'>My first phone application with jQuery Mobile and Chaka</title><content type='html'>&lt;span class="Apple-style-span" style="font-size: large;"&gt;Introduction&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Chaka, is an extension to jQuery Mobile to be able to develop HTML5 applications with Visual Studio 2010.&lt;br /&gt;&lt;br /&gt;Developing HTML5 applications with jQuery Mobile give you a lot, but there are few things that you have to manage on your own.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;How to organize your Html and JavaScript files&lt;/li&gt;&lt;li&gt;Concept of code behind with events as seen in Win Form or ASP.NET&lt;/li&gt;&lt;li&gt;JavaScript syntax verification before execution (Google Closure Compiler)&lt;/li&gt;&lt;li&gt;F5 run and debug&lt;/li&gt;&lt;li&gt;Writing your application in CoffeeScript rather than JavaScript&lt;/li&gt;&lt;li&gt;DEBUG or RELEASE mode (In RELEASE mode html, js, css files are minified and the number of js files is reduced)&lt;/li&gt;&lt;li&gt;Publishing the application to the web in RELEASE mode&lt;/li&gt;&lt;li&gt;Remote debugging with jsconsole.com for instance&lt;/li&gt;&lt;li&gt;PhoneGap integration&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;These are &amp;nbsp;things that Chaka bring to the table. &lt;br /&gt;&lt;br /&gt;I intend to release it, on github at some point, it is still in prototype mode.&lt;br /&gt;&lt;br /&gt;The main idea is to use Visual Studio and click &amp;nbsp;File -&amp;gt; New -&amp;gt; Project. Select Chaka Project.&lt;br /&gt;The project will come with: &amp;nbsp;a main page, an about page, an options page and from there you can add your own pages from a template and start coding away. &lt;br /&gt;Press F5 and start running and debugging your HTML5 application with Chrome or FireFox. then use the Visual Studio 2010 &lt;i&gt;&lt;b&gt;Publish&lt;/b&gt;&lt;/i&gt; feature, to publish your app to the web via FTP.&lt;br /&gt;Then yo can run it from all devices supported by jQuery Mobile.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;A First Application&lt;/span&gt;&lt;/div&gt;&lt;div&gt;The application is a restaurant tip calculator and total bill divider.&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;b&gt;The splash screen&lt;/b&gt;&lt;/i&gt;: The splash screen will only work on iOS.&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-FJLuD05SwDI/TjOOSDSBFTI/AAAAAAAAAeU/IzOPfxJo1cE/s1600/01.Splash.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://4.bp.blogspot.com/-FJLuD05SwDI/TjOOSDSBFTI/AAAAAAAAAeU/IzOPfxJo1cE/s320/01.Splash.png" width="213" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;b&gt;The main page&lt;/b&gt;&lt;/i&gt;:&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-f5ldcjbKWDs/TjQ0wHov2aI/AAAAAAAAAes/H4IVlG8liD4/s1600/02.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://2.bp.blogspot.com/-f5ldcjbKWDs/TjQ0wHov2aI/AAAAAAAAAes/H4IVlG8liD4/s320/02.png" width="213" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Let's enter an amount and press done&lt;/div&gt;&lt;div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-tgudAjecGSc/TjQ0zD4UbuI/AAAAAAAAAew/kDP7X0Cu-gk/s1600/03.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://2.bp.blogspot.com/-tgudAjecGSc/TjQ0zD4UbuI/AAAAAAAAAew/kDP7X0Cu-gk/s320/03.png" width="213" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;Here the results&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-lFHCRjz3WZ4/TjQ02msNP3I/AAAAAAAAAe0/yMAdjA-ARmc/s1600/04.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://4.bp.blogspot.com/-lFHCRjz3WZ4/TjQ02msNP3I/AAAAAAAAAe0/yMAdjA-ARmc/s320/04.png" width="213" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;i&gt;&lt;b&gt;The about page&lt;/b&gt;&lt;/i&gt;:&lt;/div&gt;&lt;div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/--1JOgFfe01U/TjOQB58rCkI/AAAAAAAAAek/shejZIZHtr8/s1600/05.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="400" src="http://4.bp.blogspot.com/--1JOgFfe01U/TjOQB58rCkI/AAAAAAAAAek/shejZIZHtr8/s400/05.png" width="185" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;The Visual Studio Project&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;In Visual Studio the project looks like this&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-SaFk5AWX_AI/TjdFAn6EcBI/AAAAAAAAAe4/93RY2eI_x4A/s1600/ChakaProject.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/-SaFk5AWX_AI/TjdFAn6EcBI/AAAAAAAAAe4/93RY2eI_x4A/s1600/ChakaProject.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;The pages folder contains for each page of the application an Html file and a JavaScript file.&lt;/div&gt;Here is the file aboutPage.html.&lt;br /&gt;The page id is &lt;b&gt;aboutPage&lt;/b&gt; and it contains an ok button named &lt;b&gt;butOK&lt;/b&gt;.&lt;br /&gt;This is strictly jQuery Mobile syntax except that the html is in its own file. &lt;br /&gt;&lt;pre class="brush: html;"&gt;&amp;lt;div data-role="page" data-theme="a" id="aboutPage"&amp;gt;&lt;br /&gt; &amp;lt;div data-role="header"&amp;gt;&lt;br /&gt;  &amp;lt;h1&amp;gt;Tip Calculator&amp;lt;/h1&amp;gt;&lt;br /&gt; &amp;lt;/div&amp;gt;&lt;br /&gt; &amp;lt;div data-role="content"&amp;gt;&lt;br /&gt;        &amp;lt;div align="center"&amp;gt;&lt;br /&gt;            &amp;lt;div id="aboutText"&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;        &amp;lt;/div&amp;gt;&lt;br /&gt;        &amp;lt;div data-role="fieldcontain"&amp;gt;&lt;br /&gt;            &amp;lt;ul id="lvDeviceInfo" data-role="listview" data-theme="a" data-inset="true"&amp;gt;&lt;br /&gt;            &amp;lt;/ul&amp;gt;&lt;br /&gt;        &amp;lt;/div&amp;gt;&lt;br /&gt;        &amp;lt;div align="center"&amp;gt;&lt;br /&gt;            &amp;lt;a id = "butOK" data-role="button"  style=" width:80px;" &amp;gt;OK&amp;lt;/a&amp;gt;&lt;br /&gt;        &amp;lt;/div&amp;gt;&lt;br /&gt;    &amp;lt;/div&amp;gt;    &lt;br /&gt;&amp;lt;/div&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Code Behind&lt;/b&gt;&lt;br /&gt;Here is the JavaScript Code behind from file aboutPage.js.&lt;br /&gt;The file contains a class &lt;b&gt;aboutPage&lt;/b&gt; which will automatically inherit from a Chaka.Page. A Chaka.Page expose methods and properties, for example the property Application which returns the Application instance.&lt;br /&gt;I implemented the event &lt;b&gt;Page_Load&lt;/b&gt; which will be called when the page load.&lt;br /&gt;To get or set control value, you can use jQuery or you can use some method from the Chaka.Page, because JQuery Mobile control behave differently than the regular HTML controls.&lt;br /&gt;I also implemented the event butOK_Click, which be called when the user click the OK button.&lt;br /&gt;&lt;pre class="brush: javascript;"&gt;function aboutPage(){&lt;br /&gt;&lt;br /&gt;    /////////////////////////////////////////////////////////////////////&lt;br /&gt;    ///&lt;br /&gt;    this.Page_Load = function(event, ui){&lt;br /&gt;        var&lt;br /&gt;            aboutText = this.getControl("aboutText");&lt;br /&gt;&lt;br /&gt;        // Inherited&lt;br /&gt;        this.setListViewWithDeviceInformation("lvDeviceInfo");&lt;br /&gt;&lt;br /&gt;        aboutText.html(this.ABOUT_TEXT);&lt;br /&gt;    }&lt;br /&gt;    /////////////////////////////////////////////////////////////////////&lt;br /&gt;    ///&lt;br /&gt;    this.butOK_Click =  function(control){&lt;br /&gt;&lt;br /&gt;        this.Application.mainPage.show();&lt;br /&gt;    }&lt;br /&gt;    this.ABOUT_TEXT = '\&lt;br /&gt;    &amp;lt;i&amp;gt;&amp;lt;b&amp;gt;Tip Calculator&amp;lt;/b&amp;gt;&amp;lt;/i&amp;gt;\&lt;br /&gt; is an HTML5 jQuery Mobile sample application developed with the Chaka Framework and Visual Studio 2010.\&lt;br /&gt;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;\&lt;br /&gt;See &amp;lt;a rel=external href="http://frederictorres.net/chaka/"&amp;gt;Chaka&amp;lt;/a&amp;gt; web site for details.\&lt;br /&gt;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;\&lt;br /&gt;Chaka (C) Torres Frederic 2011\&lt;br /&gt;';&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;The Application class&lt;/b&gt;&lt;br /&gt;A JavaScript Application class must be defined in the file app/app.main.js. The Application class will automatically inherit from the Chaka.Application class.&lt;br /&gt;&lt;br /&gt;In the constructor the class calls the base method initializePage() to pass the name and the class type for each page. The application instance can be refered by using the global variable MyApp. Each Chaka page can reference the application by using the property Application.&lt;br /&gt;&lt;br /&gt;The Application instance allows to access each page by its name. See event butOK_Click above,  how we go back to the main page when the user click ok.&lt;br /&gt;&lt;pre class="brush: javascript;"&gt;/////////////////////////////////////////////////////////////////////&lt;br /&gt;///&lt;br /&gt;function Application() {&lt;br /&gt;    var&lt;br /&gt;        $base = this;&lt;br /&gt;&lt;br /&gt;    $base.initializePages(&lt;br /&gt;        {&lt;br /&gt;            mainPage    : mainPage ,&lt;br /&gt;            aboutPage   : aboutPage,&lt;br /&gt;        }&lt;br /&gt;    );&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-1178339268772713930?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/1178339268772713930/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/07/my-first-phone-application-with-jquery.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/1178339268772713930'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/1178339268772713930'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/07/my-first-phone-application-with-jquery.html' title='My first phone application with jQuery Mobile and Chaka'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-FJLuD05SwDI/TjOOSDSBFTI/AAAAAAAAAeU/IzOPfxJo1cE/s72-c/01.Splash.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-4239691975863696932</id><published>2011-07-29T20:37:00.001-04:00</published><updated>2011-07-29T20:38:27.433-04:00</updated><title type='text'>Event Log service is unavailable. Verify that the service is running</title><content type='html'>I got this error on Windows 2008 64b, after some automatic updates.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Event Log service is unavailable. Verify that the service is running&lt;/b&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;Try to start the Windows Event Log service, you may get this error&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Windows could not start the Windows Event Log service on Local Computer.&lt;/b&gt;&lt;/i&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Error 2: The system cannot find the file specified.&lt;/b&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;To fix this: run regedit.exe and goto to the entry&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="border-collapse: collapse; font-family: verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif; font-size: 14px;"&gt;HKLM\System\CurrentControlSet\&lt;/span&gt;&lt;span class="Apple-style-span" style="border-collapse: collapse; font-family: verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif; font-size: 14px;"&gt;&lt;wbr&gt;&lt;/wbr&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="border-collapse: collapse; font-family: verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif; font-size: 14px;"&gt;Services\Eventlog&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="border-collapse: collapse; font-family: verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif; font-size: 14px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;There should be an empty Parameters, just rename it to _Parameters.&lt;br /&gt;The service should start now.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-R9k8sbZS1Xw/TjNSM-UzE1I/AAAAAAAAAeQ/nrw3M8spp28/s1600/blog.registry.entry.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/-R9k8sbZS1Xw/TjNSM-UzE1I/AAAAAAAAAeQ/nrw3M8spp28/s1600/blog.registry.entry.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-4239691975863696932?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/4239691975863696932/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/07/event-log-service-is-unavailable-verify.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/4239691975863696932'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/4239691975863696932'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/07/event-log-service-is-unavailable-verify.html' title='Event Log service is unavailable. Verify that the service is running'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-R9k8sbZS1Xw/TjNSM-UzE1I/AAAAAAAAAeQ/nrw3M8spp28/s72-c/blog.registry.entry.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-1798657165861318267</id><published>2011-07-21T22:22:00.004-04:00</published><updated>2011-07-21T22:29:02.235-04:00</updated><title type='text'>Calling the base constructor in JavaScript</title><content type='html'>I thought that in JavaScript while implementing inheritance, it was not possible to call the code in the base constructor like you can do in most object oriented language.&lt;br /&gt;&lt;br /&gt;I was wrong. The class Employee constructor, call the constructor of the class Person,&lt;br /&gt;using the call() method. That is how you call any base method that has been overridden.&lt;br /&gt;&lt;pre class="brush: javascript;"&gt;function Person(lastName, firstName){&lt;br /&gt;&lt;br /&gt;    this.LastName   = lastName;&lt;br /&gt;    this.FirstName  = firstName;&lt;br /&gt;&lt;br /&gt;    this.getFullName = function(){&lt;br /&gt;&lt;br /&gt;        return this.LastName + " " + this.FirstName;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;function Employee(firstName, lastName , company){&lt;br /&gt;&lt;br /&gt;    // Call the constructor of the base class&lt;br /&gt;    Person.call(this, firstName, lastName);&lt;br /&gt;&lt;br /&gt;    this.Company = company;&lt;br /&gt;&lt;br /&gt;    this.getFullName = function(){&lt;br /&gt;&lt;br /&gt;        return Employee.prototype.getFullName.call(this) + &lt;br /&gt;               " " + this.Company;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;Employee.prototype = new Person();&lt;br /&gt;&lt;br /&gt;var fred = new Employee("Torres", "Frederic", "ACompany" );&lt;br /&gt;&lt;br /&gt;console.log(fred.getFullName());&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-1798657165861318267?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/1798657165861318267/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/07/call-base-constructor-in-javascript.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/1798657165861318267'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/1798657165861318267'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/07/call-base-constructor-in-javascript.html' title='Calling the base constructor in JavaScript'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-4371168816723602021</id><published>2011-07-15T20:32:00.000-04:00</published><updated>2011-07-15T20:32:02.957-04:00</updated><title type='text'>Running JavaScript, CoffeeScript from Visual Studio 2010</title><content type='html'>Running JavaScript, CoffeeScript from Visual Studio 2010&lt;br /&gt;&lt;br /&gt;As part of of my library &lt;a href="http://github.com/fredericaltorres/DynamicJavaScriptRunTimes.NET"&gt;DynamicJavaScriptRunTimes.NET&lt;/a&gt;, I created a Visual Studio 2010 extension to run JavaScript and CoffeeScript programs.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Here is the &lt;a href="http://www.youtube.com/watch?v=HetoziaPPII"&gt;video&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-4371168816723602021?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/4371168816723602021/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/07/running-javascript-coffeescript-from.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/4371168816723602021'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/4371168816723602021'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/07/running-javascript-coffeescript-from.html' title='Running JavaScript, CoffeeScript from Visual Studio 2010'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-7364308261980073429</id><published>2011-07-12T21:46:00.002-04:00</published><updated>2011-07-30T15:01:02.627-04:00</updated><title type='text'>Static Member In JavaScript</title><content type='html'>I did not realize until recently that you can create static member for your custom classes in JavaScript.&lt;br /&gt;&lt;br /&gt;JavaScript: &lt;i&gt;You can do so much with so little.&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: javascript;"&gt;// Class Person&lt;br /&gt;function Person(lastName, firstName){&lt;br /&gt;&lt;br /&gt;    this.LastName   = lastName;&lt;br /&gt;    this.FirstName  = firstName;&lt;br /&gt;&lt;br /&gt;    this.getFullName = function(){&lt;br /&gt;&lt;br /&gt;        return this.LastName + " " + this.FirstName;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;// Static member of the class Person&lt;br /&gt;Person.create = function(lastName, firstName){&lt;br /&gt;    return new Person(lastName, firstName);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;var p1 = new Person("Torres","Frederic");&lt;br /&gt;print(p1.getFullName());&lt;br /&gt;&lt;br /&gt;var p2 = Person.create("Torres","Frederic");&lt;br /&gt;print(p2.getFullName());&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-7364308261980073429?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/7364308261980073429/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/07/static-member-in-javascript_12.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/7364308261980073429'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/7364308261980073429'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/07/static-member-in-javascript_12.html' title='Static Member In JavaScript'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-2931727796436658230</id><published>2011-06-30T00:21:00.001-04:00</published><updated>2011-06-30T00:21:09.615-04:00</updated><title type='text'>Running JavaScript from C# with a hint of dynamic</title><content type='html'>The&amp;nbsp;&lt;a href="http://javascriptdotnet.codeplex.com/"&gt;Noesis JavaScript.NET&lt;/a&gt; run-time is probably the fastest run-time that you can use from C# on Windows so far. The reason why, it uses Google V8 2.2 engine from 09/2010 (remark:this project seems to have been&amp;nbsp;abandoned by its author :&amp;lt;)&amp;nbsp;.&lt;br /&gt;&lt;br /&gt;The &lt;a href="http://jurassic.codeplex.com/"&gt;Jurassic JavaScript &lt;/a&gt;run time is not as fast, but because written in C# provides better integration with the .NET world, if you really need it.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;But both run-times do not let you access JavaScript objects and arrays in the C# world using the dynamic syntax available in JavaScript.&lt;br /&gt;&lt;/b&gt;&lt;/i&gt;&lt;br /&gt;Here is a sample from the Noesis codeplex web site&lt;br /&gt;&lt;pre class="brush: javascript;"&gt;JavascriptContext context = new JavascriptContext();&lt;br /&gt;&lt;br /&gt;context.SetParameter("console", new SystemConsole());&lt;br /&gt;context.SetParameter("message", "Hello World !");&lt;br /&gt;context.SetParameter("number", 1);&lt;br /&gt;&lt;br /&gt;string script = @"&lt;br /&gt;    var i;&lt;br /&gt;    for (i = 0; i &amp;lt; 5; i++)&lt;br /&gt;        console.Print(message + ' (' + i + ')');&lt;br /&gt;    number += i;&lt;br /&gt;";&lt;br /&gt;&lt;br /&gt;context.Run(script);&lt;br /&gt;&lt;br /&gt;Console.WriteLine("number: " + context.GetParameter("number"));&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Using the dynamic feature of C# 4.0 and my library &lt;a href="http://github.com/fredericaltorres/DynamicJavaScriptRunTimes.NET"&gt;DynamicJavaScriptRunTimes.net&lt;/a&gt;, &amp;nbsp;You can write the same code this way&lt;br /&gt;&lt;pre class="brush: javascript;"&gt;dynamic jsContext = new DynamicJavascriptContext(&lt;br /&gt;                          new JavascriptContext()&lt;br /&gt;                    );                                               &lt;br /&gt;jsContext.message = "Hello World !";&lt;br /&gt;jsContext.number = 1;&lt;br /&gt;&lt;br /&gt;string script = @"&lt;br /&gt;    var i = 0;&lt;br /&gt;    for (i = 0; i &amp;lt; 5; i++)&lt;br /&gt;        console.log(message + ' (' + i + ')');&lt;br /&gt;    number += i;&lt;br /&gt;";&lt;br /&gt;&lt;br /&gt;jsContext.Run(script);&lt;br /&gt;&lt;br /&gt;Console.WriteLine("number: " + jsContext.number);&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;JavaScript array are translated into &amp;nbsp;.NET array and JavaScript object are translated into .NET Dictonary&amp;lt;string, object&amp;gt;. The method jsContext.Array() is a helper to create an array in a JavaScript like syntax, inspired by &lt;a href="http://www.dynamicsugar.net/"&gt;DynamicSugar.Net&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;array:&lt;/b&gt;&lt;br /&gt;How to create an array in C#, modify it in JavaScript and then read it back in C#.&lt;br /&gt;&lt;pre class="brush: javascript;"&gt;dynamic jsContext   = new DynamicJavascriptContext(&lt;br /&gt;                           new JavascriptContext()&lt;br /&gt;                      );&lt;br /&gt;jsContext.a = new object [] { 1, 2, 3 };  // Regular Syntax&lt;br /&gt;jsContext.a = jsContext.Array( 1, 2, 3 ); // My Syntax&lt;br /&gt;&lt;br /&gt;string script = @"&lt;br /&gt;    a.push(4);&lt;br /&gt;";&lt;br /&gt;            &lt;br /&gt;jsContext.Run(script);&lt;br /&gt;&lt;br /&gt;Assert.AreEqual(4, jsContext.a.Length);&lt;br /&gt;&lt;br /&gt;for(var i=0; i &amp;lt; jsContext.a.Length; i++)&lt;br /&gt;    Assert.AreEqual(i+1, jsContext.a[i]);&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Objects:&lt;/b&gt;&lt;br /&gt;As you can see nested objects and arrays are supported. The [ ] syntax to access a property is also supported.&lt;br /&gt;&lt;pre class="brush: javascript;"&gt;dynamic jsContext = new DynamicJavascriptContext(&lt;br /&gt;                          new JavascriptContext()&lt;br /&gt;                    );&lt;br /&gt;string script = @"&lt;br /&gt;    Configuration =  {&lt;br /&gt;        Server   :    'TOTO',&lt;br /&gt;        Database :    'Rene', &lt;br /&gt;        Debug    :    true, &lt;br /&gt;        MaxUser  :    3, &lt;br /&gt;        Users    :    [&lt;br /&gt;            { UserName:'rdescartes'    ,FirstName:'rene'      ,LastName:'descartes'     }, &lt;br /&gt;            { UserName:'bpascal'       ,FirstName:'blaise'    ,LastName:'pascal'        }, &lt;br /&gt;            { UserName:'cmontesquieu'  ,FirstName:'charles'   ,LastName:'montesquieu'   } &lt;br /&gt;        ]&lt;br /&gt;    }&lt;br /&gt;";&lt;br /&gt;&lt;br /&gt;jsContext.Run(script);&lt;br /&gt;&lt;br /&gt;Assert.AreEqual("TOTO"      , jsContext.Configuration.Server);&lt;br /&gt;Assert.AreEqual("Rene"      , jsContext.Configuration.Database);&lt;br /&gt;Assert.AreEqual(true        , jsContext.Configuration.Debug);&lt;br /&gt;Assert.AreEqual(3           , jsContext.Configuration.MaxUser);&lt;br /&gt;Assert.AreEqual(3           , jsContext.Configuration.Users.Length);&lt;br /&gt;Assert.AreEqual("rdescartes", jsContext.Configuration.Users[0].UserName);&lt;br /&gt;&lt;br /&gt;Assert.AreEqual("TOTO"      , jsContext["Configuration"]["Server"]);&lt;br /&gt;Assert.AreEqual("Rene"      , jsContext["Configuration"]["Database"]);&lt;br /&gt;Assert.AreEqual(true        , jsContext["Configuration"]["Debug"]);&lt;br /&gt;Assert.AreEqual(3           , jsContext["Configuration"]["MaxUser"]);&lt;br /&gt;Assert.AreEqual(3           , jsContext["Configuration"]["Users"].Length);&lt;br /&gt;Assert.AreEqual("rdescartes", jsContext["Configuration"]["Users"][0].UserName);&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;More Objects&lt;/b&gt;&lt;br /&gt;We can also create objects from C#, pass them to the JavaScript run-time and then access the objects again. The method jsContext.Object() is a helper method inspired by &lt;a href="http://www.dynamicsugar.net/"&gt;DynamicSugar.Net&lt;/a&gt; to create object in a JavaScript like syntax or pass a POCO. &lt;br /&gt;&lt;br /&gt;&lt;b&gt;Note&lt;/b&gt;: Objects and arrays are not passed by reference. The data is copied from one world to the other.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: javascript;"&gt;dynamic jsContext   = new DynamicJavascriptContext(&lt;br /&gt;                            new JavascriptContext()&lt;br /&gt;                      );&lt;br /&gt;                      &lt;br /&gt;jsContext.i = jsContext.Object(&lt;br /&gt;    new {&lt;br /&gt;        a = jsContext.Object( new { LastName="Torres", Age=46 } ),&lt;br /&gt;        b = jsContext.Object( new Person("Ferry", 47) ),&lt;br /&gt;    }&lt;br /&gt;);&lt;br /&gt;string script = @"&lt;br /&gt;    var p1 = {&lt;br /&gt;        Name : i.a.LastName,&lt;br /&gt;        Age  : i.a.Age&lt;br /&gt;    }&lt;br /&gt;    var p2 = {&lt;br /&gt;        Name : i.b.LastName,&lt;br /&gt;        Age  : i.b.Age&lt;br /&gt;    }&lt;br /&gt;";&lt;br /&gt;&lt;br /&gt;jsContext.Run(script);&lt;br /&gt;&lt;br /&gt;Assert.AreEqual("Torres", jsContext.p1.Name);&lt;br /&gt;Assert.AreEqual("Torres", jsContext.p1["Name"]);&lt;br /&gt;Assert.AreEqual("Torres", jsContext["p1"]["Name"]);&lt;br /&gt;&lt;br /&gt;Assert.AreEqual(46, jsContext.p1.Age);&lt;br /&gt;Assert.AreEqual(46, jsContext.p1["Age"]);&lt;br /&gt;Assert.AreEqual(46, jsContext["p1"]["Age"]);&lt;br /&gt;&lt;br /&gt;Assert.AreEqual("Ferry", jsContext.p2.Name);&lt;br /&gt;Assert.AreEqual("Ferry", jsContext.p2["Name"]);&lt;br /&gt;Assert.AreEqual("Ferry", jsContext["p2"]["Name"]);&lt;br /&gt;&lt;br /&gt;Assert.AreEqual(47, jsContext.p2.Age);&lt;br /&gt;Assert.AreEqual(47, jsContext.p2["Age"]);&lt;br /&gt;Assert.AreEqual(47, jsContext["p2"]["Age"]);            &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;More Samples&lt;/b&gt;&lt;br /&gt;&lt;pre class="brush: javascript;"&gt;Assert.AreEqual(&lt;br /&gt;    "Fred",&lt;br /&gt;    jsContext.Run(@"&lt;br /&gt;        function Person(firstName){ this.FirstName = firstName; }&lt;br /&gt;        (new Person('Fred'))"&lt;br /&gt;    ).FirstName&lt;br /&gt;);&lt;br /&gt;&lt;br /&gt;////////////////////////////////////////////&lt;br /&gt;&lt;br /&gt;DateTime refDate = new DateTime(1964, 12, 11, 01, 02, 03);&lt;br /&gt;&lt;br /&gt;string script = @"&lt;br /&gt;    var O2 = {&lt;br /&gt;                F2: function(pInt,pDouble,pString,pBool,pDate) { &lt;br /&gt;                        return ''+this.Internal+'-'+pInt+'-'+pDouble+'-'+pString+'-'+pBool+'-'+formatDateUS(pDate);&lt;br /&gt;                },&lt;br /&gt;                Internal:1&lt;br /&gt;                }&lt;br /&gt;";&lt;br /&gt;&lt;br /&gt;jsContext.Load("format", Assembly.GetExecutingAssembly());&lt;br /&gt;&lt;br /&gt;jsContext.Run(script);&lt;br /&gt;&lt;br /&gt;var expectedF2 = "1-1-123.456-hello-true-12/11/1964 1:2:3";&lt;br /&gt;var f2Result   = jsContext.Call("O2.F2", 1, 123.456, "hello", true, refDate);&lt;br /&gt;&lt;br /&gt;Assert.AreEqual(expectedF2, f2Result);&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;The DynamicJavascriptContext class&lt;/b&gt;&lt;br /&gt;&lt;pre class="brush: javascript;"&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;/// Run the script and return the last value evaluated. Executing a declaration function&lt;br /&gt;/// or a global object literal, will load the function or object in the JavaScript context.&lt;br /&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;/// &amp;lt;param name="script"&amp;gt;&amp;lt;/param&amp;gt;&lt;br /&gt;/// &amp;lt;returns&amp;gt;&lt;br /&gt;/// &amp;lt;/returns&amp;gt;&lt;br /&gt;public object Run(string script);&lt;br /&gt;&lt;br /&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;/// Load a JavaScript text file or text ressource in the JavaScript context&lt;br /&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;/// &amp;lt;param name="name"&amp;gt;The name without the .js extension&amp;lt;/param&amp;gt;&lt;br /&gt;/// &amp;lt;param name="assembly"&amp;gt;The assembly is loading a ressource&amp;lt;/param&amp;gt;&lt;br /&gt;public void Load(string name, Assembly assembly = null);&lt;br /&gt;&lt;br /&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;/// Execute a javascript global function or method&lt;br /&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;/// &amp;lt;param name="functionName"&amp;gt;the function name&amp;lt;/param&amp;gt;&lt;br /&gt;/// &amp;lt;param name="parameters"&amp;gt;The parameters&amp;lt;/param&amp;gt;&lt;br /&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;br /&gt;public object Call(string functionName, params object[] parameters);&lt;br /&gt;&lt;br /&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;/// Helper function to make date compatible with the JavaScript&lt;br /&gt;/// run time. Jurassic date are not .net datetime and need a convertion&lt;br /&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;/// &amp;lt;param name="o"&amp;gt;&amp;lt;/param&amp;gt;&lt;br /&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;br /&gt;public object Date(DateTime d){);&lt;br /&gt;&lt;br /&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;/// Helper function to make array compatible with the JavaScript run time.&lt;br /&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;/// &amp;lt;param name="array"&amp;gt;&amp;lt;/param&amp;gt;&lt;br /&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;br /&gt;public object array(params object [] array);&lt;br /&gt;&lt;br /&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;/// Helper function to make a JavaScript object compatible with the JavaScript run-time&lt;br /&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;/// &amp;lt;param name="netObject"&amp;gt;&amp;lt;/param&amp;gt;&lt;br /&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;br /&gt;public object Object(object netObject);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Conclusion&lt;/span&gt;&lt;br /&gt;&lt;hr /&gt;&lt;a href="http://github.com/fredericaltorres/DynamicJavaScriptRunTimes.NET"&gt;DynamicJavaScriptRunTimes.net&lt;/a&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Add a nice syntatic sugar layer to execute JavaScript code from C#&lt;/li&gt;&lt;li&gt;Support 2 JavaScript run-times: Noesis and Jurassic&lt;/li&gt;&lt;li&gt;Part of the source code is a &lt;a href="http://frederictorres.blogspot.com/2011/06/editing-and-running-coffeescript-on.html"&gt;CoffeeScript v 1.1.1 compiler and run-time.&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Available on github&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-2931727796436658230?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/2931727796436658230/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/06/running-javascript-from-c-with-hint-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/2931727796436658230'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/2931727796436658230'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/06/running-javascript-from-c-with-hint-of.html' title='Running JavaScript from C# with a hint of dynamic'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-3266547859362950251</id><published>2011-06-27T00:33:00.003-04:00</published><updated>2011-06-27T13:54:31.473-04:00</updated><title type='text'>Editing and running CoffeeScript on Windows</title><content type='html'>Using my work with Noesis JavaScript.Net, I created a CoffeeScript compiler and runtime command line application for Windows, this will require .NET 4.0. I also created a Syntax Highlighter for the editor ConTEXT.&lt;br /&gt;&lt;br /&gt;I can write and run CoffeeScript scripts in a simple IDE.&lt;br /&gt;&lt;br /&gt;Here is the &lt;a href="http://www.youtube.com/watch?v=ESd_h8_vvxM"&gt;video&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I will be adding the sources code to &lt;a href="https://github.com/fredericaltorres"&gt;github account&lt;/a&gt; soon.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-3266547859362950251?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/3266547859362950251/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/06/editing-and-running-coffeescript-on.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/3266547859362950251'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/3266547859362950251'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/06/editing-and-running-coffeescript-on.html' title='Editing and running CoffeeScript on Windows'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-7982779604624208565</id><published>2011-06-26T11:43:00.005-04:00</published><updated>2011-06-27T00:38:06.157-04:00</updated><title type='text'>Embedding JavaScript in a C# application (Part I)</title><content type='html'>&lt;b&gt;Embedding JavaScript in a C# application or service&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Why would you want to do that?&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Configuration (&lt;a href="http://frederictorres.blogspot.com/2011/01/implementing-simple-configuration-file_7840.html"&gt;my post about that with IronPython&lt;/a&gt;)&lt;/li&gt;&lt;ul&gt;&lt;li&gt;JSON over XML to implement configuration file.&lt;/li&gt;&lt;li&gt;Configuration file implemented with a dynamic language can execute code.&lt;/li&gt;&lt;li&gt;Configuration file can contain object instances.&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Plug-in architecture&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Plug-ins can be updated with notepad on the fly or not&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Script-able&amp;nbsp;applications&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Implementation&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;For now I am using the JavaScript run-time Noesis JavaScript.NET which use Google V8 v 2.2.&lt;br /&gt;I wrote a library which I may name DynamicJavaScript.Net, which allow to access the JavaScript objects and arrays using the dynamic feature of C# 4 (see my post &lt;a href="http://frederictorres.blogspot.com/2011/06/using-noesis-javascriptnet-with-hint-of.html"&gt;here&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;&lt;b&gt;A simple configuration file in JavaScript&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: javascript;"&gt;function User(userName, firstName, lastName) { &lt;br /&gt;&lt;br /&gt;    this.UserName  = userName;&lt;br /&gt;    this.LastName  = lastName;&lt;br /&gt;    this.FirstName = firstName;&lt;br /&gt;}&lt;br /&gt;var Configuration = {&lt;br /&gt;&lt;br /&gt;    Server  : 'TOTO',&lt;br /&gt;    Database: 'Rene',&lt;br /&gt;    Debug   : true,&lt;br /&gt;    Users   : [&lt;br /&gt;        { &lt;br /&gt;            UserName : 'bpascal', &lt;br /&gt;            FirstName: 'blaise', &lt;br /&gt;            LastName : 'pascal' &lt;br /&gt;        },&lt;br /&gt;        new User('cmontesquieu', 'charles', 'montesquieu')&lt;br /&gt;    ]&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;The C# source code to load the configuration&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;dynamic csContext = new DynamicJavascriptContext(&lt;br /&gt;                              new JavascriptContext()&lt;br /&gt;                        );&lt;br /&gt;&lt;br /&gt;csContext.Run(System.IO.File.ReadAllText("configuration.js"));&lt;br /&gt;&lt;br /&gt;var server  = csContext.Configuration.Server;&lt;br /&gt;var databse = csContext.Configuration.Database;&lt;br /&gt;var debug   = csContext.Configuration.Debug;&lt;br /&gt;&lt;br /&gt;for(var i=0; i&amp;lt;csContext.Configuration.Users.Length; i++) {&lt;br /&gt;&lt;br /&gt;    var userName  = csContext.Configuration.Users[i].UserName;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-7982779604624208565?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/7982779604624208565/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/06/embedding-javascript-in-c-application.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/7982779604624208565'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/7982779604624208565'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/06/embedding-javascript-in-c-application.html' title='Embedding JavaScript in a C# application (Part I)'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-4342975416775475526</id><published>2011-06-23T23:55:00.116-04:00</published><updated>2011-06-30T00:02:28.478-04:00</updated><title type='text'>Running JavaScript from C# with a hint of dynamic</title><content type='html'>The&amp;nbsp;&lt;a href="http://javascriptdotnet.codeplex.com/"&gt;Noesis JavaScript.NET&lt;/a&gt; run-time is probably the fastest run-time that you can use from C# on Windows so far. The reason why, it uses Google V8 2.2 engine from 09/2010 (remark:this project seems to have been&amp;nbsp;abandoned by its author :&amp;lt;)&amp;nbsp;.&lt;br /&gt;&lt;br /&gt;The &lt;a href="http://jurassic.codeplex.com/"&gt;Jurassic JavaScript &lt;/a&gt;run time is not as fast, but because written in C# provides better integration with the .NET world, if you really need it.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;But both run-times do not let you access JavaScript objects and arrays in the C# world using the dynamic syntax available in JavaScript.&lt;br /&gt;&lt;/b&gt;&lt;/i&gt;&lt;br /&gt;Here is a sample from the Noesis codeplex web site&lt;br /&gt;&lt;pre class="brush: javascript;"&gt;JavascriptContext context = new JavascriptContext();&lt;br /&gt;&lt;br /&gt;context.SetParameter("console", new SystemConsole());&lt;br /&gt;context.SetParameter("message", "Hello World !");&lt;br /&gt;context.SetParameter("number", 1);&lt;br /&gt;&lt;br /&gt;string script = @"&lt;br /&gt;    var i;&lt;br /&gt;    for (i = 0; i &amp;lt; 5; i++)&lt;br /&gt;        console.Print(message + ' (' + i + ')');&lt;br /&gt;    number += i;&lt;br /&gt;";&lt;br /&gt;&lt;br /&gt;context.Run(script);&lt;br /&gt;&lt;br /&gt;Console.WriteLine("number: " + context.GetParameter("number"));&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Using the dynamic feature of C# 4.0 and my library &lt;a href="http://github.com/fredericaltorres/DynamicJavaScriptRunTimes.NET"&gt;DynamicJavaScriptRunTimes.net&lt;/a&gt;, &amp;nbsp;You can write the same code this way&lt;br /&gt;&lt;pre class="brush: javascript;"&gt;dynamic jsContext = new DynamicJavascriptContext(&lt;br /&gt;                          new JavascriptContext()&lt;br /&gt;                    );                                               &lt;br /&gt;jsContext.message = "Hello World !";&lt;br /&gt;jsContext.number = 1;&lt;br /&gt;&lt;br /&gt;string script = @"&lt;br /&gt;    var i = 0;&lt;br /&gt;    for (i = 0; i &amp;lt; 5; i++)&lt;br /&gt;        console.log(message + ' (' + i + ')');&lt;br /&gt;    number += i;&lt;br /&gt;";&lt;br /&gt;&lt;br /&gt;jsContext.Run(script);&lt;br /&gt;&lt;br /&gt;Console.WriteLine("number: " + jsContext.number);&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;JavaScript array are translated into &amp;nbsp;.NET array and JavaScript object are translated into .NET Dictonary&amp;lt;string, object&amp;gt;. The method jsContext.Array() is a helper to create an array in a JavaScript like syntax, inspired by &lt;a href="http://www.dynamicsugar.net/"&gt;DynamicSugar.Net&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;array:&lt;/b&gt;&lt;br /&gt;How to create an array in C#, modify it in JavaScript and then read it back in C#.&lt;br /&gt;&lt;pre class="brush: javascript;"&gt;dynamic jsContext   = new DynamicJavascriptContext(&lt;br /&gt;                           new JavascriptContext()&lt;br /&gt;                      );&lt;br /&gt;jsContext.a = new object [] { 1, 2, 3 };  // Regular Syntax&lt;br /&gt;jsContext.a = jsContext.Array( 1, 2, 3 ); // My Syntax&lt;br /&gt;&lt;br /&gt;string script = @"&lt;br /&gt;    a.push(4);&lt;br /&gt;";&lt;br /&gt;            &lt;br /&gt;jsContext.Run(script);&lt;br /&gt;&lt;br /&gt;Assert.AreEqual(4, jsContext.a.Length);&lt;br /&gt;&lt;br /&gt;for(var i=0; i &amp;lt; jsContext.a.Length; i++)&lt;br /&gt;    Assert.AreEqual(i+1, jsContext.a[i]);&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Objects:&lt;/b&gt;&lt;br /&gt;As you can see nested objects and arrays are supported. The [ ] syntax to access a property is also supported.&lt;br /&gt;&lt;pre class="brush: javascript;"&gt;dynamic jsContext = new DynamicJavascriptContext(&lt;br /&gt;                          new JavascriptContext()&lt;br /&gt;                    );&lt;br /&gt;string script = @"&lt;br /&gt;    Configuration =  {&lt;br /&gt;        Server   :    'TOTO',&lt;br /&gt;        Database :    'Rene', &lt;br /&gt;        Debug    :    true, &lt;br /&gt;        MaxUser  :    3, &lt;br /&gt;        Users    :    [&lt;br /&gt;            { UserName:'rdescartes'    ,FirstName:'rene'      ,LastName:'descartes'     }, &lt;br /&gt;            { UserName:'bpascal'       ,FirstName:'blaise'    ,LastName:'pascal'        }, &lt;br /&gt;            { UserName:'cmontesquieu'  ,FirstName:'charles'   ,LastName:'montesquieu'   } &lt;br /&gt;        ]&lt;br /&gt;    }&lt;br /&gt;";&lt;br /&gt;&lt;br /&gt;jsContext.Run(script);&lt;br /&gt;&lt;br /&gt;Assert.AreEqual("TOTO"      , jsContext.Configuration.Server);&lt;br /&gt;Assert.AreEqual("Rene"      , jsContext.Configuration.Database);&lt;br /&gt;Assert.AreEqual(true        , jsContext.Configuration.Debug);&lt;br /&gt;Assert.AreEqual(3           , jsContext.Configuration.MaxUser);&lt;br /&gt;Assert.AreEqual(3           , jsContext.Configuration.Users.Length);&lt;br /&gt;Assert.AreEqual("rdescartes", jsContext.Configuration.Users[0].UserName);&lt;br /&gt;&lt;br /&gt;Assert.AreEqual("TOTO"      , jsContext["Configuration"]["Server"]);&lt;br /&gt;Assert.AreEqual("Rene"      , jsContext["Configuration"]["Database"]);&lt;br /&gt;Assert.AreEqual(true        , jsContext["Configuration"]["Debug"]);&lt;br /&gt;Assert.AreEqual(3           , jsContext["Configuration"]["MaxUser"]);&lt;br /&gt;Assert.AreEqual(3           , jsContext["Configuration"]["Users"].Length);&lt;br /&gt;Assert.AreEqual("rdescartes", jsContext["Configuration"]["Users"][0].UserName);&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;More Objects&lt;/b&gt;&lt;br /&gt;We can also create objects from C#, pass them to the JavaScript run-time and then access the objects again. The method jsContext.Object() is a helper method inspired by &lt;a href="http://www.dynamicsugar.net/"&gt;DynamicSugar.Net&lt;/a&gt; to create object in a JavaScript like syntax or pass a POCO. &lt;br /&gt;&lt;br /&gt;&lt;b&gt;Note&lt;/b&gt;: Objects and arrays are not passed by reference. The data is copied from one world to the other.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: javascript;"&gt;dynamic jsContext   = new DynamicJavascriptContext(&lt;br /&gt;                            new JavascriptContext()&lt;br /&gt;                      );&lt;br /&gt;                      &lt;br /&gt;jsContext.i = jsContext.Object(&lt;br /&gt;    new {&lt;br /&gt;        a = jsContext.Object( new { LastName="Torres", Age=46 } ),&lt;br /&gt;        b = jsContext.Object( new Person("Ferry", 47) ),&lt;br /&gt;    }&lt;br /&gt;);&lt;br /&gt;string script = @"&lt;br /&gt;    var p1 = {&lt;br /&gt;        Name : i.a.LastName,&lt;br /&gt;        Age  : i.a.Age&lt;br /&gt;    }&lt;br /&gt;    var p2 = {&lt;br /&gt;        Name : i.b.LastName,&lt;br /&gt;        Age  : i.b.Age&lt;br /&gt;    }&lt;br /&gt;";&lt;br /&gt;&lt;br /&gt;jsContext.Run(script);&lt;br /&gt;&lt;br /&gt;Assert.AreEqual("Torres", jsContext.p1.Name);&lt;br /&gt;Assert.AreEqual("Torres", jsContext.p1["Name"]);&lt;br /&gt;Assert.AreEqual("Torres", jsContext["p1"]["Name"]);&lt;br /&gt;&lt;br /&gt;Assert.AreEqual(46, jsContext.p1.Age);&lt;br /&gt;Assert.AreEqual(46, jsContext.p1["Age"]);&lt;br /&gt;Assert.AreEqual(46, jsContext["p1"]["Age"]);&lt;br /&gt;&lt;br /&gt;Assert.AreEqual("Ferry", jsContext.p2.Name);&lt;br /&gt;Assert.AreEqual("Ferry", jsContext.p2["Name"]);&lt;br /&gt;Assert.AreEqual("Ferry", jsContext["p2"]["Name"]);&lt;br /&gt;&lt;br /&gt;Assert.AreEqual(47, jsContext.p2.Age);&lt;br /&gt;Assert.AreEqual(47, jsContext.p2["Age"]);&lt;br /&gt;Assert.AreEqual(47, jsContext["p2"]["Age"]);            &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;More Samples&lt;/b&gt;&lt;br /&gt;&lt;pre class="brush: javascript;"&gt;Assert.AreEqual(&lt;br /&gt;    "Fred",&lt;br /&gt;    jsContext.Run(@"&lt;br /&gt;        function Person(firstName){ this.FirstName = firstName; }&lt;br /&gt;        (new Person('Fred'))"&lt;br /&gt;    ).FirstName&lt;br /&gt;);&lt;br /&gt;&lt;br /&gt;////////////////////////////////////////////&lt;br /&gt;&lt;br /&gt;DateTime refDate = new DateTime(1964, 12, 11, 01, 02, 03);&lt;br /&gt;&lt;br /&gt;string script = @"&lt;br /&gt;    var O2 = {&lt;br /&gt;                F2: function(pInt,pDouble,pString,pBool,pDate) { &lt;br /&gt;                        return ''+this.Internal+'-'+pInt+'-'+pDouble+'-'+pString+'-'+pBool+'-'+formatDateUS(pDate);&lt;br /&gt;                },&lt;br /&gt;                Internal:1&lt;br /&gt;                }&lt;br /&gt;";&lt;br /&gt;&lt;br /&gt;jsContext.Load("format", Assembly.GetExecutingAssembly());&lt;br /&gt;&lt;br /&gt;jsContext.Run(script);&lt;br /&gt;&lt;br /&gt;var expectedF2 = "1-1-123.456-hello-true-12/11/1964 1:2:3";&lt;br /&gt;var f2Result   = jsContext.Call("O2.F2", 1, 123.456, "hello", true, refDate);&lt;br /&gt;&lt;br /&gt;Assert.AreEqual(expectedF2, f2Result);&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;The DynamicJavascriptContext class&lt;/b&gt;&lt;br /&gt;&lt;pre class="brush: javascript;"&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;/// Run the script and return the last value evaluated. Executing a declaration function&lt;br /&gt;/// or a global object literal, will load the function or object in the JavaScript context.&lt;br /&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;/// &amp;lt;param name="script"&amp;gt;&amp;lt;/param&amp;gt;&lt;br /&gt;/// &amp;lt;returns&amp;gt;&lt;br /&gt;/// &amp;lt;/returns&amp;gt;&lt;br /&gt;public object Run(string script);&lt;br /&gt;&lt;br /&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;/// Load a JavaScript text file or text ressource in the JavaScript context&lt;br /&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;/// &amp;lt;param name="name"&amp;gt;The name without the .js extension&amp;lt;/param&amp;gt;&lt;br /&gt;/// &amp;lt;param name="assembly"&amp;gt;The assembly is loading a ressource&amp;lt;/param&amp;gt;&lt;br /&gt;public void Load(string name, Assembly assembly = null);&lt;br /&gt;&lt;br /&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;/// Execute a javascript global function or method&lt;br /&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;/// &amp;lt;param name="functionName"&amp;gt;the function name&amp;lt;/param&amp;gt;&lt;br /&gt;/// &amp;lt;param name="parameters"&amp;gt;The parameters&amp;lt;/param&amp;gt;&lt;br /&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;br /&gt;public object Call(string functionName, params object[] parameters);&lt;br /&gt;&lt;br /&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;/// Helper function to make date compatible with the JavaScript&lt;br /&gt;/// run time. Jurassic date are not .net datetime and need a convertion&lt;br /&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;/// &amp;lt;param name="o"&amp;gt;&amp;lt;/param&amp;gt;&lt;br /&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;br /&gt;public object Date(DateTime d){);&lt;br /&gt;&lt;br /&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;/// Helper function to make array compatible with the JavaScript run time.&lt;br /&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;/// &amp;lt;param name="array"&amp;gt;&amp;lt;/param&amp;gt;&lt;br /&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;br /&gt;public object array(params object [] array);&lt;br /&gt;&lt;br /&gt;/// &amp;lt;summary&amp;gt;&lt;br /&gt;/// Helper function to make a JavaScript object compatible with the JavaScript run-time&lt;br /&gt;/// &amp;lt;/summary&amp;gt;&lt;br /&gt;/// &amp;lt;param name="netObject"&amp;gt;&amp;lt;/param&amp;gt;&lt;br /&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;br /&gt;public object Object(object netObject);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Conclusion&lt;/span&gt;&lt;br /&gt;&lt;hr /&gt;&lt;a href="http://github.com/fredericaltorres/DynamicJavaScriptRunTimes.NET"&gt;DynamicJavaScriptRunTimes.net&lt;/a&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Add a nice syntatic sugar layer to execute JavaScript code from C#&lt;/li&gt;&lt;li&gt;Support 2 JavaScript run-times: Noesis and Jurassic&lt;/li&gt;&lt;li&gt;Part of the source code is a &lt;a href="http://frederictorres.blogspot.com/2011/06/editing-and-running-coffeescript-on.html"&gt;CoffeeScript v 1.1.1 compiler and run-time.&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Available on github&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-4342975416775475526?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/4342975416775475526/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/06/using-noesis-javascriptnet-with-hint-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/4342975416775475526'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/4342975416775475526'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/06/using-noesis-javascriptnet-with-hint-of.html' title='Running JavaScript from C# with a hint of dynamic'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-6042066385156992732</id><published>2011-06-23T10:15:00.002-04:00</published><updated>2011-06-23T10:16:02.909-04:00</updated><title type='text'>JavaScript run-times performance on Windows  V1</title><content type='html'>I was looking for a JavaScript run time that I could&amp;nbsp;embed in my C# applications. I have done that in the past with IronPython. I tried different implementations written in C# and then I decided to try all executables on my Windows XP machine that could run JavaScript from a command prompt.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;All tests were executed on my Windows XP Dell Inspiron 6400.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;The source code:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: javascript;"&gt;function Fibonnaci(n){&lt;br /&gt;    var&lt;br /&gt;        previous = -1,&lt;br /&gt;        result   =  1,&lt;br /&gt;        sum;&lt;br /&gt;&lt;br /&gt;    for(var i=0; i &amp;lt; n+1; i++){&lt;br /&gt;&lt;br /&gt;        sum      = result + previous;&lt;br /&gt;        previous = result;&lt;br /&gt;        result   = sum;&lt;br /&gt;    }&lt;br /&gt;    return result;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;var expectedValues = [ 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418, 317811, 514229, 832040, 1346269, 2178309, 3524578, 5702887, 9227465, 14930352, 24157817, 39088169, 63245986, 102334155, 165580141, 267914296, 433494437, 701408733, 1134903170, 1836311903, 2971215073, 4807526976, 7778742049, 12586269025, 20365011074, 32951280099, 53316291173, 86267571272, 139583862445, 225851433717, 365435296162, 591286729879, 956722026041, 1548008755920, 2504730781961, 4052739537881, 6557470319842, 10610209857723, 17167680177565, 27777890035288, 44945570212853, 72723460248141, 117669030460994, 190392490709135, 308061521170129, 498454011879264, 806515533049393, 1304969544928657, 2111485077978050, 3416454622906707, 5527939700884757, 8944394323791464, 14472334024676220, 23416728348467684, 37889062373143900, 61305790721611580, 99194853094755490, 160500643816367070, 259695496911122560, 420196140727489660, 679891637638612200, 1100087778366101900, 1779979416004714000, 2880067194370816000, 4660046610375530000, 7540113804746346000, 12200160415121877000, 19740274219868226000, 31940434634990100000, 51680708854858330000, 83621143489848430000, 135301852344706760000, 218922995834555200000];&lt;br /&gt;&lt;br /&gt;print('Running...');&lt;br /&gt;var startTime = new Date().getTime();&lt;br /&gt;&lt;br /&gt;for (var t = 0; t &amp;lt; 10000; t++) {&lt;br /&gt;&lt;br /&gt;    for (var i = 0; i &amp;lt; 100; i++) {&lt;br /&gt;&lt;br /&gt;        var v = Fibonnaci(i);&lt;br /&gt;        if(v !== expectedValues[i])&lt;br /&gt;            throw new Error('Unexpected value ');&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;var endTime = new Date().getTime();&lt;br /&gt;var time    = (endTime - startTime)/1000;&lt;br /&gt;print('Duration:' + time);&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;JavaScript Runtimes&lt;/b&gt; &lt;br /&gt;&lt;ul&gt;&lt;li&gt;nodeJs 0.2.6 - JavaScript Runtime:V8&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Duration:0.4 s&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Noesis.Javascript 0.4 - JavaScript Runtime V8 for .NET &amp;nbsp;Release mode x86 .NET 4.0&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Duration:0.4 s&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;PhantomJs v1.1.0 - JavaScript Runtime:JavaScriptCore (with JIT compiler).&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Duration:0.5 s&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Jurassic v2.1 - JavaScript Runtime:.NET Implementation&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Duration:8.9 s Release mode x86 .NET 3.5&lt;/li&gt;&lt;li&gt;Duration:7.7 s In the silverlight application from http://jurassic.codeplex.com&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;IronJS v0.2 - JavaScript Runtime:.NET Implementation - Release mode x86 .NET 4.0&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Duration:8.5 s&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;JSDB - 10.6.21.0 - JavaScript Runtime:Mozilla SpiderMonkey&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Duration:10.8&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Microsoft JScript&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Duration:13.3 s&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Jint - JavaScript Runtime:.NET Implementation Release mode x86 .NET .NET 3.5&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Duration:255.3 s&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Embeding a JavaScript run-time in a C# application&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here we have 4 choices, Jint does not use the DLR and you can tell. IronJS and Jurassic are very close.&lt;br /&gt;&amp;nbsp;I had some bizarre issues with&amp;nbsp;compiling&amp;nbsp;my IronJS solution (I had each time to rebuild my solution to see my changes). Anyway it is difficult to beat&amp;nbsp;Noesis.Javascript which use V8.&lt;br /&gt;&lt;br /&gt;There is another solution Microsoft JS&lt;span class="Apple-style-span" style="border-collapse: collapse; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 12px; line-height: 15px;"&gt;cript.NET, the JScript that came with .NET and that nobody is using. I will have to try.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="border-collapse: collapse; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 12px; line-height: 15px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="border-collapse: collapse; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 12px; line-height: 15px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-6042066385156992732?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/6042066385156992732/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/06/javascript-run-times-performance-on.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/6042066385156992732'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/6042066385156992732'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/06/javascript-run-times-performance-on.html' title='JavaScript run-times performance on Windows  V1'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-1795472441090677257</id><published>2011-06-18T19:02:00.124-04:00</published><updated>2011-06-23T10:16:50.477-04:00</updated><title type='text'>JavaScript run-times performance on Windows</title><content type='html'>Following the mention of this post on the &lt;a href="http://javascriptshow.com/"&gt;javascriptshow.com&lt;/a&gt;, I replaced my first benchmark with the&amp;nbsp;&lt;a href="http://v8.googlecode.com/svn/data/benchmarks/v6/run.html"&gt;V8 Benchmark Suite - version 6&lt;/a&gt;, Peter and Jason were right my own benchmark was not good enough.&lt;br /&gt;&lt;br /&gt;The first version of this post is &lt;a href="http://frederictorres.blogspot.com/2011/06/javascript-run-times-performance-on.html"&gt;there&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;I was looking for a JavaScript run time that I could&amp;nbsp;embed in my C# applications. I have done that in the past with IronPython. I tried different implementations written in C# and then I decided to try all executables on my Windows XP machine that could run JavaScript from a command prompt.&lt;br /&gt;&lt;br /&gt;All tests were executed on my Windows XP Dell Inspiron 6400.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;There are the modules I used from the benchmark:&lt;/b&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Richards&lt;/li&gt;&lt;li&gt;DeltaBlue&lt;/li&gt;&lt;li&gt;Crypto&lt;/li&gt;&lt;li&gt;RayTrace&lt;/li&gt;&lt;li&gt;RegExp&lt;/li&gt;&lt;li&gt;Splay&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;b&gt;Final Scores&lt;/b&gt;&lt;br /&gt;&lt;pre&gt;About the score: bigger is better!&lt;br /&gt;&lt;br /&gt;&lt;b&gt;JavaScript Engine                                     Score&lt;/b&gt;&lt;br /&gt;-------------------------------------------------------------&lt;br /&gt;NodeJs 0.4.6            V8                             4148&lt;br /&gt;Noesis 0.4              V8 + x86 NET 4.0               2454&lt;br /&gt;PhantomJs 1.1.0         JavaScriptCore - JIT compiler  1688&lt;br /&gt;IronJS  0.2             x86 .NET 4.0                     62&lt;br /&gt;Jurassic 2.1            x86 .NET 3.5                     51&lt;br /&gt;Microsoft Jscript 5.7                                    40&lt;br /&gt;Jint                    x86 .NET 3.5                   killed after one hour&lt;br /&gt;JSDB 10.6.21.0          SpiderMonkey                   out of memory - Execution error&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;nodeJs 0.4.6 - V8&lt;/b&gt;&lt;br /&gt;===================================&lt;br /&gt;Start...Thu Jun 23 2011 02:18:08 GMT+0000 (EST)&lt;br /&gt;Crypto: 4906&lt;br /&gt;DeltaBlue: 7980&lt;br /&gt;RayTrace: 6720&lt;br /&gt;RegExp: 1707&lt;br /&gt;Richards: 5175&lt;br /&gt;Splay: 2192&lt;br /&gt;----&lt;br /&gt;Score (version 6): 4148&lt;br /&gt;Duration:15.506&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Noesis.Javascript 0.4 - V8 + x86 .NET 4.0&lt;/b&gt;&lt;br /&gt;===================================&lt;br /&gt;Start...Wed Jun 22 2011 22:32:57 GMT-0400 (Eastern Daylight Time)&lt;br /&gt;Crypto: 3604&lt;br /&gt;DeltaBlue: 3937&lt;br /&gt;RayTrace: 3763&lt;br /&gt;RegExp: 1180&lt;br /&gt;Richards: 3195&lt;br /&gt;Splay: 1084&lt;br /&gt;----&lt;br /&gt;Score (version 6): 2454&lt;br /&gt;Duration:17.067&lt;br /&gt;&lt;br /&gt;This is an older version of V8 and this is why it is slower than nodejs.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;PhantomJs v1.1.0 - JavaScriptCore with JIT compiler&lt;/b&gt;&lt;br /&gt;===================================&lt;br /&gt;Start...Wed Jun 22 2011 22:29:25 GMT-0400 (Eastern Daylight Time)&lt;br /&gt;Duration:0&lt;br /&gt;Crypto: 2278&lt;br /&gt;DeltaBlue: 1514&lt;br /&gt;RayTrace: 2617&lt;br /&gt;RegExp: 559&lt;br /&gt;Richards: 2017&lt;br /&gt;Splay: 2269&lt;br /&gt;----&lt;br /&gt;Score (version 6): 1688&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Jurassic v2.1 - .NET Implementation x86 v 3.5&lt;/b&gt;&lt;br /&gt;===================================&lt;br /&gt; Start...Wed Jun 22 2011 22:18:30 GMT-0400 (Eastern Daylight Time)&lt;br /&gt; Crypto: 57.7&lt;br /&gt; DeltaBlue: 54.4&lt;br /&gt; RayTrace: 29.9&lt;br /&gt; RegExp: 33.8&lt;br /&gt; Richards: 66.0&lt;br /&gt; Splay: 86.5&lt;br /&gt; ----&lt;br /&gt; Score (version 6): 51.3&lt;br /&gt; Duration:263.796875&lt;br /&gt;&lt;br /&gt; http://jurassic.codeplex.com&lt;br /&gt;&lt;br /&gt;&lt;b&gt;IronJS v0.2 - .NET Implementation x86 v 4.0&lt;/b&gt;&lt;br /&gt;===================================&lt;br /&gt;Start...Wed, 22 Jun 2011 22:34:25 GMT-04:00&lt;br /&gt;Crypto: 83.23&lt;br /&gt;DeltaBlue: 61.34&lt;br /&gt;RayTrace: 20.01&lt;br /&gt;RegExp: 38.03&lt;br /&gt;Richards: 74.74&lt;br /&gt;Splay: 201&lt;br /&gt;----&lt;br /&gt;Score (version 6): 62.26&lt;br /&gt;Duration:275.141&lt;br /&gt;&lt;br /&gt;Still not bad for an implementation written by one person.&lt;br /&gt;http://ironjs.wordpress.com&lt;br /&gt;&lt;br /&gt;&lt;b&gt;JSDB - 10.6.21.0 - Mozilla SpiderMonkey&lt;/b&gt;&lt;br /&gt;===================================&lt;br /&gt;Start...Wed Jun 22 2011 23:08:51 GMT-0400 (Eastern Daylight Time)&lt;br /&gt;Crypto: 142&lt;br /&gt;DeltaBlue: 155&lt;br /&gt;RayTrace: 110&lt;br /&gt;RegExp: 126&lt;br /&gt;Richards: 161&lt;br /&gt;out of memory - Execution error in C:\FredericTorres.Net.Src\JS\Benchmark\all.js.&lt;br /&gt;&lt;br /&gt;http://www.jsdb.org&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Microsoft JScript 5.7&lt;/b&gt;&lt;br /&gt;===================================&lt;br /&gt;Start...Wed Jun 22 22:23:17 EDT 2011&lt;br /&gt;Crypto: 80.8&lt;br /&gt;DeltaBlue: 44.5&lt;br /&gt;RayTrace: 62.7&lt;br /&gt;RegExp: 91.4&lt;br /&gt;Richards: 44.3&lt;br /&gt;Splay: 4.75&lt;br /&gt;----&lt;br /&gt;Score (version 6): 40.4&lt;br /&gt;Duration:194.328&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Jint - JavaScript Runtime:.NET Implementation x86 v 3.5&lt;/b&gt;&lt;br /&gt;===================================&lt;br /&gt;After one hour I killed the program.&lt;br /&gt;&lt;br /&gt;http://jint.codeplex.com&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;JavaScript Runtimes&lt;/b&gt; &lt;br /&gt;&lt;br /&gt;&lt;div&gt;Here we have 4 choices, Jint does not use the DLR and you can tell. IronJS and Jurassic are very close.&lt;br /&gt;&amp;nbsp;I had some bizarre issues with&amp;nbsp;compiling&amp;nbsp;my IronJS solution (I had to rebuild my solution to see my changes). Anyway it is difficult to beat&amp;nbsp;Noesis.Javascript which use V8.&lt;br /&gt;&lt;br /&gt;I started writing some C# code to be able to write and read JavaScript objects from/to Noesis JavaScript.net context object using the dynamic feature of .NET 4.0. I will be blogging about this in the future. The code looks like this:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;dynamic jsContext   = new DynamicJavascriptContext(new JavascriptContext());            &lt;br /&gt;&lt;br /&gt;jsContext.message   = "Hello World !";&lt;br /&gt;jsContext.number    = 1;            &lt;br /&gt;jsContext.array     = DS.List(1, 2 , 3);&lt;br /&gt;jsContext.instance  = DS.Dictionary( new { b = 2 } );&lt;br /&gt;jsContext.instance2 = DS.Dictionary( new { a = 1, b = 2 } );&lt;br /&gt;                       &lt;br /&gt;string script = @"&lt;br /&gt;    number           = 123;&lt;br /&gt;    instance['a']    = 1;&lt;br /&gt;    instance['Date'] = new Date();                &lt;br /&gt;    instance2['a']   = 123;&lt;br /&gt;    console.log('Hello log ');&lt;br /&gt;    console.log('array.length:'+array.length);&lt;br /&gt;                &lt;br /&gt;    array.push(4);&lt;br /&gt;    for(var i=0; i&amp;lt;array.length; i++)&lt;br /&gt;        console.log(array[i]);&lt;br /&gt;";&lt;br /&gt;&lt;br /&gt;jsContext.Run(script);            &lt;br /&gt;&lt;br /&gt;Console.WriteLine("number: "        + jsContext.number       );&lt;br /&gt;Console.WriteLine("instance: "      + jsContext.instance     );&lt;br /&gt;Console.WriteLine("instance.a: "    + jsContext.instance.a   );&lt;br /&gt;Console.WriteLine("instance.b: "    + jsContext.instance.b   );&lt;br /&gt;Console.WriteLine("instance.Date: " + jsContext.instance.Date);&lt;br /&gt;Console.WriteLine("instance2.a: "   + jsContext.instance2.a  );&lt;br /&gt;Console.WriteLine("array:"          + jsContext.array.Length );&lt;br /&gt;Console.WriteLine("array[3]:"       + jsContext.array[3]     );&lt;br /&gt;            &lt;br /&gt;            &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;There is another solution Microsoft JS&lt;span class="Apple-style-span" style="border-collapse: collapse; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 12px; line-height: 15px;"&gt;cript.NET, the JScript that came with .NET and that nobody is using. I will have to try.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="border-collapse: collapse; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 12px; line-height: 15px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="border-collapse: collapse; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 12px; line-height: 15px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-1795472441090677257?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/1795472441090677257/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/06/javascript-run-time-performance-on.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/1795472441090677257'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/1795472441090677257'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/06/javascript-run-time-performance-on.html' title='JavaScript run-times performance on Windows'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-6615090408975776442</id><published>2011-06-15T20:59:00.038-04:00</published><updated>2011-06-18T14:28:16.269-04:00</updated><title type='text'>Top 7 Reasons To Learn JavaScript</title><content type='html'>&lt;span class="Apple-style-span" style="font-size: large;"&gt;7 - Because nobody does&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Did anybody read a book about JavaScript?&lt;/li&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.crockford.com/javascript/javascript.html"&gt;The World's Most Misunderstood Programming Language&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Well it's time now.&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;6 - JavaScript is like VISA: Accepted Everywhere&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;No religion wars - No my language is better than your language&lt;/li&gt;&lt;li&gt;Every body does it.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&amp;nbsp;5 - HTML 5 is a cross-platform application thing&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;JavaScript was and is the programming language of the web&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Laptop, Desktop, &amp;nbsp;NetBook,&amp;nbsp;&amp;nbsp;Phone, Tablet&lt;/li&gt;&lt;ul&gt;&lt;li&gt;jQuery Mobile, Sencha Touch&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;IE9/IE10, Chrome10, FireFox4, Safari5, Opera11&lt;/li&gt;&lt;li&gt;It's not fully there yet, but it's coming.&lt;/li&gt;&lt;ul&gt;&lt;li&gt;What about Windows 8?&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Look what's coming in more distant future&lt;/li&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.w3.org/2009/dap/"&gt;Device APIs and Policy Working Group&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;4 - To build server side applications&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://nodejs.org/"&gt;http://nodejs.org&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.phantomjs.org/"&gt;http://www.phantomjs.org&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.jsdb.org/"&gt;http://www.jsdb.org&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.mongodb.org/"&gt;http://www.mongodb.org&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Looking for a library:&amp;nbsp;&lt;a href="http://microjs.com/"&gt;http://microjs.com/&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;3 - JavaScript is a dynamic and functional language&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Dynamic Languages are fun&lt;/li&gt;&lt;li&gt;Write powerfull, small and readable source code&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;2 - JavaScript is now fast&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;The new generation of JavaScript engines are really fast&lt;br /&gt;&lt;/li&gt;&lt;pre&gt;Company     Browser  JavaScript Engine HTML Rendering Engine&lt;br /&gt;-------------------------------------------------------------&lt;br /&gt;Google      Chrome   V8                 Web Kit&lt;br /&gt;Apple       Safari   Nitro              Web Kit&lt;br /&gt;Mozilla     FireFox  JägerMonkey        Gecko&lt;br /&gt;Microsoft   IE       Chakra             Trident/MSHTML&lt;br /&gt;Opera       Opera    Carakan            Presto&lt;br /&gt;&lt;/pre&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;1 - We can get rid of the Ugly parts&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Once you understand JavaScript, it is easier to only use the good parts&lt;/li&gt;&lt;li&gt;Yes, JavaScript is full of&lt;a href="http://www.wtfjs.com/"&gt; WTF!&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Any good C++, Java, C#, VB, Pascal programmer can write good JavaScript code&lt;/li&gt;&lt;/ul&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-IiH5LHMGUt0/TfldYR5yjOI/AAAAAAAAAaw/Trz4zJFdB6o/s1600/JavaScriptTheGoodParts.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/-IiH5LHMGUt0/TfldYR5yjOI/AAAAAAAAAaw/Trz4zJFdB6o/s1600/JavaScriptTheGoodParts.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-6615090408975776442?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/6615090408975776442/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/06/top-7-reasons-to-learn-javascript.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/6615090408975776442'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/6615090408975776442'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/06/top-7-reasons-to-learn-javascript.html' title='Top 7 Reasons To Learn JavaScript'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-IiH5LHMGUt0/TfldYR5yjOI/AAAAAAAAAaw/Trz4zJFdB6o/s72-c/JavaScriptTheGoodParts.jpg' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-7355343538762953842</id><published>2011-06-04T19:14:00.002-04:00</published><updated>2011-06-04T19:14:52.177-04:00</updated><title type='text'>What Can We Learn From Python And JavaScript While Programming in C#</title><content type='html'>&lt;h1&gt;What can we learn from&lt;/h1&gt;&lt;br /&gt;&lt;h1&gt;Python and JavaScript&lt;/h1&gt;&lt;br /&gt;&lt;h1&gt;while programming in C# 4.0?&lt;/h1&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;Introduction&lt;/h1&gt;&lt;br /&gt;&lt;h2&gt;Who I am?&lt;/h2&gt;&lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;First Name: Frederic&lt;br /&gt;Last Name:  Torres&lt;br /&gt;Web Site:   http://www.FredericTorres.net&lt;br /&gt;State:      Massachusett&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;I have been writing code since MS-DOS 2.0 on different continents.&lt;/li&gt;&lt;li&gt;I write code in C# by day and in Python or JavaScript by night.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;What about you ?&lt;/h3&gt;&lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Python, everyone.&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;IronPython 2.7 and tools for Visual Studio 2010 has been released.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;We all known JavaScript, right!&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://javascript.crockford.com/javascript.html"&gt;The World's Most Misunderstood Programming Language&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;a href="http://javascript.crockford.com/"&gt;Douglas Crockford Web site about JavaScript&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;img alt="Alt text" src="http://covers.oreilly.com/images/9780596517748/cat.gif" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Why am I here?&lt;/h2&gt;&lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;&lt;h3&gt;Dynamic Languages - Python, Ruby, JavaScript.&lt;/h3&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;    - Source Code Length&lt;br /&gt;&lt;br /&gt;    - Readability&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Python and Ruby&lt;/h3&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;The &lt;a href="http://faassen.n--tree.net/blog/view/weblog/2005/08/06/0/"&gt;Pythonic way&lt;/a&gt; (Python Secret Weblog)&lt;/li&gt;&lt;li&gt;Ruby is designed to make programmers happy&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Peter Norvig from Google wrote a spell checker in 21 lines in Python &lt;a href="http://frederictorres.blogspot.com/2011/04/how-to-write-spelling-corrector-from.html"&gt;How to Write a Spelling Corrector&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: python;"&gt;import re, collections&lt;br /&gt;&lt;br /&gt;def words(text): return re.findall('[a-z]+', text.lower()) &lt;br /&gt;&lt;br /&gt;def train(features):&lt;br /&gt;    model = collections.defaultdict(lambda: 1)&lt;br /&gt;    for f in features:&lt;br /&gt;        model[f] += 1&lt;br /&gt;    return model&lt;br /&gt;&lt;br /&gt;NWORDS = train(words(file('big.txt').read()))&lt;br /&gt;&lt;br /&gt;alphabet = 'abcdefghijklmnopqrstuvwxyz'&lt;br /&gt;&lt;br /&gt;def edits1(word):&lt;br /&gt;   splits     = [(word[:i], word[i:]) for i in range(len(word) + 1)]&lt;br /&gt;   deletes    = [a + b[1:] for a, b in splits if b]&lt;br /&gt;   transposes = [a + b[1] + b[0] + b[2:] for a, b in splits if len(b)&amp;gt;1]&lt;br /&gt;   replaces   = [a + c + b[1:] for a, b in splits for c in alphabet if b]&lt;br /&gt;   inserts    = [a + c + b     for a, b in splits for c in alphabet]&lt;br /&gt;   return set(deletes + transposes + replaces + inserts)&lt;br /&gt;&lt;br /&gt;def known_edits2(word):&lt;br /&gt;    return set(e2 for e1 in edits1(word) for e2 in edits1(e1) if e2 in NWORDS)&lt;br /&gt;&lt;br /&gt;def known(words): return set(w for w in words if w in NWORDS)&lt;br /&gt;&lt;br /&gt;def correct(word):&lt;br /&gt;    candidates = known([word]) or known(edits1(word)) or known_edits2(word) or [word]&lt;br /&gt;    return max(candidates, key=NWORDS.get)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Is there anything we can learn from programming Python and JavaScript and apply it in C#?&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;This is the question I have been thinking about.&lt;/li&gt;&lt;li&gt;And it is not just me!&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;A different way to code in C#&lt;/h3&gt;&lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Is there a different way to write code in C# in the air?&lt;/li&gt;&lt;li&gt;3 Samples&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;ASP.NET MVC Syntax (Microsoft Product)&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;routes.MapRoute(&lt;br /&gt;   "Default", // Route name&lt;br /&gt;   "{controller}/{action}/{id}", // URL with parameters&lt;br /&gt;   new { controller = "Home", action = "Index", id = UrlParameter.Optional } &lt;br /&gt;);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Massive and Dapper : 2 &lt;strong&gt;&lt;em&gt;small&lt;/em&gt;&lt;/strong&gt; ORMs&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Written in less than 400 lines of code each&lt;/li&gt;&lt;li&gt;Written by Rob Conery and Sam Saffron (from Stack Overflow)&lt;/li&gt;&lt;li&gt;Have been talked about on the &lt;a href="http://www.hanselminutes.com/"&gt;hanselminutes podcast&lt;/a&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;// Massive Syntax&lt;br /&gt;var table = new Products();&lt;br /&gt;table.Update( new { ProductName = "Chicken Fingers" } , 12);&lt;br /&gt;&lt;br /&gt;var resultSet1 = persons.All(columns: "*", where: "ID &amp;gt;= @0", args: 1);&lt;br /&gt;foreach(var p in resultSet1)&lt;br /&gt;    Console.WriteLine(String.Format("ID:{0}, Name:{1}, {2}", p.ID, p.LastName, p.FirstName));                &lt;br /&gt;&lt;br /&gt;//&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;em&gt;The Dapper library and reflection.&lt;/em&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Web Matrix (Microsoft Product)&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-J1ylan0-0cU/Teq7Z19W79I/AAAAAAAAAVo/qlytlWYJLOc/s1600/WebMatrix.png" imageanchor="1"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/-J1ylan0-0cU/Teq7Z19W79I/AAAAAAAAAVo/qlytlWYJLOc/s1600/WebMatrix.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;How did I got involve in this&lt;/h3&gt;&lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;The more experienced with Dynamic Languages, the more you will miss their syntaxes working in C#.&lt;/li&gt;&lt;li&gt;Is there anything that we can do with?&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Reflection&lt;/li&gt;&lt;li&gt;Generics&lt;/li&gt;&lt;li&gt;Anonymous types &lt;/li&gt;&lt;li&gt;Extension method&lt;/li&gt;&lt;li&gt;Lambda expression/statment &lt;/li&gt;&lt;li&gt;The keyword params&lt;/li&gt;&lt;li&gt;The keyword dynamic and the class DynamicObject&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;DynamicSugar.Net&lt;/h3&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.dynamicsugar.net/"&gt;http://www.DynamicSugar.Net&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;A library providing methods and classes inspired by the dynamic languages Python and JavaScript &lt;/li&gt;&lt;li&gt;To write shorter and more readable source code in C# 4.0&lt;/li&gt;&lt;li&gt;On GitHub.com&lt;/li&gt;&lt;li&gt;On NuGet.org&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;It's all about &lt;strong&gt;&lt;em&gt;Syntactic sugar&lt;/em&gt;&lt;/strong&gt;. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;Let's Start...&lt;/h1&gt;&lt;br /&gt;&lt;h2&gt;What can we learn about formatting string from JavaScript?&lt;/h2&gt;&lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;&lt;h3&gt;In &lt;code&gt;C#&lt;/code&gt;&lt;/h3&gt;&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;var firstName = "Fred";&lt;br /&gt;&lt;br /&gt;Console.WriteLine(String.Format("Hello {0}",firstName));&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;In JavaScript&lt;/h3&gt;&lt;br /&gt;In JavaScript you may find this, which is not standard, but generally implemented via extension methods.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: javascript;"&gt;var firstName = "Fred";&lt;br /&gt;&lt;br /&gt;print(String.format("Hello {0}",firstName));&lt;br /&gt;&lt;br /&gt;print("Hello {0}".format(firstName));&lt;br /&gt;&lt;br /&gt;print("Hello {firstName}".format( { firstName:"Fred" } ));&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;- Demo&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;What can we learn about formatting string from Python?&lt;/h2&gt;&lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;&lt;pre class="brush: python;"&gt;class Person(object):&lt;br /&gt;&lt;br /&gt;  def __init__(self, name, age):&lt;br /&gt;    self.Name = name&lt;br /&gt;    self.Age  = age&lt;br /&gt;&lt;br /&gt;  def Format(self, myFormat):&lt;br /&gt;      return myFormat.format(**self.__dict__)&lt;br /&gt;&lt;br /&gt;#######################################&lt;br /&gt;&lt;br /&gt;p = Person("Fred", 45)&lt;br /&gt;print p.Format("Name={Name}, Age={Age}")&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;- Demo&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Object Literals [ ]&lt;/h2&gt;&lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Python's List&lt;/h2&gt;&lt;br /&gt;&lt;pre class="brush: python;"&gt;i = 3&lt;br /&gt;&lt;br /&gt;if i in [1,3,5]:&lt;br /&gt;    print "in the list"&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;JavaScript's Array&lt;/h3&gt;&lt;br /&gt;This code is not standard JavaScript. The method Contains() and In() are&lt;br /&gt;defined before this code as extension methods.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: javascript;"&gt;var i = 3;&lt;br /&gt;&lt;br /&gt;if([1,3,5].Contains(i))&lt;br /&gt;    console.log("in the list")&lt;br /&gt;&lt;br /&gt;if(i.In([1,3,5]))&lt;br /&gt;    console.log("in the list")&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;- Demo&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;What about a function returning multiple values?&lt;/h2&gt;&lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;What Python's syntax can say about that?&lt;/h3&gt;&lt;br /&gt;&lt;pre class="brush: python;"&gt;def ComputeValues(value):&lt;br /&gt;    return True, 2.0*value, "Hello"&lt;br /&gt;&lt;br /&gt;ok, amount, message = ComputeValues(2)&lt;br /&gt;&lt;br /&gt;print ok:{0}, amount:{1}, message:{2}".format(ok, amount, message)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;More about this&lt;/h3&gt;&lt;br /&gt;&lt;pre class="brush: python;"&gt;def ComputeValues(value):&lt;br /&gt;    return True, 2.0*value, "Hello"&lt;br /&gt;&lt;br /&gt;ok, amount, message = ComputeValues(2)&lt;br /&gt;&lt;br /&gt;print "ok:%s, amount:%s, message:%s" % (ok, amount, message)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;values = ComputeValues(2)&lt;br /&gt;&lt;br /&gt;print "ok:%s, amount:%s, message:%s" % (values[0], values[1], values[2])&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;What JavaScript's syntax can say about that?&lt;/h3&gt;&lt;br /&gt;&lt;pre class="brush: javascript;"&gt;function ComputeValues(value) {&lt;br /&gt;&lt;br /&gt;    return { ok:true, amount:2.0*value, message:"Hello" };&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;var r = ComputeValues(2);&lt;br /&gt;&lt;br /&gt;print("ok:"             + r.ok);&lt;br /&gt;print("amount:"         + r.amount);&lt;br /&gt;print("message:"        + r.message);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;- Demo&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Object Literals { }&lt;/h2&gt;&lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Passing a populated dictionary to a function very common in Dynamic Languages.&lt;/li&gt;&lt;li&gt;In Python and Ruby, there is a dedicated syntax just to do that.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;This allow to pass an unlimited number of argument in very clear way, by defining the name and the value of each argument. &lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;JavaScript - an Ajax call with jQuery.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;pre class="brush: javascript;"&gt;$.ajax( &lt;br /&gt;    {&lt;br /&gt;        type    : "POST",&lt;br /&gt;        url     : "some.php",&lt;br /&gt;        data    : "name=John&amp;amp;location=Boston",&lt;br /&gt;        success : function(msg){ alert( "Data Saved: " + msg ); }&lt;br /&gt;    }&lt;br /&gt;);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Python&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;pre class="brush: python;"&gt;def MyFunction(**context):&lt;br /&gt;&lt;br /&gt;    if context["debug"]:&lt;br /&gt;        print "Debug on"&lt;br /&gt;&lt;br /&gt;    if "America" in context["continent"]:&lt;br /&gt;        print context["continent"]&lt;br /&gt;&lt;br /&gt;MyFunction( debug=True,  continent="North America" )&lt;br /&gt;MyFunction( debug=True,  continent="South America" )&lt;br /&gt;MyFunction( debug=False, continent="Europe"        )&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;With C# 4.0&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Named parameters allow a similar syntax, &lt;/li&gt;&lt;li&gt;The number of arguments is limited and have to be predefined.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;void MyFunction(bool debug, string continent){&lt;br /&gt;  // code&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;MyFunction(false, "Europe");&lt;br /&gt;&lt;br /&gt;MyFunction(debug:false, continent:"Europe");&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;- Demo&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;Conclusion&lt;/h1&gt;&lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;There are a lot of good concepts in Dynamic Languages&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;JavaScript is everywhere&lt;/li&gt;&lt;li&gt;Learn it&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://javascript.crockford.com/"&gt;Douglas Crockford Web site about JavaScript&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;img alt="Alt text" src="http://covers.oreilly.com/images/9780596517748/cat.gif" /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;C# is becoming more and more dynamic&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;More API are going to using these new language Constructs.&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;ASP.NET MVC, Web Matrix.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;C# 5 will have a REPL (Read, Eval, Print, Loop)&lt;/li&gt;&lt;li&gt;C# 5 will have Eval() method (this should not be good)&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;2 Urls:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.frederictorres.net/"&gt;http://www.FredericTorres.Net&lt;/a&gt; &lt;/li&gt;&lt;li&gt;&lt;a href="http://www.dynamicsugar.net/"&gt;http://www.DynamicSugar.Net&lt;/a&gt; &lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-J1ylan0-0cU/Teq7Z19W79I/AAAAAAAAAVo/qlytlWYJLOc/s1600/WebMatrix.png" imageanchor="1"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/-J1ylan0-0cU/Teq7Z19W79I/AAAAAAAAAVo/qlytlWYJLOc/s1600/WebMatrix.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-7355343538762953842?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/7355343538762953842/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/06/what-can-we-learn-from-python-and.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/7355343538762953842'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/7355343538762953842'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/06/what-can-we-learn-from-python-and.html' title='What Can We Learn From Python And JavaScript While Programming in C#'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/-J1ylan0-0cU/Teq7Z19W79I/AAAAAAAAAVo/qlytlWYJLOc/s72-c/WebMatrix.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-564048034516792891</id><published>2011-05-15T01:20:00.000-04:00</published><updated>2011-05-15T01:20:21.882-04:00</updated><title type='text'>Trailing Comma and Internet Explorer 8</title><content type='html'>I thought that JavaScript was supporting trailing comma as more language do now.&lt;br /&gt;Well no do not use it. Internet Explorer does not break but will add an undefined extra element. Chrome, FireFox and Safari will not.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: javascript;"&gt;var l = [1,2,3,];&lt;br /&gt;print(l.length);&lt;br /&gt;for(var i=0; i&amp;lt;l.length; i++){&lt;br /&gt;    print(""+i+"="+l[i]);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-564048034516792891?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/564048034516792891/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/05/trailing-comma-and-internet-explorer-8.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/564048034516792891'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/564048034516792891'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/05/trailing-comma-and-internet-explorer-8.html' title='Trailing Comma and Internet Explorer 8'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-4678434302504397109</id><published>2011-05-08T20:15:00.062-04:00</published><updated>2011-05-08T21:03:02.727-04:00</updated><title type='text'>Function returning multiple values in C# and Tuple</title><content type='html'>With DynamicSugar, I proposed a way for function to return multiple values by combining the dynamic keyword and anonymous type. Because anonymous type are internal it is necessary to use an extra step implemented by the method DS.Values().&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;static dynamic ComputeValues(int value){&lt;br /&gt;&lt;br /&gt;    return DS.Values( new { returnValue = true, amount = 2.0 * value, message = "Hello" } );&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;var r = ComputeValues(2);&lt;br /&gt;Console.WriteLine("returnStatus:{0}, amount:{1}, message:{2}", r.returnValue, r.amount, r.message);&lt;br /&gt;&lt;br /&gt;//&lt;br /&gt;&lt;/pre&gt;Yesterday while presenting my talk "What can we learn from Python and JavaScript while programming in C# 4.0?" at code camp CC15 (MA)&lt;br /&gt;&lt;img src="http://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-75-06-metablogapi/0216.CodeCamp_5F00_537BA91C.png" /&gt;&lt;br /&gt;Somebody suggested that using C# 4.0 Tuple could be a solution that would offer type checking and intellisense. So today I tried. Tuple do provide a solution for a function to return multiple values, with type checking and intellisense. But there is no way to name the values. We have to stick with Item1, Item2, Item3, which is not as expressive as name like amount or message.&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;public static Tuple&amp;lt;bool, double, string&amp;gt; ComputeValuesTuple(int value) {&lt;br /&gt;&lt;br /&gt;    return new Tuple&amp;lt;bool, double, string&amp;gt; (true, 2.0*value, "Hello");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;var t = ComputeValuesTuple(2);&lt;br /&gt;Console.WriteLine("returnStatus:{0}, amount:{1}, message:{2}", t.Item1, t.Item2, t.Item3);&lt;br /&gt;&lt;br /&gt;//&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;If type checking is a requirement this is actually not a bad solution.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-4678434302504397109?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/4678434302504397109/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/05/function-returning-multiple-values-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/4678434302504397109'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/4678434302504397109'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/05/function-returning-multiple-values-in-c.html' title='Function returning multiple values in C# and Tuple'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-7441296177211601109</id><published>2011-04-29T22:24:00.000-04:00</published><updated>2011-04-29T22:24:19.424-04:00</updated><title type='text'>Ruby is so cool, with its blocks</title><content type='html'>Ruby is so cool, with its blocks&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: python;"&gt;[1, 2, 3].each do |i|&lt;br /&gt;    print i&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;Here is what can be done with C#, LINQ and &lt;a href="http://www.DynamicSugar.net"&gt;DynamicSugar.net&lt;/a&gt;&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;&lt;br /&gt;DS.List(1, 2, 3).ForEach(i =&gt; {&lt;br /&gt;&lt;br /&gt;    Console.WriteLine(i);&lt;br /&gt;});&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-7441296177211601109?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/7441296177211601109/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/04/ruby-is-so-cool-with-its-blocks.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/7441296177211601109'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/7441296177211601109'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/04/ruby-is-so-cool-with-its-blocks.html' title='Ruby is so cool, with its blocks'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-7336584411502755920</id><published>2011-04-22T22:32:00.116-04:00</published><updated>2011-04-24T00:08:45.698-04:00</updated><title type='text'>The Rise of the Micro-ORM or How C# is also a Dynamic Language</title><content type='html'>It starts with Hanselminute episode &lt;a href="http://www.hanselminutes.com/default.aspx?showID=282"&gt;the Rise of the Micro-ORM with Sam Saffron and Rob Conery&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Sam Saffron wrote the micro-ORM &lt;a href="http://code.google.com/p/dapper-dot-net/"&gt;Dapper&lt;/a&gt; and Rob Connery wrote the micro-ORM &lt;a href="https://github.com/robconery/massive"&gt;massive&lt;/a&gt;. Both ORMs are written in less than 400 lines of C# code.&lt;br /&gt;&lt;br /&gt;What is interesting to me is how they both used constructs borrowed from Dynamic Languages to write their ORM and making the same point I made by writing &lt;a href="http://www.DynamicSugar.net"&gt;DynamicSugar.net&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Both ORM use&lt;br /&gt;- Anonymous Type to pass nicely a series of name/value.&lt;br /&gt;- The keyword dynamic and the class Expando to deal with the passed anonymous types as well as the accessing the data returned by SELECT statments&lt;br /&gt;&lt;br /&gt;Massive Sample:&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;//&lt;br /&gt;var dog = connection.ExecuteMapperQuery&amp;lt;dog&amp;gt;("select Age = @Age, Id = @Id", new { Age = (int?)null, Id = guid });&lt;br /&gt;//&lt;br /&gt;&lt;/pre&gt;Massive Sample:&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;// &lt;br /&gt;var newID = table.Insert(new {CategoryName = "Buck Fify Stuff", Description = "Things I like"});&lt;br /&gt;//&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;In Massive code, the anonymous types are converted into dictionaries using reflection like in &lt;a href="http://www.DynamicSugar.net"&gt;DynamicSugar.net&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Dapper is about performance and therefore does not use reflection to access the properties of the anonymous types. Instead cached Dynamic Methods containing specific generated IL&lt;br /&gt;allow to extract the information. That sounds complex, but it is not to bad.&lt;br /&gt;See file &lt;a href="http://code.google.com/p/dapper-dot-net/source/browse/Dapper/SqlMapper.cs"&gt;SqlMapper.cs&lt;/a&gt; method CreateParamInfoGenerator().&lt;br /&gt;&lt;br /&gt;For &lt;a href="http://www.DynamicSugar.net"&gt;DynamicSugar.net&lt;/a&gt; I like to get rid of reflection to access anonymous types, in the same way. But before using IL, I tried using Expression Trees which I got working, and then I discovered &lt;a href="http://fastreflectionlib.codeplex.com/"&gt;FastReflection&lt;/a&gt; which provided exactly what I needed including the caching. I did have a problem with a property containing a generic type and therefore I decided to keep reflection for the first version.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-7336584411502755920?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/7336584411502755920/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/04/rise-of-micro-orm-or-how-c-is-also.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/7336584411502755920'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/7336584411502755920'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/04/rise-of-micro-orm-or-how-c-is-also.html' title='The Rise of the Micro-ORM or How C# is also a Dynamic Language'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-4190629197101182610</id><published>2011-04-17T00:26:00.028-04:00</published><updated>2011-04-17T00:51:48.085-04:00</updated><title type='text'>How to Write a Spelling Corrector? From Python to C# with Dynamic Sugar</title><content type='html'>There is a famous Python code sample named &lt;a href="http://norvig.com/spell-correct.html"&gt;How to Write a Spelling Corrector?&lt;/a&gt;, written by Peter Norvig in 21 line of code (No counting the white line).&lt;br /&gt;&lt;br /&gt;And different people have written their own version in different languages, see at the end of the Norvig's page, including &lt;a href="http://www.codegrunt.co.uk/2010/11/02/C-Sharp-Norvig-Spelling-Corrector.html#norvigSpell"&gt;3 different versions written in C#&lt;/a&gt; by Lorenzo Stoakes.&lt;br /&gt;&lt;br /&gt;I thought it would interresting to see what kind of result we could get using C# and &lt;a href="http://www.DynamicSugar.net"&gt;Dynamic Sugar.net&lt;/a&gt;. &lt;br /&gt;&lt;br /&gt;My C# version is 69 lines of code including white line, the Norvig's version is 30 lines. A ratio of 2.3 which is actually pretty good, it tells me that using DynamicSugar.net allowed me to reduce the number of line. &lt;br /&gt;Counting line is definitely not a very relevant indicator except that it give you a ball park.&lt;br /&gt;&lt;br /&gt;So here it is&lt;br /&gt;&lt;br /&gt;First the python code&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: python;"&gt;import re, collections&lt;br /&gt;&lt;br /&gt;def words(text): return re.findall('[a-z]+', text.lower()) &lt;br /&gt;&lt;br /&gt;def train(features):&lt;br /&gt;    model = collections.defaultdict(lambda: 1)&lt;br /&gt;    for f in features:&lt;br /&gt;        model[f] += 1&lt;br /&gt;    return model&lt;br /&gt;&lt;br /&gt;NWORDS = train(words(file('big.txt').read()))&lt;br /&gt;&lt;br /&gt;alphabet = 'abcdefghijklmnopqrstuvwxyz'&lt;br /&gt;&lt;br /&gt;def edits1(word):&lt;br /&gt;   splits     = [(word[:i], word[i:]) for i in range(len(word) + 1)]&lt;br /&gt;   deletes    = [a + b[1:] for a, b in splits if b]&lt;br /&gt;   transposes = [a + b[1] + b[0] + b[2:] for a, b in splits if len(b)&gt;1]&lt;br /&gt;   replaces   = [a + c + b[1:] for a, b in splits for c in alphabet if b]&lt;br /&gt;   inserts    = [a + c + b     for a, b in splits for c in alphabet]&lt;br /&gt;   return set(deletes + transposes + replaces + inserts)&lt;br /&gt;&lt;br /&gt;def known_edits2(word):&lt;br /&gt;    return set(e2 for e1 in edits1(word) for e2 in edits1(e1) if e2 in NWORDS)&lt;br /&gt;&lt;br /&gt;def known(words): return set(w for w in words if w in NWORDS)&lt;br /&gt;&lt;br /&gt;def correct(word):&lt;br /&gt;    candidates = known([word]) or known(edits1(word)) or known_edits2(word) or [word]&lt;br /&gt;    return max(candidates, key=NWORDS.get)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;My C# code &lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;class SpellCorrector {&lt;br /&gt;&lt;br /&gt;    Dictionary&amp;lt;string, int&amp;gt; DWORDS;&lt;br /&gt;    const string            ALPHABET = "abcdefghijklmnopqrstuvwxyz";&lt;br /&gt;&lt;br /&gt;    public SpellCorrector() {&lt;br /&gt;&lt;br /&gt;        DWORDS = this.Train(this.Words(System.IO.File.ReadAllText("big.txt")));&lt;br /&gt;    }&lt;br /&gt;    List&amp;lt;string&amp;gt; Words(string text) {&lt;br /&gt;&lt;br /&gt;        return Regex.Matches(text.ToLower(), "[a-z]+").ToList();&lt;br /&gt;    }&lt;br /&gt;    Dictionary&amp;lt;string, int&amp;gt; Train(List&amp;lt;string&amp;gt; features) {&lt;br /&gt;&lt;br /&gt;        var model = new Dictionary&amp;lt;string, int&amp;gt;();&lt;br /&gt;        foreach (var f in features)&lt;br /&gt;            model[f] = model.Get(f, 0) + 1;&lt;br /&gt;        return model;&lt;br /&gt;    }&lt;br /&gt;    class StringPair {&lt;br /&gt;&lt;br /&gt;        public string a, b;&lt;br /&gt;    }&lt;br /&gt;    List&amp;lt;string&amp;gt; Edits1(string word) {&lt;br /&gt;            &lt;br /&gt;        var splits     = DS.Range(word.Length+1).Map(i =&amp;gt; new StringPair { a = word.Slice(0,i), b = word.Slice(i) } );&lt;br /&gt;        var deletes    = splits.Map(s =&amp;gt; s.a + s.b.Slice(1));&lt;br /&gt;        var transposes = splits.Map(s =&amp;gt; s.b.Length &amp;gt; 1 ? s.a + s.b[1] + s.b[0] + s.b.Slice(2) : "**");&lt;br /&gt;                    &lt;br /&gt;        var replaces = new List&amp;lt;string&amp;gt;();&lt;br /&gt;        foreach (var s in splits)&lt;br /&gt;            foreach (var c in ALPHABET)&lt;br /&gt;                if(s.b.Length&amp;gt;0)&lt;br /&gt;                    replaces.Add(s.a + c + s.b.Slice(1, -1));&lt;br /&gt;&lt;br /&gt;        var inserts = new List&amp;lt;string&amp;gt;();&lt;br /&gt;        foreach (var s in splits)&lt;br /&gt;            foreach (var c in ALPHABET)&lt;br /&gt;                inserts.Add(s.a + c + s.b);&lt;br /&gt;            &lt;br /&gt;        return deletes.Add(transposes).Add(replaces).Add(inserts);&lt;br /&gt;    }&lt;br /&gt;    List&amp;lt;string&amp;gt; KnownEdits2(string word) {&lt;br /&gt;&lt;br /&gt;        var l = new List&amp;lt;string&amp;gt;();&lt;br /&gt;        foreach(var e1 in this.Edits1(word))&lt;br /&gt;            foreach(var e2 in Edits1(e1))&lt;br /&gt;                if(this.DWORDS.ContainsKey(e2))&lt;br /&gt;                    l.Add(e2);&lt;br /&gt;        return l;&lt;br /&gt;    }&lt;br /&gt;    List&amp;lt;string&amp;gt; Known(List&amp;lt;string&amp;gt; words){&lt;br /&gt;&lt;br /&gt;        return words.Filter(w =&amp;gt; this.DWORDS.ContainsKey(w));&lt;br /&gt;    }&lt;br /&gt;    public string Correct(string word){&lt;br /&gt;&lt;br /&gt;        var candidateWords = this.Known(DS.List(word));&lt;br /&gt;        if(candidateWords.Count==0)&lt;br /&gt;            candidateWords = this.Known(this.Edits1(word));&lt;br /&gt;        if(candidateWords.Count==0)&lt;br /&gt;            candidateWords = this.KnownEdits2(word);&lt;br /&gt;        if(candidateWords.Count==0)&lt;br /&gt;            candidateWords = DS.List(word);&lt;br /&gt;&lt;br /&gt;        return this.DWORDS.Max(candidateWords);         &lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-4190629197101182610?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/4190629197101182610/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/04/how-to-write-spelling-corrector-from.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/4190629197101182610'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/4190629197101182610'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/04/how-to-write-spelling-corrector-from.html' title='How to Write a Spelling Corrector? From Python to C# with Dynamic Sugar'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-4019201572483783712</id><published>2011-04-12T21:24:00.032-04:00</published><updated>2011-04-12T22:27:48.403-04:00</updated><title type='text'>Browser Benchmarks on my Windows XP 32b - Safari 5.0.4 FireFox 4.0 Opera 11.10 - IE 8 - Chrome 10</title><content type='html'>Machine:Dell Inspiron 6400, running Windows XP.&lt;br /&gt;&lt;br /&gt;BenchMarks: &lt;a href="http://www.webkit.org/perf/sunspider/sunspider.html"&gt;SunSpider JavaScript Benchmark&lt;/a&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;table cellpadding="2" cellspacing="2" border="1"&gt;&lt;tr&gt;&lt;td&gt;Chrome 10 &lt;/td&gt;&lt;td&gt;397.8ms +/- 1.7%&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;FireFox 4.0 &lt;/td&gt;&lt;td&gt; 417.6ms +/- 3.4%&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Opera 11.10 &lt;/td&gt;&lt;td&gt; 440.8ms +/- 5.7%&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Safari 5.0.4 &lt;/td&gt;&lt;td&gt; 591.4ms +/- 5.5% &lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;The smaller the faster.&lt;br /&gt;&lt;br /&gt;BenchMarks: &lt;a href="http://v8.googlecode.com/svn/data/benchmarks/v6/run.html"&gt;V8 Benchmark Suite - version 6&lt;/a&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;table cellpadding="2" cellspacing="2" border="1"&gt;&lt;tr&gt;&lt;td&gt;Chrome 10 &lt;/td&gt;&lt;td&gt;5871&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;FireFox 4.0 &lt;/td&gt;&lt;td&gt;2483&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Opera 11.10 &lt;/td&gt;&lt;td&gt;2587&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Safari 5.0.4 &lt;/td&gt;&lt;td&gt;1843&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;The higher the better.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;BenchMarks: &lt;a href="http://frederictorres.blogspot.com/2011/03/javascript-engine-performance-ie-90.html"&gt;My Fibonaci Non Recursive benchmark&lt;/a&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;Here is the result in seconds.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-7g8qSwgXWJs/TY1KdHfpLZI/AAAAAAAAATI/2sb_I_S5L-o/s1600/perf2.jpg" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="368" width="400" src="http://1.bp.blogspot.com/-7g8qSwgXWJs/TY1KdHfpLZI/AAAAAAAAATI/2sb_I_S5L-o/s400/perf2.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;table cellpadding="2" cellspacing="2" border="1"&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;Browser&lt;/b&gt;&lt;/TD&gt;&lt;td&gt;&lt;b&gt;Execution Time&lt;/b&gt;&lt;/TD&gt;&lt;td&gt;&lt;b&gt;Performance Compared To Chrome&lt;/b&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;tr&gt;&lt;td&gt;IE 9&lt;/TD&gt;&lt;td align="right"&gt;7.3&lt;/TD&gt;&lt;td align="right"&gt;9.1 slower&lt;/TD&gt;&lt;/TR&gt;&lt;tr&gt;&lt;td&gt;Safari 5&lt;/TD&gt;&lt;td align="right"&gt;4.3&lt;/TD&gt;&lt;td align="right"&gt;5.4 slower&lt;/TD&gt;&lt;/TR&gt;&lt;tr&gt;&lt;td&gt;Opera 11&lt;/TD&gt;&lt;td align="right"&gt;4.5&lt;/TD&gt;&lt;td align="right"&gt;5.6 slower&lt;/TD&gt;&lt;/TR&gt;&lt;tr&gt;&lt;td&gt;Firefox 4&lt;/TD&gt;&lt;td align="right"&gt;3.6&lt;/TD&gt;&lt;td align="right"&gt;4.5 slower&lt;/TD&gt;&lt;/TR&gt;&lt;tr&gt;&lt;td&gt;Chrome 10&lt;/TD&gt;&lt;td align="right"&gt;0.8&lt;/TD&gt;&lt;td align="right"&gt;same&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;The smaller the faster.&lt;br /&gt;Now I know why I prefer Chrome.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-4019201572483783712?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/4019201572483783712/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/04/browser-benchmark-on-my-windows-xp-32b.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/4019201572483783712'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/4019201572483783712'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/04/browser-benchmark-on-my-windows-xp-32b.html' title='Browser Benchmarks on my Windows XP 32b - Safari 5.0.4 FireFox 4.0 Opera 11.10 - IE 8 - Chrome 10'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-7g8qSwgXWJs/TY1KdHfpLZI/AAAAAAAAATI/2sb_I_S5L-o/s72-c/perf2.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-1855913590347663195</id><published>2011-03-25T21:55:00.079-04:00</published><updated>2011-04-12T22:24:35.053-04:00</updated><title type='text'>JavaScript Engine Performance: IE 9.0, Safari 5.0, Chrome 10.0, FireFix 5.0, Opera 11.</title><content type='html'>Which one of this JavaScript engine is the fastest? &lt;br /&gt;This test worth only what is worth as it only execute a very limited subset of the JavaScript language, but it should give us a first indication.&lt;br /&gt;&lt;br /&gt;This is my first test, I will replace the test code with something more demanding in the future.&lt;br /&gt;&lt;br /&gt;First the source code&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;function print(s){&lt;br /&gt;    var oldValue = jQuery("#Output").val();&lt;br /&gt;    oldValue    += "\r\n" + s;&lt;br /&gt;    jQuery("#Output").val(oldValue);&lt;br /&gt;}&lt;br /&gt;function Fibonnaci(n){&lt;br /&gt;&lt;br /&gt;    var previous = -1;&lt;br /&gt;    var result   =  1;&lt;br /&gt;&lt;br /&gt;    for(var i=0; i &lt; n+1; i++){&lt;br /&gt;&lt;br /&gt;        var sum  = result + previous;&lt;br /&gt;        previous = result;&lt;br /&gt;        result   = sum;&lt;br /&gt;    }&lt;br /&gt;    return result;&lt;br /&gt;}&lt;br /&gt;function Test() {&lt;br /&gt;    try {&lt;br /&gt;        print("Running...");&lt;br /&gt;&lt;br /&gt;        var startTime = new Date().getTime();&lt;br /&gt;&lt;br /&gt;        for (var t = 0; t &lt; 1000; t++) {&lt;br /&gt;&lt;br /&gt;            for (var i = 0; i &lt; 1000; i++) {&lt;br /&gt;&lt;br /&gt;                var v = Fibonnaci(i);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;        var endTime = new Date().getTime();&lt;br /&gt;        var time = (endTime - startTime)/1000;&lt;br /&gt;        print("Duration:" + time);&lt;br /&gt;    }&lt;br /&gt;    catch (ex) {&lt;br /&gt;        alert(ex);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;Here is the result in seconds.&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-7g8qSwgXWJs/TY1KdHfpLZI/AAAAAAAAATI/2sb_I_S5L-o/s1600/perf2.jpg" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="368" width="400" src="http://1.bp.blogspot.com/-7g8qSwgXWJs/TY1KdHfpLZI/AAAAAAAAATI/2sb_I_S5L-o/s400/perf2.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;table cellpadding="2" cellspacing="2"&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;Browser&lt;/b&gt;&lt;/TD&gt;&lt;td&gt;&lt;b&gt;Execution Time&lt;/b&gt;&lt;/TD&gt;&lt;td&gt;&lt;b&gt;Performance Compared To Chrome&lt;/b&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;tr&gt;&lt;td&gt;IE 9&lt;/TD&gt;&lt;td align="right"&gt;7.3&lt;/TD&gt;&lt;td align="right"&gt;9.1 slower&lt;/TD&gt;&lt;/TR&gt;&lt;tr&gt;&lt;td&gt;Safari 5&lt;/TD&gt;&lt;td align="right"&gt;4.3&lt;/TD&gt;&lt;td align="right"&gt;5.4 slower&lt;/TD&gt;&lt;/TR&gt;&lt;tr&gt;&lt;td&gt;Opera 11&lt;/TD&gt;&lt;td align="right"&gt;4.5&lt;/TD&gt;&lt;td align="right"&gt;5.6 slower&lt;/TD&gt;&lt;/TR&gt;&lt;tr&gt;&lt;td&gt;Firefox 4&lt;/TD&gt;&lt;td align="right"&gt;3.6&lt;/TD&gt;&lt;td align="right"&gt;4.5 slower&lt;/TD&gt;&lt;/TR&gt;&lt;tr&gt;&lt;td&gt;Chrome 10&lt;/TD&gt;&lt;td align="right"&gt;0.8&lt;/TD&gt;&lt;td align="right"&gt;same&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;Now I know why I prefer Chrome.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-1855913590347663195?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/1855913590347663195/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/03/javascript-engine-performance-ie-90.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/1855913590347663195'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/1855913590347663195'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/03/javascript-engine-performance-ie-90.html' title='JavaScript Engine Performance: IE 9.0, Safari 5.0, Chrome 10.0, FireFix 5.0, Opera 11.'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-7g8qSwgXWJs/TY1KdHfpLZI/AAAAAAAAATI/2sb_I_S5L-o/s72-c/perf2.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-930169449011385249</id><published>2011-03-15T22:52:00.000-04:00</published><updated>2011-03-15T22:52:49.750-04:00</updated><title type='text'>DynamicTextFileManager</title><content type='html'>Playing again with the C# 4.0 DynamicObject class. The class DynamicTextFileManager provides a different way to read and write text files.&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;var path       = String.Format(@"{0}\DynamicTextFile", Environment.GetEnvironmentVariable("TEMP"));&lt;br /&gt;dynamic dtfm   = new DynamicTextFileManager(path, "txt");&lt;br /&gt;&lt;br /&gt;dtfm.MyNewFile = "Hello World"; // Write "Hello World" in the file %TEMP%\DynamicTextFile\MyNewFile.txt&lt;br /&gt;&lt;br /&gt;string s       = dtfm.MyNewFile; // Read the content of the file %TEMP%\DynamicTextFile\MyNewFile.txt&lt;br /&gt;       &lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-930169449011385249?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/930169449011385249/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/03/dynamictextfilemanager.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/930169449011385249'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/930169449011385249'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/03/dynamictextfilemanager.html' title='DynamicTextFileManager'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-322267089803998700</id><published>2011-03-12T23:24:00.244-05:00</published><updated>2011-04-04T23:22:56.031-04:00</updated><title type='text'>Function returning multiple values in C#</title><content type='html'>I always like the Python feature allowing functions to return multiple values. Behind the scene it is just about returning a list. But the Python syntax provides the perfect amount of &lt;a href="http://en.wikipedia.org/wiki/Syntactic_sugar"&gt;syntactics sugar&lt;/a&gt;.&lt;br /&gt;&lt;pre class="brush: python;"&gt;def ComputeValues():&lt;br /&gt;    return 1, 2.0, "Hello"&lt;br /&gt;&lt;br /&gt;a, b, c = ComputeValues()&lt;br /&gt;&lt;br /&gt;print a, b, c&lt;br /&gt;&lt;/pre&gt;JavaScript also provides a interesting and different solution, may be not as good as Python, by returning an instance.&lt;br /&gt;&lt;pre class="brush: javascript;"&gt;function ComputeValues(){&lt;br /&gt;&lt;br /&gt;    return { returnValue:1, amount:2.0, message:"Hello" };&lt;br /&gt;}&lt;br /&gt;var r = ComputeValues();&lt;br /&gt;print("returnValue:"    + r.returnValue);&lt;br /&gt;print("amount:"         + r.amount);&lt;br /&gt;print("message:"        + r.message);&lt;br /&gt;&lt;/pre&gt;In C#, I hate declaring ref and out parameters, they require more line of code, make code more difficult to read and create side effects (&lt;a href="http://en.wikipedia.org/wiki/Functional_programming"&gt;functional programming&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;I came up with one solution with .NET 3.5 3 months ago, which I never liked. While working on the post &lt;a href="http://frederictorres.blogspot.com/2011/03/nice-syntax-to-read-json-in-c.html"&gt;Nice syntax to read JSon in C#&lt;/a&gt;, which is based on new C# 4.0 class &lt;a href="http://msdn.microsoft.com/en-us/library/dd487598.aspx"&gt;DynamicObject&lt;/a&gt;, I saw a solution. The DynamicObject allows to implement among other things what is called in Ruby &lt;a href="http://www.slideshare.net/sarah.allen/rubys-methodmissing"&gt;method_missing&lt;/a&gt; and in Python getattr().&lt;br /&gt;&lt;br /&gt;I came up with different syntaxes in the past weeks, including one using an infinite list of optional parameters, but I finally settled with passing an anonymous type.&lt;br /&gt;&lt;br /&gt;Here a sample:&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;// Here is a function returning 3 values&lt;br /&gt;static dynamic ComputeValues() {&lt;br /&gt;                        &lt;br /&gt;    return DS.Values( new { a=1, b=2.0, c="Hello" } );&lt;br /&gt;}&lt;br /&gt;// Here is how to use the results&lt;br /&gt;static void MultiValuesSample() {&lt;br /&gt;                        &lt;br /&gt;    var values = ComputeValues();&lt;br /&gt;    Console.Write(values.a);&lt;br /&gt;    Console.Write(values.b);&lt;br /&gt;    Console.Write(values.c);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;And there is no need to cast values&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;static void MultiValuesSample() {&lt;br /&gt;                        &lt;br /&gt;    var values = ComputeValues();&lt;br /&gt;    int a      = values.a;&lt;br /&gt;    double b   = values.b;&lt;br /&gt;    string c   = values.c;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;Wait a minute why not use this syntax?&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;// Here is a function returning 3 values&lt;br /&gt;&lt;br /&gt;static dynamic ComputeValues() {&lt;br /&gt;                        &lt;br /&gt;    return new { a=1, b=2.0, c="Hello" };&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;If the caller and callee are located in different assembly, the anonymous type will not be accessible by the caller because an anonymous type is defined as internal. The function DS.Values() return an instance of the class DynamicSugar.MultiValues which takes care of the problem.&lt;br /&gt;&lt;br /&gt;Why not use the Expando Object? The  Expando Object works but does not allow to defines the values in one expression. The Expando Object would require one statement per name/value.&lt;br /&gt;&lt;br /&gt;The MultiValues class is part of my library Dynamic Sugar # available soon on codeplex.com and as&lt;br /&gt;a &lt;a href="http://nuget.org"&gt;NuGet package&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-322267089803998700?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/322267089803998700/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/03/function-returning-multiple-values-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/322267089803998700'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/322267089803998700'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/03/function-returning-multiple-values-in-c.html' title='Function returning multiple values in C#'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-7035022050585989913</id><published>2011-03-12T13:47:00.073-05:00</published><updated>2011-03-12T20:51:43.125-05:00</updated><title type='text'>Nice syntax to read JSon in C#</title><content type='html'>I am working on a prototype involving MongoDB and HTML5, so it is going to be a lot about JavaScript.&lt;br /&gt;So I want to able to define my configuration files in JavaScript/JSON, rather than using IronPython, like I did in the past. I turned to &lt;a href="http://james.newtonking.com/projects/json-net.aspx"&gt;Json.NET&lt;/a&gt; to parse the JSon and came up with this idea.&lt;br /&gt;&lt;br /&gt;My JSON File&lt;br /&gt;&lt;pre class="brush: javascript;"&gt;{&lt;br /&gt;  'Name'    : 'Apple',&lt;br /&gt;  'Expiry'  : '2000-01-02T00:00:00.000Z',&lt;br /&gt;  'Price'   : 3.99,&lt;br /&gt;  'Quantity': 123,&lt;br /&gt;  'Sizes'   : ['Small','Medium','Large']&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;My C# Syntax to get access to the properties of my instance&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;dynamic config  = new JSonConfiguration(JSon_TestString);&lt;br /&gt;&lt;br /&gt;    DateTime expiry = config.Expiry;&lt;br /&gt;    string name     = config.Name;&lt;br /&gt;    double price    = config.Price;            &lt;br /&gt;    int quantity    = config.Quantity;&lt;br /&gt;    string size0    = config.Sizes[0]; &lt;br /&gt;  &lt;br /&gt;    int? quantity2  = config.Quantity2;&lt;br /&gt;&lt;/pre&gt;If a property does not exist the value returned is null. Date are supported as described, as you may not know JSON does not support Date, so they is no real standard.&lt;br /&gt;While I was at it I also added this syntax:&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;dynamic config  = new JSonConfiguration(JSon_TestString);&lt;br /&gt;&lt;br /&gt;    DateTime expiry = config["Expiry"];&lt;br /&gt;    string name     = config["Name"];&lt;br /&gt;    double price    = config["Price"];&lt;br /&gt;    int quantity    = config["Quantity"];&lt;br /&gt;    string size0    = config["Sizes"][0];&lt;br /&gt;&lt;br /&gt;    int? quantity2  = config["Quantity2"];     &lt;br /&gt;&lt;/pre&gt;The class JSonConfiguration, does not support nested objects, it is just a simple config file reader.&lt;br /&gt;Here is the magic class.&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;using System;&lt;br /&gt;using System.Text;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Linq;&lt;br /&gt;using DynamicSugarSharp;&lt;br /&gt;using System.Dynamic;&lt;br /&gt;using Newtonsoft.Json.Linq;&lt;br /&gt;using Newtonsoft.Json;&lt;br /&gt;using Newtonsoft.Json.Converters;&lt;br /&gt;&lt;br /&gt;public class JSonConfiguration : DynamicObject {&lt;br /&gt;&lt;br /&gt;        JObject _jSonObject = null;&lt;br /&gt;&lt;br /&gt;        public JSonConfiguration(string json){&lt;br /&gt;&lt;br /&gt;            _jSonObject = JObject.Parse(json); &lt;br /&gt;        }&lt;br /&gt;        public override bool TryGetIndex(GetIndexBinder binder, Object[] indexes, out Object result){&lt;br /&gt;            &lt;br /&gt;            return __TryGetMember(indexes[0].ToString(), out result);&lt;br /&gt;        }&lt;br /&gt;        public override bool TryGetMember(GetMemberBinder binder, out object result) {&lt;br /&gt;            &lt;br /&gt;            return __TryGetMember(binder.Name, out result);&lt;br /&gt;        }&lt;br /&gt;        private bool IsDate(string s) {&lt;br /&gt;&lt;br /&gt;            // "2000-12-15T22:11:03.055Z"&lt;br /&gt;            var rx = @"^""\d{2,4}-\d{1,2}-\d{1,2}T\d{1,2}:\d{1,2}:\d{1,2}.*Z""$";&lt;br /&gt;            return System.Text.RegularExpressions.Regex.IsMatch(s,rx);            &lt;br /&gt;        }&lt;br /&gt;        private bool __TryGetMember(string Name, out object result) {&lt;br /&gt;&lt;br /&gt;            result = _jSonObject[Name];&lt;br /&gt;&lt;br /&gt;            if(result!=null){&lt;br /&gt;&lt;br /&gt;                if(IsDate(result.ToString())){ // Date&lt;br /&gt;&lt;br /&gt;                    result = JsonConvert.DeserializeObject&amp;lt;DateTime&amp;gt;(result.ToString(), new IsoDateTimeConverter());&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;            return true;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-7035022050585989913?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/7035022050585989913/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/03/nice-syntax-to-read-json-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/7035022050585989913'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/7035022050585989913'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/03/nice-syntax-to-read-json-in-c.html' title='Nice syntax to read JSon in C#'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-8650773717943616009</id><published>2011-03-11T22:27:00.010-05:00</published><updated>2011-03-12T00:34:14.129-05:00</updated><title type='text'>Dynamic Sugar # Library's Format Method - Another Sample</title><content type='html'>Here is another example of the Dynamic Sugar # Library's Format Method.&lt;br /&gt;&lt;ol&gt;&lt;li&gt;First we have 2 classes, which&amp;nbsp;overrides&amp;nbsp;the ToString() method and use the Format method as defined as an extension method.&lt;/li&gt;&lt;li&gt;The ToString() method from class Person, will invoke the property DrivingLicenses which will trigger the ToString() method of the class License.&lt;/li&gt;&lt;li&gt;This example shows how the method Format(), format List&amp;lt;T&amp;gt;.&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;You can see my&lt;a href="http://www.youtube.com/watch?v=ggFEs0JyM90"&gt; screencast&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Linq;&lt;br /&gt;using System.Text;&lt;br /&gt;using DynamicSugarSharp;&lt;br /&gt;&lt;br /&gt;namespace ScreenCastConsole {&lt;br /&gt;&lt;br /&gt;    public class License {&lt;br /&gt;&lt;br /&gt;        public DateTime Date;&lt;br /&gt;        public string   Type;&lt;br /&gt;&lt;br /&gt;        public override string ToString() {&lt;br /&gt;            return this.Format("Type:{Type} - Date :{Date:yyyy-MM-dd}");&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    public class Person {&lt;br /&gt;&lt;br /&gt;        public string        LastName  { get; set; }&lt;br /&gt;        public string        FirstName { get; set; }&lt;br /&gt;        public DateTime      BirthDate { get; set; }&lt;br /&gt;        public List&amp;lt;License&amp;gt; DrivingLicenses = null;&lt;br /&gt;&lt;br /&gt;        public override string ToString() {&lt;br /&gt;            var format = @"&lt;br /&gt;Name            :{LastName}, {FirstName}&lt;br /&gt;BirthDate       :{BirthDate:yyyy-MM-dd}&lt;br /&gt;DrivingLicenses :{DrivingLicenses}        &lt;br /&gt;";&lt;br /&gt;            return this.Format(format);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    public static class ExtensionMethods {&lt;br /&gt;&lt;br /&gt;        public static string Format(this Person person, string format, params object[] args) {&lt;br /&gt;            return ExtendedFormat.Format(person, format, args);&lt;br /&gt;        }&lt;br /&gt;        public static string Format(this License person, string format, params object[] args) {&lt;br /&gt;            return ExtendedFormat.Format(person, format, args);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    class Program {&lt;br /&gt;&lt;br /&gt;        static void Main(string [] args) {&lt;br /&gt;&lt;br /&gt;            var p = new Person(){&lt;br /&gt;                LastName        = "TORRES",&lt;br /&gt;                FirstName       = "Frederic",&lt;br /&gt;                BirthDate       = new DateTime(1964, 12, 11),&lt;br /&gt;                DrivingLicenses = DS.List(&lt;br /&gt;                    new License() { Date = new DateTime(1983, 1, 2), Type = "Cars"      },&lt;br /&gt;                    new License() { Date = new DateTime(1985, 4, 5), Type = "MotoBike"  }&lt;br /&gt;                )&lt;br /&gt;            };&lt;br /&gt;            Console.WriteLine(p.ToString());            &lt;br /&gt;            Console.WriteLine("Hit enter to end the application");&lt;br /&gt;            Console.ReadLine();&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Here is this output&lt;br /&gt;&lt;pre&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;Name            :TORRES, Frederic&lt;br /&gt;BirthDate       :1964-12-11&lt;br /&gt;DrivingLicenses :[Type:Cars - Date :1983-01-02, Type:MotoBike - Date :1985-04-05]&lt;br /&gt;&lt;br /&gt;Hit enter to end the application&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-8650773717943616009?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/8650773717943616009/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/03/dynamic-sugar-librarys-format-method_11.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/8650773717943616009'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/8650773717943616009'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/03/dynamic-sugar-librarys-format-method_11.html' title='Dynamic Sugar # Library&apos;s Format Method - Another Sample'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-1057771885165364771</id><published>2011-03-09T22:27:00.000-05:00</published><updated>2011-03-09T22:27:05.472-05:00</updated><title type='text'>Dynamic Sugar # Library's Format Method</title><content type='html'>&lt;a href="http://frederictorres.blogspot.com/2011/01/dynamic-sugar-library.html"&gt;Dynamic Sugar # Library &lt;/a&gt; provides methods and functions inspired by the dynamic/functional language Python to write more readable code in C#.&lt;br /&gt;My favorite method is the static member Format, which also can be turned into an extension method to be assigned to any class.&lt;br /&gt;&lt;br /&gt;It first started with this Python code:&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;class Person(object):&lt;br /&gt;&lt;br /&gt;  def __init__(self, name, age):&lt;br /&gt;    self.name = name&lt;br /&gt;    self.age  = age&lt;br /&gt;&lt;br /&gt;  def Format(self, format):&lt;br /&gt;      return format.format(**self.__dict__)&lt;br /&gt;&lt;br /&gt;p = Person("Fred", 45)&lt;br /&gt;print p.Format("name={name}, age={age}")&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;With reflection and extension methods, I obtained this code, which I like.&lt;br /&gt;You can define how to format the value of the properties (see the property BirthDay below). &lt;br /&gt;And the method know hows to output nicely List&amp;lt;T&amp;gt;, Dictionary&amp;lt;K,V&amp;gt; and Array.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;Person p = new Person() {&lt;br /&gt;&lt;br /&gt;    LastName        = "TORRES"  ,&lt;br /&gt;    FirstName       = "Frederic",&lt;br /&gt;    BirthDay        = new DateTime(1964,12, 11),&lt;br /&gt;    DrivingLicenses = DS.List("Car", "Moto Bike")&lt;br /&gt;};&lt;br /&gt;Console.WriteLine( // Call 4 properties in the format&lt;br /&gt;    p.Format("FullName:'{LastName},{FirstName}', BirthDay:{BirthDay:MM/dd/yyyy}, DrivingLicenses:{DrivingLicenses}")&lt;br /&gt;);&lt;br /&gt;&lt;br /&gt;//&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Here is the output&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"&gt;FullName:'TORRES,Frederic', BirthDay:12/11/1964, DrivingLicenses:["Car", "Moto Bike"]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You can also format based on a dictionary, like this&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;var format = "LastName:{LastName}, FirstName:{FirstName}, Age:{Age:000}";&lt;br /&gt;&lt;br /&gt;var Values = new Dictionary&amp;lt;string, object&amp;gt;() {&lt;br /&gt;&lt;br /&gt;    { "LastName" , "TORRES"   },&lt;br /&gt;    { "FirstName", "Frederic" },&lt;br /&gt;    { "Age"      , 45         }&lt;br /&gt;};&lt;br /&gt;Console.WriteLine(ExtendedFormat.Format(format, Values));&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;And while I was at it, I added support for the ExpandoObject, which make this kind of simple formatting more concise&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;var format    = "LastName:{LastName}, FirstName:{FirstName}, Age:{Age:000}";&lt;br /&gt;            &lt;br /&gt;dynamic bag   = new ExpandoObject();&lt;br /&gt;bag.LastName  = "TORRES";&lt;br /&gt;bag.FirstName = "Frederic";&lt;br /&gt;bag.Age       = 45;&lt;br /&gt;            &lt;br /&gt;Console.WriteLine(ExtendedFormat.Format(format, bag));&lt;br /&gt;&lt;br /&gt;//&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-1057771885165364771?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/1057771885165364771/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/03/dynamic-sugar-librarys-format-method.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/1057771885165364771'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/1057771885165364771'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/03/dynamic-sugar-librarys-format-method.html' title='Dynamic Sugar # Library&apos;s Format Method'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-5519193124153725754</id><published>2011-02-27T23:20:00.072-05:00</published><updated>2011-03-03T23:10:45.027-05:00</updated><title type='text'>Tracing Program Execution, My Dream Came True</title><content type='html'>Tracing, has been an obsession of mine for a long time. Why? Because I want to be ready when&amp;nbsp;a customer calls and says that the application crashed and just before displayed:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;"Object reference not set to an instance of an object"&lt;i&gt;&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;How can you troubleshoot this or any form of unexpected error? If you do not have a backup plan. Installing any debugging tools on a customer production server is generally a no-no.&lt;br /&gt;&lt;br /&gt;What I want is to be able to turn a switch and ask the customer to redo the same scenario,&lt;br /&gt;but this time we are going to record in a file&lt;br /&gt;&lt;ul&gt;&lt;li&gt;All the method calls with all the parameters values&amp;nbsp;&lt;/li&gt;&lt;li&gt;All the exceptions and where they were&amp;nbsp;caught&amp;nbsp;or raised.&lt;/li&gt;&lt;li&gt;All information that the developer, saw as important to troubleshoot the application&lt;/li&gt;&lt;/ul&gt;In 1998, with VB6 I used a custom tool that would insert in the source code&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Error handlers for each method, and trace the error&lt;/li&gt;&lt;li&gt;At the top of each method a call to a specific function passing the class name, the method name and the parameters values.&lt;/li&gt;&lt;/ul&gt;Around 2005 I wrote the same thing in C#, and thanks to reflection it was easier and the source code needed in each method was smaller. But I still had to insert myself call to trace methods and exceptions.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;AOP&lt;/b&gt;&lt;br /&gt;I knew about AOP (Aspect Oriented Programming), and I knew it was the solution, but I did not find a framework simple enough that could do what I wanted.&amp;nbsp;I knew about the Spring.net framework and Unity and Castle Windsor dependency injection framework to support some level of AOP. But they require to use interfaces and virtual methods all over the place.&lt;br /&gt;&lt;br /&gt;I knew that the company &lt;a href="http://www.preemptive.com/products/runtime-intelligence/overview"&gt;preemptive.com&lt;/a&gt; has some kind of solution, I never looked at it.&lt;br /&gt;&lt;br /&gt;I think that the library used by Code Contract to inject code in an assembly after compilation is available to anybody, if you look for it.&lt;br /&gt;&lt;br /&gt;This week, I listened to &lt;a href="http://www.dotnetrocks.com/default.aspx?showNum=640"&gt;DotNetRocks episode 640  Gael Fraiteur is Still PostSharp!&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Well &lt;a href="http://www.sharpcrafters.com/"&gt;PostSharp&lt;/a&gt; is what I was totally looking for.&lt;br /&gt;&lt;br /&gt;I installed it and the Trace sample works great, but this information displayed is not that fantastic.&lt;br /&gt;&lt;br /&gt;Starting with the sample I wrote my own Aspect, that is the word, to implement tracing to a file the way I want it. Among other thing,&amp;nbsp;when parameters of type Array, List&amp;lt;T&amp;gt; and Dictionary&amp;lt;K,V&amp;gt; are used the content is traced, the return value of each function is also traced. And every thing with the right indentation.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;The Trace&lt;/b&gt;&lt;br /&gt;Here is a screenshot of &lt;a href="http://frederictorres.blogspot.com/2011/01/flogviewernet.html"&gt;fLogViewer.net&lt;/a&gt; viewing a trace file.&amp;nbsp;As you can see parameters name and value are part of the trace. Dictionary content are defined with { } and list or array are defined with [ ] (I like Python).&amp;nbsp;Exception&amp;nbsp;caught&amp;nbsp;or un&amp;nbsp;caught&amp;nbsp;will be traced.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="https://lh3.googleusercontent.com/-wTCv7067Cms/TWsVdlWZOfI/AAAAAAAAASg/UR31swkm3MY/s1600/AOPTrace.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="https://lh3.googleusercontent.com/-wTCv7067Cms/TWsVdlWZOfI/AAAAAAAAASg/UR31swkm3MY/s1600/AOPTrace.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;b&gt;The Source code&lt;/b&gt;&lt;br /&gt;All you need to do is to applied one attribute to a class, this is the magic of &lt;a href="http://www.sharpcrafters.com/"&gt;PostSharp&lt;/a&gt;&amp;nbsp;and set a logger instance.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;using DynamicSugarSharp;&lt;br /&gt;&lt;br /&gt;[Tracer]&lt;br /&gt;class TracedClass {&lt;br /&gt;&lt;br /&gt;  // code here&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;static void Main(string[] args) {&lt;br /&gt;&lt;br /&gt;  Tracer.Logger = new CachedTextFileWriter();&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The FullTraceAttribute Attribute require an object implementing the ILogger interface,&lt;br /&gt;to start tracing. The class CachedTextFileWriter implement tracing to a file.&lt;br /&gt;A file is created in the %TEMP% folder based on the name of the executing program or you can set the property FileName. Writing to the file is temporarily cached to avoid writing to the disk too often and slow down too much the application. Now be aware that when the trace is on this will slow down the application.&lt;br /&gt;&lt;br /&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;b&gt;Using Tracing with ASP.NET (MVC or not)&lt;/b&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;In the past I used my own manual AOP to implement tracing for ASP.NET application. When I was troubleshooting a problem there was most likely one user on the production system. So every thing worked out great. But&amp;nbsp;it is not thread safe. Now creating a thread safe singleton to be used under the ASP.NET framework should be possible.&lt;/div&gt;&lt;br /&gt;&lt;b&gt;Dynamic Sugar Sharp Library&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;I made my FullTrace Attribute part of the Dynamic Sugar Sharp Library as I will release it soon on codeplex.com.&lt;br /&gt;&lt;br /&gt;To use the attribute you must&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Download and install PostSharp. To get a community free license click on&amp;nbsp;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;The Start Menu -&amp;gt;&amp;nbsp;PostSharp -&amp;gt;&amp;nbsp;PostSharp User Option&lt;/li&gt;&lt;li&gt;Request a free license&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;To implement tracing you do not need to buy a license, this is the beauty of open-source, which i am not sure I&amp;nbsp;totally&amp;nbsp;understand. A commercial license is $340, but it is not that obvious what are the features you are paying for.  &lt;ul&gt;&lt;/ul&gt;&lt;li&gt;Reference the assembly PostSharp.dll.&lt;/li&gt;&lt;li&gt;Reference the&amp;nbsp;assembly&amp;nbsp;DynamicSugarSharp.dll&lt;/li&gt;&lt;li&gt;Mark you classes with the attribute[DynamicSugarSharp.FullTrace]&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-5519193124153725754?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/5519193124153725754/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/02/tracing-program-execution-my-dream-came.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/5519193124153725754'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/5519193124153725754'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/02/tracing-program-execution-my-dream-came.html' title='Tracing Program Execution, My Dream Came True'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='https://lh3.googleusercontent.com/-wTCv7067Cms/TWsVdlWZOfI/AAAAAAAAASg/UR31swkm3MY/s72-c/AOPTrace.jpg' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-6372425395004042009</id><published>2011-02-19T00:32:00.024-05:00</published><updated>2011-08-09T15:23:11.788-04:00</updated><title type='text'>Dynamic Puzzle in C#</title><content type='html'>I was designing an API using the dynamic keyword influenced by the ASP.NET MVC router API and I faced a run time error that I could not explain. In the end I turned this into a C# puzzle question.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Step 1&lt;/h2&gt;Create a console application and paste this code in the Program.cs namespace.&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;public class MyClass {&lt;br /&gt;&lt;br /&gt;    public static string GetID(dynamic d) {&lt;br /&gt;&lt;br /&gt;        return d.ID;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;class Program {&lt;br /&gt;&lt;br /&gt;    static void Main(string [] args) {&lt;br /&gt;&lt;br /&gt;        var o = new { ID = "123" };&lt;br /&gt;        Console.WriteLine(MyClass.GetID(o));&lt;br /&gt;&lt;br /&gt;        Console.ReadLine();&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Run the application. The application displays 123.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Step 2&lt;/h2&gt;Add a new class library project, move the class &lt;b&gt;MyClass&lt;/b&gt; in the library. Reference the library. Run the application. An exception will be raise by the line "return d.ID;".&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;b&gt;Explain why ?&lt;/b&gt;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Beautifull&lt;/h2&gt;The watch window tell me that my instance d has an ID property and the exception tell me it does not.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-niUaBSRMXHg/TV9V6laA82I/AAAAAAAAASY/jxtbu5ijAk0/s1600/CSPuzzle1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/-niUaBSRMXHg/TV9V6laA82I/AAAAAAAAASY/jxtbu5ijAk0/s1600/CSPuzzle1.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-6372425395004042009?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/6372425395004042009/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/02/dynamic-puzzle-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/6372425395004042009'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/6372425395004042009'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/02/dynamic-puzzle-in-c.html' title='Dynamic Puzzle in C#'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-niUaBSRMXHg/TV9V6laA82I/AAAAAAAAASY/jxtbu5ijAk0/s72-c/CSPuzzle1.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-5662848331856131571</id><published>2011-02-13T02:04:00.003-05:00</published><updated>2011-04-03T20:28:05.820-04:00</updated><title type='text'>Initializing a Dictionary of List with the Dynamic Sugar library in C#</title><content type='html'>The Dynamic Sugar Sharp library is all about syntactic sugar. Here is one example.&lt;br /&gt;&lt;br /&gt;I want to initialize a Dictionary containing a key and a List&lt;int&gt;.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;In standard C#&lt;/b&gt;&lt;br /&gt;&lt;gr&gt;&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;var dic1 = new Dictionary&amp;lt;string, List&amp;lt;int&amp;gt;&amp;gt;() { &lt;br /&gt;&lt;br /&gt;  { "L1" , new List&amp;lt;int&amp;gt;() { 1,2,3 } },&lt;br /&gt;  { "L2" , new List&amp;lt;int&amp;gt;() { 1,2,3 } },&lt;br /&gt;};&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;In  C# with Dynamic Sugar&lt;/b&gt;&lt;br /&gt;&lt;gr&gt;&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;var dic2 = DS.Dictionary(&lt;br /&gt;                &lt;br /&gt;  L1:DS.List(1,2,3),&lt;br /&gt;  L2:DS.List(1,2,3)&lt;br /&gt;);&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-5662848331856131571?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/5662848331856131571/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/02/initializing-dictionary-of-list-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/5662848331856131571'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/5662848331856131571'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/02/initializing-dictionary-of-list-with.html' title='Initializing a Dictionary of List&lt;int&gt; with the Dynamic Sugar library in C#'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-2309712325820176545</id><published>2011-02-12T01:16:00.000-05:00</published><updated>2011-02-12T01:58:48.529-05:00</updated><title type='text'>Fibonnaci() - JavaScript (Node.Js v.0.2.6) versus C# 4.0 on Windows XP 32b</title><content type='html'>In my previous post I compared the speed of execution of Python, Ruby and JavaScript V8 computing the Fibonnaci() function written in iterative mode.&lt;br /&gt;The speed of JavaScript V8, is so incredible that I tried comparing it against C#. &lt;br /&gt;In this sample, C# is twice faster but still, this explain why JavaScript and Node.js&lt;br /&gt;are so popular.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;JavaScript V8 tested on Node.js&lt;/b&gt;&lt;br /&gt;&lt;hr&gt;&lt;pre class="brush: javascript;"&gt;function Fibonnaci(n){&lt;br /&gt;&lt;br /&gt;    var previous = -1;&lt;br /&gt;    var result   =  1;&lt;br /&gt;&lt;br /&gt;    for(var i=0; i &amp;lt; n+1; i++){&lt;br /&gt;&lt;br /&gt;        var sum  = result + previous;&lt;br /&gt;        previous = result;&lt;br /&gt;        result   = sum;&lt;br /&gt;    }&lt;br /&gt;    return result;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;console.log("Node.js "+new Date());&lt;br /&gt;&lt;br /&gt;for(var t=0; t &amp;lt; 1000; t++){&lt;br /&gt;&lt;br /&gt;    for(var i=0; i &amp;lt; 1000; i++){&lt;br /&gt;&lt;br /&gt;        var v = Fibonnaci(i);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;console.log(new Date());&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;C# .NET 4.0 x86&lt;/b&gt;&lt;br /&gt;&lt;hr&gt;&lt;pre class="brush: csharp;"&gt;static long Fibonnaci(long n){&lt;br /&gt;&lt;br /&gt;    long previous = -1;&lt;br /&gt;    long result   =  1;&lt;br /&gt;    for(var i=0; i &amp;lt; n+1; i++){&lt;br /&gt;        long sum  = result + previous;&lt;br /&gt;        previous = result;&lt;br /&gt;        result   = sum;&lt;br /&gt;    }&lt;br /&gt;    return result;&lt;br /&gt;}&lt;br /&gt;static void Main(string[] args) {&lt;br /&gt;&lt;br /&gt;    Console.WriteLine("C# 4.0 {0}", DateTime.Now);&lt;br /&gt;&lt;br /&gt;    for(var t=0; t &amp;lt; 1000; t++){&lt;br /&gt;&lt;br /&gt;        for(var i=0; i &amp;lt; 1000; i++){&lt;br /&gt;&lt;br /&gt;            var v = Fibonnaci(i);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    Console.WriteLine("{0}", DateTime.Now);&lt;br /&gt;    Console.ReadLine();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;The results&lt;/h1&gt;&lt;br /&gt;JavaScript&lt;br /&gt;Sat Feb 12 2011 06:04:11&lt;br /&gt;Sat Feb 12 2011 06:04:17&lt;br /&gt;6 seconds&lt;br /&gt;&lt;br /&gt;C#&lt;br /&gt;2/12/2011 1:10:53 AM&lt;br /&gt;2/12/2011 1:10:56 AM&lt;br /&gt;3 seconds&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-2309712325820176545?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/2309712325820176545/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/02/fibonnaci-javascript-nodejs-v026-versus.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/2309712325820176545'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/2309712325820176545'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/02/fibonnaci-javascript-nodejs-v026-versus.html' title='Fibonnaci() - JavaScript (Node.Js v.0.2.6) versus C# 4.0 on Windows XP 32b'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-471101233929253850</id><published>2011-02-12T00:56:00.000-05:00</published><updated>2011-02-12T01:38:59.988-05:00</updated><title type='text'>Speed of execution of the Fibonnaci() in Python v2.7, Ruby v1.9.2 and JavaScript (Node.Js v.0.2.6)</title><content type='html'>This week i was writing some JavaScript running on Node.JS (Windows XP 32B), to generate data to be saved in MongoDB once the script is executed in MongoDB console.&lt;br /&gt;&lt;br /&gt;I was creating 1 million invoices like the one below generating random date, random number of items (max 10) and pulling customers and products information out of lists randomly.&lt;br /&gt;&lt;br /&gt;It was so fast, I thought there was something wrong with my code. Well there was nothing wrong&lt;br /&gt;with my code JavaScript V8 is just super fast.&lt;br /&gt;&lt;br /&gt;This is the JSon of a typical invoice generated once in MongoDB.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: javascript;"&gt;{&lt;br /&gt;"InvoiceID"     : 5000,&lt;br /&gt;"Customer"      : { "Name" : "Hot Stuff Foods", "ID" : 22 },&lt;br /&gt;"ArchiveDate"   : "Tue May 20 2008 00:00:00 GMT-0400 (Eastern Daylight Time)",&lt;br /&gt;"Date"          : "Sat Feb 12 2011 00:29:08 GMT-0500 (Eastern Standard Time)",&lt;br /&gt;"TotalInvoice"  : 188.11,&lt;br /&gt;"Status"        : "Unknown",&lt;br /&gt;"Items" : [&lt;br /&gt;        {&lt;br /&gt;                "Product" : {&lt;br /&gt;                        "Name"  : "CHI-CHI'S Con Queso",&lt;br /&gt;                        "Price" : 1.3,&lt;br /&gt;                        "ID"    : 2&lt;br /&gt;                },&lt;br /&gt;                "Price"     : 1.3,&lt;br /&gt;                "Quantity"  : 8,&lt;br /&gt;                "TotalItem" : 10.4&lt;br /&gt;        },&lt;br /&gt;        {&lt;br /&gt;                "Product" : {&lt;br /&gt;                        "Name"  : "Di Lusso Mediterranean Mixed Olives",&lt;br /&gt;                        "Price" : 8.99,&lt;br /&gt;                        "ID"    : 182&lt;br /&gt;                },&lt;br /&gt;                "Price"     : 8.99,&lt;br /&gt;                "Quantity"  : 9,&lt;br /&gt;                "TotalItem" : 80.91&lt;br /&gt;        },&lt;br /&gt;        {&lt;br /&gt;                "Product" : {&lt;br /&gt;                        "Name"  : "CHI-CHI'S Fiesta Sweet Corn Cake Mix",&lt;br /&gt;                        "Price" : 8.9,&lt;br /&gt;                        "ID"    : 56&lt;br /&gt;                },&lt;br /&gt;                "Price"     : 8.9,&lt;br /&gt;                "Quantity"  : 2,&lt;br /&gt;                "TotalItem" : 17.8&lt;br /&gt;        },&lt;br /&gt;        {&lt;br /&gt;                "Product" : {&lt;br /&gt;                        "Name"  : "CHI-CHI'S Fiesta PlatesT Creamy Chipotle Chicken",&lt;br /&gt;                        "Price" : 7.8,&lt;br /&gt;                        "ID"    : 12&lt;br /&gt;                },&lt;br /&gt;                "Price"     : 7.8,&lt;br /&gt;                "Quantity"  : 1,&lt;br /&gt;                "TotalItem" : 7.8&lt;br /&gt;        },&lt;br /&gt;        {&lt;br /&gt;                "Product" : {&lt;br /&gt;                        "Name"  : "CHI-CHI'S Fiesta Sweet Corn Cake Mix",&lt;br /&gt;                        "Price" : 8.9,&lt;br /&gt;                        "ID"    : 56&lt;br /&gt;                },&lt;br /&gt;                "Price"     : 8.9,&lt;br /&gt;                "Quantity"  : 8,&lt;br /&gt;                "TotalItem" : 71.2&lt;br /&gt;        }&lt;br /&gt;        ]&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;So I decided to compare Python, Ruby and JavaScript using Fibonnaci() in iterative mode.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Python&lt;/b&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;pre class="brush: python;"&gt;import datetime&lt;br /&gt;&lt;br /&gt;def Fibonnaci(n):&lt;br /&gt;    previous = -1&lt;br /&gt;    result   =  1&lt;br /&gt;    for i in range(n+1):&lt;br /&gt;        sum         = result + previous&lt;br /&gt;        previous    = result&lt;br /&gt;        result      = sum&lt;br /&gt;    return result&lt;br /&gt;&lt;br /&gt;print "Python %s" % datetime.datetime.now()&lt;br /&gt;&lt;br /&gt;for t in range(100):&lt;br /&gt;    for i in range(1000):&lt;br /&gt;        v = Fibonnaci(i)&lt;br /&gt;&lt;br /&gt;print  "%s" % (datetime.datetime.now())&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Ruby&lt;/b&gt;&lt;br /&gt;&lt;hr&gt;&lt;pre class="brush: ruby;"&gt;def Fibonnaci(n)&lt;br /&gt;    previous = -1&lt;br /&gt;    result   =  1&lt;br /&gt;    for i in (1..n)&lt;br /&gt;        sum         = result + previous&lt;br /&gt;        previous    = result&lt;br /&gt;        result      = sum&lt;br /&gt;    end&lt;br /&gt;    result&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;p "Ruby #{Time.now}"&lt;br /&gt;for t in (1..100)&lt;br /&gt;    for i in (1..1000)&lt;br /&gt;        v = Fibonnaci(i)&lt;br /&gt;    end&lt;br /&gt;end&lt;br /&gt;p "#{Time.now}"  &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;JavaScript V8 tested on Node.js&lt;/b&gt;&lt;br /&gt;&lt;hr&gt;&lt;pre class="brush: javascript;"&gt;function Fibonnaci(n){&lt;br /&gt;&lt;br /&gt;    var previous = -1;&lt;br /&gt;    var result   =  1;&lt;br /&gt;&lt;br /&gt;    for(var i=0; i &amp;lt; n+1; i++){&lt;br /&gt;&lt;br /&gt;        var sum  = result + previous;&lt;br /&gt;        previous = result;&lt;br /&gt;        result   = sum;&lt;br /&gt;    }&lt;br /&gt;    return result;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;console.log("Node.js "+new Date());&lt;br /&gt;&lt;br /&gt;for(var t=0; t &amp;lt; 100; t++){&lt;br /&gt;&lt;br /&gt;    for(var i=0; i &amp;lt; 1000; i++){&lt;br /&gt;&lt;br /&gt;        var v = Fibonnaci(i);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;console.log(new Date());&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h1&gt;The results&lt;/h1&gt;&lt;br /&gt;I must be doing something wrong with my Ruby code. I do not understand why it is so slow.&lt;br /&gt;But the speed of execution on JavaScript with V8 is incredible.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Python&lt;/b&gt;&lt;br /&gt;2011-02-12 00:51:50&lt;br /&gt;2011-02-12 00:52:03&lt;br /&gt;13s&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Ruby&lt;/b&gt;&lt;br /&gt;2011-02-12 00:48:38&lt;br /&gt;2011-02-12 00:49:24&lt;br /&gt;46s&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Node.js&lt;/b&gt;&lt;br /&gt;Sat Feb 12 2011 05:50:50&lt;br /&gt;Sat Feb 12 2011 05:50:50&lt;br /&gt;1s&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-471101233929253850?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/471101233929253850/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/02/fibonnaci-python-v27-ruby-v192-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/471101233929253850'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/471101233929253850'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/02/fibonnaci-python-v27-ruby-v192-and.html' title='Speed of execution of the Fibonnaci() in Python v2.7, Ruby v1.9.2 and JavaScript (Node.Js v.0.2.6)'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-6974791960220141502</id><published>2011-02-05T11:43:00.000-05:00</published><updated>2011-02-13T16:44:53.603-05:00</updated><title type='text'>Install Node JS On Windows 2008 and Windows XP</title><content type='html'>Installing Node JS on Windows 2008 and XP, took me some time and a lot of&amp;nbsp;Googling.&lt;br /&gt;Plus, if you are like me: not a Linux and Cygwin guy, that's even more a challenge.&lt;br /&gt;Anyway I was able to make it.&lt;br /&gt;&lt;br /&gt;Here is a summary:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Remarks&lt;/b&gt;: On Windows XP thing are simpler, I will mention step that can be skipped for Windows XP. Different version of node.js seems to have different problems. So first I will install and compile node-v0.2.0. &lt;br /&gt;At the of the post I will show how to download and compile&amp;nbsp;node-v0.2.6.&lt;br /&gt;At this time 2011/2/5, I have problems building v0.3.x. I decided not to look into it.&lt;br /&gt;&lt;br /&gt;This post is based on information I gathered on the following blog posts and my own experiments:&lt;br /&gt;&lt;br /&gt;- &lt;a href="http://boxysystems.com/index.php/step-by-step-instructions-to-install-nodejs-on-windows/comment-page-1/#comment-617"&gt;Step by step instructions to install NodeJS on Windows&lt;/a&gt;&lt;br /&gt;- &lt;a href="http://blog.brev.name/2010/09/nodejs-on-windows-7-under-cygwin.html?showComment=1284936993253_AIe9_BEuSc8B_nu9KzMfcAkQW3YQuXtbqZj7M33avU74Waa1oMLbyOQ3wTDHHkCiW4wJ7eIAyeTqubS7EE3I9wswhzY2QBj4Pc0XhvL6e77Ag6u47oNY8EQrhpEkvij4W1r7JKmt3VchNR0KpWzD796Z3U0jqBP1mClwww_V7F2tiie5Jd5xOLr0gLw6Ur5UpnRRu3Knvksb3itiR3WlF_cwsZEDmcR9GQ_etqSRvE_bKXqIwGUOngx_vVsP-RkpN-BNeIZkU3JhXOYbW_ACU4_6QiQ1Ox1jeyfCJdq6tQsP2vOfmcc27HkzPHU5rtNknX63_hUpqoi_TqVxEIQncYn5JGKzvO3pm0bLYRhtZBm1MxlpHrW82dTSwkiipR1Moy2tFBiYYXDUUBluGd-DWyWIUcMLyE1UWHmDKGirZq_oO5F0MT8eMbOaLrQWGjs5TNFKH9yMkoebCvgKTE6d0gCbV4gcO5uUukSlBS5DjsPWtBPrTmUd94Kj9wq7i0meknClWONnjWPlYKklRSFefjUBmafUy8URlkkSp0v6Fmt2zhu23Nt6Q35ZkblcxqLgmdmUq_YWgRnMdvc58HGR-e__63hxyX7GIH4j09PM0uaCJx0OeGFHET4cvP_u1eK6dwspuhNiqzN6Abltz2gNpeLrUaL30vKfhtqrb2Z1Quxrh9hedx6zQuU#c1502407389787754114"&gt;Node.js on Windows 7 under Cygwin, "FixImage error 13" problem&lt;/a&gt;&lt;br /&gt;- &lt;a href="http://code.google.com/p/cyg-apt/issues/detail?id=8"&gt;cyg-apt&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: 32px; font-weight: bold;"&gt;Installing cygwin.com&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;- Goto http://www.cygwin.com/ and download setup.exe&lt;br /&gt;- Run setup.exe &lt;b&gt;as an administrator&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_qdDSPqcuZ3Y/TU2mUZ0pb9I/AAAAAAAAAQ0/YEP3D3JwJiw/s1600/NodeJSInstall%2B%25282%2529.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="144" src="http://2.bp.blogspot.com/_qdDSPqcuZ3Y/TU2mUZ0pb9I/AAAAAAAAAQ0/YEP3D3JwJiw/s200/NodeJSInstall%2B%25282%2529.jpg" width="200" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TU2m_e1M5sI/AAAAAAAAAQ8/d64QbCE1NRw/s1600/NodeJSInstall%2B%25283%2529.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="144" src="http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TU2m_e1M5sI/AAAAAAAAAQ8/d64QbCE1NRw/s200/NodeJSInstall%2B%25283%2529.jpg" width="200" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TU2njcQsqLI/AAAAAAAAARE/Kp_km7GURyo/s1600/NodeJSInstall%2B%25284%2529.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="144" src="http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TU2njcQsqLI/AAAAAAAAARE/Kp_km7GURyo/s200/NodeJSInstall%2B%25284%2529.jpg" width="200" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_qdDSPqcuZ3Y/TU2njiA9aiI/AAAAAAAAARM/TajerC-0uPc/s1600/NodeJSInstall%2B%25285%2529.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="144" src="http://3.bp.blogspot.com/_qdDSPqcuZ3Y/TU2njiA9aiI/AAAAAAAAARM/TajerC-0uPc/s200/NodeJSInstall%2B%25285%2529.jpg" width="200" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TU2njm2vxGI/AAAAAAAAARU/TG4v08CWHVw/s1600/NodeJSInstall%2B%25286%2529.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="144" src="http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TU2njm2vxGI/AAAAAAAAARU/TG4v08CWHVw/s200/NodeJSInstall%2B%25286%2529.jpg" width="200" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_qdDSPqcuZ3Y/TU2nj4kv5mI/AAAAAAAAARc/cfDt0F-TP24/s1600/NodeJSInstall%2B%25287%2529.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="144" src="http://2.bp.blogspot.com/_qdDSPqcuZ3Y/TU2nj4kv5mI/AAAAAAAAARc/cfDt0F-TP24/s200/NodeJSInstall%2B%25287%2529.jpg" width="200" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_qdDSPqcuZ3Y/TU2nkkUd_CI/AAAAAAAAARk/n_vAxy5VesI/s1600/NodeJSInstall%2B%25288%2529.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="144" src="http://3.bp.blogspot.com/_qdDSPqcuZ3Y/TU2nkkUd_CI/AAAAAAAAARk/n_vAxy5VesI/s200/NodeJSInstall%2B%25288%2529.jpg" width="200" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- &amp;nbsp;Filter on &lt;b&gt;python &lt;/b&gt;and install all from the python section&lt;br /&gt;&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_qdDSPqcuZ3Y/TU2otHvUy7I/AAAAAAAAARs/eKfpBnr3AKs/s1600/NodeJSInstall%2B%25289%2529.jpg" imageanchor="1" style="clear: left; display: inline !important; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="427" src="http://4.bp.blogspot.com/_qdDSPqcuZ3Y/TU2otHvUy7I/AAAAAAAAARs/eKfpBnr3AKs/s640/NodeJSInstall%2B%25289%2529.jpg" width="640" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;- Filter on &lt;b&gt;make &lt;/b&gt;and install all from the devel section&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_qdDSPqcuZ3Y/TU2o9JY2doI/AAAAAAAAAR0/of-ojvr_KF4/s1600/NodeJSInstall+%252810%2529.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="425" src="http://4.bp.blogspot.com/_qdDSPqcuZ3Y/TU2o9JY2doI/AAAAAAAAAR0/of-ojvr_KF4/s640/NodeJSInstall+%252810%2529.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;- Filter on &lt;b&gt;G++&lt;/b&gt; and install all from the devel section&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_qdDSPqcuZ3Y/TU2pMbNHqcI/AAAAAAAAAR4/0BdEnKfPg3g/s1600/NodeJSInstall+%252811%2529.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="425" src="http://4.bp.blogspot.com/_qdDSPqcuZ3Y/TU2pMbNHqcI/AAAAAAAAAR4/0BdEnKfPg3g/s640/NodeJSInstall+%252811%2529.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;- Filter on &lt;b&gt;wget &lt;/b&gt;and install all from the devel section&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TU2pUcf3wCI/AAAAAAAAAR8/dcx-MZMqIo4/s1600/NodeJSInstall+%252812%2529.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="426" src="http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TU2pUcf3wCI/AAAAAAAAAR8/dcx-MZMqIo4/s640/NodeJSInstall+%252812%2529.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;Update file rebaseall (Not need for XP)&lt;/span&gt;&lt;br /&gt;- With an editor open the file "C:\cygwin\bin/bin/rebaseall"&lt;br /&gt;- Goto line 83 and comment line TmpDir="${TMP:-${TEMP:-/tmp}}"&lt;br /&gt;- Add this line: TmpDir="/tmp"&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_qdDSPqcuZ3Y/TU2pg2azX7I/AAAAAAAAASA/JLw6QNXaGkY/s1600/NodeJSInstall+%252814%2529.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="368" src="http://4.bp.blogspot.com/_qdDSPqcuZ3Y/TU2pg2azX7I/AAAAAAAAASA/JLw6QNXaGkY/s640/NodeJSInstall+%252814%2529.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;- Goto line 110 and add this extra filter&lt;br /&gt;-e '/\/sys-root\/mingw\/bin/d'&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TU2pr50NmDI/AAAAAAAAASE/qqES3Q7DM50/s1600/NodeJSInstall+%252815%2529.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="248" src="http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TU2pr50NmDI/AAAAAAAAASE/qqES3Q7DM50/s640/NodeJSInstall+%252815%2529.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;Run rebaseall (Not needed for XP)&lt;/span&gt;&lt;br /&gt;- open a command prompt &lt;b&gt;as administrator&lt;/b&gt;&lt;br /&gt;- goto C:\cygwin\bin&lt;br /&gt;- run ash.exe&lt;br /&gt;- enter: rebaseall -v&lt;br /&gt;- quit ash anyway you can (click the close icon)&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;Get the source code of node.js v0.2.0&lt;/span&gt;&lt;br /&gt;- Open the Cygwin console&lt;br /&gt;- Run this batch file &lt;b&gt;as administrator&lt;/b&gt; C:\cygwin\Cygwin.bat&lt;br /&gt;- type:pwd [enter]&lt;br /&gt;- You should be located in your folder folder &lt;i&gt;&lt;b&gt;/home/ftorres&amp;nbsp;&lt;/b&gt;&lt;/i&gt;which is on the disk &lt;i&gt;&lt;b&gt;C:\cygwin\home\ftorres&lt;/b&gt;&lt;/i&gt;&lt;br /&gt;- To download source code and compile Node.js enter the following command&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&lt;/span&gt;wget http://nodejs.org/dist/node-v0.2.0.tar.gz&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&lt;/span&gt;tar xvf node-v0.2.0.tar.gz&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&lt;/span&gt;cd node-v0.2.0/ &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&lt;/span&gt;./configure&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&lt;/span&gt;make&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&lt;/span&gt;make install&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;- To check that node js has been built enter&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;C:\&amp;gt;node --version&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;Testing helloWorld.js&lt;/span&gt;&lt;br /&gt;- from&amp;nbsp;&lt;a href="http://nodejs.org/"&gt;http://nodejs.org/&lt;/a&gt;&amp;nbsp;download the hello world sample&lt;br /&gt;- save it to a file in the current directory&lt;br /&gt;- run node.exe HelloWorld.js&lt;br /&gt;- Enter the following url in any browser http://127.0.0.1:8124&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-size: x-large;"&gt;Get the source code of node.js v0.2.6&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;- Open the Cygwin console&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;- Run this batch file&amp;nbsp;&lt;b&gt;as administrator&lt;/b&gt;&amp;nbsp;C:\cygwin\Cygwin.bat&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;- type:pwd [enter]&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;- You should be located in your folder folder&amp;nbsp;&lt;i&gt;&lt;b&gt;/home/ftorres&amp;nbsp;&lt;/b&gt;&lt;/i&gt;which is on the disk&amp;nbsp;&lt;i&gt;&lt;b&gt;C:\cygwin\home\ftorres&lt;/b&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;- To download source code and compile Node.js enter the following command&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&lt;/span&gt;wget http://nodejs.org/dist/node-v0.2.6.tar.gz&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&lt;/span&gt;tar xvf node-v0.2.6.tar.gz&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&lt;/span&gt;cd node-v0.2.6/&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&lt;/span&gt;./configure&amp;nbsp;--without-ssl&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&lt;/span&gt;make&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&lt;/span&gt;make install&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;- To check that node js has been built enter&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;C:\&amp;gt;node --version&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: 32px; font-weight: bold;"&gt;&lt;br /&gt;Issue with DNS&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I tried to write a program that was downloading an rss feed and was faced with DNS error.&lt;br /&gt;&lt;br /&gt;I find this post &lt;a href="http://codebetter.com/matthewpodwysocki/2010/09/08/getting-started-with-node-js-on-windows/"&gt;Getting Started with Node.js on Windows &lt;/a&gt; from Matthew Podwysocki,&lt;br /&gt;which had the solution.&lt;br /&gt;&lt;br /&gt;with the notepad create the file C:\cygwin\etc\resolv.conf and paste the following:&lt;br /&gt;&lt;br /&gt;nameserver 8.8.8.8&lt;br /&gt;nameserver 8.8.4.4&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-6974791960220141502?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/6974791960220141502/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/02/install-node-js-on-windows-2008.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/6974791960220141502'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/6974791960220141502'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/02/install-node-js-on-windows-2008.html' title='Install Node JS On Windows 2008 and Windows XP'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_qdDSPqcuZ3Y/TU2mUZ0pb9I/AAAAAAAAAQ0/YEP3D3JwJiw/s72-c/NodeJSInstall%2B%25282%2529.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-5020680714551188209</id><published>2011-01-30T00:32:00.283-05:00</published><updated>2011-04-04T22:26:55.253-04:00</updated><title type='text'>The Dynamic Sugar Library</title><content type='html'>The Dynamic Sugar Library provides methods, functions and classes inspired by the  dynamic language Python and JavaScript to write more readable code in C#.&lt;br /&gt;&lt;br /&gt;It's all about &lt;a href="http://en.wikipedia.org/wiki/Syntactic_sugar"&gt;Syntactic Sugar&lt;/A&gt;. Obviously this is based on my own taste.&lt;br /&gt;&lt;br /&gt;Is it syntactic saccharin? You decide!&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;    &lt;li&gt;Some extensions method to the class List&amp;lt;T&amp;gt; are borrowed from the javascript library &lt;a href="http://documentcloud.github.com/underscore"&gt;underscore.js&lt;/A&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;hr /&gt;&lt;hr /&gt;&lt;br /&gt;&lt;h1&gt;But Why?&lt;/H1&gt;To make C# code shorter, simpler and cleaner.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Let's look at a first example - Formatting string&lt;/b&gt;&lt;br /&gt;&lt;hr&gt;Let's format a string&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;// Regular syntax&lt;br /&gt;var s = string.Format("[{0}] Age={1:000}", "TORRES", 45);&lt;br /&gt;&lt;br /&gt;// Dynamic Sugar syntax&lt;br /&gt;var s = "[{LastName}] Age={Age:000}".Format( new { LastName="TORRES", Age=45 } );&lt;br /&gt;&lt;br /&gt;//&lt;br /&gt;&lt;/pre&gt;The new Format() method support the following as parameter any POCO object, Anonymous Type, IDictionary&amp;lt;K,V&amp;gt;, ExpandoObject and DynamicSugar.DynamicBag.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Let's look at a second example - How to instanciate, populate and use a List&amp;lt;T&amp;gt;&lt;/b&gt;&lt;br /&gt;&lt;hr&gt;Let's check if one value exist in a list.&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;// Regular syntax&lt;br /&gt;List&amp;lt;int&amp;gt; someIntegers = new List&amp;lt;int&amp;gt;() { 1, 2, 3 };&lt;br /&gt;int i                  = 2;&lt;br /&gt;if(someIntegers.Contains(i)){&lt;br /&gt;&lt;br /&gt;    Console.WriteLine("2 is in the list");&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;Here is the syntax with DynamicSugar&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;int i = 2;&lt;br /&gt;if(i.In(DS.List( 1, 2, 3 ))){&lt;br /&gt;&lt;br /&gt;    Console.WriteLine("2 is in the list");&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Let's look at a third example - How to instanciate, populate and pass a dictionary to a method&lt;/b&gt;&lt;br /&gt;&lt;hr&gt;&lt;pre class="brush: csharp;"&gt;&lt;br /&gt;void InitializeSettings(IDictionary&amp;lt;string, object&amp;gt; settings){&lt;br /&gt;            &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// Regular syntax&lt;br /&gt;InitializeSettings( new Dictionary&amp;lt;string, object&amp;gt;() {&lt;br /&gt;    { "UserName", "RRabbit"  },&lt;br /&gt;    { "Domain"  , "ToonTown" },&lt;br /&gt;    { "UserID"  , 234873     }&lt;br /&gt;});&lt;br /&gt;&lt;br /&gt;// Dynamic Sugar syntax&lt;br /&gt;InitializeSettings( DS.Dictionary( new {&lt;br /&gt;    UserName = "RRabbit" ,&lt;br /&gt;    Domain   = "ToonTown",&lt;br /&gt;    UserID   = 234873&lt;br /&gt;}));&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Let's look at a forth example - Function returning multiple values&lt;/b&gt;&lt;br /&gt;&lt;hr&gt;A C# function can only return one value, but with Dynamic Sugar we can change that.&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;// Here is a function returning 3 values using Dynamic Sugar&lt;br /&gt;static dynamic ComputeValues() {&lt;br /&gt;                        &lt;br /&gt;    return DS.Values( new { a=1, b=2.0, c="Hello" } );&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// Here is how to use the results&lt;br /&gt;static void MultiValuesSample() {&lt;br /&gt;                        &lt;br /&gt;    var values = ComputeValues();&lt;br /&gt;    Console.Write(values.a);&lt;br /&gt;    Console.Write(values.b);&lt;br /&gt;    Console.Write(values.c);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;Extension Methods For Classes&lt;/H1&gt;&lt;br /&gt;&lt;b&gt;Format() Method&lt;/b&gt;&lt;br /&gt;&lt;hr&gt;Extend any class with the method Format(), and start formating string using the properties name of the class. Post fix the name with ":format" and format the value of the property.&lt;br /&gt;The method knows how to format the following types: &lt;b&gt;&lt;i&gt;List&amp;lt;T&amp;gt;, array, Dictionary&amp;lt;K,V&amp;gt; &lt;/b&gt;&lt;/i&gt;and user custom types.&lt;br /&gt;You can also call member function with no input parameters.&lt;br /&gt;The method fall back on the String.Format(), so you can also combine "{0}" in the format. &lt;br /&gt;&lt;pre class="brush: csharp;"&gt;Person p = new Person() {&lt;br /&gt;&lt;br /&gt;    LastName        = "TORRES"  ,&lt;br /&gt;    FirstName       = "Frederic",&lt;br /&gt;    BirthDay        = new DateTime(1964,12, 11),&lt;br /&gt;    DrivingLicenses = DS.List("Car", "Moto Bike")&lt;br /&gt;};&lt;br /&gt;Console.WriteLine( // Call 4 properties in the format&lt;br /&gt;    p.Format("FullName:'{LastName},{FirstName}', BirthDay:{BirthDay:MM/dd/yyyy}, DrivingLicenses:{DrivingLicenses}")&lt;br /&gt;);&lt;br /&gt;Console.WriteLine( // Call a method in the format&lt;br /&gt;    p.Format("LoadInformation:{LoadInformation()} ")&lt;br /&gt;);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Output:&lt;/b&gt;&lt;br /&gt;FullName:'TORRES,Frederic', BirthDay:12/11/1964, DrivingLicenses:["Car", "Moto Bike"]&lt;br /&gt;LoadInformation:Information&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;Static Members&lt;/H1&gt;&lt;br /&gt;&lt;b&gt;Range()&lt;/b&gt;&lt;br /&gt;&lt;hr&gt;Instead of writing this&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;for (int i = 0; i &amp;lt; 5; i++) {&lt;br /&gt;                &lt;br /&gt;    Console.WriteLine(i);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;Write that&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;foreach(var i in DS.Range(5)){&lt;br /&gt;&lt;br /&gt;    Console.WriteLine(i);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// Definition&lt;br /&gt;public static List&amp;lt;int&amp;gt; Range(int max);&lt;br /&gt;public static List&amp;lt;int&amp;gt; Range(int max, int increment);&lt;br /&gt;public static List&amp;lt;int&amp;gt; Range(int start, int max, int increment);&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;List() Method&lt;/b&gt;&lt;br /&gt;&lt;hr&gt;To quickly create a List&amp;lt;T&amp;gt;.&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;var l1 = DS.List(1, 2, 3, 4);&lt;br /&gt;var l2 = DS.List("A", "B", "C");&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Dictionary() Method&lt;/b&gt;&lt;br /&gt;&lt;hr&gt;To quickly create a IDictionary&amp;lt;String, Object&amp;gt;.&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;var d1 = DS.Dictionary( LastName:"Pascal", FirstName:"Blaise" );&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h1&gt;Extension Methods For All Types&lt;/H1&gt;&lt;br /&gt;&lt;b&gt;In() Method&lt;/b&gt;&lt;br /&gt;&lt;hr&gt;The &lt;b&gt;in&lt;/b&gt; operator in Python, is translated with an extension method named &lt;b&gt;In()&lt;/b&gt; available to all the types in the .NET framework. It is may be a little bit pushy.&lt;br /&gt;You must implement the method &lt;br /&gt;&lt;pre class="brush: csharp;"&gt;public override bool Equals(object obj);&lt;/pre&gt;for your custom classes to be able to use the function &lt;b&gt;In()&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;Here is what you can write :&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;int i = 1;&lt;br /&gt;&lt;br /&gt;if(i.In(1,2,3)){&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;List&amp;lt;int&amp;gt; l = DS.List(1,2,3);&lt;br /&gt;&lt;br /&gt;if(i.In(l)){&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;var state = "good";&lt;br /&gt;&lt;br /&gt;if(state.In("good","bad","soso")){&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;enum CustomerType {&lt;br /&gt;&lt;br /&gt;  Good,&lt;br /&gt;  Bad,&lt;br /&gt;  SoSo&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;var customerType = CustomerType.Good;&lt;br /&gt;&lt;br /&gt;if(customerType.In(CustomerType.Good, CustomerType.SoSo)){&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Dictionary() Method&lt;/b&gt;&lt;br /&gt;&lt;hr&gt;The Dictionary() is an extension method that can be applied to any POCO.&lt;br /&gt;This is the equivalent of the Python __dict__ member.&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;// Extension method for the class Person&lt;br /&gt;public static IDictionary&amp;lt;string,object&amp;gt; Dictionary(this Person person, List&amp;lt;string&amp;gt; propertiesToInclude = null) {&lt;br /&gt;    return DynamicSugar.ReflectionHelper.GetDictionary(person, propertiesToInclude);&lt;br /&gt;}&lt;br /&gt;// Usage&lt;br /&gt;Person p = new Person() {&lt;br /&gt;&lt;br /&gt;  LastName  = "TORRES",&lt;br /&gt;  FirstName = "Frederic",&lt;br /&gt;  BirthDay  = new DateTime(1964, 12, 11)&lt;br /&gt;};&lt;br /&gt;foreach(var k in p.Dictionary()){&lt;br /&gt;&lt;br /&gt;  Console.WriteLine("{0}='{1}'", k.Key, k.Value);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h1&gt;Extension Methods For List&amp;lt;T&amp;gt;&lt;/H1&gt;All methods return a brand new List&amp;lt;T&amp;gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Map() and Format() Method&lt;/b&gt;&lt;br /&gt;&lt;hr&gt;The method Map() allow to process each element of a list and return a new list of the same type.&lt;br /&gt;The method Format() for a List&amp;lt;T&amp;gt; allow to format a list into a string.&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;// Compute the square values of a list&lt;br /&gt;&lt;br /&gt;var l = DS.List(1,2,3,4).Map( e =&gt; e*e );&lt;br /&gt;Console.WriteLine(l.Format()); // =&gt; 1, 4, 9, 16&lt;br /&gt;&lt;br /&gt;var l2 = DS.Map( DS.Range(10), e =&gt; e*e );&lt;br /&gt;Console.WriteLine(l2.Format("'{0}'", ",")); // =&gt; '0','1','4','9','16','25','36','49','64','81'&lt;br /&gt;&lt;br /&gt;//&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Inject() Method&lt;/b&gt;&lt;br /&gt;&lt;hr&gt;Inject() inspired by Ruby. The function re-uses the .NET Aggregate() function.&lt;br /&gt;Yes, it is not exactly the same, as the end result type must be the same as the type of the list.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;// Sum the values from 0 to 4&lt;br /&gt;&lt;br /&gt;var l = DS.Range(5).Inject( (v,e) =&gt; v += e ) ;&lt;br /&gt;var l = DS.List(0,1,2,3,4).Inject( (v,e) =&gt; v += e ) ;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Filter() Method&lt;/b&gt;&lt;br /&gt;&lt;hr&gt;Filter is the same as FindAll(), I just prefer Filter().&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;var l = DS.Range(10).Filter(e =&gt; e % 2 == 0);&lt;br /&gt;Console.WriteLine( l.Format() );&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Map() Method&lt;/b&gt;&lt;br /&gt;&lt;hr&gt;This map function can only return a list of same type, after all C# is not Python.&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;string MyConst = "Hi ";&lt;br /&gt;var l          = DS.List("fred", "joe", "diane").Map(e =&amp;gt; MyConst + e));&lt;br /&gt;// =&gt; ["Hi fred", "Hi joe", "Hi diane"]&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;ToFile() and FromFile() Methods&lt;/b&gt;&lt;br /&gt;&lt;hr&gt;To write and read List&amp;lt;T&amp;gt; from a text file where T is a value type.&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;var l1        = DS.Range(10);&lt;br /&gt;var fileName  = @"{0}\DSSharpLibrary_UnitTests.txt".format(Environment.GetEnvironmentVariable("TEMP"));&lt;br /&gt;&lt;br /&gt;l1.ToFile(fileName, true);&lt;br /&gt;&lt;br /&gt;var l2        = DS.FromFile&amp;lt;int&amp;gt;(fileName);&lt;br /&gt;&lt;br /&gt;DS.AssertListEqual(l1, l2);            &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Include() Method&lt;/b&gt;&lt;br /&gt;&lt;hr&gt;&lt;pre class="brush: csharp;"&gt;var l1 = DS.Range(10);&lt;br /&gt;&lt;br /&gt;if(l1.Include(5)){&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;if(l1.Include(1, 2, 3)){&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;if(l1.Include(DS.List(1, 2 , 3))){&lt;br /&gt;&lt;br /&gt;}  &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Without() Method&lt;/b&gt;&lt;br /&gt;&lt;hr&gt;Borrowed from underscore.js.&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;var l1 = DS.Range(10);            &lt;br /&gt;var l2 = l1.Without(0, 2, 4, 6, 8);&lt;br /&gt;var l3 = l1.Without(DS.List(0, 2, 4, 6, 8));&lt;br /&gt;Console.WriteLine(l2.Format()); // =&gt; 1, 3, 5, 7, 9&lt;br /&gt;Console.WriteLine(l3.Format()); // =&gt; 1, 3, 5, 7, 9&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;First(), Last(), Rest(), IsEmpty() Methods&lt;/b&gt;&lt;br /&gt;&lt;hr&gt;Borrowed from underscore.js.&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;var l1 = DS.Range(10);            &lt;br /&gt;&lt;br /&gt;while(!l1.IsEmpty()){&lt;br /&gt;&lt;br /&gt;    var first = l1.First();&lt;br /&gt;    var last  = l1.Last();&lt;br /&gt;    l1        = l1.Rest();&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Identical() Methods&lt;/b&gt;&lt;br /&gt;&lt;hr&gt;&lt;pre class="brush: csharp;"&gt;var l1 = DS.Range(10);            &lt;br /&gt;var l2 = DS.Range(10);            &lt;br /&gt;&lt;br /&gt;if(l1.Identical(l2)){&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Pluck() Methods&lt;/b&gt;&lt;br /&gt;&lt;hr&gt;Borrowed from underscore.js.&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;var people = DS.List(&lt;br /&gt;    new Person() { LastName = "Descartes",   FirstName = "Rene",          BirthDay = new DateTime(1596,3,31) },&lt;br /&gt;    new Person() { LastName = "Montesquieu", FirstName = "Charles-Louis", BirthDay = new DateTime(1689,1,18) },&lt;br /&gt;    new Person() { LastName = "Rousseau",    FirstName = "JJ",            BirthDay = new DateTime(1712,3,31) }&lt;br /&gt;);&lt;br /&gt;Console.WriteLine(people.Pluck&amp;lt;int, Person&amp;gt;("Age").Format()); // =&gt; 415, 322, 299 in 2010          &lt;br /&gt;&lt;br /&gt;//&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Reject() Methods&lt;/b&gt;&lt;br /&gt;&lt;hr&gt;Borrowed from underscore.js.&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;// Remove some elements based on an lambda expression&lt;br /&gt;Console.WriteLine(&lt;br /&gt;            DS.Range(10).Reject(e =&gt; e % 2 == 0).Format()&lt;br /&gt;        ); // =&gt; 1, 3, 5, 7, 9&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;b&gt;Class RazorHelper - An easy way to use the Microsoft Razor Template Engine outside of the MVC framework&lt;/b&gt;&lt;br /&gt;&lt;hr&gt;The Razor helper class does the following:&lt;br /&gt;&lt;UL&gt;    &lt;li&gt;Simplify the execution of Razor templates&lt;/li&gt;    &lt;li&gt;Compiled and cache templates in memory&lt;/li&gt;    &lt;li&gt;Implement the concept of bag populated from any .NET POCO, Anonymous Type or ExpandoObject to pass variables to be rendered in the template.&lt;/li&gt;&lt;/UL&gt;See unit tests from usage samples&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;string BAG_TEMPLATE = @"&lt;br /&gt;var @bag.Class = {&lt;br /&gt;    ID          : @bag.ID,&lt;br /&gt;    LastName    :'@bag.LastName',&lt;br /&gt;    FirstName   :'@bag.FirstName',&lt;br /&gt;    &lt;br /&gt;    Execute: function(i){&lt;br /&gt;        &lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;";&lt;br /&gt;dynamic bag   = new ExpandoObject();&lt;br /&gt;bag.LastName  = "DESCARTES";&lt;br /&gt;bag.FirstName = "Rene";&lt;br /&gt;bag.Class     = "User";&lt;br /&gt;bag.ID        = 1234;&lt;br /&gt;&lt;br /&gt;using (var r = new RazorHelper()) {&lt;br /&gt;&lt;br /&gt;    var t = r.Run("JavascriptTemplate", BAG_TEMPLATE, bag);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-5020680714551188209?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/5020680714551188209/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/01/dynamic-sugar-library.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/5020680714551188209'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/5020680714551188209'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/01/dynamic-sugar-library.html' title='The Dynamic Sugar Library'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-731477020319860328</id><published>2011-01-27T21:55:00.003-05:00</published><updated>2011-04-21T13:14:06.354-04:00</updated><title type='text'>What is QuickUnit.net ?</title><content type='html'>May 2007.&lt;br /&gt;&lt;br /&gt;QuickUnit.net is unit test framework of another kind. The key idea was to define test case input and output values as .NET attributes in the source code itself.&lt;br /&gt;&lt;br /&gt;It was inspired by the post &lt;a href="http://secretgeek.net/simple_tests.asp"&gt;Annotating Your Code with Simple Tests&lt;/a&gt; from Leon Bambrick in may 2007.&lt;br /&gt;&lt;br /&gt;QuickUnit.net was an experiment and because .NET attribute only support array of value type, building complex set of input and output data was not feasible.&lt;br /&gt;&lt;br /&gt;The main feature still worth looking at it.&lt;br /&gt;&lt;br /&gt;QuickUnit.net  is written in C# 3.5 with samples in C# and VB.NET.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.frederictorres.net/QuickUnit.net/QuickUnit.Net.zip"&gt;Download the source code&lt;/a&gt;.   &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Unit Testing IsALeapYear() Function&lt;/h2&gt;Assign the .NET attribute TestMethod to the method, define the expected value and the parameter set. &lt;br /&gt;&lt;hr&gt;&lt;pre class="brush: csharp;"&gt;/// &lt;summary&gt; &lt;br /&gt;/// Is Year a leap year? &lt;br /&gt;/// &lt;/summary&gt; &lt;br /&gt;/// &lt;param name="Year"&gt;The year in question&lt;/param&gt;/// &lt;returns&gt; &lt;br /&gt;/// true if year is a leap year. false otherwise &lt;br /&gt;/// &lt;/returns&gt; &lt;br /&gt;[&lt;br /&gt;    TestMethod( true  , 2000 ),&lt;br /&gt;    TestMethod( false , 1900 ),&lt;br /&gt;    TestMethod( true  , 1996 ),&lt;br /&gt;    TestMethod( false , 2003 ),&lt;br /&gt;    TestMethod( false , 1973 ),&lt;br /&gt;    TestMethod( false , 1971 )&lt;br /&gt;]&lt;br /&gt;public  static  bool  IsALeapYear(int  year) {&lt;br /&gt;&lt;br /&gt;    return  (((year % 4) == 0) &amp;&amp; ((year % 100) != 0)) || ((year % 400) == 0);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;Command Line Parameters&lt;/h2&gt;QuickUnit.net's tests can be executed by using the QuickUnit.net Console. &lt;br /&gt;&lt;hr&gt;&lt;pre&gt;QuickUnit.net.Console.exe -a MyAssembly.dll [-class classname1,classname2] [-method methodname1,methodname2] [-logo false] [-pause true]&lt;br /&gt;&lt;/pre&gt;The exit code returns the number of error. During the build process, execute your QuickUnit.net unit tests before calling your unit tests implemented with an xUnit framework. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Unit Testing FullName Property&lt;br /&gt;&lt;/h2&gt;Here we test a property and also define the parameter set for the class constructor.&lt;br /&gt;&lt;hr&gt;&lt;pre class="brush: csharp;"&gt;[TestClass()]&lt;br /&gt;public  class  CPerson  {&lt;br /&gt;&lt;br /&gt;    private  string       _LastName;&lt;br /&gt;    private  string       _FirstName;&lt;br /&gt;    &lt;br /&gt;    public  CPerson(string  firstName, string  lastName) {&lt;br /&gt;    &lt;br /&gt;        this .FirstName  = firstName;&lt;br /&gt;        this .LastName   = lastName;        &lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    /// &lt;summary&gt; &lt;br /&gt;    /// Gets the full name. &lt;br /&gt;    /// &lt;/summary&gt; &lt;br /&gt;    /// &lt;value&gt;The full name.&lt;/value&gt; &lt;br /&gt;    [&lt;br /&gt;        QuickUnit.Net.TestProperty("Joe Smith" , new  object [] { "Joe" , "Smith"  }) , &lt;br /&gt;        QuickUnit.Net.TestProperty("John Doe" ,  new  object [] { "John" , "Doe"   })&lt;br /&gt;    ]&lt;br /&gt;    public  string  FullName {&lt;br /&gt;    &lt;br /&gt;        get  { return  this .FirstName + " "  + this .LastName; }&lt;br /&gt;    }&lt;br /&gt;}    &lt;br /&gt;&lt;br /&gt;&lt;br /&gt; &lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;Unit Testing AgeAt() Function&lt;br /&gt;&lt;/h2&gt;This example shows how to define the type of the parameters used when it is not infered. &lt;br /&gt;&lt;hr&gt;&lt;pre class="brush: csharp;"&gt;/// &lt;summary&gt; &lt;br /&gt;     /// If person was born on birthdate,'s their age, in whole years at atDate? &lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;param name="birthDate"&gt;The birth date.&lt;/param&gt;/// &lt;param name="atDate"&gt;At date.&lt;/param&gt;/// &lt;returns&gt;Age in years (floored)&lt;/returns&gt;&lt;br /&gt;[&lt;br /&gt;    TestMethod(43, new  object [] { "12/11/1964"  , "07/01/2007"  }),&lt;br /&gt;    TestMethod(50, new  object [] { "12/11/1964"  , "07/01/2014"  }),&lt;br /&gt;    TestMethod(15, new  object [] { "10/29/1992"  , "07/01/2007"  }),&lt;br /&gt;    TestMethod(16, new  object [] { "10/29/1992"  , "07/01/2008"  }),&lt;br /&gt;    TestMethod( 9, new  object [] { "01/29/1998"  , "07/01/2007"  }),&lt;br /&gt;    TestMethod(10, new  object [] { "01/29/1998"  , "07/01/2008"  }),&lt;br /&gt;]&lt;br /&gt;public  int  AgeAt(DateTime birthDate, DateTime atDate) {&lt;br /&gt;&lt;br /&gt;    System.TimeSpan TS = new  System.TimeSpan(atDate.Ticks-birthDate.Ticks);&lt;br /&gt;    return  Convert.ToInt32(TS.TotalDays/365.25);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;Expect an Exception&lt;br /&gt;&lt;/h2&gt;This example shows how to define the type of the parameters used when it is not infered. &lt;br /&gt;&lt;hr&gt;&lt;pre class="brush: csharp;"&gt;[&lt;br /&gt;    TestMethod(EX.EXCEPTION, typeof (System.DivideByZeroException ), new  object [] { 64, 0 } ),&lt;br /&gt;    TestMethod( 3, new  object [] {  6, 2 } ),&lt;br /&gt;    TestMethod(32, new  object [] { 64, 2 } )&lt;br /&gt;]&lt;br /&gt;public  int  DivInt(int  a, int  b) {&lt;br /&gt;&lt;br /&gt;    return  a / b;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;Pass an array&lt;br /&gt;&lt;/h2&gt;This example shows how to define the type of the parameters used when it is not infered. &lt;br /&gt;&lt;hr&gt;&lt;pre class="brush: csharp;"&gt;[&lt;br /&gt;    TestMethod(    3, new  object [] { new  int [] { 1,      2            } } ),&lt;br /&gt;    TestMethod(11100, new  object [] { new  int [] { 100, 1000, 10000     } } ),&lt;br /&gt;    TestMethod(  -10, new  object [] { new  int [] {  -1,   -2,    -3, -4 } } )&lt;br /&gt;]&lt;br /&gt;public int SumIntArray(int [] intValues) {&lt;br /&gt;&lt;br /&gt;    int  a = 0;&lt;br /&gt;&lt;br /&gt;    foreach  (int  i in  intValues) {&lt;br /&gt;&lt;br /&gt;        a += i;&lt;br /&gt;    }&lt;br /&gt;    return  a;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;Default and specific constructor value&lt;br /&gt;&lt;/h2&gt;&lt;hr&gt;&lt;pre class="brush: csharp;"&gt;[TestClass(new  object [] { 1 })] // Default constructor value&lt;br /&gt;public  class  TestClassIntegerUnitTest  {&lt;br /&gt;&lt;br /&gt;    private  int  _InitializedValue = -1;&lt;br /&gt;    &lt;br /&gt;    public  TestClassIntegerUnitTest(int  initializedValue) {&lt;br /&gt;    &lt;br /&gt;        this ._InitializedValue = initializedValue;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    [&lt;br /&gt;        TestMethod(1, new  object [] {} ), // Use the default constructor parameter value&lt;br /&gt;        TestMethod(2, new  object [] {} , new  object [] {2}) // Define a constructor parameter value&lt;br /&gt;    ]&lt;br /&gt;    public  int  InitializedValue() {&lt;br /&gt;    &lt;br /&gt;        return  this ._InitializedValue;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;Testing the function IsInArray()&lt;br /&gt;&lt;/h2&gt;&lt;hr&gt;&lt;pre class="brush: csharp;"&gt;[&lt;br /&gt;    // Value not in the array ignore case or not&lt;br /&gt;    TestMethod(false , new  object [] { "Z" ,  new  string [] { "A" , "B"  , "C"  } , true   } ),&lt;br /&gt;    TestMethod(false , new  object [] { "Z" ,  new  string [] { "A" , "B"  , "C"  } , false  } ),&lt;br /&gt;    &lt;br /&gt;    // Value in the array ignore case or not&lt;br /&gt;    TestMethod(true ,  new  object [] { "A" ,  new  string [] { "A" , "B"  , "C"  } , true   } ),&lt;br /&gt;    TestMethod(true ,  new  object [] { "A" ,  new  string [] { "A" , "B"  , "C"  } , false  } ),&lt;br /&gt;    &lt;br /&gt;    // Value in the array if ignore case&lt;br /&gt;    TestMethod(true ,  new  object [] { "a" ,  new  string [] { "A" , "B"  , "C"  } , true   } ),&lt;br /&gt;    TestMethod(false , new  object [] { "a" ,  new  string [] { "A" , "B"  , "C"  } , false  } ),&lt;br /&gt;    &lt;br /&gt;    // Value in the array if ignore case - variant&lt;br /&gt;    TestMethod(true ,  new  object [] { "A" ,  new  string [] { "a" , "B"  , "C"  } , true   } ),&lt;br /&gt;    TestMethod(false , new  object [] { "A" ,  new  string [] { "a" , "B"  , "C"  } , false  } ),&lt;br /&gt;    &lt;br /&gt;    // Value not in a empty array  ignore case or not&lt;br /&gt;    TestMethod(false , new  object [] { "A" ,  new  string [] {                } , false  } ),&lt;br /&gt;    TestMethod(false , new  object [] { "A" ,  new  string [] {                } , true   } ),&lt;br /&gt;    &lt;br /&gt;    // Null value not in the array ignore case or not&lt;br /&gt;    TestMethod(false , new  object [] { null , new  string [] { "a" , "B"  , "C"  } , true   } ),&lt;br /&gt;    TestMethod(false , new  object [] { null , new  string [] { "a" , "B"  , "C"  } , false  } ),&lt;br /&gt;    &lt;br /&gt;    // Null value in the array case ignore case or not&lt;br /&gt;    TestMethod(true ,  new  object [] { null , new  string [] { "a" , "B"  , null } , true   } ),&lt;br /&gt;    TestMethod(true ,  new  object [] { null , new  string [] { "a" , "B"  , null } , false  } ),&lt;br /&gt;    &lt;br /&gt;    // We do not pass an array, we pass null ignore case or not&lt;br /&gt;    TestMethod(EX.EXCEPTION, typeof (System.NullReferenceException ),  new  object [] { "A" ,  null  , true    } ),&lt;br /&gt;    TestMethod(EX.EXCEPTION, typeof (System.NullReferenceException ),  new  object [] { "A" ,  null  , false   } ),&lt;br /&gt;]&lt;br /&gt;public  static  bool  IsInArray(string  value, string [] values, bool  ignoreCase) {&lt;br /&gt;    &lt;br /&gt;    if  ( (ignoreCase) &amp;&amp; (value!=null ) ) value = value.ToLower();&lt;br /&gt;    &lt;br /&gt;    foreach  (string  ss in  values) {&lt;br /&gt;    &lt;br /&gt;        string  s = ss;&lt;br /&gt;        &lt;br /&gt;        if  ( (ignoreCase) &amp;&amp; (s!=null ) ) s = s.ToLower();&lt;br /&gt;        &lt;br /&gt;        if  (s == value) {&lt;br /&gt;        &lt;br /&gt;            return  true ;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    return  false ;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;HiShort()&lt;br /&gt;&lt;/h2&gt;&lt;hr&gt;&lt;pre class="brush: csharp;"&gt;[&lt;br /&gt;    TestMethod(  0,     0),&lt;br /&gt;    TestMethod(  0,     1),&lt;br /&gt;    TestMethod(  0,     2),&lt;br /&gt;    TestMethod(  0,     4),&lt;br /&gt;    TestMethod(  0,     8),&lt;br /&gt;    TestMethod(  0,    16),&lt;br /&gt;    TestMethod(  0,    32),&lt;br /&gt;    TestMethod(  0,    64),&lt;br /&gt;    TestMethod(  0,   128),&lt;br /&gt;    TestMethod(  1,   256),&lt;br /&gt;    TestMethod(  2,   512),&lt;br /&gt;    TestMethod(  4,  1024),&lt;br /&gt;    TestMethod(  8,  2048),&lt;br /&gt;    TestMethod( 16,  4096),&lt;br /&gt;    TestMethod( 32,  8192),&lt;br /&gt;    TestMethod( 64, 16384),&lt;br /&gt;    TestMethod(127, 32767)&lt;br /&gt;]&lt;br /&gt;public  static  int  HiShort(short  number) {&lt;br /&gt;&lt;br /&gt;    return  (number &gt;&gt; 8) &amp; 0xff;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;Fibonacci()&lt;br /&gt;&lt;/h2&gt;&lt;hr&gt;&lt;pre class="brush: csharp;"&gt;[&lt;br /&gt;    TestMethod(      0 ,  0 ),&lt;br /&gt;    TestMethod(      1 ,  1 ),&lt;br /&gt;    TestMethod(      1 ,  2 ),            &lt;br /&gt;    TestMethod(      2 ,  3 ),&lt;br /&gt;    TestMethod(      3 ,  4 ),&lt;br /&gt;    TestMethod(      5 ,  5 ),&lt;br /&gt;    TestMethod(     55 , 10 ),&lt;br /&gt;    TestMethod(    610 , 15 ),&lt;br /&gt;    TestMethod(   6765 , 20 ),&lt;br /&gt;    TestMethod( 832040 , 30 )&lt;br /&gt;]&lt;br /&gt;public  static  int  Fibonacci(int  n){&lt;br /&gt;    switch (n){&lt;br /&gt;        case  0 : return  0;&lt;br /&gt;        case  1 : return  1;&lt;br /&gt;        default  : return  Fibonacci(n-1) + Fibonacci(n-2);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-731477020319860328?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/731477020319860328/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/01/what-is-quickunitnet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/731477020319860328'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/731477020319860328'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/01/what-is-quickunitnet.html' title='What is QuickUnit.net ?'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-4747903832005282410</id><published>2011-01-26T22:51:00.011-05:00</published><updated>2011-11-11T17:31:40.814-05:00</updated><title type='text'>fLogViewer.net</title><content type='html'>&lt;h1&gt;Overview&lt;/h1&gt;&lt;hr /&gt;fLogViewer.net is a free Windows program which allows one to view large log text files with color coding and filtering. fLogViewer.net is the replacement of fLogViewer.com. &lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_qdDSPqcuZ3Y/TUDrcxK86pI/AAAAAAAAAQA/uLO7FQ21img/s1600/Main.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="264" src="http://3.bp.blogspot.com/_qdDSPqcuZ3Y/TUDrcxK86pI/AAAAAAAAAQA/uLO7FQ21img/s640/Main.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;center&gt;&lt;b&gt;&lt;a href="http://www.frederictorres.net/flogviewer.net/exe/release/fLogViewer.net.exe.zip"&gt;Download fLogViewer.net v 1.37&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href="mailto:FredericALTorres@gmail.com?subject=fLogViewer.net"&gt;FredericALTorres@gmail.com&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href="http://www.youtube.com/watch?v=cg--1xFWjg8" target="top"&gt;Screencast&lt;/a&gt;&lt;/b&gt;&lt;/center&gt;&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;Features&lt;/h1&gt;&lt;hr /&gt;&lt;ul&gt;&lt;li&gt;Dynamically updates the display when the file changes. (Support IIS log file)&lt;/li&gt;&lt;li&gt;Support large files up to 4GB while not using too much memory. Load a 1 Gb text file with 15.6 millions lines using about 172 Mb of memory.&lt;/li&gt;&lt;li&gt;Support color coding based on keywords or regular expressions.&lt;/li&gt;&lt;li&gt;Support filtering based on keywords, regular expressions or IronPython plug-ins.&lt;/li&gt;&lt;li&gt;Support searching based on keywords or regular expressions.&lt;/li&gt;&lt;li&gt;Export in HTML format using the user defined colors.&lt;/li&gt;&lt;li&gt;Automatically archive and zip file.&lt;/li&gt;&lt;li&gt;Drag and drop text and zip files (automatically unzip the zip file content).&lt;/li&gt;&lt;li&gt;Special plug-in to visualize CSV, TAB separated and W3C Extended Log File (IIS log file).&lt;/li&gt;&lt;li&gt;Write your own plug-in to process the selected text in C#, VB.NET or IronPython.&lt;/li&gt;&lt;li&gt;Write your own plug-in to view the selected line in C#, VB.NET or IronPython.&lt;/li&gt;&lt;li&gt;View and monitor the local event viewer logs.&lt;/li&gt;&lt;li&gt;View remote file via http.&lt;/li&gt;&lt;li&gt;Support of Unicode and Windows code pages.&lt;/li&gt;&lt;li&gt;Require .NET 2.0 and no install. Download and run fLogViewer.net.exe&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;br /&gt;&lt;h1&gt;ScreenShots&lt;/h1&gt;&lt;hr /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_qdDSPqcuZ3Y/TUDrbbbWedI/AAAAAAAAAP0/bONnd7ADDHU/s1600/ColorEditor.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="403" src="http://2.bp.blogspot.com/_qdDSPqcuZ3Y/TUDrbbbWedI/AAAAAAAAAP0/bONnd7ADDHU/s640/ColorEditor.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_qdDSPqcuZ3Y/TUDrcJMqcdI/AAAAAAAAAP8/Y2Q1OBRqJHE/s1600/Filters.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="354" src="http://4.bp.blogspot.com/_qdDSPqcuZ3Y/TUDrcJMqcdI/AAAAAAAAAP8/Y2Q1OBRqJHE/s640/Filters.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_qdDSPqcuZ3Y/TUDrduJ2g7I/AAAAAAAAAQM/0xEeqhkutgE/s1600/Options.General.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="536" src="http://3.bp.blogspot.com/_qdDSPqcuZ3Y/TUDrduJ2g7I/AAAAAAAAAQM/0xEeqhkutgE/s640/Options.General.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_qdDSPqcuZ3Y/TUDrd7r831I/AAAAAAAAAQQ/hcPOlkCwfkk/s1600/Options.PlugIns.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="536" src="http://2.bp.blogspot.com/_qdDSPqcuZ3Y/TUDrd7r831I/AAAAAAAAAQQ/hcPOlkCwfkk/s640/Options.PlugIns.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_qdDSPqcuZ3Y/TUDrdTsiPZI/AAAAAAAAAQI/xQbaBss_Pgw/s1600/Options.DisplaySettings.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="536" src="http://4.bp.blogspot.com/_qdDSPqcuZ3Y/TUDrdTsiPZI/AAAAAAAAAQI/xQbaBss_Pgw/s640/Options.DisplaySettings.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TUDrdNA9vVI/AAAAAAAAAQE/898ulpLq6eU/s1600/Options.Archive.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="536" src="http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TUDrdNA9vVI/AAAAAAAAAQE/898ulpLq6eU/s640/Options.Archive.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; font-size: 16px;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;h1&gt;Data Processing Plug-In&lt;/h1&gt;&lt;hr /&gt;Plug in written in IronPython, can be defined to process the selected rows of the file. Save the .py file in the folder %APPDATA%\fLogViewer.Net\PlugIns and start fLogViewer.net.&lt;br /&gt;&lt;pre class="brush: python;"&gt;import  sys&lt;br /&gt; import  clr&lt;br /&gt; import  System&lt;br /&gt;&lt;br /&gt; class  PlugIn:&lt;br /&gt;&lt;br /&gt;      def  __init__( self):&lt;br /&gt;         self. PlugInType     =  "OnSelection"&lt;br /&gt;         self. Text           =  "&amp;amp;Export As HTML (IronPython)"&lt;br /&gt;         self. UserMessage    =  "Exporting As HTML"&lt;br /&gt;         self. Extensions     =  ""&lt;br /&gt;&lt;br /&gt;      def  Open( self,  fileName,  backGroundColor,  textGroundColor,  font):&lt;br /&gt;         self. FileName =  "%s\\ExportedAsHTML.html"  %  ( System. Environment. GetEnvironmentVariable("TEMP"),  )&lt;br /&gt;         self. handler  =  open( self. FileName,  "w")&lt;br /&gt;         self. handler. write("&amp;lt;HTML&amp;gt;&amp;lt;TABLE''''&amp;gt;\\n"  %  ( backGroundColor,  ))&lt;br /&gt;         return  True&lt;br /&gt;&lt;br /&gt;      def  Close( self):&lt;br /&gt;         self. handler. write("&amp;lt;/TABLE&amp;gt;&amp;lt;/HTML&amp;gt;\\n")&lt;br /&gt;         self. handler. close()&lt;br /&gt;         return  self. FileName&lt;br /&gt;&lt;br /&gt;      def  Execute( self,  line,  textGroundColor):&lt;br /&gt;         line =  line. replace("&amp;amp;mp;",  "&amp;amp;")&lt;br /&gt;         line =  line. replace("&amp;amp;gt;",  "&amp;gt;")&lt;br /&gt;         line =  line. replace("&amp;amp;lt;",  "&amp;lt;")&lt;br /&gt;&lt;br /&gt;         self. handler. write("&amp;lt;TR&amp;gt;&amp;lt;TD nowrap&amp;gt;&amp;lt;FONT'Courier''&amp;gt;"  %  ( textGroundColor,  ))&lt;br /&gt;         self. handler. write("\\n")&lt;br /&gt;         self. handler. write( line)&lt;br /&gt;         self. handler. write("\\n")&lt;br /&gt;         self. handler. write("&amp;lt;/FONT&amp;gt;&amp;lt;/TD&amp;gt;&amp;lt;/TR&amp;gt;")&lt;br /&gt;         self. handler. write("\\n")&lt;br /&gt;         return  True&lt;br /&gt; &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h1&gt;Filter Plug-In&lt;/h1&gt;&lt;hr /&gt;Filter can be written as an IronPython Plug in.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: python;"&gt;import  sys&lt;br /&gt; import  clr&lt;br /&gt; import  System&lt;br /&gt; &lt;br /&gt; class  PlugIn: &lt;br /&gt; &lt;br /&gt;      def  __init__( self): &lt;br /&gt;         self. PlugInType     =  "Filter" &lt;br /&gt;         self. Text           =  "Error Filter Plug In" &lt;br /&gt;         self. UserMessage    =  "" &lt;br /&gt;         self. Extensions     =  "" &lt;br /&gt;         &lt;br /&gt;      def  Open( self): &lt;br /&gt;         return  True&lt;br /&gt;         &lt;br /&gt;      def  Close( self): &lt;br /&gt;         return  True&lt;br /&gt;         &lt;br /&gt;      def  Execute( self,  line): &lt;br /&gt;         return  line. find("[ERROR]")  !=  - 1&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h1&gt;What people said about fLogViewer&lt;/h1&gt;&lt;hr /&gt;&lt;br /&gt;fLogViewer was part of the Scott Hanselman's 2005 and 2006 Ultimate Developer and Power Users Tool List. Scott's comment:&lt;i&gt;Great freeware highlighting log viewer for large log files.&lt;/i&gt; &lt;a href="http://www.hanselman.com/blog/ScottHanselmans2006UltimateDeveloperAndPowerUsersToolListForWindows.aspx" target="TOP"&gt;2006&lt;/a&gt; &lt;a href="http://www.hanselman.com/blog/ScottHanselmans2005UltimateDeveloperAndPowerUsersToolList.aspx" target="TOP"&gt;2005&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;hr /&gt;...But those of us stuck on Windows would usually prefer some sort of GUI tool.&lt;br /&gt;fLogViewew fits into this niche nicely. It's a MDI program wirtten in VB6, but seems to be plenty fast.&lt;br /&gt;&lt;br /&gt;Features include color-coding (done by looking for keywords in the lines of the log), the smarts to monitor log files and refresh them on the fly (even with IIS's caching scheme), and a variety of filtering and export options...&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.mcpmag.com/newsletter/article.asp?EditorialsID=157" target="TOP"&gt;Mike Gunderloy's NewsLettter.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;hr /&gt;Thanks for developing flogviewer, it is a great help for me. If it wouldn´t be freeware I even would pay for it. ;-)&lt;br /&gt;&lt;a href="http://www.blogger.com/" target="TOP"&gt;Jens. M.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;hr /&gt;LogViewer - Great freeware highlighting log viewer for large log files.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://mostlylucid.net/archive/0001/01/01/possibly-the-ultimate-developer-tools-list.aspx" target="TOP"&gt;Scott Galloway's Possibly the ultimate developer tools list.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;hr /&gt;Je m'étais débrouillé avec fLogViewer (freeware:http://www.flogviewer.com). Bon, il faut définir soi-même les filtres mais c'est un outil très puissant... &lt;a href="http://www.gotoandplay.ca/archives/2004/04/29/trace-dans-un-fichier-text-suite.html" target="TOP"&gt;Unknown&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;hr /&gt;Hej! Jeg kan stærkt anbefale dette freeware program til at læse diverse logfiler med.&lt;br /&gt;&lt;br /&gt;Det kan bla. opdatere logfilerne dynamisk mens de er åbne, hvilket er super til f.eks. troubleshooting osv. :)&lt;br /&gt;... Hent programmet fLogViewer her: http://www.flogviewer.com&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.it-experts.dk/forum/topic.asp?TOPIC_ID=37" target="TOP"&gt;Peter Schmidt&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Since we do not speak Danish at fLogViewer.com, we hope this comment is good.&lt;br /&gt;&lt;br /&gt;&lt;hr /&gt;I've posted about baretail previously as a tail program for Windows, but now I see there is a similar tool with some more functionality to it. fLogViewer picks up and runs with the "Windows way" by taking a simple tool and putting more and more features onto it (note: Yes, I am fairly sarcastic there, but the features are appreciated nonetheless!). I kinda like this tool, although the necessity of an install and the way it uses some older system files than what I have on my XP system anyway are detractors to replacing baretail with fLogViewer.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.terminal23.net/2007/05/flogviewer.html"&gt;Michael L. Dickey&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;hr /&gt;I had been searching for a free logfile viewer supporting filtering and coloring for a while.&lt;br /&gt;I finally found flogviewer: free, support regexp based filtering, and regexp line coloring. All I need to dive into those 80mb logfiles.&lt;br /&gt;Although not perfect (I find it a bit slow for logfile of 80mb), it does the job really well.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.dotnetguru2.org/tbarrere/index.php?p=335&amp;amp;more=1&amp;amp;c=1&amp;amp;tb=1&amp;amp;pb=1"&gt;Thibault Barrere&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;hr /&gt;We are developing a consumer device with an embedded ARM microcontroller.&lt;br /&gt;Our prototype system has a very simple ASCII serial trace output. In order to confirm reliability of the product, it must be run for long periods and trace logs taken for subsequent analysis. I have found that flogviewer is ideal not only for this, but also for real time analysis of the trace output. From experience, most terminal emulators have problems with large log files, in particular if one attempts to look at the trace history. However, by viewing the trace log file with flogviewer, the problems are significantly reduced.&lt;br /&gt;Furthermore, filters can be used to look at particular traces in real time.&lt;br /&gt;All in all flogviewer is an excellent tool for our purposes.&lt;br /&gt;Hope that´s OK and many thanks for a great tool.&lt;br /&gt;Cheers.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Lisa Kingscott.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;hr /&gt;A Tail with more power in its tip than the original has in 'full length'. Powerful filter options, together with extensive highlighting options and scripting support will make sure you will spot just those lines in your logs that matter to you. Even if the structure of your logfiles varies.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Ruud, NL&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;hr /&gt;I stumbled over flogviewer a few years ago on a post by Scott Hanselman.&lt;br /&gt;I was looking for a freeware logviewer which would give me the possibility to&lt;br /&gt;adapt it's color-highlighting to my differing needs.&lt;br /&gt;Flogviewer is an awesome piece of software which helped me a lot in my daily routines and&lt;br /&gt;in tracking down probs on my servers.&lt;br /&gt;&lt;br /&gt;Great job Fred. Thanks a lot for your great work.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Ralf R, Germany.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;License&lt;/h1&gt;&lt;hr /&gt;&lt;hr size="2" /&gt;&lt;pre&gt;You must read the following license agreement before installing fLogViewer. By doing so, you indicate your acceptance of what is written here.&lt;br /&gt;&lt;br /&gt;fLogViewer.net (the SOFTWARE) is provided "as is" without warranty of any kind, including, but not limited to, implied warranties of merchantability or fitness for a particular purpose. &lt;br /&gt;&lt;br /&gt;In no event shall the author be liable for any damages to hardware or loss of data whatsoever arising out the use of (or inability to use) the SOFTWARE even if advised of the possibility.&lt;br /&gt;&lt;br /&gt;fLogViewer.net is free.&lt;br /&gt;&lt;br /&gt;Installing and using fLogViewer signifies acceptance of these terms and conditions of the license. If you do not agree with the terms of this license you must remove fLogViewer files from your storage devices and cease to use the product.&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-4747903832005282410?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/4747903832005282410/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/01/flogviewernet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/4747903832005282410'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/4747903832005282410'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/01/flogviewernet.html' title='fLogViewer.net'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_qdDSPqcuZ3Y/TUDrcxK86pI/AAAAAAAAAQA/uLO7FQ21img/s72-c/Main.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-735238663735715247</id><published>2011-01-19T22:14:00.000-05:00</published><updated>2011-01-20T23:47:51.943-05:00</updated><title type='text'>Roy Osherove's String Calculator Kata  - My third try with video</title><content type='html'>My third take at the Roy Osherove's &lt;a href="http://www.osherove.com/tdd-kata-1/"&gt;String Calculator Kata&lt;/a&gt;. The video is on youtube &lt;a href="http://www.youtube.com/watch?v=TgLfdsjJREI"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;The class.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;/// &lt;summary&gt;&lt;br /&gt;/// http://www.osherove.com/tdd-kata-1/&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;class Calculator {&lt;br /&gt;&lt;br /&gt;    public static int Add(string numbers) {&lt;br /&gt;        &lt;br /&gt;        if(numbers=="") return 0;&lt;br /&gt;&lt;br /&gt;        var delimiters = new string[1] { "," };&lt;br /&gt;        delimiters     = DetermineDelimiters(ref numbers);&lt;br /&gt;        numbers        = numbers.Replace("\n",delimiters[0]);&lt;br /&gt;        var values     = Split(numbers, delimiters);&lt;br /&gt;&lt;br /&gt;        return SumValues(values);        &lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    private static int SumValues(string[] values) {&lt;br /&gt;        var sum = 0;&lt;br /&gt;        foreach (var v in values) {&lt;br /&gt;&lt;br /&gt;            if (String.IsNullOrEmpty(v.Trim())) throw new ArgumentException();&lt;br /&gt;            var num = int.Parse(v);&lt;br /&gt;            if (num &gt;= 1000) num = 0;&lt;br /&gt;            if (num &lt; 0) throw new ArgumentException();&lt;br /&gt;            sum += num;&lt;br /&gt;        }&lt;br /&gt;        return sum;&lt;br /&gt;    }&lt;br /&gt;    private static string [] DetermineDelimiters(ref string numbers) {&lt;br /&gt;&lt;br /&gt;        var delimiters = new string[1] { "," };&lt;br /&gt;&lt;br /&gt;        if (numbers.StartsWith("//[")) {&lt;br /&gt;&lt;br /&gt;            int posLF  = numbers.IndexOf("\n");&lt;br /&gt;            delimiters = numbers.Substring(3, posLF - 4).Replace("]", "").Split('[');&lt;br /&gt;            numbers    = numbers.Substring(posLF + 1);&lt;br /&gt;        }&lt;br /&gt;        else if (numbers.StartsWith("//")) {&lt;br /&gt;&lt;br /&gt;            delimiters[0] = numbers[2].ToString();&lt;br /&gt;            numbers       = numbers.Substring(4);&lt;br /&gt;        }&lt;br /&gt;        return delimiters;&lt;br /&gt;    }&lt;br /&gt;    // 2 functions to split based on a string&lt;br /&gt;    // or a string array&lt;br /&gt;    static string[] Split(string value, &lt;br /&gt;                          string [] splitingWords) {&lt;br /&gt; &lt;br /&gt;        return value.Split(splitingWords, StringSplitOptions.None);&lt;br /&gt;    }&lt;br /&gt;    static string [] Split(string value, &lt;br /&gt;                           string splitingWord){&lt;br /&gt; &lt;br /&gt;        return value.Split(new string[] { splitingWord }, StringSplitOptions.None);&lt;br /&gt;    }    &lt;br /&gt;    &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-735238663735715247?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/735238663735715247/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/01/roy-osheroves-string-calculator-kata-my_19.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/735238663735715247'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/735238663735715247'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/01/roy-osheroves-string-calculator-kata-my_19.html' title='Roy Osherove&apos;s String Calculator Kata  - My third try with video'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-7987665638563608318</id><published>2011-01-15T01:57:00.000-05:00</published><updated>2011-01-15T02:08:09.378-05:00</updated><title type='text'>Pythonistas, rubyists, I thought they were friends!</title><content type='html'>Interresting reflection about Ruby.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://blog.peepcode.com/tutorials/2010/what-pythonistas-think-of-ruby"&gt;What pythonistas think of ruby ?&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The RubyShow PodCast - &lt;a href="http://5by5.tv/rubyshow/133"&gt;Python Edition&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-7987665638563608318?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/7987665638563608318/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/01/pythonistas-rubyist-i-thought-they-were.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/7987665638563608318'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/7987665638563608318'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/01/pythonistas-rubyist-i-thought-they-were.html' title='Pythonistas, rubyists, I thought they were friends!'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-1611122967689888710</id><published>2011-01-12T23:42:00.000-05:00</published><updated>2011-01-12T23:42:36.169-05:00</updated><title type='text'>Reading an Rss feed with argotic</title><content type='html'>Findind an example on how to read a rss feed and access the encoded content was a pain.&lt;br /&gt;Looks like the web is all about writing feed but not about reading one.&lt;br /&gt;&lt;br /&gt;So here it is.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;&lt;br /&gt;private void button1_Click(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;    string url  = @"http://feeds.feedburner.com/cenedella?format=xml";&lt;br /&gt;    SyndicationResourceLoadSettings settings = new SyndicationResourceLoadSettings();                       &lt;br /&gt;            &lt;br /&gt;    RssFeed feed = RssFeed.Create(new Uri(url), settings);&lt;br /&gt;                        &lt;br /&gt;    foreach(var i in feed.Channel.Items) {&lt;br /&gt;&lt;br /&gt;        var title   = i.Title;&lt;br /&gt;        var date    = i.PublicationDate;&lt;br /&gt;        var content = GetBlogPostContent(i, true);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;private string GetBlogPostContent(RssItem i, bool removeHtml){&lt;br /&gt;&lt;br /&gt;    string content = null;&lt;br /&gt;                &lt;br /&gt;    foreach(ISyndicationExtension s in i.Extensions) {&lt;br /&gt;&lt;br /&gt;        if(s is SiteSummaryContentSyndicationExtension){&lt;br /&gt;&lt;br /&gt;            SiteSummaryContentSyndicationExtension ss = s as SiteSummaryContentSyndicationExtension;                    &lt;br /&gt;            var t                                     = ss.Context.Encoded;&lt;br /&gt;            content                                   = System.Web.HttpUtility.HtmlDecode(t);&lt;br /&gt;            if(removeHtml)&lt;br /&gt;                content = Regex.Replace(content, "&lt;[^&gt;]*&gt;", "", RegexOptions.Compiled);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    return content;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-1611122967689888710?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/1611122967689888710/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/01/reading-rss-feed-with-argotic.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/1611122967689888710'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/1611122967689888710'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/01/reading-rss-feed-with-argotic.html' title='Reading an Rss feed with argotic'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-5742229660026817669</id><published>2011-01-08T22:48:00.000-05:00</published><updated>2011-01-08T22:48:48.887-05:00</updated><title type='text'>Roy Osherove's String Calculator Kata  - My first version</title><content type='html'>I recently heard about programming kata. So I tried Roy Osherove's &lt;a href="http://www.osherove.com/tdd-kata-1/"&gt;String Calculator Kata&lt;/a&gt; .&lt;br /&gt;&lt;br /&gt;This was my first time and will try it probably more because I like to make it into a video.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;The class.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// http://www.osherove.com/tdd-kata-1/&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;class Calculator {&lt;br /&gt;&lt;br /&gt;    private static string[] Split(string value, string [] splitingWords) {&lt;br /&gt;&lt;br /&gt;        return value.Split(splitingWords, StringSplitOptions.None);&lt;br /&gt;    }&lt;br /&gt;    private static string [] Split(string value, string splitingWord){&lt;br /&gt;&lt;br /&gt;        return value.Split(new string[] { splitingWord }, StringSplitOptions.None);&lt;br /&gt;    }&lt;br /&gt;    private static bool IsNumber(string n) {&lt;br /&gt;        int a = 0;&lt;br /&gt;        return int.TryParse(n, out a);&lt;br /&gt;    }        &lt;br /&gt;    public static int Add(string numbers) {&lt;br /&gt;&lt;br /&gt;        string delimiter    = ",";&lt;br /&gt;        string[] delimiters = null;&lt;br /&gt;&lt;br /&gt;        if (numbers.StartsWith("//[")) {&lt;br /&gt;                                &lt;br /&gt;            var newLinePos  = numbers.IndexOf("\n");&lt;br /&gt;            delimiters      = numbers.Substring(3, newLinePos - 4).Replace("[", "").Split(']');&lt;br /&gt;            numbers         = numbers.Substring(newLinePos + 1);&lt;br /&gt;        }&lt;br /&gt;        else if (numbers.StartsWith("//")) {&lt;br /&gt;&lt;br /&gt;            var newLinePos = numbers.IndexOf("\n");&lt;br /&gt;            if (newLinePos == -1) throw new System.FormatException(String.Format("Invalid custom delimiters in expression '{0}'", numbers));&lt;br /&gt;            delimiter = numbers[newLinePos - 1].ToString();&lt;br /&gt;            numbers   = numbers.Substring(newLinePos + 1);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        numbers = numbers.Replace("\n", delimiter);&lt;br /&gt;&lt;br /&gt;        if (numbers.Contains(delimiter + delimiter))&lt;br /&gt;            throw new System.FormatException(String.Format("Invalid expression '{0}'", numbers));&lt;br /&gt;&lt;br /&gt;        string[] values;&lt;br /&gt;&lt;br /&gt;        if (delimiters != null) {&lt;br /&gt;            values = Split(numbers, delimiters);&lt;br /&gt;        }&lt;br /&gt;        else if (delimiter.Length &gt; 1) {&lt;br /&gt;            values = Split(numbers, delimiter);&lt;br /&gt;        }&lt;br /&gt;        else {&lt;br /&gt;            values = numbers.Split(delimiter[0]);&lt;br /&gt;        }&lt;br /&gt;        int sum    = 0;&lt;br /&gt;        var negativeNumbers = "";&lt;br /&gt;&lt;br /&gt;        foreach (var i in values) {&lt;br /&gt;&lt;br /&gt;            if ((i != "") &amp;&amp; (int.Parse(i) &lt; 0)) {&lt;br /&gt;                negativeNumbers += i + ",";&lt;br /&gt;            }&lt;br /&gt;            if ((i != "") &amp;&amp; (int.Parse(i) &gt;= 1000)) { &lt;br /&gt;            }&lt;br /&gt;            else {&lt;br /&gt;                sum += int.Parse(i == "" ? "0" : i);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;        if(!String.IsNullOrEmpty(negativeNumbers))&lt;br /&gt;            throw new System.ArgumentException(String.Format("negatives not allowed '{0}'", negativeNumbers));&lt;br /&gt;&lt;br /&gt;        return sum;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;The unit tests.&lt;/b&gt;&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;&lt;br /&gt;[TestClass] &lt;br /&gt;public class CalculatorUnitTests {&lt;br /&gt;        &lt;br /&gt;    [TestMethod] public void Add_EmptyString() {&lt;br /&gt;&lt;br /&gt;        Assert.AreEqual(0, Calculator.Add(""));&lt;br /&gt;    }&lt;br /&gt;    [TestMethod] public void Add_1() {&lt;br /&gt;&lt;br /&gt;        Assert.AreEqual(1, Calculator.Add("1"));&lt;br /&gt;    }&lt;br /&gt;    [TestMethod]&lt;br /&gt;    public void Add_1Coma2() {&lt;br /&gt;&lt;br /&gt;        Assert.AreEqual(3, Calculator.Add("1,2"));&lt;br /&gt;    }&lt;br /&gt;    [TestMethod]&lt;br /&gt;    public void Add_1Coma2Coma3() {&lt;br /&gt;&lt;br /&gt;        Assert.AreEqual(6, Calculator.Add("1,2,3"));&lt;br /&gt;    }&lt;br /&gt;    [TestMethod]&lt;br /&gt;    public void Add_1Coma2Coma3Coma4() {&lt;br /&gt;&lt;br /&gt;        Assert.AreEqual(10, Calculator.Add("1,2,3,4"));&lt;br /&gt;    }&lt;br /&gt;    [TestMethod]&lt;br /&gt;    public void Add_1NewLine2Coma3() {&lt;br /&gt;&lt;br /&gt;        Assert.AreEqual(6, Calculator.Add("1\n2,3"));&lt;br /&gt;    }&lt;br /&gt;    [TestMethod, ExpectedException(typeof(System.FormatException))]&lt;br /&gt;    public void Add_InvalidFormatMissingParameter() {&lt;br /&gt;&lt;br /&gt;        Calculator.Add("1,\n");&lt;br /&gt;    }       &lt;br /&gt;    [TestMethod] public void Add_CustomDelimiter() {&lt;br /&gt;&lt;br /&gt;        Assert.AreEqual(3, Calculator.Add("//;\n1;2"));&lt;br /&gt;    }&lt;br /&gt;    [TestMethod, ExpectedException(typeof(System.ArgumentException))]&lt;br /&gt;    public void Add_OneNegativeNumber() {&lt;br /&gt;&lt;br /&gt;        Assert.AreEqual(3, Calculator.Add("-1"));&lt;br /&gt;    }&lt;br /&gt;    [TestMethod, ExpectedException(typeof(System.ArgumentException))]&lt;br /&gt;    public void Add_OnePositiveOneNegativeNumber() {&lt;br /&gt;&lt;br /&gt;        Assert.AreEqual(3, Calculator.Add("1,-1"));&lt;br /&gt;    }&lt;br /&gt;    [TestMethod]&lt;br /&gt;    public void Add_NumberGreaterThan1000() {&lt;br /&gt;&lt;br /&gt;        Assert.AreEqual(2, Calculator.Add("2,1000"));&lt;br /&gt;    }&lt;br /&gt;    [TestMethod]&lt;br /&gt;    public void Add_CustomStringDelimiter() {&lt;br /&gt;&lt;br /&gt;        Assert.AreEqual(6, Calculator.Add("//[***]\n1***2***3"));&lt;br /&gt;    }&lt;br /&gt;    [TestMethod]&lt;br /&gt;    public void Add_MultipleCustomStringDelimiter() {&lt;br /&gt;&lt;br /&gt;        Assert.AreEqual(6, Calculator.Add("//[*][%]\n1*2%3"));&lt;br /&gt;    }&lt;br /&gt;    [TestMethod]&lt;br /&gt;    public void Add_MultipleCustomStringDelimiterOfSizeGreaterThan1() {&lt;br /&gt;&lt;br /&gt;        Assert.AreEqual(6, Calculator.Add("//[***][%%%]\n1***2%%%3"));&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public CalculatorUnitTests() { } private TestContext testContextInstance; public TestContext TestContext { get { return testContextInstance; } set { testContextInstance = value; } }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-5742229660026817669?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/5742229660026817669/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/01/roy-osheroves-string-calculator-kata-my.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/5742229660026817669'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/5742229660026817669'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/01/roy-osheroves-string-calculator-kata-my.html' title='Roy Osherove&apos;s String Calculator Kata  - My first version'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-3756437583637132324</id><published>2011-01-08T22:39:00.000-05:00</published><updated>2011-01-08T22:39:42.412-05:00</updated><title type='text'>Different way to loop through a list of number in C#</title><content type='html'>As I work more and more in a TDD or almost TDD way, I strive to write more concise and clear unit tests. For what ever reason i find the first way to loop clearer to read and faster to type.&lt;br /&gt;&lt;pre class="brush: csharp;"&gt; foreach(var i in Range(16)) {&lt;br /&gt; &lt;br /&gt;     l.Measures.Current.Tracks[0].Steps[i].Set(100);&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; for(int i=0; i&lt;16; i++) {&lt;br /&gt; &lt;br /&gt;     l.Measures.Current.Tracks[0].Steps[i].Set(100);&lt;br /&gt; }&lt;br /&gt;    &lt;br /&gt; Here is how to loop with an increment of 2.&lt;br /&gt;&lt;br /&gt; foreach (var i in Range(16, 2)){&lt;br /&gt; &lt;br /&gt;     l.Measures.Current.Tracks[0].Steps[i].Set(100);&lt;br /&gt; }&lt;br /&gt;&lt;/pre&gt;Here is the function Range (v 1) &lt;pre class="brush: csharp;"&gt;/// &lt;summary&gt;  &lt;br /&gt; /// Return a list of integer from 0 to max-1  &lt;br /&gt; /// &lt;/summary&gt;  &lt;br /&gt; /// &lt;param name="max"&gt;The maximum number of integer to return&lt;/param&gt; /// &lt;returns&gt;&lt;/returns&gt;  &lt;br /&gt; public  IEnumerable &lt;int&gt; Range(int  max)&lt;br /&gt; {&lt;br /&gt;     return  Range(max, 1);&lt;br /&gt; }&lt;br /&gt; /// &lt;summary&gt;  &lt;br /&gt; /// Return a list of integer from 0 to max-1 with an increment  &lt;br /&gt; /// &lt;/summary&gt;  &lt;br /&gt; /// &lt;param name="max"&gt;The maximum number of integer to return&lt;/param&gt; /// &lt;param name="increment"&gt;The increment&lt;/param&gt; /// &lt;returns&gt;&lt;/returns&gt;  &lt;br /&gt; public  IEnumerable &lt;int&gt; Range(int  max, int  increment)&lt;br /&gt; {&lt;br /&gt;     return  Range(0, max, increment);&lt;br /&gt; }&lt;br /&gt; /// &lt;summary&gt; &lt;br /&gt; /// Return a list of integer from start to max-1 with an increment  &lt;br /&gt; /// &lt;/summary&gt; &lt;br /&gt; /// &lt;param name="start"&gt;The start value&lt;/param&gt; /// &lt;param name="max"&gt;The max value&lt;/param&gt; /// &lt;param name="increment"&gt;the increment&lt;/param&gt; /// &lt;returns&gt;&lt;/returns&gt; &lt;br /&gt; public  IEnumerable &lt;int&gt; Range(int  start, int  max, int  increment)&lt;br /&gt; {&lt;br /&gt;     int  i = start;&lt;br /&gt;     while  (i &lt; max)&lt;br /&gt;     {&lt;br /&gt;         yield  return  i;&lt;br /&gt;         i += increment;&lt;br /&gt;     }&lt;br /&gt; }&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-3756437583637132324?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/3756437583637132324/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/01/different-way-to-loop-through-list-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/3756437583637132324'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/3756437583637132324'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/01/different-way-to-loop-through-list-of.html' title='Different way to loop through a list of number in C#'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-8565319717440793196</id><published>2011-01-08T22:37:00.000-05:00</published><updated>2011-01-08T22:37:21.764-05:00</updated><title type='text'>PowerShell color coding for Visual Studio 2010</title><content type='html'>I updated my Visual Studio extension TextHighlighter and added support for PowerShell and Cmd files. .Cmd file edited in Visual Studio 2010 will have the same color coding as a .Bat file.&lt;br /&gt;In summary the TextHighlighter extension provides color coding in Visual Studio 2010 for:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;.Ini file&lt;/li&gt;&lt;li&gt;.Txt and .Log files based on customizable regular expressions &lt;br /&gt;&lt;ul&gt;&lt;li&gt;Ship with special rules to visualize MSBuild log file&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;.Bat and .Cmd files&lt;/li&gt;&lt;li&gt;.Ps1 file (PowerShell)     &lt;br /&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Multi line strings and commenst are not supported. I cannot figure out how to do this in the TokenTagger class method GetTag().&lt;/li&gt;&lt;li&gt;Help wanted&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_qdDSPqcuZ3Y/TSkrWsx-cSI/AAAAAAAAAPo/GKNouHnI8VI/s1600/vs_sh_3.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_qdDSPqcuZ3Y/TSkrWsx-cSI/AAAAAAAAAPo/GKNouHnI8VI/s1600/vs_sh_3.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_qdDSPqcuZ3Y/TSkrffysJLI/AAAAAAAAAPs/Kj92cvTt4_k/s1600/vs_sh_4.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_qdDSPqcuZ3Y/TSkrffysJLI/AAAAAAAAAPs/Kj92cvTt4_k/s1600/vs_sh_4.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_qdDSPqcuZ3Y/TSjX8iCSCsI/AAAAAAAAAPY/F35t8D9SMcE/s1600/vs_sh_1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/_qdDSPqcuZ3Y/TSjX8iCSCsI/AAAAAAAAAPY/F35t8D9SMcE/s1600/vs_sh_1.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_qdDSPqcuZ3Y/TSjZaITjXNI/AAAAAAAAAPg/i-9snfo3lZc/s1600/vs_sh_2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_qdDSPqcuZ3Y/TSjZaITjXNI/AAAAAAAAAPg/i-9snfo3lZc/s1600/vs_sh_2.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;To install the extension in Visual Studio, Click menu Tools -&amp;gt; Extension Manager. And enter the keyword&amp;nbsp;TextHighlighter in the search for the gallery.&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_qdDSPqcuZ3Y/TSktLboZznI/AAAAAAAAAPw/d9bwDbHpSGs/s1600/vs_sh_7.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="257" src="http://3.bp.blogspot.com/_qdDSPqcuZ3Y/TSktLboZznI/AAAAAAAAAPw/d9bwDbHpSGs/s400/vs_sh_7.jpg" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-8565319717440793196?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/8565319717440793196/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/01/powershell-color-coding-for-visual.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/8565319717440793196'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/8565319717440793196'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/01/powershell-color-coding-for-visual.html' title='PowerShell color coding for Visual Studio 2010'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_qdDSPqcuZ3Y/TSkrWsx-cSI/AAAAAAAAAPo/GKNouHnI8VI/s72-c/vs_sh_3.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-5263522179462788836</id><published>2011-01-08T22:25:00.001-05:00</published><updated>2011-01-08T22:25:56.788-05:00</updated><title type='text'>The PDDLA Programming Language - LIB.EAO file</title><content type='html'>&lt;pre&gt;&lt;code&gt;&lt;span style="font: 9pt Courier New;"&gt;&lt;span class="mygeneral1-comment"&gt;*******************************************************************************&lt;br /&gt;**&lt;br /&gt;**&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Procedure&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; UserPause&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;();&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;    touche &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;:=&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; LireTouche&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;();&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Fin&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-comment"&gt;*******************************************************************************&lt;br /&gt;**&lt;br /&gt;**&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Procedure&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; Screen.Clear&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;();&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;    Efface&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;(&lt;/span&gt;&lt;span class="mygeneral1-number"&gt;0&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;,&lt;/span&gt;&lt;span class="mygeneral1-number"&gt;0&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;,&lt;/span&gt;&lt;span class="mygeneral1-identifier"&gt;MaxX&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;,&lt;/span&gt;&lt;span class="mygeneral1-identifier"&gt;MaxY&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;,&lt;/span&gt;&lt;span class="mygeneral1-identifier"&gt;Noir&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Fin&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-comment"&gt;*******************************************************************************&lt;br /&gt;**&lt;br /&gt;**&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Procedure&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; Screen.PrintXY&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;(&lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Entier&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; x&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;,&lt;/span&gt;&lt;span class="mygeneral1-identifier"&gt;y &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Chaine&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; text&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;    TexteGraphique&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;(&lt;/span&gt;&lt;span class="mygeneral1-identifier"&gt;x&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;,&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; y&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;,&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; cyanClair&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;,&lt;/span&gt;&lt;span class="mygeneral1-identifier"&gt;text&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Fin&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-comment"&gt;*******************************************************************************&lt;br /&gt;**&lt;br /&gt;**&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Procedure&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; GlobalVariables.Initialize&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;();&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  &lt;/span&gt;&lt;span class="mygeneral1-comment"&gt;*&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  &lt;/span&gt;&lt;span class="mygeneral1-comment"&gt;* Toutes les variables declarees dans cette procedure sont globales par&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  &lt;/span&gt;&lt;span class="mygeneral1-comment"&gt;* rapport au niveau precedent seulement.&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  &lt;/span&gt;&lt;span class="mygeneral1-comment"&gt;*&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  DeclareVariableGlobale&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Entier&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; Noir           &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;:=&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-number"&gt;0&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Entier&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; Bleu           &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;:=&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-number"&gt;1&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Entier&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; Vert           &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;:=&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-number"&gt;2&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Entier&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; Cyan           &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;:=&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-number"&gt;3&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Entier&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; Rouge          &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;:=&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-number"&gt;4&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Entier&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; Magenta        &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;:=&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-number"&gt;5&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Entier&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; Marron         &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;:=&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-number"&gt;6&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Entier&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; GrisClair      &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;:=&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-number"&gt;7&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Entier&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; GrisFonce      &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;:=&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-number"&gt;8&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Entier&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; BleuClair      &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;:=&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-number"&gt;9&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Entier&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; VertClair      &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;:=&lt;/span&gt;&lt;span class="mygeneral1-number"&gt;10&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Entier&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; CyanClair      &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;:=&lt;/span&gt;&lt;span class="mygeneral1-number"&gt;11&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Entier&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; RougeClair     &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;:=&lt;/span&gt;&lt;span class="mygeneral1-number"&gt;12&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Entier&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; MagentaClair   &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;:=&lt;/span&gt;&lt;span class="mygeneral1-number"&gt;13&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Entier&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; Jaune          &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;:=&lt;/span&gt;&lt;span class="mygeneral1-number"&gt;14&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Entier&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; Blanc          &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;:=&lt;/span&gt;&lt;span class="mygeneral1-number"&gt;15&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Entier&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-keywords2"&gt;Vrai&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;           &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;:=&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-number"&gt;1&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Entier&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-keywords2"&gt;Faux&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;           &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;:=&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-number"&gt;0&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Entier&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; touche&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Entier&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; ToucheRCH      &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;:=&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-number"&gt;13&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Entier&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; ToucheBCK      &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;:=&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-number"&gt;8&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Entier&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; ToucheESC      &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;:=&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-number"&gt;27&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Entier&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; ToucheSPC      &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;:=&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-number"&gt;32&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Entier&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; MaxX           &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;:=&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-number"&gt;640&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;-&lt;/span&gt;&lt;span class="mygeneral1-number"&gt;1&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Entier&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; MaxY           &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;:=&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-number"&gt;480&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;-&lt;/span&gt;&lt;span class="mygeneral1-number"&gt;1&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Chaine&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; strGras&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;[&lt;/span&gt;&lt;span class="mygeneral1-number"&gt;2&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;]&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;     &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;:=&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-string"&gt;"&amp;amp;G"&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Chaine&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; strNormal&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;[&lt;/span&gt;&lt;span class="mygeneral1-number"&gt;2&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;]&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;   &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;:=&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-string"&gt;"&amp;amp;N"&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Chaine&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; strCentre&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;[&lt;/span&gt;&lt;span class="mygeneral1-number"&gt;2&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;]&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;   &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;:=&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-string"&gt;"&amp;amp;Z"&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Chaine&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; strOmbre&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;[&lt;/span&gt;&lt;span class="mygeneral1-number"&gt;2&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;]&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;    &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;:=&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-string"&gt;"&amp;amp;S"&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Chaine&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; strOmbre2&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;[&lt;/span&gt;&lt;span class="mygeneral1-number"&gt;3&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;]&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;   &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;:=&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-string"&gt;"&amp;amp;S~"&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Chaine&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; texte_bas_1  &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;[&lt;/span&gt;&lt;span class="mygeneral1-number"&gt;80&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;]&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Chaine&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; texte_bas_2  &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;[&lt;/span&gt;&lt;span class="mygeneral1-number"&gt;80&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;]&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Chaine&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; texte_bas_3  &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;[&lt;/span&gt;&lt;span class="mygeneral1-number"&gt;80&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;]&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;FIN&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-5263522179462788836?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/5263522179462788836/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/01/pddla-programming-language-libeao-file.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/5263522179462788836'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/5263522179462788836'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/01/pddla-programming-language-libeao-file.html' title='The PDDLA Programming Language - LIB.EAO file'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-68280113043528486</id><published>2011-01-08T22:23:00.000-05:00</published><updated>2011-01-08T22:24:59.376-05:00</updated><title type='text'>The PDDLA Programming Language</title><content type='html'>&lt;pre&gt;&lt;code&gt;&lt;span style="font: normal normal normal 9pt/normal 'Courier new';"&gt;&lt;span class="mygeneral1-comment"&gt;*******************************************************************************&lt;br /&gt;*&lt;br /&gt;* PRODIDACT Language Auteur - PDDLA&lt;br /&gt;*&lt;br /&gt;* This is a sample of the PRODIDACT programming Language created&lt;br /&gt;* to develope multi-media MS-DOS applications. The language was&lt;br /&gt;* created by Frederic Torres in 1990 and used in numerous applications&lt;br /&gt;* up to 1993. The run time was written in Turbo Pascal/Borland Pascal.&lt;br /&gt;*&lt;br /&gt;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *&lt;br /&gt;*&lt;br /&gt;* The PDDLA Programming Language&lt;br /&gt;* ------------------------------&lt;br /&gt;* The language was a simple structured programming language inspired by the&lt;br /&gt;* PASCAL language. All the reserved keywords are in French.&lt;br /&gt;* The language execution was based on an interpreter.&lt;br /&gt;*&lt;br /&gt;*&lt;br /&gt;* Language&lt;br /&gt;* - - - - -&lt;br /&gt;*&lt;br /&gt;* Though, it was inspired by PASCAL there was some differences.&lt;br /&gt;*&lt;br /&gt;* - No user function.&lt;br /&gt;*&lt;br /&gt;* - Variable Scope: Local variables were actually available to any sub&lt;br /&gt;*   procedures called. This is bizarre and a probably not a good idea.&lt;br /&gt;*   But this is how I implemented the variable/memory manager.&lt;br /&gt;*   At the end of a procedure all local variables would be discarded.&lt;br /&gt;*   It was also possible to declare global variables.&lt;br /&gt;*&lt;br /&gt;* - Array: There was no array, but array could be simulated using the&lt;br /&gt;*   &amp;amp; macro concept as implemented in the dBASE language. See below in&lt;br /&gt;*   this file.&lt;br /&gt;*&lt;br /&gt;* - Procedure Pointer/Delegate: It was possible to simulate procedure&lt;br /&gt;*   pointer/delegate using the &amp;amp; macro concept.See below in this file.&lt;br /&gt;*&lt;br /&gt;* - Object Orientation: The language was not object oriented, but allowed&lt;br /&gt;*   the char '.' in procedure and variable name. Therefore creating the&lt;br /&gt;*   illusion of some kind of object orientation.&lt;br /&gt;*&lt;br /&gt;* - Debugger: There was no debugger, but a real time tracing mode at the&lt;br /&gt;*   top of the screen.&lt;br /&gt;*&lt;br /&gt;* - Source code overlay:It was possible to load and un load dynamically&lt;br /&gt;*   source code. The reason why is that we had only 640 Kb of memory.&lt;br /&gt;*&lt;br /&gt;* - String could has predefined max length to save memory.&lt;br /&gt;*&lt;br /&gt;*&lt;br /&gt;* Multi media support: (Obvisouly in 2010 this sound lame, but it was in 1990).&lt;br /&gt;* - - - - - - - - - -&lt;br /&gt;*&lt;br /&gt;* - Keyboard and mouse&lt;br /&gt;* - 16 colors PCX image&lt;br /&gt;* - Amimation (list of images displayed in loop)&lt;br /&gt;* - Hypertext file (basically it was simple HTML file)&lt;br /&gt;* - Special text display and menu in form of comic strip&lt;br /&gt;* - Customizable font.&lt;br /&gt;* - Virtual memory manager to save and restore screen area.&lt;br /&gt;*&lt;br /&gt;*&lt;br /&gt;* Integrity&lt;br /&gt;* - - - - -&lt;br /&gt;*&lt;br /&gt;* The source files can be encrypted before shipping. Applications shipped&lt;br /&gt;* could not be altered all image files, hypertext files and dictionary&lt;br /&gt;* definition files would be verified at the starting time. If a change was&lt;br /&gt;* detected the application would not start.&lt;br /&gt;*&lt;br /&gt;*******************************************************************************&lt;br /&gt;&lt;br /&gt;* Include the file Lib.EAO&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;$&lt;/span&gt;&lt;span class="mygeneral1-identifier"&gt;I Lib&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-comment"&gt;*******************************************************************************&lt;br /&gt;** Procedure Debug (AKA Main)&lt;br /&gt;**&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Procedure&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; DEBUT&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;    GlobalVariables.Initialize&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;    Chemin&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;(&lt;/span&gt;&lt;span class="mygeneral1-string"&gt;"images"&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;,&lt;/span&gt;&lt;span class="mygeneral1-string"&gt;""&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;);&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-comment"&gt;* Define the sub paths where to the pcx images&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;    Screen.Clear&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;    Screen.PrintXY&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;(&lt;/span&gt;&lt;span class="mygeneral1-number"&gt;0&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;,&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-number"&gt;0&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;,&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-string"&gt;"Hello World - Press SPACE to continue"&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;    Image&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;(&lt;/span&gt;&lt;span class="mygeneral1-string"&gt;"VOITURE1"&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;,&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-number"&gt;200&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;,&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-number"&gt;200&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;    UserPause&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;    Screen.Clear&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;    Array.Demonstration&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;    UserPause&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;    Screen.Clear&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;    ProcedurePointer.Demonstration&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;    UserPause&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;    Screen.Clear&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;    RunModule&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;(&lt;/span&gt;&lt;span class="mygeneral1-string"&gt;"MyModule"&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;,&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-string"&gt;"PrintThis"&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;    UserPause&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;    HyperTexte&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;(&lt;/span&gt;&lt;span class="mygeneral1-string"&gt;"HyperText.HT"&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;,&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-string"&gt;"Page1"&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;    UserPause&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Fin&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-comment"&gt;*******************************************************************************&lt;br /&gt;**&lt;br /&gt;**&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Procedure&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; Array.Demonstration&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;    &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Chaine&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; MSG_0 &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;:=&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-string"&gt;"message 1"&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-comment"&gt;* declare a string&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;    &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Chaine&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; MSG_1 &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;:=&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-string"&gt;"message 2"&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;    &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Chaine&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; MSG_2 &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;:=&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-string"&gt;"message 3"&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;    &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Entier&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; i     &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;:=&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-number"&gt;0&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;    &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;TantQue&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; i&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;&amp;lt;=&lt;/span&gt;&lt;span class="mygeneral1-number"&gt;2&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Faire&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-comment"&gt;* While loop&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;        &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Chaine&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; s  &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;:=&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-string"&gt;"MSG_"&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;+&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Chaine&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;(&lt;/span&gt;&lt;span class="mygeneral1-identifier"&gt;i&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;        &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Chaine&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; ss &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;:=&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;&amp;amp;&lt;/span&gt;&lt;span class="mygeneral1-identifier"&gt;s&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;        Screen.PrintXY&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;(&lt;/span&gt;&lt;span class="mygeneral1-number"&gt;0&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;,&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; i &lt;/span&gt;&lt;span class="mygeneral1-comment"&gt;* 14, ss);&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;        i &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;:=&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; i &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;+&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-number"&gt;1&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;    &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Fin&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Fin&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-comment"&gt;*******************************************************************************&lt;br /&gt;**&lt;br /&gt;**&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Procedure&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; ProcedurePointer.Demonstration&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;    &lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Chaine&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; s &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;:=&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-string"&gt;"MyProcedure"&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;    &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;&amp;amp;&lt;/span&gt;&lt;span class="mygeneral1-identifier"&gt;s&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-comment"&gt;* Call procedure MyProcedure indirectly&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Fin&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-comment"&gt;*******************************************************************************&lt;br /&gt;**&lt;br /&gt;**&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Procedure&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; MyProcedure&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;    Screen.Clear&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;    Screen.PrintXY&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;(&lt;/span&gt;&lt;span class="mygeneral1-number"&gt;0&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;,&lt;/span&gt;&lt;span class="mygeneral1-number"&gt;0&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;,&lt;/span&gt;&lt;span class="mygeneral1-string"&gt;"My Procedure"&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;    UserPause&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Fin&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-comment"&gt;*******************************************************************************&lt;br /&gt;**&lt;br /&gt;**&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Procedure&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; RunModule&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;(&lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;Chaine&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; m&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;,&lt;/span&gt;&lt;span class="mygeneral1-identifier"&gt;p&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  ChargeModule&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;(&lt;/span&gt;&lt;span class="mygeneral1-identifier"&gt;m&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;)&lt;/span&gt;&lt;span class="mygeneral1-space"&gt; &lt;/span&gt;&lt;span class="mygeneral1-comment"&gt;* Load module&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  &lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;&amp;amp;&lt;/span&gt;&lt;span class="mygeneral1-identifier"&gt;p&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;             &lt;/span&gt;&lt;span class="mygeneral1-comment"&gt;* Execute procedure name contained in variable p&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-space"&gt;  DeChargeModule  &lt;/span&gt;&lt;span class="mygeneral1-comment"&gt;* Unload module&lt;br /&gt;&lt;/span&gt;&lt;span class="mygeneral1-keywords1"&gt;FIN&lt;/span&gt;&lt;span class="mygeneral1-symbol"&gt;;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;See file &lt;a href="http://www.frederictorres.net/BlogEngine/post/The-PDDLA-Programming-Language-LIBEAO-file.aspx"&gt;LIB.EAO&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-68280113043528486?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/68280113043528486/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/01/kjl.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/68280113043528486'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/68280113043528486'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/01/kjl.html' title='The PDDLA Programming Language'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-2179620861727256546</id><published>2011-01-08T22:20:00.000-05:00</published><updated>2011-01-08T22:20:27.630-05:00</updated><title type='text'>DrumsLoopMe Demo</title><content type='html'>&lt;span class="Apple-style-span" style="color: #444444; font-family: calibri, arial; font-size: 15px; line-height: 18px;"&gt;DrumsLoopMe is wav file editor and loop maker specialized in working with real drums live sample.&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #444444; font-family: calibri, arial; font-size: 15px; line-height: 18px;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #444444; font-family: calibri, arial; font-size: 15px; line-height: 18px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #444444; font-family: calibri, arial; font-size: 15px; line-height: 18px;"&gt;DrumsLoopMe was written in 1996 in Delphi 32b.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #444444; font-family: calibri, arial; font-size: 15px; line-height: 18px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;p align="center"&gt;&lt;object width="480" height="385"&gt;&lt;param name="movie" value="http://www.youtube.com/v/M6fSyb4qW_Q?fs=1&amp;amp;hl=en_US" /&gt;&lt;param name="allowFullScreen" value="true" /&gt;&lt;param name="allowscriptaccess" value="always" /&gt;&lt;embed type="application/x-shockwave-flash" width="480" height="385" src="http://www.youtube.com/v/M6fSyb4qW_Q?fs=1&amp;amp;hl=en_US" allowscriptaccess="always" allowfullscreen="true"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-2179620861727256546?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/2179620861727256546/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/01/drumsloopme-demo.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/2179620861727256546'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/2179620861727256546'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/01/drumsloopme-demo.html' title='DrumsLoopMe Demo'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-8614495806249909756</id><published>2011-01-08T22:17:00.000-05:00</published><updated>2011-01-08T22:18:28.804-05:00</updated><title type='text'>fLogViewer.net Demo</title><content type='html'>&lt;a href="http://www.frederictorres.net/flogviewer.net/"&gt;fLogViewer.net&lt;/a&gt; is a free Windows program which allows one to view large log text files with color coding and filtering.&lt;br /&gt;&lt;br /&gt;fLogViewer.net is the replacement of fLogViewer.com.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Dynamically updates the display when the file changes. (Support IIS log file)&lt;/li&gt;&lt;li&gt;Support large files up to 4GB.&lt;/li&gt;&lt;li&gt;Support color coding based on keyword or regular expression.&lt;/li&gt;&lt;li&gt;Support filtering based on keyword, regular expression or IronPython plug-in.&lt;/li&gt;&lt;li&gt;Support searching based on keyword or regular expression.&lt;/li&gt;&lt;li&gt;Export in HTML format using the user defined colors.&lt;/li&gt;&lt;li&gt;Automatically archive and zip file.&lt;/li&gt;&lt;li&gt;Drag and drop text and zip files (automatically unzip the zip file content).&lt;/li&gt;&lt;li&gt;Special plug-in to visualize CSV, TAB separated and W3C Extended Log File (IIS log file).&lt;/li&gt;&lt;li&gt;Write your own plug-in to process the selected text in C#, VB.NET or IronPython.&lt;/li&gt;&lt;li&gt;Write your own plug-in to view the selected line in C#, VB.NET or IronPython.&lt;/li&gt;&lt;li&gt;View and monitor the local event viewer logs.&lt;/li&gt;&lt;li&gt;View remote file via http.&lt;/li&gt;&lt;li&gt;Require .NET 2.0 and no install. Download and run fLogViewer.net.exe.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;object height="385" width="640"&gt; &lt;param name="movie" value="http://www.youtube.com/v/cg--1xFWjg8?fs=1&amp;amp;hl=en_US" /&gt;&lt;param name="allowFullScreen" value="true" /&gt;&lt;param name="allowscriptaccess" value="always" /&gt;&lt;embed type="application/x-shockwave-flash" width="640" height="385" src="http://www.youtube.com/v/cg--1xFWjg8?fs=1&amp;amp;hl=en_US" allowscriptaccess="always" allowfullscreen="true"&gt;&lt;/embed&gt; &lt;/object&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-8614495806249909756?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/8614495806249909756/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/01/flogviewernet-demo.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/8614495806249909756'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/8614495806249909756'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/01/flogviewernet-demo.html' title='fLogViewer.net Demo'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-1985208581862573464</id><published>2011-01-08T22:15:00.000-05:00</published><updated>2011-01-08T22:15:46.624-05:00</updated><title type='text'>Extended the .NET string.format() Part II</title><content type='html'>I updated my ExtendedFormat class to support a dictionary, so one can write the following code:&lt;br /&gt;&lt;pre class="brush: csharp;"&gt; static  void  Main(string [] args) {&lt;br /&gt; &lt;br /&gt;     string  format                       = "LastName:{LastName}, FirstName:{FirstName}, Age:{0}" ;&lt;br /&gt;     Dictionary &amp;lt;string , object &amp;gt; Values = new  Dictionary &lt;string , object &gt;();&lt;br /&gt;     Values["LastName" ]                  = "TORRES" ;&lt;br /&gt;     Values["FirstName" ]                 = "Frederic" ;&lt;br /&gt; &lt;br /&gt;     Console.WriteLine(ExtendedFormatNamespace.ExtendedFormat.Format(format, Values, 45));&lt;br /&gt; }&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-1985208581862573464?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/1985208581862573464/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/01/extended-net-stringformat-part-ii.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/1985208581862573464'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/1985208581862573464'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/01/extended-net-stringformat-part-ii.html' title='Extended the .NET string.format() Part II'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-8840442835773733987</id><published>2011-01-08T22:10:00.000-05:00</published><updated>2011-01-08T22:14:30.065-05:00</updated><title type='text'>Extended the .NET string.format()</title><content type='html'>&lt;b&gt;Introduction&lt;/b&gt;&lt;br /&gt;Inspired by Python, I wanted to extend the .NET string.format() method so I can write the following C# code.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;public  class  Person  {&lt;br /&gt; &lt;br /&gt;     public  string    LastName;&lt;br /&gt;     public  string    FirstName   { get ; set ; }&lt;br /&gt;     public  int       Age         { get ; set ; }&lt;br /&gt;     public  DateTime  BirthDay    { get ; set ; }&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;static  void  Main(string [] args) {&lt;br /&gt; &lt;br /&gt;     var  person = new Person () { LastName = "TORRES" , FirstName = "Frederic" , Age = 45, BirthDay = DateTime .Parse("1964-12-11" ) };&lt;br /&gt; &lt;br /&gt;     Console.WriteLine(person.Format("{0} LastName:{LastName}, FirstName:{FirstName}" , DateTime .Now));&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Without the extension method.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;class  Program  {&lt;br /&gt; &lt;br /&gt;     static  void  Main(string [] args) {&lt;br /&gt; &lt;br /&gt;         var  person = new  Person () { LastName  = "TORRES" ,  FirstName = "Frederic" , Age = 45, BirthDay  = DateTime .Parse("1964-12-11" ) };&lt;br /&gt; &lt;br /&gt;         Console.WriteLine(ExtendedFormat.Format(person, "LastName:{LastName}, FirstName:{FirstName}" ));&lt;br /&gt; &lt;br /&gt;         // Combine extended and default mode &lt;br /&gt;         Console.WriteLine(ExtendedFormat.Format(person, "{0} LastName:{LastName}, FirstName:{FirstName}" , DateTime .Now));&lt;br /&gt;     }&lt;br /&gt; }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The ExtendedFormat.Format() fall back on the string.Format() method and therefore it is 100% compatible. Basically The ExtendedFormat.Format() add the tag {property-name} to call a property or field of the instance passed.&lt;br /&gt;I also added the ability to call a function with no parameter with the syntax{MyFunction()}.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Next Steps&lt;/b&gt;&lt;br /&gt;I will look at different template class in Python. I sometime need a little bit more for than just the simple format.&lt;br /&gt;I will add the source code to codeplex.com.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-8840442835773733987?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/8840442835773733987/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/01/extended-net-stringformat.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/8840442835773733987'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/8840442835773733987'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/01/extended-net-stringformat.html' title='Extended the .NET string.format()'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-6873904170071995845</id><published>2011-01-08T21:20:00.000-05:00</published><updated>2011-01-08T21:20:36.726-05:00</updated><title type='text'>Something The C# Compiler Will Let You Do</title><content type='html'>While writing unit tests, I shoot myself in the foot &lt;b&gt;trying the re use an already declared int&lt;i&gt;&lt;/i&gt;&lt;/b&gt;. &lt;br /&gt;I am surprise that the C# compiler will let you do this.&lt;br /&gt;The result is that we will only loop once in the first loop.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;        static  void  LoopIssue()&lt;br /&gt;         {             &lt;br /&gt;             for  (int  i = 0; i &amp;lt; 5; i++){&lt;br /&gt; &lt;br /&gt;                 Console .WriteLine("i:{0}" , i);&lt;br /&gt; &lt;br /&gt;                 for  (i = 0; i &amp;lt; 10; i++){&lt;br /&gt;&lt;br /&gt;                     Console .WriteLine("   i:{0}" , i);&lt;br /&gt;                 }&lt;br /&gt;             }            &lt;br /&gt;         }&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-6873904170071995845?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/6873904170071995845/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/01/something-c-compiler-will-let-you-do.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/6873904170071995845'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/6873904170071995845'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/01/something-c-compiler-will-let-you-do.html' title='Something The C# Compiler Will Let You Do'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-9163936456647947080</id><published>2011-01-08T21:19:00.000-05:00</published><updated>2011-01-08T21:19:20.388-05:00</updated><title type='text'>Looping through an array in Javascript</title><content type='html'>A little bit confused with Javascript array. I was.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.hunlock.com/blogs/Mastering_Javascript_Arrays#quickIDX1"&gt;Mastering Javascript Arrays&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: js;"&gt;function  LoopingTroughArray() {&lt;br /&gt; &lt;br /&gt;     var  Values = ["A" ,"B" ,"C" ];&lt;br /&gt;                                 &lt;br /&gt;     for  (var  i = 0; i &lt; Values.length; i++) {  // Solution 1 &lt;br /&gt; &lt;br /&gt;         alert(Values[i]);&lt;br /&gt;     }&lt;br /&gt;                 &lt;br /&gt;     for  (var  index in  Values) { // Solution 2 &lt;br /&gt; &lt;br /&gt;         alert(Values[index]);&lt;br /&gt;     }&lt;br /&gt;                 &lt;br /&gt;     jQuery.each(Values,         // Solution 3 with jQuery &lt;br /&gt;                 function (index, value){ &lt;br /&gt;                     alert(value); &lt;br /&gt;                     // return true;  same as continue &lt;br /&gt;                     // return false; same as break &lt;br /&gt;                 } &lt;br /&gt;     );&lt;br /&gt;     // The array method forEach is supportted in FireFox but not in Internet Explorer. &lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; function  FilteringAnArray() {&lt;br /&gt; &lt;br /&gt;     var  Values    = [1,2,3];&lt;br /&gt;     var  NewValues = jQuery.map( Values,&lt;br /&gt;                                 function  (value){&lt;br /&gt;                                     if  (value &gt; 2)                                &lt;br /&gt;                                         return  value;                                &lt;br /&gt;                                     else &lt;br /&gt;                                         return  null ; // remove the item from the array &lt;br /&gt;                                 }&lt;br /&gt;     );&lt;br /&gt;     alert(NewValues.valueOf());&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; function  ChangingTheContentOfAnArray() {&lt;br /&gt; &lt;br /&gt;     var  Values    = [1,2,3];                                &lt;br /&gt;     var  NewValues = jQuery.map( Values,&lt;br /&gt;                                 function (value){                                 &lt;br /&gt;                                 return  value*2;&lt;br /&gt;                                 }&lt;br /&gt;     );&lt;br /&gt;     alert(NewValues.valueOf());                &lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; function  LoopingTroughAnObjectProperties() {&lt;br /&gt; &lt;br /&gt;     var  Person = {&lt;br /&gt;         LastName:   "Descartes" ,&lt;br /&gt;         FirstName:  "Rene" &lt;br /&gt;     }&lt;br /&gt;                 &lt;br /&gt;     jQuery.each(Person,&lt;br /&gt;         function (key, value){ &lt;br /&gt;             alert(key+"=" +value);&lt;br /&gt;         }&lt;br /&gt;     );                &lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-9163936456647947080?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/9163936456647947080/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/01/looping-through-array-in-javascript.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/9163936456647947080'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/9163936456647947080'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/01/looping-through-array-in-javascript.html' title='Looping through an array in Javascript'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-4127480487826479214</id><published>2011-01-08T21:17:00.001-05:00</published><updated>2011-01-08T21:17:57.777-05:00</updated><title type='text'>Code Contrat Cheat Sheet</title><content type='html'>&lt;pre class="brush: csharp;"&gt;&lt;br /&gt;class  CodeContratCheatSheet  {&lt;br /&gt; &lt;br /&gt;     public int Value { get ; set ; }&lt;br /&gt;         &lt;br /&gt;     [ContractInvariantMethod ]&lt;br /&gt;     private void RationalInvariant(){&lt;br /&gt; &lt;br /&gt;         Contract .Invariant( this .Value &amp;gt; 0 );&lt;br /&gt;     }&lt;br /&gt; &lt;br /&gt;     public int VerifyInputParameter(int  a){&lt;br /&gt;             &lt;br /&gt;         Contract .Requires ( (a &amp;gt; 0) &amp;&amp; (a &amp;lt; 100) );&lt;br /&gt;         Contract .Ensures  ( a &amp;gt; 0 );&lt;br /&gt;         Contract .Ensures  ( Contract .Result&amp;lt;int &amp;gt;() &amp;gt; 0 );&lt;br /&gt; &lt;br /&gt;         return  1;&lt;br /&gt;     }&lt;br /&gt; &lt;br /&gt;     public void VerifyDataInInputOutputParameterOfTypeList(List &amp;lt;int &amp;gt; L){&lt;br /&gt; &lt;br /&gt;         Contract .Requires( Contract .ForAll( L, l =&amp;gt; l &amp;gt; 0 ) );             &lt;br /&gt;         Contract .Ensures ( Contract .ForAll( L, l =&amp;gt; l &amp;gt; 0 ) );&lt;br /&gt;     }&lt;br /&gt; &lt;br /&gt;     public void VerifyOutputParameters(out  int  i){&lt;br /&gt; &lt;br /&gt;         Contract .Ensures(Contract .ValueAtReturn&amp;lt;int &amp;gt;(out  i) &amp;gt; 0 );&lt;br /&gt;         i=1;&lt;br /&gt;     }&lt;br /&gt; &lt;br /&gt;     public List &amp;lt;int&amp;gt; VerifyDataInListReturned(){&lt;br /&gt;         Contract .Ensures( Contract .Result&amp;lt;List &amp;lt;int &amp;gt;&amp;gt;().Count &amp;gt; 1 );&lt;br /&gt;         Contract .Ensures(&lt;br /&gt;             Contract .ForAll(&lt;br /&gt;                 0, Contract .Result&amp;lt;List &amp;lt;int &amp;gt;&amp;gt;().Count,&lt;br /&gt;                 index =&amp;gt; Contract .Result&amp;lt;List &amp;lt;int &amp;gt;&amp;gt;()[index] &amp;gt; 0&lt;br /&gt;                 )&lt;br /&gt;         );&lt;br /&gt;             &lt;br /&gt;         List &amp;lt;int &amp;gt; l = new  List &amp;lt;int &amp;gt;();&lt;br /&gt;         l.Add(1); l.Add(2); l.Add(3);&lt;br /&gt;         return  l;&lt;br /&gt;     }&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; &lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-4127480487826479214?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/4127480487826479214/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/01/code-contrat-cheat-sheet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/4127480487826479214'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/4127480487826479214'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/01/code-contrat-cheat-sheet.html' title='Code Contrat Cheat Sheet'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-1147937958252595237</id><published>2011-01-08T21:15:00.001-05:00</published><updated>2011-04-03T23:19:58.052-04:00</updated><title type='text'>Implementing a simple configuration file in Python for a C# application - Part III</title><content type='html'>In this post I want to make my user description richer and for this I going to implement a class with 3 attributes UserName, LastName and FirstName.&lt;br /&gt;Now my Users attribute from my Configuration dictionary is a list containing 3 instances of the class User.&lt;br /&gt;You can even write some code to test the Python indepently of the C#.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: python;"&gt;"""&lt;br /&gt;     Configuration of my application&lt;br /&gt; """ &lt;br /&gt; class User(object): &lt;br /&gt; &lt;br /&gt;      def  __init__( self,  userName,  lastName,  firstName): &lt;br /&gt;         self. UserName   =  userName&lt;br /&gt;         self. LastName   =  lastName&lt;br /&gt;         self. FirstName  =  firstName&lt;br /&gt;         &lt;br /&gt;      def  __str__( self):  # Same as C# ToString() &lt;br /&gt;         return  "UserName:%s, LastName:%s, FirstName:%s"  %  ( self. UserName,  self. LastName,  self. FirstName) &lt;br /&gt;         &lt;br /&gt; &lt;br /&gt;  Configuration =  { &lt;br /&gt;     "Server"     :    "TOTO", &lt;br /&gt;     "Database"   :    "Rene", &lt;br /&gt;     "Debug"      :    True, &lt;br /&gt;     "MaxUser"    :    3, &lt;br /&gt;     "Users"      :    [ &lt;br /&gt;                         User("rdescartes"    ,"rene"      ,"descartes"     ), &lt;br /&gt;                         User("bpascal"       ,"blaise"    ,"pascal"        ), &lt;br /&gt;                         User("cmontesquieu"  ,"charles"   ,"montesquieu"   ) &lt;br /&gt;                     ] &lt;br /&gt; } &lt;br /&gt; &lt;br /&gt; # Code for quickly testing the user class. This Python code will work with IronPython or the C Python.&lt;br /&gt; if  __name__ == "" : &lt;br /&gt;     u =  User("rdescartes"    ,"rene"      ,"descartes"     ) &lt;br /&gt;     u =  User("bpascal"       ,"blaise"    ,"pascal"        ) &lt;br /&gt;     u =  User("cmontesquieu"  ,"charles"   ,"montesquieu"   ) &lt;br /&gt;     print  u&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;How to read this configuration variables in C# 4.0.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;static void Demo() {&lt;br /&gt; &lt;br /&gt;     ScriptRuntime  PythonScriptRuntime = Python .CreateRuntime();&lt;br /&gt;     dynamic        PythonScript        = PythonScriptRuntime.UseFile("Configuration3.py" );&lt;br /&gt; &lt;br /&gt;     Console.WriteLine(PythonScript.Configuration["Server" ]);&lt;br /&gt;     Console.WriteLine(PythonScript.Configuration["Database" ]);&lt;br /&gt;     Console.WriteLine(PythonScript.Configuration["Debug" ]);&lt;br /&gt;     Console.WriteLine(PythonScript.Configuration["MaxUser" ]);&lt;br /&gt; &lt;br /&gt;     foreach (var u in PythonScript.Configuration["Users" ]){&lt;br /&gt;     &lt;br /&gt;         // Force to convert the User instance into a string which will call __str__ &lt;br /&gt;         Console .WriteLine((string )u);&lt;br /&gt;     }                                       &lt;br /&gt;     foreach (var u in PythonScript.Configuration["Users" ]){&lt;br /&gt;         &lt;br /&gt;         Console .WriteLine(u.UserName);&lt;br /&gt;     }&lt;br /&gt;     Console .ReadLine();&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-1147937958252595237?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/1147937958252595237/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/01/implementing-simple-configuration-file_7840.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/1147937958252595237'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/1147937958252595237'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/01/implementing-simple-configuration-file_7840.html' title='Implementing a simple configuration file in Python for a C# application - Part III'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-348343572686235281</id><published>2011-01-08T21:14:00.000-05:00</published><updated>2011-01-08T21:14:26.726-05:00</updated><title type='text'>Implementing a simple configuration file in Python for a C# application - Part II</title><content type='html'>In this post I going to use a Python dictionary to store my configuration variables:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: python;"&gt;"""&lt;br /&gt;Configuration of my application&lt;br /&gt;""" &lt;br /&gt;Configuration =  { &lt;br /&gt;"Server"     :    "TOTO", &lt;br /&gt;"Database"   :    "Rene", &lt;br /&gt;"Debug"      :    True, &lt;br /&gt;"MaxUser"    :    3, &lt;br /&gt;"Users"      :    ["rdescartes",  "bpascal",  "cmontesquieu"] &lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;How to read this configuration variables in C# 4.0.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;static void Demo() {&lt;br /&gt; &lt;br /&gt;     ScriptRuntime  PythonScriptRuntime = Python .CreateRuntime();&lt;br /&gt;     dynamic        PythonScript        = PythonScriptRuntime.UseFile("Configuration2.py" );&lt;br /&gt; &lt;br /&gt;     Console.WriteLine(PythonScript.Configuration["Server" ]);&lt;br /&gt;     Console.WriteLine(PythonScript.Configuration["Database" ]);&lt;br /&gt;     Console.WriteLine(PythonScript.Configuration["Debug" ]);&lt;br /&gt;     Console.WriteLine(PythonScript.Configuration["MaxUser" ]);&lt;br /&gt; &lt;br /&gt;     foreach (string u in PythonScript.Configuration["Users" ]){&lt;br /&gt; &lt;br /&gt;         Console .WriteLine(u);&lt;br /&gt;     }                                    &lt;br /&gt;     Console .ReadLine();&lt;br /&gt; }&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-348343572686235281?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/348343572686235281/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/01/implementing-simple-configuration-file_08.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/348343572686235281'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/348343572686235281'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/01/implementing-simple-configuration-file_08.html' title='Implementing a simple configuration file in Python for a C# application - Part II'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-5222920365495081411</id><published>2011-01-08T16:44:00.000-05:00</published><updated>2011-01-08T16:44:27.738-05:00</updated><title type='text'>Implementing a simple configuration file in Python for a C# application</title><content type='html'>Combining IronPython and C# can bring very interresting things. For example implementing configuration. In this first post I am implementing a configuration file by using IronPython global variables. I am using C# 4.0 which make things easier but this can be done with C# 2.0.&lt;br /&gt;&lt;br /&gt;The configuration file Configuration1.py.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: python;"&gt; """&lt;br /&gt;     Configuration of my application&lt;br /&gt; """ &lt;br /&gt; Server      =    "TOTO" &lt;br /&gt; Database    =    "Rene" &lt;br /&gt; Debug       =    True&lt;br /&gt; Users       =    ["rdescartes",  "bpascal",  "cmontesquieu"] &lt;br /&gt; &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;How to read this configuration variables in C# 4.0.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp;"&gt; static void Demo() {&lt;br /&gt; &lt;br /&gt;     ScriptRuntime  PythonScriptRuntime = Python.CreateRuntime();&lt;br /&gt;     dynamic        PythonScript        = PythonScriptRuntime.UseFile("Configuration1.py" );&lt;br /&gt; &lt;br /&gt;     Console .WriteLine(PythonScript.Server);&lt;br /&gt;     Console .WriteLine(PythonScript.Database);&lt;br /&gt;     Console .WriteLine(PythonScript.Debug);&lt;br /&gt; &lt;br /&gt;     foreach (string u in PythonScript.Users){&lt;br /&gt; &lt;br /&gt;         Console .WriteLine(u);&lt;br /&gt;     }                                    &lt;br /&gt;     Console .ReadLine();&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;You will need to install IronPython 2.6 For .NET 4.0 and reference the following assemblies:&lt;br /&gt;&lt;br /&gt;IronPython.dll&lt;br /&gt;Microsoft.Dynamic.dll&lt;br /&gt;Microsoft.Scripting.dll&lt;br /&gt;&lt;br /&gt;Here are the namespaces used:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;using  Microsoft.Scripting.Hosting;&lt;br /&gt;using  IronPython.Hosting;&lt;br /&gt;using  Microsoft.Scripting;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-5222920365495081411?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/5222920365495081411/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/01/implementing-simple-configuration-file.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/5222920365495081411'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/5222920365495081411'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/01/implementing-simple-configuration-file.html' title='Implementing a simple configuration file in Python for a C# application'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-7011418631150846875</id><published>2011-01-08T16:39:00.000-05:00</published><updated>2011-01-08T16:39:58.137-05:00</updated><title type='text'>Bat File Syntax Highlighter For Visual Studio 2010</title><content type='html'>I created an extension for Visual Studio 2010 to display batch files (.bat) with syntax highlighting.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_qdDSPqcuZ3Y/TSjZaITjXNI/AAAAAAAAAPg/i-9snfo3lZc/s1600/vs_sh_2.jpg" imageanchor="1"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_qdDSPqcuZ3Y/TSjZaITjXNI/AAAAAAAAAPg/i-9snfo3lZc/s1600/vs_sh_2.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;The colors can be configured by editing a Python file named COLORS_DEFINITION.py.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: python;"&gt; BAT_COLORS_DEFINITIONS =  { &lt;br /&gt;     "Keyword"        :  "Blue",             # Echo, Copy any Bat keyword &lt;br /&gt;     "Comment"        :  "Green",            # rem &lt;br /&gt;     "Param"          :  "Brown",            # /b /s &lt;br /&gt;     "Label"          :  "Darkmagenta",      # label &lt;br /&gt;     "EnvVar"         :  "MediumPurple",     # %TEMP% &lt;br /&gt;     "Redirection"    :  "Red",              # &gt; and &gt;&gt;  &lt;br /&gt;     "Default"        :  "Black" &lt;br /&gt; }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Download the extension at &lt;a href="http://visualstudiogallery.msdn.microsoft.com/en-us/6706b602-6f10-4fd1-8e14-75840f855569"&gt;http://visualstudiogallery.msdn.microsoft.com/en-us/6706b602-6f10-4fd1-8e14-75840f855569&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-7011418631150846875?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/7011418631150846875/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/01/bat-file-syntax-highlighter-for-visual.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/7011418631150846875'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/7011418631150846875'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/01/bat-file-syntax-highlighter-for-visual.html' title='Bat File Syntax Highlighter For Visual Studio 2010'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_qdDSPqcuZ3Y/TSjZaITjXNI/AAAAAAAAAPg/i-9snfo3lZc/s72-c/vs_sh_2.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-6727334306677914050</id><published>2011-01-08T16:37:00.000-05:00</published><updated>2011-01-08T16:37:37.941-05:00</updated><title type='text'>Text File Syntax Highlighter For Visual Studio 2010</title><content type='html'>I created an extension for Visual Studio 2010 to display .txt and .log file with colors. Based on a simple rule the line is displayed in full in a specific color.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_qdDSPqcuZ3Y/TSjX8iCSCsI/AAAAAAAAAPY/F35t8D9SMcE/s1600/vs_sh_1.jpg" imageanchor="1"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/_qdDSPqcuZ3Y/TSjX8iCSCsI/AAAAAAAAAPY/F35t8D9SMcE/s1600/vs_sh_1.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;The colors can be configured by editing a Python file named COLORS_DEFINITION.py. If the line contains the string defined in ColorDefinition or if the line matches the regular expression the color is selected. To get the regular expression to work you will need to install IronPython 2.6 for .NET 4.0. in the default folder (%PROGRAMFILES%\IronPython 2.6 for .NET 4.0).&lt;br /&gt;&lt;br /&gt;The rules are evaluated from top to bottom, we stop at the first one that match. You can add as many rules as you want.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: python;"&gt;COLORS_DEFINITIONS =  { &lt;br /&gt;     "txt":  [  # Color definition for .txt file &lt;br /&gt;         ColorDefinition (  "[WARNING]"                ,"DarkGoldenrod"         ), &lt;br /&gt;         ColorDefinition (  ".*\\[ERROR\\].*Minor.*"   ,"Salmon"        ,  True ),         &lt;br /&gt;         ColorDefinition (  ".*\\[ERROR\\].*"          ,"Red"           ,  True ), &lt;br /&gt;         ColorDefinition (  "[INFO]"                   ,"Blue"                  ), &lt;br /&gt;         ColorDefinition (  "[PASSED]"                 ,"Green"                 ), &lt;br /&gt;         ColorDefinition (  ""                         ,"Black"                 )  # The last item is the default color &lt;br /&gt;     ] &lt;br /&gt; }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Download the extension at &lt;a href="http://visualstudiogallery.msdn.microsoft.com/en-us/6706b602-6f10-4fd1-8e14-75840f855569"&gt;http://visualstudiogallery.msdn.microsoft.com/en-us/6706b602-6f10-4fd1-8e14-75840f855569&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Once you ran the install, start Visual Studio 2010, click on the menu Tool Extension Manager, selection the extension and click Enable.&lt;br /&gt;Restart Visual Studio 2010.&lt;br /&gt;&lt;br /&gt;To change the colors edit the file&lt;br /&gt;&lt;br /&gt;%userprofile%\Local Settings\Application Data\Microsoft\VisualStudio\10.0\Extensions\TextHighlighterExtension\COLORS_DEFINITION.py&lt;br /&gt;&lt;br /&gt;with Visual Studio. Once done, restart Visual Studio.&lt;br /&gt;&lt;br /&gt;To get PYTHON syntax highlighting see &lt;a href="http://ironpython.net/tools/"&gt;IronPython tools for Visual Studio&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-6727334306677914050?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/6727334306677914050/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/01/text-file-syntax-highlighter-for-visual.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/6727334306677914050'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/6727334306677914050'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/01/text-file-syntax-highlighter-for-visual.html' title='Text File Syntax Highlighter For Visual Studio 2010'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_qdDSPqcuZ3Y/TSjX8iCSCsI/AAAAAAAAAPY/F35t8D9SMcE/s72-c/vs_sh_1.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-1912261650109017628</id><published>2011-01-08T16:25:00.000-05:00</published><updated>2011-01-08T16:25:30.599-05:00</updated><title type='text'>C# function returning multiple values</title><content type='html'>Python functions can return multiple values.&lt;br /&gt;&lt;pre class="brush: python;"&gt; class  MultiValueFunctionExperiment(object): &lt;br /&gt; &lt;br /&gt;      def  MyFunctionWithMultiValues(self): &lt;br /&gt;         return 1, 2, "Toto"&lt;br /&gt; &lt;br /&gt;      def  Demo(self): &lt;br /&gt;         a, b, s =  self. MyFunctionWithMultiValues() &lt;br /&gt;         print  a&lt;br /&gt;         print  b&lt;br /&gt;         print  s&lt;br /&gt; &lt;br /&gt; e =  MultiValueFunctionExperiment() &lt;br /&gt; e. Demo() &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;I like to do the same in C#. Here is the syntax I came with by using a class named MultiValue.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;&lt;br /&gt; class  MultiValueFunctionExperiment  {&lt;br /&gt; &lt;br /&gt;     private MultiValue MyFunctionWithMultiValues() { &lt;br /&gt; &lt;br /&gt;         return new MultiValue().Add(1).Add(2).Add("Toto");&lt;br /&gt;     }&lt;br /&gt;     public void Demo() { &lt;br /&gt; &lt;br /&gt;         MultiValue mv = MyFunctionWithMultiValues();&lt;br /&gt;         int a         = mv.Value&amp;lt;int &amp;gt;();&lt;br /&gt;         int b         = mv.Value&amp;lt;int &amp;gt;();&lt;br /&gt;         string s      = mv.Value&amp;lt;string &amp;gt;();&lt;br /&gt; &lt;br /&gt;         Console.WriteLine(a);&lt;br /&gt;         Console.WriteLine(b);&lt;br /&gt;         Console.WriteLine(s);&lt;br /&gt;     }&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Here is the class MultiValue&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;&lt;br /&gt; class MultiValue  { &lt;br /&gt; &lt;br /&gt;     List&amp;lt;object &amp;gt; _values;&lt;br /&gt; &lt;br /&gt;     public MultiValue(){&lt;br /&gt; &lt;br /&gt;         _values = new  List&amp;lt;object &amp;gt;();&lt;br /&gt;     }&lt;br /&gt;     public MultiValue Add(object  i) { &lt;br /&gt; &lt;br /&gt;         this ._values.Add(i);&lt;br /&gt;         return  this ;&lt;br /&gt;     }&lt;br /&gt;     public T Value&amp;lt;T&amp;gt;() { &lt;br /&gt; &lt;br /&gt;         T i = (T)this ._values[0];&lt;br /&gt;         this ._values.RemoveAt(0);&lt;br /&gt;         return  i;&lt;br /&gt;     }&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-1912261650109017628?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/1912261650109017628/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/01/c-function-returning-multiple-values.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/1912261650109017628'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/1912261650109017628'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/01/c-function-returning-multiple-values.html' title='C# function returning multiple values'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-6546922964140656707</id><published>2011-01-08T16:17:00.000-05:00</published><updated>2011-01-08T16:17:35.664-05:00</updated><title type='text'>IDisposable+Using keyword in Python</title><content type='html'>In Python the keyword &lt;span class="Apple-style-span" style="background-color: white;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;with&lt;/span&gt;&lt;/b&gt; &lt;/span&gt;match the C# keyword &lt;b&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;using&lt;/span&gt;&lt;/b&gt;. The method __exit__() match the method Dispose(). But a method __enter__() is required. The __enter__() simply returns the instance itself.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: python;"&gt;class  MyClass: &lt;span&gt;&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;      def  __init__( self): &lt;br /&gt;         print  "Initializing..." &lt;br /&gt; &lt;br /&gt;      def  __enter__( self): &lt;br /&gt;         print  "Entering..." &lt;br /&gt;         return  self&lt;br /&gt; &lt;br /&gt;      def  __exit__( self,  type,  value,  traceback): &lt;br /&gt;         print  "Exiting..." &lt;br /&gt;         return  False # Do not swallow raised exception &lt;br /&gt; &lt;br /&gt;      def  Run( self): &lt;br /&gt;         print  "Running" &lt;br /&gt; &lt;br /&gt; def  Main(): &lt;br /&gt; &lt;br /&gt;      with  MyClass()  as  e: &lt;br /&gt;         e. Run() &lt;br /&gt; &lt;br /&gt;  Main()&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-6546922964140656707?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/6546922964140656707/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/01/idisposableusing-keyword-in-python_08.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/6546922964140656707'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/6546922964140656707'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/01/idisposableusing-keyword-in-python_08.html' title='IDisposable+Using keyword in Python'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-6685089069451290422</id><published>2011-01-08T16:08:00.000-05:00</published><updated>2011-01-08T16:08:36.876-05:00</updated><title type='text'>IDisposable+Using keyword in Python, another implementation using inheritance</title><content type='html'>&lt;pre class="brush: python;"&gt;&lt;br /&gt;class  IDisposableBaseClass: &lt;br /&gt;&lt;br /&gt;def  __enter__( self): &lt;br /&gt;print  "Entering..." &lt;br /&gt;return  self&lt;br /&gt;&lt;br /&gt;def  __exit__( self,  type,  value,  traceback): &lt;br /&gt;self. Dispose() &lt;br /&gt;return  False&lt;br /&gt;&lt;br /&gt;class  MyClass( IDisposableBaseClass): &lt;br /&gt;&lt;br /&gt;def  __init__( self): &lt;br /&gt;print  "Initializing..." &lt;br /&gt;&lt;br /&gt;def  Dispose( self): &lt;br /&gt;print  "Exiting..." &lt;br /&gt;&lt;br /&gt;def  Run( self): &lt;br /&gt;print  "Running" &lt;br /&gt;&lt;br /&gt;def  Main(): &lt;br /&gt;&lt;br /&gt;with  MyClass()  as  e: &lt;br /&gt;e. Run() &lt;br /&gt;&lt;br /&gt;Main()&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-6685089069451290422?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/6685089069451290422/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/01/idisposableusing-keyword-in-python.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/6685089069451290422'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/6685089069451290422'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/01/idisposableusing-keyword-in-python.html' title='IDisposable+Using keyword in Python, another implementation using inheritance'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-9195431397593369023</id><published>2011-01-08T01:34:00.000-05:00</published><updated>2011-01-08T01:44:01.708-05:00</updated><title type='text'>Dependency Injection C# vs Python</title><content type='html'>Just to make sure I understand the dependency &lt;a href="http://en.wikipedia.org/wiki/Dependency_injection"&gt;injection concept&lt;/a&gt;, I wrote a little simple showing 2 highly coupled classes and the &lt;a href="http://en.wikipedia.org/wiki/Loose_coupling"&gt;loosely coupled&lt;/a&gt; solution in C# and in Python.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Highly Coupled Dependency in C#&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Because the classes Invoice and SaleTaxe are Highly Coupled and the class SaleTaxe use the DB class to read the sale taxe from the database, it is impossible to unit test the Invoice class without an SaleTaxe instance and a database.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;public class SaleTaxe {&lt;br /&gt;&lt;br /&gt;        private Decimal _Value = 0;&lt;br /&gt;&lt;br /&gt;        public SaleTaxe() {&lt;br /&gt;&lt;br /&gt;            _Value = DB.Read("SaleTaxe");&lt;br /&gt;        }&lt;br /&gt;        &lt;br /&gt;        public Decimal Value {&lt;br /&gt;            get { &lt;br /&gt;                return this._Value;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public class Invoice {&lt;br /&gt;&lt;br /&gt;        private SaleTaxe  _SaleTaxes          = null;&lt;br /&gt;        private Decimal   _AmountBeforeTaxe   = 0;&lt;br /&gt;&lt;br /&gt;        public Invoice(decimal amountBeforeTaxe) { &lt;br /&gt;&lt;br /&gt;            _SaleTaxes        = new SaleTaxe();   // &lt;&lt; HighlyCoupledDependency&lt;br /&gt;            _AmountBeforeTaxe = amountBeforeTaxe;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public Decimal TotalAmount {&lt;br /&gt;            get { &lt;br /&gt;                return this._AmountBeforeTaxe + (this._AmountBeforeTaxe * this._SaleTaxes.Value / 100);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;b&gt;Loosely Coupled Dependency in C#&lt;/b&gt;To implement a loose coupling we are using an interface.&lt;pre class="brush: csharp;"&gt;public interface ISaleTaxes {&lt;br /&gt;&lt;br /&gt;        decimal Value { get; }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public class SaleTaxes : ISaleTaxes {&lt;br /&gt;&lt;br /&gt;        private Decimal _Value = 0;&lt;br /&gt;&lt;br /&gt;        public SaleTaxes() {&lt;br /&gt;&lt;br /&gt;            _Value = DB.Read("SaleTaxe");&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public Decimal Value {&lt;br /&gt;            get { &lt;br /&gt;                return this._Value;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public class Invoice {&lt;br /&gt;&lt;br /&gt;        private ISaleTaxes  _SaleTaxes          = null;&lt;br /&gt;        private Decimal     _AmountBeforeTaxe   = 0;&lt;br /&gt;&lt;br /&gt;        public Invoice(decimal amountBeforeTaxe, ISaleTaxes saleTaxes) { &lt;br /&gt;&lt;br /&gt;            _SaleTaxes          = saleTaxes;&lt;br /&gt;            _AmountBeforeTaxe   = amountBeforeTaxe; // &lt;&lt; LooseCoupling&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public Decimal TotalAmount {&lt;br /&gt;            get { &lt;br /&gt;&lt;br /&gt;                return this._AmountBeforeTaxe + (this._AmountBeforeTaxe * this._SaleTaxes.Value / 100);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;b&gt;Unit Testing&lt;/b&gt;Now we can create a class SaleTaxesForTesting just for unit testing.&lt;pre class="brush: csharp;"&gt;class SaleTaxesForTesting : DependencyInjection.LooseCoupling.ISaleTaxes {&lt;br /&gt;&lt;br /&gt;            public Decimal Value {&lt;br /&gt;                get {&lt;br /&gt;                    return 10;&lt;br /&gt;                }&lt;br /&gt;            }        &lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        [TestMethod]&lt;br /&gt;        public void LooseCouplingDependency_TotalAmount() {&lt;br /&gt;            &lt;br /&gt;            DependencyInjection.LooseCoupling.Invoice i = new DependencyInjection.LooseCoupling.Invoice(1, new SaleTaxesForTesting());&lt;br /&gt;            Assert.AreEqual(1.10M, i.TotalAmount);            &lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;b&gt;And now in Python&lt;/b&gt;In Python there is no need to create the interface. Any instance referencing another is loosely coupled. See Uncle Bob's SOLID principal.&lt;pre class="brush: python;"&gt;class SaleTaxes:&lt;br /&gt;&lt;br /&gt;    def __init__(self):&lt;br /&gt;&lt;br /&gt;        self.Value = DB.Read("SaleTaxe")&lt;br /&gt;&lt;br /&gt;class Invoice:&lt;br /&gt;&lt;br /&gt;    def __init__(self, amountBeforeTaxe, saleTaxes):&lt;br /&gt;&lt;br /&gt;        self.AmountBeforeTaxe   = amountBeforeTaxe&lt;br /&gt;        self.SaleTaxes          = saleTaxes&lt;br /&gt;&lt;br /&gt;    def TotalAmount(self):&lt;br /&gt;&lt;br /&gt;        return self.AmountBeforeTaxe + (self.AmountBeforeTaxe * self.SaleTaxes.Value / 100.0)&lt;br /&gt;&lt;br /&gt;# Unit Tests&lt;br /&gt;&lt;br /&gt;class SaleTaxesForTesting:&lt;br /&gt;&lt;br /&gt;    def __init__(self):&lt;br /&gt;&lt;br /&gt;        self.Value = 10&lt;br /&gt;&lt;br /&gt;class UnitTests(unittest.TestCase):&lt;br /&gt;&lt;br /&gt;    def test_LooseCouplingDependency_TotalAmount(self):&lt;br /&gt;&lt;br /&gt;        i = Invoice(1, SaleTaxesForTesting())&lt;br /&gt;        self.assertEqual(1.10, i.TotalAmount())&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-9195431397593369023?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/9195431397593369023/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/01/dependency-injection-c-vs-python.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/9195431397593369023'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/9195431397593369023'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/01/dependency-injection-c-vs-python.html' title='Dependency Injection C# vs Python'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-5537439379808999742</id><published>2011-01-06T22:58:00.000-05:00</published><updated>2011-01-08T01:56:09.568-05:00</updated><title type='text'>ASP.NET form authentication, cookie encryption and IIS7</title><content type='html'>With IIS7 the encryption key, to encrypte the ASP.NET form authentication cookie is by default &lt;br /&gt;re-generated every time IIS start or every time the application process is recycled&lt;br /&gt;(when the application pool is recycled). My guess is that IIS6 uses a static encryption key.&lt;br /&gt;&lt;br /&gt;Thefore if your application is trying the decrypte a cookie saved before the last recycling&lt;br /&gt;the method FormsAuthentication.Decrypt() will raise the following Exception&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.Security.Cryptography.CryptographicException: Padding is invalid and cannot be removed.&lt;br /&gt;One solution is to add your own machine key in the web.config file in the section &amp;lt;system.web&amp;gt;.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: xml;"&gt;&amp;lt;machinekey decryption="AES"&lt;br /&gt;  decryptionkey="04BCBB3929F44DE6B7C0DD5C4A992A24E0E05565D5A718B59C3..." &lt;br /&gt;  validation="SHA1" &lt;br /&gt;  validationkey="40107878EFF79547946F85EE34808A7BDB9B7CB0EC2184029F1..."&lt;br /&gt;&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;You can google machinekey generator to find online application that will generate the xml for you:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.developmentnow.com/articles/machinekey_generator.aspx"&gt;http://www.developmentnow.com/articles/machinekey_generator.aspx&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.developmentnow.com/articles/machinekey_generator.aspx"&gt;&lt;/a&gt;&lt;a href="http://aspnetresources.com/tools/keycreator.aspx"&gt;http://aspnetresources.com/tools/keycreator.aspx&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-5537439379808999742?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/5537439379808999742/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/01/with-iis7-encryption-key-to-encrypte.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/5537439379808999742'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/5537439379808999742'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/01/with-iis7-encryption-key-to-encrypte.html' title='ASP.NET form authentication, cookie encryption and IIS7'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9068934273738604863.post-5954372551024171877</id><published>2011-01-06T22:24:00.001-05:00</published><updated>2011-01-08T01:45:10.281-05:00</updated><title type='text'>SyntaxHighlighter Syntax</title><content type='html'>For this blog I am going to use the javascript library &lt;a href="http://alexgorbatchev.com/SyntaxHighlighter"&gt;SyntaxHighlighter&lt;/a&gt;&lt;br /&gt;from alexgorbatchev.com 3.0.83.&lt;br /&gt;&lt;br /&gt;The goal of this post is to remember me how to include source code in others posts.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;JavaScript&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: js;"&gt;function helloSyntaxHighlighter()&lt;br /&gt;{&lt;br /&gt; return "hi!";&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;C#&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp;"&gt;function helloSyntaxHighlighter()&lt;br /&gt;{&lt;br /&gt; return "hi!";&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Python&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: python;"&gt;def helloSyntaxHighlighter(self):&lt;br /&gt;  return "hi!";&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Ruby&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: ruby;"&gt;def helloSyntaxHighlighter()&lt;br /&gt;  "hi!"&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;XML&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: xml;"&gt;&lt;a href="" id="123"&gt;&lt;br /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9068934273738604863-5954372551024171877?l=frederictorres.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://frederictorres.blogspot.com/feeds/5954372551024171877/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://frederictorres.blogspot.com/2011/01/this-is-test.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/5954372551024171877'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9068934273738604863/posts/default/5954372551024171877'/><link rel='alternate' type='text/html' href='http://frederictorres.blogspot.com/2011/01/this-is-test.html' title='SyntaxHighlighter Syntax'/><author><name>Frederic Torres</name><uri>http://www.blogger.com/profile/17273277115960109065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_qdDSPqcuZ3Y/TSaGxR2H_GI/AAAAAAAAAOk/j0BZ7_Z_EVI/S220/FredForInterweb.jpg'/></author><thr:total>0</thr:total></entry></feed>
