Thursday, December 15, 2011

5 hours @ ICPC Asia Regionals Amritapuri

  At 8:30 am On 12th December, Aditya Prajapati, Arth Patel and myself or in other words Team Zion wwere sitting in the Computer Lab of Amrita University waitingo for the ACM ICPC Asia Regionals to start.
  Going back 2 days, 10th December morning, we were completing our final examination of the 5th Semester. Just after the exam we rushed to the printers for our tickets, then went to railway station to catch a 4pm train to Mumbai then a 5am flight to Kochi and finally a car ride to the campus. We were exhausted but we had a night to partially recharge our batteries.
  Anyways, the contest time, we idiotically didnot get Kevin sir's "notebook" printed and that was our first of several mistakes to come. We were without practice anyways. Then the questions arrived. I read question A, Aditya read question B and Arth was reading question E. I realised question A was the 2D version of one of the online round questions and hence found it easy to code. By that time Arth had already started coding for question E. He made the code and ran it for some test cases, working! We thought, yeah! He submitted it! Wrong Answer! There it was staring at our faces! Then Aditya Jumped in and realised Arth had read the question wrong! I then saw that question G was being submitted pretty quickly so we went for it and submitted it at 27 or so minutes. Relief! Then I returned to testing the algorithm for A and Arth and Aditya tried to find a proper algorithm for E. We all spent more than an hour just trying to figure out the algorithm! Then I finally showed Aditya my algorithm, we then coded and submitted it. Wrong Answer! Aw man! Arth then read the question E again and then realised that they were reading it wrong entirely! The reaction that we had after Arth said it! We had spent 2.5 hours trying to solve a question that we had read wrong! We finally coded it properly and submitted it it finally was correct! Meanwhile I had found the trivial case for my algorithm in A and had moved to problem J as Arth was coding for E.
     The question seemed very simple to solve but turned out all our optimization algorithms were failing and we had 5 TLE submissions! The last one was 2 seconds before the end! At the end we ended up being 94th after solving 2 questions. We were not happy but the bigger realization dawned next! We had not submitted question A! I had found out the trivial case and made the necessary change! But since we were to occupied with E we made A wait and rest is history! Angry at ourselves we got out of the room, sulked for some time but then the closing ceremony started in came C J Hwang and we forgot about our performance!
    All in all we had a fun time at ICPC Amritapuri but next time we may go to Coimbatore or Kanpur for a change!


Monday, November 7, 2011

An afternoon with canvas

   Today I returned to my hostel after a 2 week long Diwali Break. Well, since it was Diwali it was obvious that I wouldnot be doing a single bit of coding and I am not complaining, but the last 3 days at home were free so I thought of getting in the mood slowly. So I picked up an old painting application that i had developed.
   The previous one was a simple jQuery based application and did not have a feature to save your work so all the Davincis and Picassos out there could not show others their creations. So I thought of making the same app but on HTML Canvas element as it was very easy to save what you did!
   This time again it was very easy to make the JQuery code that was used to paint. While it took me a long time setting up the positioning of the objects.Let me share some code needed to get the canvas up and running.

<canvas id="can" width="500" height="500">

   border:1px solid black;

var dodraw = false;

var size=15;

var canvas = document.getElementById("can");

var ctx = canvas.getContext('2d');









$("#can").mousedown( dodraw=false;)


This code should be enough to get your canvas be able to draw stuff. You can further add features and modify the code as required.
I have currently added eraser,brush,save, new and size +/- buttons to the page.
The demo is available here:Open World


Sunday, October 16, 2011

