Monday, April 19, 2010

Create quick and dirty YQL Mash-up in 10 seconds (using MashupBuilder)


Sometime, you might have experienced that  you have to wait till whole website is downloaded just to see a stock-quote, game score, or league points table(etc.). Mostly these kind of websites are poorly managed, and they are very slow or contains too many annoying ads. I have created a Mash-up-builder that will help you in creating YQL based mash-up, very quickly. These mash-ups will be capable of showing just a small portion of the original web page. Mash-up will be dynamic and content will be pulled from original page every-time you will visit the mash-up. Additionally mash-up will be hosted on my website, so you need not to bother about hosting, though you can copy HTML code anytime if you want to host on your own.(these mashups are pure JavaScript, no server side coding).

Advantage is getting a faster & neat web page.

It was very easy to create mash-up-builder. I used YQL's html table.

How it works?
As you see that YQL's HTML table gives you output if you provide the URL and xpath of the content. Similarly Mash-up builder take 2 parameters as input, a URL of the web page and an XPATH of the content. Once these 2 things are ready, I cleverly used JSONP to render the content on page.

I recommend you to see the source {view-source} to understand the working of the mash-up.


Warning
Since mash-up builder injects HTML content directly from external source, its  prone to CrossSite Scripting attack. My website is not hosting any private content , so to me its fine because no security can be breached, do not try to replicate this functionality on your website if your website is hosting some private content.

  LIVE DEMO  




Feel free to share on twitter, Facebook & other social networking sites. 

Saturday, April 3, 2010

IPL Tables made sortable

Ever since I visited the official IPL website, I hated those static points table.

So I used YQL to grab that data and place in very sortable fashion here.




To create this I am using,
YQL 
Google visualization API  (optionally one can use YUI)
Jquery tabs

Friday, March 26, 2010

How to write your own spell checker ? C#.net

Hi There,
Today I wrote a readable & usable implementation of Norvig's Spell corrector.
Norvi's implementation of spell check is awesome! On his site he has link to many other implementation in various languages, including C#.

Most of the implementation are focused on minimum number of lines , so they are not readable. I have written my own implementation which you can use on your own risk.

Here is the source code

You can also check-out entire code using this svn command




            svn checkout https://jugad.googlecode.com/svn/trunk/C%23/SpellCheck SpellCheck




How Algorithm works?



1.Initially Algorithms builds a dictionary* data-structure of words, from a huge English text. (so algorithm does not uses dictionary# file as such). This dictionary* contains words-to-frequency-of-occurrence mapping. lets say it as nWords.



2.When you will fetch a word(lets say 'w') for spell correction,Then the algorithm builds a list of all possible words that can be formed from w by doing following operation

  1. Deletion (delete 1 character, for all possible combination)
  2. Transposition (flip 1 character, for all possible combination)
  3. Alteration (modify 1 character, for all possible combination)
  4. Insertion (insert 1 character, for all possible combination)

Lets say name of this list is 'edits' , note that all words in this list are just 1 step away from original word.
3. If edits has 1 or more words that exists in nWords, then it returns the word from nWords with maximum frequency, as a result.
4. If No words in 'edits' are present in nWords, then it creates another edits using edits to get second level word (word which are 2 step away from original input word)
5.Repeats from step-3 (or give up if your are already 2/3 steps apart from original word 'w')
Read more Here.

How To Use This code ?
To use this code instantiate class spell by passing huge-string of English text (from where it will build dictionary)
Then call function correct() to get the corrected word as result.

Note:This code is just to demonstrate the algorithm, modify constructor to build dictionary directly from file. You can also avoid calling sort operation in function 'correct'. Thoroughly understand the code before using it. Notify me if you find any critical problem.


*dictionary data-structure of programming
#real dictionary

Thursday, March 25, 2010

How to get Tabs (navigation bar) on new blogger templates

Hi There,
First of all you might have seen that blogger has brought-up new Template Designer. This article is to tell you that "how can you add tabs in these new templates?"

Its very easy

  1. Open http://draft.blogger.com/home
  2. Go To layout section and add a page element of type "HTML/Javascript" just below "Blog Header"
  3. Now add this code in the widget.



<ul>
<li><a href="http://sampleurl.com">Sample URL</a></li>
<li><a href="http://example.com" >Example Links</a></li>
</ul>

Note that between ul tag you can add many as li items as you want.
each li item will have a anchor ("a") element whose href property needs to be set to the URL you want this tab to link, and text portion goes in between.

customize this code as you want, and then paste them in the widget section.
save your widget and enjoy the tabs.

Thanks for reading my blog

Sunday, March 21, 2010

How to organize life using twitter?

{Happy Birthday To Twitter, Today on 21st March 2010, little bird (twitter) is all grown up. }
Today in this article I am going to tell you some little tip to organize your life with twitter. Read my old article about how I have linked my social network.

Twitter is popular because of 2 main reasons, Simplicity & Accessibility. Twitter Updates (tweets) are just 140 character long, and you can post these update from any media e.g Browser, twitter clients, phone client, by SMS or even by writing down on paper.

For centuries there are 2 very popular ways of organizing life,
1.Note Making
2.ToDo List
Despite these things being a popular way of organizing life, majority of people fails to maintain a single note-book or a ToDo list, because if your life is so organized to maintain a ToDo List or notebook then probably you never need them. Point is, either you are using a paper, phone, iPod or your laptop to maintain your ToDo list , none of them is accessible all the time & everywhere. Eventually this accessibility problem is almost solved by twitter, So there can not be any better tool like twitter to organize your life.

I always loved 2 tools on web for maintaining my todo list and notes, because they are also accessible via twitter.

EverNote
EverNote is very nice note making tool. I am not going to tell you much about it. You can just go an try it. I love its web-clip boorkmarklet to take note while browsing. Addition to specific client it has for iPhone, Android and Win-Mobile, You can also add a note in EverNote by just @replying to @myen or send a DM(direct message) to it. Now since tweet can be posted by all ways described above , you can access your note from every where.

e.g
   note to self "kill all currupt politicians" @myen
OR
d myen think about explaination why photo frame is better than diamond necklace on valentine's day
Remember The Milk

Remember the milk has a very similar accessibility options as EverNote, the difference is in aproach, This is a ToDo list for task management. You can also access it by sending DM to @rtm
e.g.
d rtm pick up the milk
d rtm !complete call jimmy

Search Your Tweets
Here is last tip, Since twitter has become your primary place to dump thoughts, Its better to have a way to search your tweets. Twitter search is a real time search, it only gives you results from a very small time-frame, sometime you might like to search your old tweets. To get this functionality here is a hack, subscribe your twitter feed in Google Reader, Google readers stores all the feeds subscribed by you and indexes it, so that you can search them latter. RSS feed of your tweets will be at this address (if you have unprotected updates only)
http://twitter.com/statuses/user_timeline/[your TWITTER HANDLE].rss




Thanks for reading my blog. Hope this was helpful. Please share on twitter and Facebook if you liked it.