Wednesday, September 25, 2013

In a previous post I showed a sample of the source index tool. Today we can talk about a webUI to a source index server. I started with an ASP.NET MVC4 WebAPI project and added model and views for a search from and results display. The index built before-hand from a local enlistment source seems to work just fine.
There is a caveat though. The Tokenizer or in this case as it is called the Analyzer in Lucene.Net object model, is not able to tokenize some symbols. But this is customizable and so long as we strip the preceding or succeeding delimiters such as '[', '{', '(', '=', ':", we should be able to use the syntax.
The size of the index is around a few MB for around 32000 files of source with the basic tokenizer. So this is not expected to grow beyond a few GB of storage if all the symbols were tokenized.
Since the indexing happens offline and can be rebuilt periodically or when the source has sufficiently changed, the index rebuilding does not affect the users for the source index server.
As an aside, for those following the previous posts on OAuth token database, maintenance of the source index server is similar to maintenance of the token database. An archival policy helps the token database to be in certain size because all expired tokens are archived and the token expiry time is usually one hour. Similarly, the input index for the source index server can periodically rebuilt and swapped with the existing index.
With regards to the analyzer, a StandardAnalyzer could be used instead of a simple Analyzer. It takes a parameter for different versions and more recent version could be used to better tokenize source code.
Declarative versus code based security
Configuration files are very helpful to declare all the settings that affect the application running. These changes are made without affecting the code. Since security is configurable, security settings are often declared in the config file. In WCF, there are options to set the elements for different aspects of communication contracts in the configuration file as well as to set them via properties on objects in the code. For example, service binding has numerous parameters that are set in the configuration file.
In production, these settings can be overriden and provides a least intrusive mechanism to resolve issues. This is critical in production because code or data changes require tremendous validation to prevent regression and that is time-consuming and costly.
Configuration files are also scoped to appdomain, machine and enterprise wide. So the changes can be applied to the appropriate scope. Usually application configuration files alone have a lot of settings.
Changes need not be applied directly to the configuration file. It can be applied externally via usersettings file which will override existing configuration files. This again is very desirable in production.
However, the settings can explode to a large number. When the configuration settings are too many, they are occasionally stored in a database. This adds to an external repository for these settings.
Usually the settings are flat and are easy to be iterated while some involve their own sections.
Settings provided this way are easy to be validated as well.
Besides, CM tools are available that can make the configuration changes across a number of servers.

Tuesday, September 24, 2013

Passbook

Passbook is an application on the iOS devices which lets you keep track of your tickets, rewards, coupons all in one place. It lets you keep track of the images and the bar codes so you can display it on your phone and avail requests. This works well for items we like to keep in our digital wallet and use later. Since most of the items are digital today, this wallet is a convenient app to keep in your wallet. What is interesting is that the items are stored on the server and are accessed by a URI. And even more interesting is that the items can be anything as long as they meet the criteria for inclusion in the passbook.
If we consider the various cards we collect and dangle to our keychain, such as rewards cards and gift cards, then these are a substantial collection and therefore convenience to be stored digitally. E-Tickets are another example. All of this is in the passbook. This is a huge convenience to not have loose scraps of paper or card with you anymore. And have everything stored and tracked digitally.
If we could customize these where the user is able to drag and drop different items seen on different screens into the passbook, we add yet another convenience. Images or screenshots can be taken from all the different websites or applications using the phone features and then if they could be dragged and dropped into the passbook, the user now has done away with almost all the copying and pasting that ever needed to be done. Further, the application is the best possible way to keep track images outside the device since its now stored and reclaimed via web requests and responses.
There are already services that integrate with the Passbook already. For example, square provides registration serivices to push cards into the passbook. Most retailers can now directly work with Square integration.
Square provides services that let you charge cards directly from the phone. This is a device you attach to the phone and it lets you swipe credit card on the device. An application on the device reads the card information to process the payment. This application is called the register. This is a native application on the handheld device.
Square also provides a REST API to add cards to Passbook. These APIs lets you create, update, delete and retrieve Passbook pass. With the CRUD functionality available via APIs, there is complete elimination of maintaining any passbook objects on the caller side. The requests and responses are made with a service credential so there is a registration involved. And the same can be used for any type of cards. So if an application could be written to flow passes to your Passbook using integration service such as this, it could enable any user desired card to be cut out and made to flow into the passbook. 
CSS stylesheet elements review
Class is a selector. You could use class from a stylesheet directly in the controls within the HTML body. All elements with that class can then be defined in the stylesheet as .classname  { color : green } Only one class can be specified per selector
 ID is also a selector and can be used for unique elements such as a particular paragraph element.
The style sheets can be more than one and can be combined so that the individual sections are modular. Hence the term cascading style sheets. Both the author and the reader can influence the presentation through the stylesheets using the same language.
Conflicts between different stylesheets are resolved as follows:
1) Find all declarations that apply to the element or property. If there is no declaration, an inherited value is used.
2) Sort the declarations by explicit weight such as with the marking important.
Weights of individual declarations can be improved with the notation important.
3) Sort by origin : the author's style sheets override the reader's style sheet
4) Sort by specificity of selector - more specific selectors will override more general ones. For example, id attributes is applied over class.
5) Sort by order specified, use the latter specified in the order.

 

Monday, September 23, 2013

In the previous posts, we looked at possible solutions for keyword detection. Most of those relied on large corpus for statistical modeling. I want to look into solutions on the client side or at least rely on web based requests to a central server. When we relied on the keyword detection using corpus data, there was a large volume of text parsed and statistics gathered. These are useful when we are doing server side computing but in the case of client tools such as a word doc plugin we hardly have that luxury unless we rely on web requests and responses. If the solution works on the server side, the text on the client side can be sent to the server side for processing. If the server side is implemented with APIs, then it can enable several clients to connect and process.
This means we can write a website that works with different handheld devices for a variety of text.  Since the text can be parsed from several types of document, the proposed services can work with any.
The APIs can be simple in that they take input text and generate a list of keywords in the text in the form of word offsets, leaving the pagination and rendering to the client. This works well when a text or a collection of words can be looked up based on relative offsets which guarantee a consistent and uniform way to access any incoming text.
Also, some of the things we could do with server side processing is to build our corpus if that is permissible. The incoming text is something that we could get more representative text for which this strategy is important. The representative text is not only important from a collection perspective but also gives common keywords that are most prevalent. The identification of this subset alone can help with pure client side checks and processing.
Along the lines of the previous post, some common lambda expressions:
Func<bool> tester = () => true;
Func<string, string> selector = str => str.ToUpper();
Func<string, int, string[]> extract = (s,i) => i > 0 ? s.Split(delimiters,i) :  s.Split(delimiters);
Func<string, NumberStyles, IFormatProvider, int> parser = int.Parse;
button1.Click += async (sender, e) =>  { await Task.Delay(1000); textbox1.Text = "Voila!" }
var firstLargerThanIndexNumbers = numbers.TakeWhile( (n,index) => n > index);
var query = people.join( pets,
                                    people => people,
                                    pets => pets.Owner,
                                    (person, pet) => new { Pet = pet.Name, "OwnerName"=person.Name });
grades.OrderByDescending(grade => grade).Take(3);
Enumerable.Repeat("Repetition", 15);
var squares = Enumerable.Range(1, 10).Select(x => x * x);

Sunday, September 22, 2013

Sentence reversal in msdn

var sentence = "the quick brown fox jumped over the lazy dog";
var words = sentence.split(' ');

var reversedSentence  = words.Aggregate((sent, next) =>  next + " " + sent);

Console.WriteLine(reversedSentence);