Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Mozilla

Journal Journal: Standalone Javascript: Breaking out of the browser

The major problem most people have with Javascript is that there is no easy way to test your code outside the browser. Often it so happens that you might want to test out a string split or array splice quickly. Here's a quick tip on getting a python'ish javascript shell.

/usr/lib/firefox-1.0/run-mozilla.sh /usr/lib/firefox-1.0/xpcshell

This should give you something like

js> a = [42, "is" , "the" , "answer"]
42,is,the,answer
js> a.sort()
42,answer,is,the

You can run your javascript code like this and pretty much everything outside the DOM and Window stuff can be well tested. And lastly the ultimate javascript hack of all time - Object orientation.

function base() { }

base.prototype.myname = function () { return "I am base"; }

function derieved()
{
this.base = base;
this.base();
}

derieved.prototype = new base;

derieved.prototype.__myname = derieved.prototype.myname;

derieved.prototype.myname = function () { return "I am derieved"; }

print(new derieved().myname());
print(new derieved().__myname());

User Journal

Journal Journal: Honesty is the Best policy ... or is it ?

When look into the murky pools of the business world, you might wonder how cynical Mark Twain had to be to say "Honesty is the Best Policy - when there's money in it", because that's exactly how honesty works in the so-called modern world. It is as if the world fears that an overdose of truth can hurt and kill - which might not be far from the truth (aah !!).

What is a lie ?. Lies are not just black or white , actually they are black and white sometimes. White lies have been the real true invention in language - to communicate by not saying sometime. That's the sort of lie a lawyer says when he says "There are no reliable witnesses". And some tell the truth, but "Reality is often inaccurate" .

Why do we lie: If you have seen Liar, Liar you might have realized the normal places where people lie. Society as an instituion relies on the ability of people to curb their natural instincts and say things which go against their better (or worse) nature. It is an institution built on the basis that nobody can see into your mind and the skeletons it might hold. In short, if you can't lie, decieve or pretend, you cannot survive in society. It started with the first sychopant caveman who said "Nobody makes such a warm fire like you, Ogg. And your club is huge" and it's been downhill all the way from there.

Whom do we lie to the most ?. I truthfully (ha ha !) think that we lie to ourselves the most. Self delusions of importance and ability which feeds the ego are necessary for survival. Truly depressed are those who are free from these precious illusions . Of course this attitude towards truth is mutual. When you buy a car, you don't want to hear that this model blows up once in a while - you want to hear about it's invisible anti-rust coating and push-to-start features. Truth can be brutal and offending - you don't want to be called a loser, you'd want to be called undeveloped potential. When you ask your girfriend "Do you love me ?" , you want to hear an emphatic Yes, not an "of course" or "not really". Most of us live our lives happy and content walled off by the facade of lies erected by society for our protection.

The really interesting thing about lies is that society takes a really interesting stand on it. It is as if it's ok to lie but not to get caught, which makes a lot of sense from an darwinian point of view. The differentiating factor seems to be the aspect of getting caught. But a society with a majority of absolute liars would collapse, so it maintains an equilibrium of truth and lies - or more correctly induviduals do. The threat of getting caught is the fine line that all of us walk when we lie.

In this politically correct world, the truthfully challenged seem to prosper. And an image seems to fade out in my mind - telling , no asking me - "The truth is out there". But I dare not . Do you ?.

The Almighty Buck

Journal Journal: Withdrawal Symptoms: India Budget 2005

With two economic reformers - Manmohan Singh and P Chidambaram - at the helm and stern, we expected this budget from our FM to be music to our ears. But the jarring note was struck on February 28th , when the dream budget hit a few icebergs.

