Now WTH is Blind Debugging? Well, thats what I have been doing for the past 2 weeks everyday for 14-16 hours a day! I am working on a new top secret project(!) where there is a lot of intercommunication happening between 2 systems. One of them is a master and one is a slave. The intercommunication happens with a list of complicated protocols. Now comes the bad part. I don’t have source code access to either of the systems and my task is to get some things working in both the systems!
Ant and Grosshopper – Indian Version of story
Original Story:
——————-
The Ant works hard in the withering heat all summer building its house and laying up supplies for the winter. The Grasshopper thinks the Ant is a fool and laughs dances plays the summer away. Come winter, the Ant is warm and well fed. The Grasshopper has no food or shelter so he dies out in the cold.
Indian Version:
——————-
The Ant works hard in the withering heat all summer building its house and laying up supplies for the winter. The Grasshopper thinks the Ant’s a fool and laughs dances plays the summer away. Come winter, the shivering Grasshopper calls a press conference and demands to know why the Ant should be allowed to be warm and well fed while others are cold and starving.
NDTV, BBC, CNN show up to provide pictures of the shivering Grasshopper next to a video of the Ant in his comfortable home with a table filled with food.
The World is stunned by the sharp contrast. How can this be that this poor Grasshopper is allowed to suffer so? Arundhati Roy stages a demonstration in front of the Ant’s house. Medha Patkar goes on a fast along with other Grasshoppers demanding that Grasshoppers be relocated to warmer climates during winter . Mayawati states this as ‘injustice’ done on Minorities. Amnesty International and Koffi Annan criticize the Indian Government fornot upholding the fundamental rights of the Grasshopper.
The Internet is flooded with online petitions seeking support to theGrasshopper (many promising Heaven & Everlasting Peace for prompt support as against the wrath of God for non-compliance). Opposition MPs stage a walkout. Trinamool Congress call for ‘Bengal Bandh’ in West Bengal. CPM in Kerala demanding a Judicial Enquiry and immediately passes a law preventing Ants from working hard in the heat so as to bring about equality of poverty among Ants and Grasshoppers. Adhir Chowdhury allocates one free coach to Grasshoppers on all Indian Railway Trains, aptly named as the ‘Grasshopper Rath’.
Finally, the Judicial Committee drafts the ‘Prevention of Terrorism Against Grasshoppers Act'[POTAGA] , with effect from the beginning of the winter.
Arjun Singh makes ‘Special Reservation’ for Grasshoppers in Educational Institutions in Government Services.
The Ant is fined for failing to comply with POTAGA and having nothing left to pay his retroactive taxes, it’s home is confiscated by the Government and handed over to the Grasshopper in a ceremony covered by NDTV, BBC, CNN.
Arundhati Roy calls it ‘A Triumph of Justice’. Mamata calls it ‘Socialistic Justice’. CPM calls it the ‘Revolutionary Resurgence of the Downtrodden’ Koffi Annan invites the Grasshopper to address the UN General Assembly.
Many years later…
The Ant has since migrated to the US and set up a multi-billion dollar company in Silicon Valley,
100s of Grasshoppers still die of starvation despite special privileges somewhere in India ,
….AND
As a result of losing lot of hard working Ants and feeding the grasshoppers, India is still a developing country…!!
N.B.: I have no idea whose creative mind this has come out from, but this piece is awesome
Windows 8 on a Virtual Hard Disk (VHD)
Now now, don’t get me wrong. I am not recommending and writing about installation of Windows 8 over Linux. Infact, I am not recommending you guys to install Windows 8 (W8) at all except if you like me are developers and creators at heart and would like to do some applications for Windows Phone 8 (WP8). Microsoft being the good guys (deeply sarcastic if you don’t get me) have released a 1.5GB download for tools related to WP8 development. It also includes a gratis version of Visual Studio 2012 Express edition!
One day, I was just thinking, hey maybe I am biased. WP8 is not as bad and I should port all my Android applications to it. It is not a big task anyways. So, I pumped up my Windows 7 (W7) machine and was about to download the tools when I read through the requirements for the WP8 development tools. A WP8 professional x64-bit was needed to run them. And NO. I am not going to turn my desktop into a big PHONE. I will never allow that to happen till I am alive. And I don’t want to re-partition my HDD and I don’t want to buy a separate HDD to run WP8. So there I was, wanting to help Microsoft with 5 great apps and stuck at the first step.
The first thought was to install W8 in virtual box. But WP8 emulator needs Hypervisor-V support and that could take a lot of power from my PC and most probably not run properly as well. My W7 machine is very capable of running but I don’t want the extra overhead as well as lost cpu cycles because of running WP8 simulator (virtual box->W8->Hypervisor-V->WP8 emulator). I mean seriously, why Microsoft do you need to make a phone out of the desktop for creating WP8 products. Anyways, I would like to run W8 on bare metal but still not mess up with my existing FS or HDD. So I did install W8 on a Virtual Hard Disk (VHD).
VHD is a special kind of file format (well basically a blob) and the best part is that Microsoft supports it (of course it will, the specifications are made available under the Microsoft Open Specification Promise). So my whole install of W8 is just in a single file. No messing with anything else in the system setup. And I can boot up from that VHD on bare metal and run W8. When I am done, I will just have to restart and I will be in the familiar and trusted W7 environment. I don’t like the dual boot entries but hey, we need to let some slack to Microsoft OK.
So, how do we go about doing it. I am writing it down but since I am not in front of my W7 computer, you need to find the relevant menu items yourself (no spoon feeding). In W7, go to computer management, disk services and open it. Now from the menu select create a VHD. Select a location where you want it, save it with a file name, give it some size (100GB) and select dynamically expanding so that you don’t have to give it all the 100GB at once. The file will increase in size as and when it is needed but never expanding beyond 100GB. Once created, select attach VHD and select the file so created. Now you will have an extra drive in My Computer. It will be empty though.
Now put in your W8 Pro x64 installation DVD and let it run the setup. Give the VHD HDD attached drive (G: or something) and let it install W8 there. Reboot and W8 should have created a nice entry. Continue with the installation and you are all done. In some cases, it might happen that the VHD is not attached when the W8 reboots to continue with the installation. In that case, on the select drives screen, press CTRL+F10 and you end up in command line.
Now use diskpart to do the job. You will definitely land up in DISKPART prompt.
C:\> diskpart
DISKPART> sel vdisk file="<file location>"
DISKPART> attach vdisk
There you go. Now enjoy the W8 installation to create WP8 stuff. You can still access all your W7 files and folders. And W8 will not mess up with existing system. Removing W8 is also easy! Just delete the VHD file (after detaching it of course). So there my readers, you get what you want without being dirty. ENJOY!
case and enums in C – Discipline vs Discipline
After a couple of philosophy articles, I am back to my usual self writing about technology and related rants. This time, I will write about a heated discussion that happened between me and my fellow colleague. And that was on 2 points. So let the rant begin. Now before I begin, let me write that these days I am doing a lot of coding in C. So assume C in the below discussions.
1. Why use 0 and 1 instead of an enum?
This probably is a very simple question to answer. If using binary values in C, one can always define enums corresponding to all 0 and 1 values that are being used but is it worth it? Let me explain what happens on the compiler level. The compiler will simply replace the enums so defined by the actual values (especially for binary) when used on the LHS. But if it is used in assigning variables (on RHS), it adds two more instruction in the assembly code to fetch the enum value from the memory location holding the enum definition and assigning it to LHS. Now on the big resourceful systems we have today, it wouldn’t matter but in the embedded world that I live with, it does matter a lot. All process instructions and memory usage should be reduced as much as possible. And as long as variable value usage is properly documented it does not matter. eg: iCount is giving as much information as integer_Count_For_A_Loop. I mean how far should we go for making code presumably readable? An optimizing compiler would definitely omit those 2 instructions and make sure the assignments will be done in the compiled code itself but then, aren’t we depending too much on things we probably don’t know will happen or not? My final say on such an issue is to make sure that the code is commented and try to reduce unnecessary layers of code instead of writing 0 or 1. As an aside, ever wondered by bool is not defined in C? 😉
2. Why club multiple case statements?
Again, I would like to re-use every part of code that I write. So if there is a case where the re-use is happening even for a couple of C statements, I would try to re-use it. Clubbing multiple cases or having an intentional case fall through is a programming discipline and should not be despised. If the statements in multiple cases are repeated why not have an intentional fall through instead of repeating stuff? Of course you have to add an if somewhere in the code to get some variable properly done but hey, than it is code re-use.
So it was a clash of disciplines and I don’t have any opinion on which one is better. As long as the code is readable, maintainable, bug-free, extensible and scalable plus consumes less cpu cycles and memory and is performance oriented, it is okay to follow whatever you choose to follow. So as someone said, your programming discipline to you as long as it does not cause code wars! 😉
Rant out…
Bhakti – Important and unique concepts in Sanatana Dharma aka Hinduism
I got a lot of positive feedback on my previous article and I have been asked to write more and share my views on philosophy in general and on Sanatana Dharma in particular. And it is my duty to do so and spread what I have learned from all the books that I have read and my personal experience. I will keep using the same style of writing i.e. define certain words so that all of us get on the same page and similar line of thinking before I start writing anything. Of course parts of it will be controversial and there will be a lot of readers who will disagree and outright disapprove but thats the good thing about Sanatana Dharma. You don’t have to agree to neither everything nor anything. And still the whole world can leave in peace and harmony. Lets point out some important words here.
– Sanatana Dharma: Sanatana Dharma is a word in Sanskrit meaning “the eternal law” existed long before “religion” was invented as an “organized corporation”. It was a way of life for the people. There are/were a whole lot of beliefs and scriptures incorporated in the structure based on Sruti, Smriti, Puranas and Vedas.
– Dharma: Roughly translated into English as “Religion”. But one needs to be aware that religion is an organized collection of belief systems, cultural systems and world views that related to spirituality and “sometimes to moral values” (http://en.wikipedia.org/wiki/Religion). This definition of religion is very narrow and does not cover all the aspects of the word Dharma as defined in Sanskrit. Dharma is that which upholds, supports or maintains the regulatory order of the universe and designates those behaviours considered necessary for the maintenance of the natural order of things. It encompasses ideas such as duty, vocation, religion and all behaviour considered approriate, correct and morally upright (http://en.wikipedia.org/wiki/Dharma).
– Hinduism: Is the western name given to the people who follow the Hindu religion. In the past the Indus River was a predominant historic appellation in the northwestern part of the Indian Subcontinent also known as Sindhu (http://en.wikipedia.org/wiki/Hinduism). After the 8th century, there began a series of attacks from the newly found Muslim religion from the west. The first of those attacks started from the persian speaking mulsims (please do not confuse them with Parsis). The culture on the east side of Indus was everything different than the muslims had ever seen. So they began referring to the people on the east of Indus river by the local name Sindhu. But since Persian does not have an “S” sound, they used to say “H”indu. Hence the name Hindu was coined and it has been stuck with the followers of Sanatana Dharma since the 8th century.
– Bhakti: Is devotion in the form of active involvement of a devotee in worksho pof the divine (http://en.wikipedia.org/wiki/Bhakti).
Now with the words out of our way, lets start by discussing some very important and unique concepts that are only available in Sanatana Dharma. I will just focus on “Bhakti” as the main topic for this article. Bhakti is one of the basics of our Dharma and it is unique. It is not enforced through a fear for hell, or through a revengeful god or through an evil and lusty devil or through gifts and promises in the afterlife or through any other consideration. Bhakti is just driven by the moral need to do the right thing at the right time and follow the Dharma (as defined above) i.e. make sure that there is the maintenance of the natural order of things. There are many different forms of Bhakti and traiditons ascribed to it. Parts of some have been taken by other “Religions” although they have modified and twisted it to form a totally different beast out of the original concept! In this article, I will focus on the nine forms of Bhakti (Navdha Bhakti) which is described in Valmiki Ramanayan.
As the history goes, Lord Sri Ram was with Laxmana in search of Mata Sita when she was abducted by the evil Brahman King Ravana. I want to stress that Ravana was a Brahman since there are a lot of people who believe that he was of the lower varnas. Again there is a lot of mis-propoganda on Ravana which I will tackle in some of my other article. But looking for a clue to take the next step in search of Mata Sita, Lord Sri Ram comes to Matan Rishi’s Ashram where he meets Sabri. Sabri is a lower caste, tribal woman who has spent her whole life in order to meet the Lord. On her request to know about Navdha Bhakti, Lord Sri Ram narrates about the 9 different forms of Bhakti as listed below.
1. Satsang Bhakti: Is the kind of Bhakti which happens when a person sits with learned people/saints and participates in various discussions.
2. Katha Bhakti: Is the kind of Bhakti where the person listens to the tales/stories/deeds of the Lord and his leela (games that Lord plays with us mortals).
3. Guru Seva Bhakti: Is the kind of Bhakti where the person does selfless service to his Guru without any pride. In Santana Dharma, both Guru and parents have higher positions than the Lord himself. I will explain this concept in some other article.
4. Gungaan Bhakti: Is the kind of Bhakti where one praises the Lord’s virtues with a heart clear of guile, deceipt or hypocrisy.
5. Naam Jaap Bhakti: Is the kind of Bhakti where one chants the name of the Lord as revealed in the Vedas.
6. Moral/Vairagya Bhakti: Is the kind of Bhakti where one practices self-control, has a good character, has detachment from manfold duties and follows the various Dharmas as ascribed in the Vedas.
7. Sant Bhakti: Is the kind of Bhakti where one precieves the word as God himself and regards the saints higher than the Lord.
8. Contentment: Is the kind of Bhakti where there is no desire but perfect peace and contentment with everything one posses and does not see fault in others even in his dreams. Such a state is attained after the person travels through the first seven kinds of Bhakti margs.
9. The Lord Everywhere: Is the kind of Bhakti where one has full faith in the Lord and becomes clean of any hypocrisy or deceit. One has strong faith in the Lord with neither exaltation or depression in any situation.
The interested can read more at http://creative.sulekha.com/navadha-bhakti-the-nine-steps-of-devotion-ramayana_423770_blog and http://murari.com/srimadbhagvatmahapuran/navdhabhakti.html. In the latter link, you also find the Navdha Bhakti as detailed out in Srimad Bhagvad. Essentially it is the same thing but instead closely and more tightly devoted to Lord Sri Krishna. Of course there are many other different kinds of Bhakti margs which I am not listing here.
One other form of Bhakti which I would like to mention is known as “Para-Bhakti”. It is the highest form of devotion in which the devotee himself is one with the Lord. He is so engrosed in the Lord that he sees him everywhere, he even feels like he is the Lord himself and tries to act and do what the Lord would act and do. An example of such Para-bhakti is given in Vishnu Puran where Raja Paundrak himself feels that he is the ultimate Lord Sri Krishna! He calls Lord Sri Krishna an imposter whereas himself as the real Lord Sri Krishna! And he even dresses like Sri Krishna, even owns a Chakra like Sri Krishna and even has a sevak similar to Lord Sri Hanumanji and calls himself “Murlidhar”!
When Rukminiji asks about Paundrak to Lord Sri Krishna and why Lord Sri Krishna is allowing Paundrak to be an imposter, the simple answer by the Lord is that Paundrak is so much into the Lord’s Bhakti that he considers himself to be one with Lord Sri Krishna. It is taken by Lord Sri Krishna as the highest instance of “Para-Bhakti”. And to Paundrak’s good luck, his soul was later given “Salvation” as he was killed by Lord Sri Krishna. He got the “Salvation” despite of his bad deeds since he was totally engrossed in “Para-Bhakti”. You can read more about the story from http://krsnabook.com/ch66.html as written by Srila Prabhupada himself.
With that, I end up my article on Bhakti wherein I haven’t touched much on Apara-bhakti but that maybe for next time. I would like to have your comments and suggestions. Hare Krishna, Jai Sri Krishna.