Friday, March 11, 2011
contributing to codeplex .... my 2 cents
1. GrammaerIntelliForJS - A simple grammar based intellisense for Html/Javascript. Useful for web pages that wants user to type according to some grammar. First cut of the solution is a simple one, I'm not building the parsed AST .. instead kept it a simple associative array.
2. LSystem fractal curves - was always fascinated by L-fractal curves, wrote a wpf application implementing the algorithms that Lindenmayer talks about in his book "the algorithmic beauty of plants" - a classic.
planning to submit two more projects to codeplex .... will write about it.
Friday, September 24, 2010
FlipThroughMovies - our Yahoo HackDay work
Also published a youtube video at http://www.youtube.com/watch?v=fy6nR1naxOY
Since the solution works against a huge data-set of movies, the first time load may be little slow, especially if your internet speed is less than 1 mbps.
Wednesday, April 14, 2010
what i liked @ COMPUTE 2010 (acm)
An ACM summit is worth attending, especially never miss a chance to hear the Turing Award winners. It was amazing hearing Prof. Barbara Liskov talk on 'The Power of Abstraction' and C.A.R. Hoare on automatic software verification.
Thursday, November 5, 2009
XSD to Class generation in .Net
Visual Studio comes with a very handy tool called XSD.Exe. It helps to generate a C# class from a XML Schema (xsd). Once you have the class its very easy to serialize / de-serialize XML instances. Personally I find two thing very annoying in the code generated by xsd:
1. For collection types Xsd.exe generates an array definition instead of List generic.
2. By default it marks the code generated as “not Debuggable” !!!, you’ll be surprised that you cannot step-in the generated class by default.
After having faced this two problem 4-5 times, I decided to write some helper tool to solve these. Took the simple path of writing two macros in visual studio. One for removing the “not Debuggable” [aka System.Diagnostics.DebuggerStepThroughAttribute()] and other to convert every field/property of array type to List.
The macro code is available at my Aha e-Assets page.
Monday, October 19, 2009
Simple Grammar for Arithmetic over English
These days writing a parser has become very easy, there are MANY free compiler-compiler available … and all of them does pretty decent job of code generation. Gold Parser is one such compiler-compiler. The good thing about Gold parser is that it generates C# parser code for your Grammar, combined with the Calitha Engine you get a pretty robust infrastructure to write your own language parser.
Sometime back, I wrote a simple grammar for basic arithmetic over English. The idea is simple, use English phrases as equivalent to mathematical operators. Example: the grammar allows you to say “sum of x and y” instead of “x + y”. As with mathematical operators, you can “pump” the output of one operator into another, example “subtract 10 from sum of 200 and 50”.
Here’s the Grammar:
Another aspect of this parser library is that it also allows “variables”. The object model as seen by the calling code is shown below:
The complete code along with a sample client and a demo recording is shared at my Aha World! .
Note:
1. The code to handle the interest rate rules is not yet done :(.
2, The video works with Windows media player, didn’t work with VLC :(. … may be some missing driver issue.
Wednesday, September 30, 2009
String Search & IntelliSense/Suggestion in .Net/C#
Problem: Given a set of keywords (or key phrases), provide a mechanism to suggest to user whether s/he is typing a valid word or phrase (i.e. word or phrase from the given list).
Example: Suppose, you wanted to maintain a list of commonly used English words like :
brake, boiling, driving, error, even, event
Then if user :
Types “e” --> System should suggest –> even, event
Types “br” --> System should suggest –> brake
I had this problem with an additional caveat – the list of words/phrases were actually description of features & with every suggestion i wanted to maintain the association with the feature object. It was close to a generic dictionary in C# only that the key-search was based on “starts with” instead of an exact key match.
So, here’s a simple solution that worked for me. The idea similar to a Definite Finite Automata, only that I’ve exploited the dictionary generics of C# to maintain the transitions. Here’s how the main classes look like:
The generic type T represents the type of the object to be associated with every keyword. A the library and a sample client is shared in my Aha World site. The project is called the SmartTextStore.
Here’s a snap of the sample client with a list of about 850 English words (the word list is included in the solution zip).
The solution was developed in Visual Studio 2008 as that’s what i had in my machine. However, the underlying principle for SmartTextStore is simple enough to be ported in Visual Studio 2005 or lesser as long as there is support for generics.
Wednesday, August 26, 2009
Modeling a Diff tool…
| To - Common really - Addition understand - Common the - Common solution, - Update (comma) you - Common should - Update (Previously: must) see - Update (Previously: understand) the - Common prototype - Update (first letter casing changed) |
The problem is very well known in the computer algorithm world & there are algorithms that solves it in linear time [ O(n) ]. You could use these algorithms in making "Diff" tools (example - WinMerge ).
Subscribe to Posts [Atom]