Skip to main content

Posts

Showing posts from 2014
Ember.js Talk @ JS Channel Bangalore 2014 . The day when i shared the stage with Douglas Crockford Himself.
And Google cardboard is here, hail virtual reality #googleio #vr
The Video Of My Talk @RootConf2014, Scaling 2000 Writes/Sec 

Yahoo News Digest - Now on Android - Adds International and Canadian Editions

Link: Yahoo News Digest - Now on Android - Adds International and Canadian Editions yahoo : By Nick D’Aloisio, Product Manager, Yahoo News Digest When we launched the Yahoo News Digest in January for iPhone users in the United States and United Kingdom, our goal was to ensure that our audience is “in the know” of the top news and information in the shortest amount of time, all while…

Suffix Trees , a bit complicated but really powerful data structure

Continuing with my obsession with the string matching algorithms , after  KMP algorithm which does string matching in O(n +k) time , where n is length of the string and k is the length of the pattern. I tried exploring another data structure called as “Suffix Trees” , Suffix trees are nothing but compressed tries , where you model all the suffix present in a string in an optimized tree/trie structure. this is how a suffix tree for word “BANANA” will look like some of the other common use cases , where suffix trees can be used is  Find the longest common substring of the strings S and T. This can be done in time O(|S| + |T|) Find the longest substring of S that appears at least m > 1 times. This query can be answered in O(|S|) time. Traverse the suffix tree labeling the branch nodes with the sum of the label lengths from the root and also with the number of information nodes in the subtrie. Traverse the suffix tree visiting branch nodes with information node count >= m. Determine

Ruby implementation of the famous Knuth–Morris–Pratt Algorithm

today just decided to write the   Knuth–Morris–Pratt string searching algorithm  , implementation in ruby.  As you can see that the algorithm is divided into two parts , one is the preprocess , which is the crux of the Algo and the actual string searching using the preprocessed metadata. The preprocess function is run only on the patterns, and it calculates π[i] = the longest proper prefix of pattern[0..i] , which is also a suffix of pattern[0..i]. e.g. if the pattern you are searching for is  P = [ ‘A’,'B’,'A’,'B’,'A’,'C’,'A’] the π array will look like π = [ 0,0,1,2,3,0,1] which shows that longest running prefix of the pattern is ABA . Buy doing the above calculations the algo saves itself some of the comparisons which it had to do in the naive , brute force approach. if you get the preprocessing function then the rest of the things are straight forward , the algorithm is intelligent enough to understand that if next char in the seq does not match , but if it

HATEOAS - Hypermedia as the Engine of Application State

Just came across this term HATEOAS , which some of my team members were using in describing what we did in our previous project wrt to REST. My Last project was about building an e-commerce platform for one of the largest book publisher and distributor in Latin America.As part of that project we had thought to use the LEVEL-3 for rest communication which is using REST as a hypermedia controls.  You can read about different levels of REST at this Martin Fowler’s Blog  . When we said we wanted to use REST as hypermedia controls , the main idea behind this was to be able to navigate the result of a REST call. For Example if there is a product catalogue call which looks like GET /products/123456 So It would return  As you can see that apart from the the properties of the product 123456 it also has a links array. This links array contains the the link description in rel and the location of that document. so essentially what i could do is parse the JSON response , and then look for what all

The dam which has slowed down Earth's rotation!

Link: The dam which has slowed down Earth's rotation! China'™s Three Gorges Dam is world'€™s largest hydroelectric station. First envisioned in 1919 and finally completed in 2012, the dam spans the Yangtze River and measures 2.3 kilometers (1.4 miles) long and 185 meters (607 feet) tall. Almost 30 million cubic meters (just over 35 million cubic yard…

Using RSVP for multiple ajax promises

So i was working on a bug in my project the other day wherein the requirement so we had to make multiple ajax calls to our backend and then once when “all were done” we had to trigger the success callback, even if any one of the calls fails we do not trigger the success callback. And the asynchronus nature of the the ajax calls make it more difficult. So to solve this problem we had a count variable with a promise, with every callback we were incrementing the callback and then when the count was equal to the number of calls then we would resolve the deffered object which would fire the success callback. This approach worked but was difficult to understand and debug. To simplify this a bit we used the RSVP which was bundled with the ember source. so instead of maintaining the count and then manually resolving the promise we used the Ember.RSVP.all(<array to observe>, function(){ console.log(“success callback”)}) so it resolves the success callback once all the promises which are p

Segregation of responsibilty with EmberJS router actions and store

Recently we upgraded our application to ember 1.3.0 and ember-data 1.0.0-beat4.Though it was a challenging task , since most of the api’s , conventions and names had changed so it involved in a lot of effort ( the upgrade deserves a separate blog post ).The one of the many things which has changed in the ember-data and ember 1.0 is the actions hash in the routes . So routes can now have actions which look something like. You can call these actions from Handelbars using {{ my-button action= “ showUser”}} or  from the view code using  this.sendAction( ’ action’, param1, param2); The events gets bubble up from the { Handebars } -> View -> Route  This picture form Emberjs docs explains it in a better way.  you can read  http://emberjs.com/guides/templates/actions/#toc_action-bubbling  for more details about action bubbling. The other change which the ember-data library brings about is making store the centre of all the interactions to the server , Store basically is a repository of
Even I have a selfie now ;)
London underground has always amazed me (at Holborn London Underground Station)
And the dinners have started #marrigeaftereffects