Posts

Showing posts from 2011

Listen a property for changes in JavaScript

There are two very interesting functions of Object in JavaScript - watch and unwatch. These two methods could be used to track changes of some specific properties of any Object. watch() watches for a property of an Object, if a value is assigned to that property, it will run registered function. Example,             Here i have an Object obj1 which has property myprop with value 1. Later watch method is used to register myprop property, if any changes/assignment is made to that property appropriate function is called. In this case whenever myprop of obj1 is assigned a value function is executed and alerts a msg. obj1 = {myprop:1}; //  start watch on obj1.myprop from here obj1.watch("myprop",    function (prop_name, oldval, newval) {       alert("obj1." + prop_name + " changed from " + oldval + " to " + newval)       return newval;    }); // assign new values obj1.myprop = 2; obj1.myprop = 3; obj1.myprop = 4; // unwa

Tips on coding style..

Well his post will be regarding some tips on coding style. I googled about this topic, checked many sites, read many posts, finally made a list on them... Meaningful names to variables -- i.e., name them meaningfully so that it corresponds as closely as possible to verbal description of its usage. Maintain a labbook from the beginning of a project to the end. Code each variable so that it corresponds as closely as possible to a verbal description of the substantive hypothesis the variable will be used to test. Errors in code should be corrected where they occur and the code re-run. Separate tasks related to data-manipulation vs data-analysis into separate files. Each program should perform only one task. Do not try to be as clever as possible when coding. Try to write code that is as simple as possible. Each section of a program should perform only one task. Use a consistent style regarding lower and upper case letters. Use

Oldest computer???

Image
Which is the oldest computer??         Well some would say ENIAC, others would say Colossus, what ever it is, im sure its not my computer :) because i just purchased it, didnt invent it :) The Answer is : " Antikythera "         It is an ancient mechanical computer which was being in use around 200BC (around 2000 years ago!!!). This device has been recovered from Antikythera Wreck (near greek island called crete), hence it gets its name "Antikythera". It is figured out that it was being used for two purposes, Astronomical and Astrological purposes. This device was used by greek astronomers for their research works!         Above is the picture of the recovered Antikythera. Scientists say, there are large number interconnected gears and is very complicated than a modern swiss watch!!. This device was recovered in 1900-1901. It took around 70 years to understand the complete inner workings of the Antikythera. In 1974, Price published a paper "Gears fr

First post

Well guys this will be my blog to share some cool stuffs related to computers. My first post will be soon..!