ICPC 2011 Where do we stand?

  First of all, sorry that I have not been posting anything lately. Have a lot to share but unfortunately higher priorities coming up!
  So, today was the online selection round of ICPC 2011 for Amritapuri regionals. Now, as the dates for Regionals at Kanpur clashes with that of our end-sem exams, that was ruled out! So, we HAD to perform well to get selected(no option,none at all)! That meant, good hands on practice. But, that was not part of our plans! On past monday I realized the contest was just a week away! Then started frenzied practice sessions!
   Anyways, cut to the contest time. The contest started at 9 am and after 15 or so login attempts, we were finally able to login and see the questions. At first we thought there were 3 easy questions, one medium and one hard. After one "Time LImit Exceeded" submission for problem A we realised that it was actually difficult to solve (eventually only 8 teams all India could solve it!) While Arth was coding the first question, I and Aditya made the algo for problem B and C. The problem B was accepted without any issue and C had one minor glitch. We were so excited after the second submission that we actually screamed "ACCEPTED!" Just 5-6 minutes after that Arth submitted problem D and we again screemed "ACCEPTED!". But, that was the end of all of our screams. We submitted 3 questions at the end of the first hour and then no submission for the next 3 hours!
     After 2.5 hours, me and Adi left all hope of solving problem E and were just sitting there watching Arth try and solve the questions. We ended up being 3rd in our college and somewhere in the 120s or 130s all India. The final result will come on Tuesday. Fingers crossed!
     BTW Shrey Agarwal has shared algorithms for some questions at


Thursday, September 1, 2011

Old game new interface

   Since last week or so I had a strange craving to play the games that I used to play when I was in school. Those were all small and short games unlike the Most Wanteds or the Counter Strikes and all. Surprisingly, the only long running game that I used to play was Age Of Empires-II. A single regicide match would last for 15+ hours but not in a single stretch ofcourse.
   Now, coming back to the point, ever seen an alcoholic when he is unable to get alcohol? Well, that was my condition when I realised that I had lost the CD in which the games were there! What now??
   *LightBulb!* I suddenly remembered I had already developed the mobile version of Battleship! Why not a mobile version of one of these games? So I started testing my memory to check how much of what game did I remember. Eventually, I ended up deciding to make the mobile version of the K-tour a simple chess board based game. You have to move your knight on all 64 squares of the chess board without repeating at any location.
    Simple to make, I coded it in very little time. I hated my code when I looked at it because it had too many conditions, well to help me out there, my friend simplified the checking algorithm and hence helped me(Felt it worth mentioning).
   Anyways, there was no point in simply doing what I had already played and also there was no point in changing the game play as that would beat the purpose of recreation. Solution?? Change the interface. Added a few tweaks here and there and well, the app was ready!
  Will post it on Open World soon! Till then stay tuned to this space for updates and more posts!

Wednesday, August 17, 2011 for lazy people like me

   It is always very difficult for me to remember the time-table, especially for the first few weeks of semester. The condition was worse this semester, so I HAD to find a solution for this.I know, taking a photograph of the timetable would do it but I thought of doing something new (yeah!!)
   Since, the start of this semester, I had started using Linux and so I thought of making a shell script to help me.Well, fortunately I stuck to this idea and hence after about an hour of Googling, I was able to learn enough of shell scripting to help me here.Well, to save u from even one hour of googling, I am sharing the skeleton of the program:

#! /bin/bash

if [ "$#" == "0" ]
   set `date +%u`
if [ "$1" -eq "1" ]
   echo -e "Monday's timetable\n"

else if [ "$1" -eq "2" ]
   echo -e "\nTuesday\n"
else if [ "$1" -eq "3" ]
   echo -e "\n Wednesday\n"
else if [ "$1" -eq "4" ]
   echo -e "\n Thursday\n"
else if [ "$1" -eq "5" ]
   echo -e "\nFriday\n"

if [ "$1" == "1" ]
      same thing again



So, why did I use $# here?
  $# tells me the no of arguments passed. So if we passed a day number as an argument, then show that day's timetable, otherwise find the day of the week and then display the timetable.

why echo -e?
   Normally, echo doesnot support escape sequences so we need to add -e for them.

and date +%u gives u  the day of the week

We use the set command to give the value to the variable $1. $1 and all are special variables used in Shell script.

U can use == or -eq for checking the comparison. And it is visible that u need to end each if statement using fi!!

Anyways, now I have a shell script to tell me the timetable whenever I need it. Now all I need to do is make it autorun everyday in the morning and also turn it into a linux command. Will do that, and let u know :)

Enjoy this code till then. Yes, u are also welcome to tell me how to do the above!

Friday, July 8, 2011

Pixel Paint:what ,how and how much?

   Ever since I heard about jQuery, I wanted to use it,explore it and play with but due to some other reason(or in other words procrastination!) I was unable to do so. Finally, last Friday and set and learnt it from w3schools, the best available tutor I guess. Now, coming to the topic:
