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 http://allaboutalgorithms.wordpress.com/

  

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

timetable.sh 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" ]
then
 
   set `date +%u`
if [ "$1" -eq "1" ]
then
   echo -e "Monday's timetable\n"

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

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


fi

fi


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:
What?
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.

How?
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')
{
document.bgColor="#00ff00";
}
else
{
document.bgColor="#ffffff";
}
}


        function back()
       {
                document.bgColor="#ffffff";
       }
</script>


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!