First shocker: Fringe Benifits tax covering the benifits enjoyed by employees in all but not traceable to a single employee. I wonder if internet connections for each employee belongs in this tax (whether I'm being pessimistic or just cynical, I don't know yet). The irony of the situation is that you can expect most companies to withdraw the benifits and blame it on the government (it's a win-win, you see), rather than pay the tax.

The One Two punch: Withdrawal Tax of 0.1 % on cash withdrawals from banks above the sum of 10,000 INR (convert). The ostensible purpose of this is to reduce the cash based transactions in the country. The account payable checks and electronic money won't be affected. The black money and the black market won't be really be affected by this tax - they operate by Hawala channels where they pay ~0.25 % commision to the hawala operators. Truthfully this tax seems to be thrown in for the general effect - sort of to distract the public from the rest of the budget's power plays.

Final K.O with Value Added Tax. The intentions behind these are good in an economic ense - if the grain was taxed, the tax on the bread would be only for the value added. But the road to hell is paved with good intentions or so the saying goes. I have this faint cynical suspicion that this will end up being an excuse to drive up the price of commodities being traded across state borders. All the states accustomed to getting their full cut of taxes, will either institute an entry tax or maybe an exit tax as well. The concept may provide the rationalizations for the state to push their own Reforms into the mix. I might be pessimistic, but it doesn't look quite that bright for the consumer.

Onto Caesar what is Caesar's: The budget is not without any redeeming qualities for the salaried class. The direct taxes have been cleaned up with a clear slab system without involving any imaginary numbers in the tax calculation. No more shuffling with tax rebates and investments which reduce both your income and income tax (surprise !!). The key concept here is that, the more forms you have to fill in, the probablility of you filling in all properly goes down and vice versa. QED (as any self respecting under graduate would have put it).

The gender inequality in the budget would have been controversial - but it is not , because it discriminates against men only (what do these people have AGAINST men ?). Well, if that sounded wierd, just add "wo" to the men and read it again. Coming from a matriarchal society, I find the idea of "We have to give women an unfair advantage to level the playing ground" repulsive to the core. If that becomes the accepted norm, then the feminists have lost (even though they won) - because it translates into "You didn't beat us, we let you win" from the male counterpart. It degrades the victories justly earned. Pardon my rants on this topic but - Nobody is more equal than others !.

Except for the few bits (or controversy-bait for the cynical), the budget is pretty much split between gender sensitivies, good intentions subverted and plain old power politics. Nothing for you to see here, move along.

User Journal

Journal Journal: Joined Yahoo! India

I've joined Yahoo! Bangalore SDC as a platforms guy. Nice place, nice work (so far) and nice people.

Need to buy a PC at home or get a laptop and a home internet connection. Then I'm all settled down here in Bangalore.

User Journal

Journal Journal: Quest for God: Religion vs Science

Most people have an illusion that an Absolute, Omnipotent, Omniscient God is in contradiction with Science and all the scientific methods associated with it. Science has had it's disciples called as devil worshippers and athiests by centuries of religious dogma. But as Hawking has so lucidly commented "it [Science] would be the ultimate triumph of human reason -- for then we should know the mind of God".

For those who have read Douglas Adam's scintillating lecture Is There An Artificial God will realize, that there is no role of a God in our world. However, on the flip side of the coin we do have Scott Adams (of Dilbert fame) who wrote a very insightful commentary on God called God's Debris. The essential of the book is that we are God's debris - Probability and Dust, trying to rebuild a global consciousness due to some unknown urge to defy the entropy of the universe.

Of all the biblical fundamentalists claiming Creationism as an absolute - can't you see the hand of your God in evolution ?. My religion (Hinduism) relies on the evolution (call it Reincarnation) until the soul achieves Moksha (salvation) by transcending the human fallibility and ego. Coming from the background, the concept of evolution by natural selection seems to be the act of God. This is more so because Nature (as in Natural selection) is the God in this point. It might look primitive, but in fact Science was the duty of the religious monks who imagined the atom before Plato & Pythagoras was even born in Europe. Science was packaged with religion - for example Manusmrithi prohibits marriages within 10 generations of a single ancestor. The genetic dangers of in-breeding are clearly known in the modern era - but in 200 BC ?.

To conclude, Science is the religion which has had prophets who were right all along. They were prone to human fallibility and admitted to it , rather than claim divinity. For an agnostic like me , I accept relativity in just the same way I accept in God - one as the rule and the other as the maker of rules. Science is just unravelling what God has left for us to figure out for ourselves (again, read God's Debris).

GNU is Not Unix

Journal Journal: My Thoughts about RMS

Most of RMS's recent interviews have revolved around his insistence that GNU/Linux is the correct name for what Redhat, Suse and Mandrake grew rich selling. Most of the trolls connected to that also discuss how RMS criticizes Linus' use of BitKeeper for Linux kernel tree. Everyone seems to be so much about how he is Unreasonable and Impractical. So let's see rehash a few issues shall we ?.

Q: He is opposed to porting FOSS to Windows.
Wrong. He wrote his entire code base using Unix - a proprietary OS - so I'd say Firefox on Windows should be quite acceptable to him. After all entire GNU grew up from propreitary unix environments. The suggested idea is like banning visits to encourage immigration.

Q: He opposes making money from FOSS .
Wrong. He lived for around 3 years selling Emacs for $150 per tape. He predates (no pun intended) Redhat and Suse in making money selling FOSS.

I've met RMS in person and have had email conversations with him. He's essentially a Hippie. But unlike what others interpret it , he doesn't have any tie-downs to society. Hell ! he doesn't even have a password for root to his laptop. It is very hard to achieve that kind of disconnection from society. Indians would know know this as Karma Yoga - Salvation by Action (normally translated as "Service"). He doesn't want a compromise on Freedom - yours or his or anyone else's.

The reasonable man adapts himself to the world; the unreasonable man persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man.
--- Bernard Shaw

It's an Utopia he sees - but we may come near recovering the paradise selfishness destroyed ... Without him, we won't have realized what we LOST !.

The Almighty Buck

Journal Journal: The Induvi-dual Economy

Does the taxation economy screw the salaried employee ?. I've been thinking a lot about it recently. Government of India has a very profitable income tax department in which I fall in the highest tax bracket (ie people who are paid more than 160 USD per month) - which means that my cumulative tax burden comes to around 33% of my total income.

Let us compare that with a business man shall we ?. He is incorporated and has his own private company. He has a big house which is given to him by the company , a company car and take regular business trips abroad (to Switzerland , France or Maldives depending on the season). All in all, his company declares a profit of 8-10% and pays tax ONLY for that profit.

On the other hand, an employee of the same firm - pays tax on his entire income (the basic deduction is considered as the "normal expenses") and not on the profit. Essentially I'm getting screwed in no small fashion.

Economics is a strange thing - these people buy stuff to avoid paying taxes and I pay taxes - at least they get some bang for their buck (while I don't). All I get is a big Form 16 to fill in.

I wonder what I can do about it ... Nothing, I guess.

User Journal

Journal Journal: Cool gdb features

gdb is the best debugger I've ever encountered. It can't do your homework , walk the dog or make coffee - but I discovered yesterday that there's nothing else that can debug JIT compiled code properly :).

I'm working on this PPC unroller - so I had to debug bits.

Program received signal SIGTRAP, Trace/breakpoint trap.
0x3003b158 in ?? ()
(gdb) x/4i $pc
0x3003b158: trap
0x3003b15c: or r9,r9,r10
0x3003b160: or r11,r11,r8
0x3003b164: stw r9,-32(r19)
(gdb) set $pc = $pc + 4
(gdb) ni

It's amazing ... I found this doc from the jikes RVM list - but that guy still didn't figure out how to do it the easy way by incrementing PC. Life's a lot easier now that I use gdb. Now to figure out how to make this a macro :)

User Journal

Journal Journal: PPC unroller in progress

The PowerPC JIT is in progress in DotGNU . I've got basic arithmetic working and benchmark's up by 20% :)
User Journal

Journal Journal: Portable.net 0.6.10 Released

Portable.net 0.6.10 has been released. Have a peek at it .

Features some real cool stuff like Serial Port programming and BeOS support ... (not to mention capable of running Gtk#/Gnome#). More of Whidbey stuff implemented too .

Lots of ports this time around. AS/400 , CRIS , BeOS to quote a few . Handhelds , embedded systems , almost everywhere gcc works (I need SymbianOs badly).

Worked hard on that .... XPath support, profile fixes ... woohooo !.

User Journal

Journal Journal: System.IO.Ports working now

Hell, Microsoft has not even released this stuff.
But LongHorn will have this (*snigger*)

All done for Windows (by me) and Linux (by Rhys)..

User Journal

Journal Journal: XSP ported to portable.net

I've finally got XSP ported to pnet. Except for persistant states and a few other minor issues with CodeBehind, everything else works beautifully.

Slashdot Top Deals

When bad men combine, the good must associate; else they will fall one by one, an unpitied sacrifice in a contemptible struggle. - Edmund Burke

Working...