Well Pixel paint is an under development painting tool that I have created and uploaded to OpenWorld . You can try it there. The painting stuff is completely based on jQuery as that is what I wanted to practise while creating this. I will be adding more features as and when I am able to develop them. Currently, because of poor internet connectivity I am unable to add the latest eraser tool that I just created but anyways, the current pen tool is just fine.I think the tool is the best explanation of what it is.

Like I mentioned it above, I was learning jQuery and wanted to practise it. Coincidentally, Google+ came out the same week. With it's excellent UI and vibrant colors, it inspired me to add more color to what all stuff I made. I was thinking on what new animations could be done and suddenly light Bulb! The idea of an online painting tool just popped up to me.Making of the first version of Online Paint needed just 1 hour of jQuery designing and testing. A few more hours of designing and the first version was out! Coming to the next point:

How much?

As talked above, the version 0.2.3 had just dot painting facility, now the online version is 1.3.3 which has an addition of pen tool which enables you to draw lines. The one in my laptop is 2.4.3 which has the same UI but with an addition of eraser tool which is still a bit buggy, also one of the bugs of the previous versions have been removed. I wish to add a load more number of  features but I need to improve my skills and may eventually have to change the coding completely.

Anyways, that's all about Pixel paint that I can share with you right now. Will post more updates and will notify you people too!


Sunday, June 26, 2011

Boosting Mozilla Firefox's speed

     This post is continuation of one of my old post . Firefox lets us tweak it in a large number of ways and hence there is always a scope of your getting a better performance out of the browser. For eg, if you are contnuously online and if suppose you donot frequently visit same pages, you may limit the cache size on the disk or ram to reduce the memory usage of the browser to a lower value without much problems. Anyways, coming back to the post.
     Last time I talked about changing the disk and memory cache size of the browser.But, these are not of much use during offline viewing of pages. Certain pages having smart javascripts can make use of the offline caching facility of the browser to serve you better. To provide these with larger size, you just need to increase the size of browser.cache.offline.capacity to a larger value, 100000 in my case.
     It might happen that your browser may have browser.cache.offline.enable false i.e off. So you better turn it on!Just by double clicking it!
     You may also increase the value of image.cache.size Though I donot feel the need to do it. Also one thing should be taken care of. Providing large cache to Firefox will help to a certain extent. Beyond that it will only cause memory related issues.
   These were a few tweaks at the background level of the browser. There is another way to increase the speed also!  Just don't install add-ons without thinking. It may cause the browser to go slow.Also, it is recommended that you constantly update your browser and add-ons.
   There is a known issue with Java Console that while installing new versions, it forgets to remove the older ones so you will have to personally remove them.
   Will meet you soon with new updates, till then keep coding and stay tuned to the blog!

Friday, June 17, 2011

New animation: could be used for tutorial pages

   Many times writing tutorials, you may need to put up some questions for the user to answer. It maybe just to give him an example or for some other reason. But, they all have the same working: type the answer and then press the "check!" button. Some will give an alert saying you are incorrect or others will just put up a text or something.But in all of them you have to press the button.
  Lazy guys like me hate doing that much too! So I prefer to use this code to take in the input:

<input type="text" onkeyup="checkanswer()" onfocusout="back()" id="ans"/>

also to show whether the answer is correct or not, I made this script:

<script type="text/javascript">
function checkanswer()
var check = document.getElementById("ans");
if(check.value=='Your Answer Here')

        function back()

Well the script is self explanatory. After everykeypress, it checks if the answer is correct because of the onkeyup event.If answer is correct, the background colour changes to green, otherwise red. When you move the focus away from the text box the background becomes white away due to the onfocusout event.

This is quite useful for lazy guys like me :)

My main intention was to change the background color of the textbox but could not figure out how to do it so far. So send in your comments on how to do that :)
BTW check the demo here :

Thursday, June 2, 2011

Twitter Sorter

  I'm sure all the tweeters will be following different people for different purposes. Some for news, some people coz they are family, some coz you are their fans and many more reasons. Some of these people tend to tweet a lot and hence you timeline is flooded with their tweets.
  It happens with me many times that Engadget is tweeting excessively while I am not interested in them right now. God! I hate such moments! I always wished that My timeline was sorted according to category. Yes, Twitter has lists and you can read the tweets of the lists but that is too long. Hence, I am making an application called twitter sorter. It sorts all my tweets according to categories. My basic plan is setting the categories according to the Lists created by the user but not all users create lists (damn them!). Also, I wonder wether I should keep the tweets as seperate selectable objects or just show them as texts.
   Well, I am waiting for suggestions so please send them in!

