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);
Here's a quick reference on WCF Contract Attributes, jargons etc.
1) MSMQ - message delivery guarantees such as when receiver is offline, transactional delivery of messages, durable storage of messages, exception management through dead letter and poison letter queues dead letter queues used when messages expire or purged from other queues. Poison letter queues used when max retry count is exceeded. Security over AD. MSMQ management console facilitates administration.
NetMsmqBindingFeatures :
ExactlyOnce, TimeToLive (default 1day), QueueTransferProtocol ( SRMP for HTTP expose ), ReceiveRetryCount, MaxRetryCycles, UseMsmqTracing, UseActiveDirectory, UseSourceJournal,
ClientTransactions - TransactionScope, Queued Service Contract - TrasnactionFlow(TransactionFlowOption.Allowed)
Security Features:
Authentication - mutual sender and receiver, Authorization - access level, Integrity , Confidentiality,
SecurityMode - None, Transport, Message, Both -  TransportWithMessageCredential and TransportCredentialOnly, Client credentials are passed with the transport layer.
ClientCredentialType can be WindowsClient  property, HttpDigest property,  UserName property, ClientCertificate property, ServiceCertificate property, IssuedToken property, Peer property,
SecurityPrincipal - roles, identity. ServiceSecurityContext - claims, identity.
Claims based security model - security tokens and claims. using ClaimType, Right and Resource.
A X.509 token has a claim set where a list of claims selected from an indexer set are issued by a particular issuer. Authorization calls based on custom claims
Windows CardSpace is used for creating, managing and sharing digital identities in a secure and reliable manner. CardSpace usually has  a local STS that can issue SAML tokens. When a card is used to authenticate, a local or remote STS looks at the claims in the card to generate a token.
In a federated security, AAA is sometimes delegated to STS. The client application authenticates to the STS to request a token for a particular user. The STS returns a signed and encrypted token that can be presented to the relying party.
Exception handling - SOAP faults have faultCode, faultString, faultFactor, and detail.
Exception, SystemException, CommunicationException, FaultException, FaultException<T>.
BindingFeatures - Transport protocols, Message enconding, Message version, transport security, message security, duplex, reliable messaging and Transactions.
Reliability  - implemented via RM Buffer on both client and server side and session maintenance. RequireOrderedDelivery, retry attempts, SessionThrottling. Reliable sessions can be configured with Acknowledgement Interval, Flow Control, Inactivity Timeout, Max pending Channels, Max retry count, Max Transfer Size Window, Ordered etc.
Here are some more along with the previous post:

Decorator Pattern :  Here we don't change the interface like we did in the adapter. We wrap the object to add new functionalities. Extension methods is an example as well as a specific example with Stream class. BufferedStream, FileStream can all be wrapped from existing stream.

Iterator pattern :  This is evident from the IEnumerable pattern in .Net. This is very helpful with LINQ expressions where you can take the collection as Enumerable and invoke the standard query operators. The GetEnumerator() method and the MoveNext() on the IEnumerable enable the iteration.

Observer pattern : This is used to notify changes from one class to the other. Here we use an interface so that any object can subscribe to notifications that are invoked by calling the Notify method on the Observer.
public interface Observer {
void Notify(State s);
}
public class Subject
{
  private List<IObservers> observers;
  public void Add(IObserver);
  public void Remove(IObserver);
  public void NotifyObservers(State s)
  {
     observers.ForEach (x => x.Notify(s));
  }
}

Strategy pattern : When we are able to switch different ways to do the same task such as say sorting where we take a parameter for different comparisions, we implement the strategy pattern. Here the IComparer interface enables different comparisions between elements so that the same sorting operation on the same input can yield different results based on the different algorithms used. This pattern is called the Strategy pattern.
public class ArrayList : IList, ICollection, IEnumerable, ICloneable
{
    public virtual void Sort(IComparer comparer);
}