Wednesday, April 13, 2011

High Quality Pages Algorithm:Google becomes more strict

  We know that Google consistently strives to give it's users better search results(why else would we use it?). Recently it launched a +1 button. And now it has launched a high quality pages algorithm . Some feel that this move is a reflecion of block sites chrome extension. Especially given that 85% of the black list is same as that of  the extension.
Why need such an algorithm?
  We are all aware of the presence of spammer sites, sites having copied content and the phishing sites.Its best that we donot get such sites in our search results. Hence Google is constantly striving to refine it's search results. The +1 service had been launched some time back, but it was just for social searches.Also it felt a bit manipulatable. Hence such an algorithm to get rid of so called 'Content Farming' websites.

What are high quality site?
 Here is a Google guideline as to what is a good quality site.All in all we can say that if a site is anyways trying to steal your data, cloaks link or has deceptive or a manipulative behaviour, then you are degrading the quality of your site. Also you better not spam through your website.

Is this algorithm powerful?
  Well, given the fact that it has been created by Google, says it all doesn't it? During the testing period, 2% of overall search queries were affected in the US. The percentage may seem small but given the number of daily search queries on Google, we can definitely say that a large number of sites will have been hit.

Will my site be affected?
 It all depends on your sites performance on Google's quality test.One thing though, don't think that your site can be manually be removed from the filter coz the system is currently fully automated and I think only if there will be negative responses, will Google think of manually adding exceptions. Till then, give your users something to love.Also make sure you go through Google's manual of good quality sites!Time to be obedient students to a strict teacher.

This service has been released just in US so far but will come to other English speaking users soon. Lastly, here is a list of all the sites affected by Googles algorithm ,for people who still believe that their site can beat it :)

Sunday, April 3, 2011

One wrong click and all my files gone!

   Currently I am working on an application for syncing folders(yeah I know its a common app,but it's a useful one!).I as usual started could not compile the code in the first time coz of some syntax errors but what followed next was more horrific(for me) and enjoyable(for some).
   In my code I instead of copying the file, wrote the command for moving the file.Now, for the command we need to give a name for the output file. As this is a sync app, I need to give the same name to the output file.Hence, there came a villain named extractname(). It extracted the name Ok but it gave the name in the reverse order! Hence beads.c became c.sdaeb! Also, I forgot to add another '\' at the end of the folder name.
  But, this was a logical error and not a syntax error so it passed without any trouble till I ran it. While running it, I thought that there would not be a major problem and hence selected a not so important folder as the source and a new folder as destination.
  But, fate had something else in mind! Not only did all my files move out of the folder but as I had forgotten to put the extra '\' in place, they all went to the wrong folder and it's not over yet. The files were named like testc.sdaebs and testc.xiptas .I was stunned, confuse and angry over myself. Thankfully, after some debugging I came to know about the horrific mistake I made. Now I have renamed the files and they are at the right places. Also the code is corrected and the basic version of my app is ready.Now some more functionality and the app will be completely ready!

Monday, March 28, 2011

New animation I tried out today

    Right now I am busy working on a website with my friend where we are going to put up all the projects that we have made so far(Exciting !). Well, while making the sidebar for the creators page, I already added the animation of enlarging images(it's still clunky though :(  ) but anyways, there's some animation atleast.
   I thought of modifying my links aswell. I just had the color change effect and nothing else, so I came up with a new effect! I just changed the position of the image as it was hovered on!
  I added 'text-align:center' in the portion a:hover and it worked. You can try it out on my page in the site . The site is still under development so there is no meaning clicking on the links :( but keep in touch it will soon be available

Monday, March 21, 2011

Unique way of Checking Internet Availability

     I constantly try to improve my browser homepage. The most recent addition that I made was adding animation to the links. I had been using the icons of the webpages to show the links.Just using the icons bettered the appearance of the page but I wasn't satisfied (I never am! ). Anyways, so I added animation to the icons. I did not do something special but I just made the icon's size larger when the mouse hovered over it. This task can be done by simply adding this CSS:
.img hover
The initial height and width were 40 px each.

      Anyways, the main tweak that I made was to check the internet availability.Initially I put an i-frame of my blog and hence if the connection would not be available, it would be seen in the frame.But in this trick, if there was no internet connection, the page looked ugly. So, I thought of a new tweak. I put an image at the top of the page and the location of this image was not on my hard-drive but on the internet.In the alt part of the tag, I wrote down "You are not currently connected to the internet". 

<img src="" alt="You aren't connected to the internet" />

This tweak, showed my connection status at the top of the page and also, if there wasn't an internet connection, it didnot take away the look of the page.
     But, there is one problem with this technique, chrome doesnot show the alternate text(Why??) .I will find some unique solution for chrome as well but I won't promise anything. Anyways, I am loving this tweak in my firefox and IE browsers. Hope you will like it too.
   Happy coding!

Saturday, March 12, 2011

Chrome A more developer friendly browser

                   I support Mozilla firefox a lot because it is an open-source web-browser. Not saying that it is not good but Chrome is also good. There are many factors where Chrome beats firefox as a better browser. One of those aspects is how easy it is for developers to create new add-ons. Lets face it, The features in built in a browser are never enough for us. Most of us are using some or the other add-on. Thus, making it easy for developers to make new applications makes your browser tick more because you don't know how imaginative/innovative the developers are.
                  Chrome beats Mozilla hands down in this aspect. Mozilla has several add-ons but Chrome has better(thanks to Google) and more in number. The second point is because of the number of developers.
This year, as a part of my ACM project I thought of making some cool Mozilla add-on as I had never used Chrome before.But, while going through the tutorial , I was unable to complete even the sample add-on. After trying for 2-3 times more I gave up on it and eventually moved on and made a windows mobile application.
In December 2010, Google launched the chrome web-store and had a big event. So, I thought of trying out the browser and Wow! how great the feeling was when I went to the link for the webstore. It was full of amazing extensions and so many of them! After using it for a month or so, I got curious and wanted to make one extension for myself. So i went to the google code page for tutorials and found it ridiculously easy compared to the Firefox tutorial(Again thanks to Google).
                I went through different examples and within a week I had my first application ready!Now I have made another simple extension for searching the same term in different search engines and believe me it was very easy to make.No fuss of making several folders for manifest , chrome and xul. Just one folder and you are set.
              I would request the Mozilla people to make the add-on making process a little easier for developers.

Tuesday, March 1, 2011

Firefox 4 by default disables all tab preview Option

On the release of the firefox 4 beta 6, I had blogged about my reviews.But, recently many people were asking me about tab-candy feature of firefox 4. So just while exploring this feature I found out that Firefox had simply disabled one of it's features.
The tab preview option comes disabled by default in firefox 4.The reason maybe that there is already a tab-candy option, where you can do much more than just preview the tabs. The tab-candy feature being more important and dear to the firefox 4 team, they want to give more importance to it and hence have disabled the preview.
I am not against any such step, I just wanted to let everyone know that the tabs preview option still exists and can be enabled by going into about:config and double clicking on browser.allTabs.previews option.
I hope the post will be useful to atleast one or two people.Anyways, there will be more posts from me so stay tuned to this page!

Spread Firefox Affiliate Button

Monday, February 21, 2011

2 changes I want in firefox 4

Last time i wrote about2 lesser known firefox add-ons. This time i will talk about 2 changes i want to see in the version 4.
I know that Firefox beta 12 is about to be released but these are very minor changes and can be done easily.

 The first and foremost is:"Making the Donot Track feature enabled by default"
Everyone is talking about firefox 4 having a donot track option for the sites but we don't know that the feature is by default disabled!
I would like to ask the firefox team that why have you kept the feature of this stature disabled by default. We all know how much we care about the default settings.Mozilla shouldn't think everyone will try and play with such technical aspects of browser.

  The second one is:"Keep Google as default search engine"

After using chrome for a month or so, i was used to writing everything in the omnibox(address bar) and when i typed in a search query, BOOM! bing search result! I was shocked and at first thought that it was because of some add-on but eventually came to know that Mozilla had changed the default search engine to Bing! Why Mozilla why?? Google is so reliable and loved!

I request Mozilla people to make these changes. Google is much better than Bing and unless don't track pages isn't made default, it will be unused and will fail to get the required acknowledgement.
Hope this page reaches to atleast one person who can do something

Saturday, February 19, 2011

2 lessser known firefox features

I assume that you all know what firefox is(u have to be highly ignorant for contrary!).
We all know that firefox and browsers in general are feature rich.Most of the useful ones are by default activated but I don't know why some aren't! I am writing about 2 of them in this post.

The first one is 'Search  as you type'
 For finding some text in browsers, we need to first press Ctrl+F and then type the text.
  Firefox has an inbuilt but by default deactivated feature to search without having to type Ctrl+F. Useful isn't it?
  You can activate it from:
 Tools → Options → Advanced → General → Search for text when I start typing
Here is the link for the Mozilla page on it

The other one is 'smooth Scrolling'
This feature might not produce a quite significant difference to the usefulness of firefox but gives an aesthetic feeling while using it.
As it's name suggests it will smooth the scrolling process to make it feel better. Though not productive it is worth a try and hence should be made a default setting
To turn it on try these steps:
Tools → Options → Advanced → General → 'Use Smooth Scrolling'
Hope you will like using the features.Will join you with more features soon.

Monday, January 31, 2011

A simple Google Search Gadget

  For designing a new-homepage for myself(yeah I do that a lot!), I wanted a google search gadget.So, as usual I decided to make one for myself.Just a simple tweak to one of the online tutorial javascripts and I had a javascript that could be used for google search!
Here's the script that I came up with.

<script type="text/javascript">
function search()
var searchkey = getElementById('mytext');
if(myTextField.value != "")
alert("Would you please enter some text?");

To complete the gadget, You need a text-box and a button.Also you need to use 'mytext' as the text-box's id and 'search()' as the onclick event for the button.
So the remaining code is:

<input type='text' id='mytext' /><br>
<input type='button' value='search' onclick='search()' />

This simple script doesn't pass all the parameters that Google does,but I am not Google, am I? This thing does the job so whats the problem? You can make the same thing for Bing by just replacing with . Also you can make it site specific by using this line:


Enjoy scripting!

Saturday, January 22, 2011

Innovative Idea: URL shortener

   Its been a long time since i posted about an innovative idea.But in my defense something is better than nothing! Lame isn't it? Anyways, getting started on the topic, this time it is the idea of URL shorteners.
  Many of us would have at some point on the web, encountered a shortened URL. It would be like or Twitter users find this idea as a boon considering the fact that we can tweet only 140 characters at a time.Well for others it is a tool to reduce the address of the website to a calm to eyes length. For eg the address of can be shortened to

  How depressing do the websites with looong addresses look!Imagine being forced to remember one of them. Some god-sent developer came up with a solution of URL shortening. It started with TinyURLin 2002. Though the idea became widely used with launch of twitter, it came to rage when was started being used by other famous websites in 2009.
   Some common URL shortening services are TinyURL , and The URL shorteners donot show the entire web address but redirect us to the actual website. Though novel this idea has been used for sending worms also. Read this article
  Well, the article may petrify you but don't worry, just go to shortened URLs given on standard web-sites or if you are still worried you can use tweet-deck or a service like google safe browsing.Well like all great technologies, URL shortener is quite useful but should be used wisely and the surfers should beware of the malicious use of the service and hence should take proper care while using them.

Thursday, January 6, 2011

Battleship for Windows Mobile

    Addiction may cause you to do several things.It makes the some steal from or hurt someone. Well, in my case it made me write more than thousand lines of code. My addiction is to the game of Battleship.
  In case you are wondering what it is, well in this game you are supposed to search for the enemy's fleet of battleships before he finds yours.You have to keep hitting till you completely destroy the fleet. Its quite a fun to play the game.
  When I formatted the hard-drive of my computer I foolishly forgot to backup the game.Hence I had no choice but to search for it. But I got a PC version of the game.So, being overcome by the addiction I just thought of making my own version for the Windows phone(coz it's the easiest to code!).
 So after an evening of coding the basic version of the game was ready. Then all that was left was some improvisation in interface but that could wait. First I had my game-lust to be satisfied. Well as it turns out even after 7 days I still haven't improved the interface but I am able to play the game so no complains!
  Anyways now I am planning to make a multiplayer version of the game and will need some time to make that happen but I am on it. In case anyone wants to try it out just mail me.